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