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