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