2 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
29 #if __has_include(<MobileKeyBag/MobileKeyBag.h>)
30 #include <MobileKeyBag/MobileKeyBag.h>
31 #define HAVE_MobileKeyBag_MobileKeyBag 1
35 #import <Foundation/Foundation.h>
38 CF_ASSUME_NONNULL_BEGIN
40 #if !HAVE_MobileKeyBag_MobileKeyBag
42 typedef struct __MKBKeyBagHandle
* MKBKeyBagHandleRef
;
43 int MKBKeyBagCreateWithData(CFDataRef keybagBlob
, MKBKeyBagHandleRef _Nullable
* _Nonnull newHandle
);
45 #define kMobileKeyBagDeviceIsLocked 1
46 #define kMobileKeyBagDeviceIsUnlocked 0
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
);
54 #define kMobileKeyBagSuccess (0)
55 #define kMobileKeyBagError (-1)
56 #define kMobileKeyBagDeviceLockedError (-2)
57 #define kMobileKeyBagInvalidSecretError (-3)
58 #define kMobileKeyBagExistsError (-4)
59 #define kMobileKeyBagNoMemoryError (-5)
62 #endif // HAVE_MobileKeyBag_MobileKeyBag
66 @interface SecMockAKS
: NSObject
67 @
property (class) keybag_state_t keybag_state
;
69 + (bool)isLocked
:(keyclass_t
)key_class
;
71 + (bool)useGenerationCount
;
76 + (void)unlockAllClasses
;
80 + (void)failNextDecryptRefKey
:(NSError
* _Nonnull
) decryptRefKeyError
;
81 + (NSError
* _Nullable
)popDecryptRefKeyFailure
;
90 #endif /* mockaks_h */