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