]> git.saurik.com Git - apple/security.git/blob - tests/secdmockaks/mockaks.h
Security-59306.61.1.tar.gz
[apple/security.git] / tests / secdmockaks / mockaks.h
1 /*
2 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef mockaks_h
25 #define mockaks_h
26
27 #import <libaks.h>
28
29 #if __has_include(<MobileKeyBag/MobileKeyBag.h>)
30 #include <MobileKeyBag/MobileKeyBag.h>
31 #define HAVE_MobileKeyBag_MobileKeyBag 1
32 #endif
33
34 #if __OBJC2__
35 #import <Foundation/Foundation.h>
36 #endif
37
38 CF_ASSUME_NONNULL_BEGIN
39
40 #if !HAVE_MobileKeyBag_MobileKeyBag
41
42 typedef struct __MKBKeyBagHandle* MKBKeyBagHandleRef;
43 int MKBKeyBagCreateWithData(CFDataRef keybagBlob, MKBKeyBagHandleRef _Nullable * _Nonnull newHandle);
44
45 #define kMobileKeyBagDeviceIsLocked 1
46 #define kMobileKeyBagDeviceIsUnlocked 0
47
48 int MKBKeyBagUnlock(MKBKeyBagHandleRef keybag, CFDataRef _Nullable passcode);
49 int MKBKeyBagGetAKSHandle(MKBKeyBagHandleRef _Nonnull keybag, int32_t *_Nullable handle);
50 int MKBGetDeviceLockState(CFDictionaryRef _Nullable options);
51 CF_RETURNS_RETAINED CFDictionaryRef _Nullable MKBUserTypeDeviceMode(CFDictionaryRef _Nullable options, CFErrorRef _Nullable * _Nullable error);
52 int MKBForegroundUserSessionID( CFErrorRef _Nullable * _Nullable error);
53
54 #define kMobileKeyBagSuccess (0)
55 #define kMobileKeyBagError (-1)
56 #define kMobileKeyBagDeviceLockedError (-2)
57 #define kMobileKeyBagInvalidSecretError (-3)
58 #define kMobileKeyBagExistsError (-4)
59 #define kMobileKeyBagNoMemoryError (-5)
60
61
62 #endif // HAVE_MobileKeyBag_MobileKeyBag
63
64 #if __OBJC2__
65
66 @interface SecMockAKS : NSObject
67 @property (class) keybag_state_t keybag_state;
68
69 + (bool)isLocked:(keyclass_t)key_class;
70 + (bool)isSEPDown;
71 + (bool)useGenerationCount;
72
73 + (void)lockClassA_C;
74 + (void)lockClassA;
75
76 + (void)unlockAllClasses;
77
78 + (void)reset;
79
80 + (void)failNextDecryptRefKey:(NSError* _Nonnull) decryptRefKeyError;
81 + (NSError * _Nullable)popDecryptRefKeyFailure;
82
83 @end
84
85 #endif // OBJC2
86
87 CF_ASSUME_NONNULL_END
88
89
90 #endif /* mockaks_h */