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