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