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