1*19c3b8c2SApple OSS Distributions #include <libkern/libkern.h> 2*19c3b8c2SApple OSS Distributions #include <libkern/section_keywords.h> 3*19c3b8c2SApple OSS Distributions #include <libkern/apple_encrypted_archive/apple_encrypted_archive.h> 4*19c3b8c2SApple OSS Distributions 5*19c3b8c2SApple OSS Distributions #if defined(SECURITY_READ_ONLY_LATE) 6*19c3b8c2SApple OSS Distributions SECURITY_READ_ONLY_LATE(const apple_encrypted_archive_t *) apple_encrypted_archive = NULL; 7*19c3b8c2SApple OSS Distributions SECURITY_READ_ONLY_LATE(registration_callback_t) registration_callback = NULL; 8*19c3b8c2SApple OSS Distributions #else 9*19c3b8c2SApple OSS Distributions const apple_encrypted_archive_t *apple_encrypted_archive = NULL; 10*19c3b8c2SApple OSS Distributions registration_callback_t registration_callback = NULL; 11*19c3b8c2SApple OSS Distributions #endif 12*19c3b8c2SApple OSS Distributions 13*19c3b8c2SApple OSS Distributions void apple_encrypted_archive_interface_register(const apple_encrypted_archive_t * aea)14*19c3b8c2SApple OSS Distributionsapple_encrypted_archive_interface_register(const apple_encrypted_archive_t *aea) 15*19c3b8c2SApple OSS Distributions { 16*19c3b8c2SApple OSS Distributions if (apple_encrypted_archive) { 17*19c3b8c2SApple OSS Distributions panic("apple_encrypted_archive interface already set"); 18*19c3b8c2SApple OSS Distributions } 19*19c3b8c2SApple OSS Distributions 20*19c3b8c2SApple OSS Distributions apple_encrypted_archive = aea; 21*19c3b8c2SApple OSS Distributions 22*19c3b8c2SApple OSS Distributions if (registration_callback) { 23*19c3b8c2SApple OSS Distributions registration_callback(); 24*19c3b8c2SApple OSS Distributions } 25*19c3b8c2SApple OSS Distributions } 26*19c3b8c2SApple OSS Distributions 27*19c3b8c2SApple OSS Distributions void apple_encrypted_archive_interface_set_registration_callback(registration_callback_t callback)28*19c3b8c2SApple OSS Distributionsapple_encrypted_archive_interface_set_registration_callback(registration_callback_t callback) 29*19c3b8c2SApple OSS Distributions { 30*19c3b8c2SApple OSS Distributions if (callback && registration_callback) { 31*19c3b8c2SApple OSS Distributions panic("apple_encrypted_archive interface registration callback is already set"); 32*19c3b8c2SApple OSS Distributions } 33*19c3b8c2SApple OSS Distributions 34*19c3b8c2SApple OSS Distributions registration_callback = callback; 35*19c3b8c2SApple OSS Distributions } 36