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