]> git.saurik.com Git - apple/security.git/blob - tests/secdmockaks/aks_real_witness.c
Security-59754.80.3.tar.gz
[apple/security.git] / tests / secdmockaks / aks_real_witness.c
1
2 #include "aks_real_witness.h"
3 #include <TargetConditionals.h>
4
5 #if !TARGET_OS_SIMULATOR
6
7 #include <libaks.h>
8 #include <MobileKeyBag/MobileKeyBag.h>
9
10 #include <utilities/debugging.h>
11
12 bool hwaes_key_available(void)
13 {
14 keybag_handle_t handle = bad_keybag_handle;
15 keybag_handle_t special_handle = bad_keybag_handle;
16 #if TARGET_OS_OSX
17 special_handle = session_keybag_handle;
18 #elif TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
19 special_handle = device_keybag_handle;
20 #else
21 #error "supported keybag target"
22 #endif
23
24 kern_return_t kr = aks_get_system(special_handle, &handle);
25 if (kr != kAKSReturnSuccess) {
26 #if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
27 /* TODO: Remove this once the kext runs the daemon on demand if
28 there is no system keybag. */
29 int kb_state = MKBGetDeviceLockState(NULL);
30 secinfo("aks", "AppleKeyStore lock state: %d", kb_state);
31 #endif
32 }
33 return true;
34 }
35
36 #endif