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