2 * Copyright (c) 2013-2014 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@
25 @header SecKeybagSupport.h - The thing that does the stuff with the gibli.
28 #ifndef _SECURITYD_SECKEYBAGSUPPORT_H_
29 #define _SECURITYD_SECKEYBAGSUPPORT_H_
31 #include <CoreFoundation/CoreFoundation.h>
32 #include <utilities/SecAKSWrappers.h>
33 #include <libaks_acl_cf_keys.h>
36 #define USE_KEYSTORE TARGET_HAS_KEYSTORE
40 #include <Kernel/IOKit/crypto/AppleKeyStoreDefs.h>
41 #include <Security/SecAccessControlPriv.h>
42 #endif /* USE_KEYSTORE */
46 // TODO: Get this out of this file
48 typedef int32_t keyclass_t
;
51 /* TODO: this needs to be available in the sim! */
52 typedef int32_t keyclass_t
;
53 typedef int32_t key_handle_t
;
63 #endif /* !USE_KEYSTORE */
65 /* KEYBAG_NONE is private to security and have special meaning.
66 They should not collide with AppleKeyStore constants, but are only referenced
69 #define KEYBAG_NONE (-1) /* Set q_keybag to KEYBAG_NONE to obtain cleartext data. */
70 #define KEYBAG_DEVICE (g_keychain_keybag) /* actual keybag used to encrypt items */
71 extern keybag_handle_t g_keychain_keybag
;
74 bool ks_crypt(CFTypeRef operation
, keybag_handle_t keybag
,
75 keyclass_t keyclass
, uint32_t textLength
, const uint8_t *source
, keyclass_t
*actual_class
,
76 CFMutableDataRef dest
, CFErrorRef
*error
);
78 bool ks_encrypt_acl(keybag_handle_t keybag
, keyclass_t keyclass
, uint32_t textLength
, const uint8_t *source
,
79 CFMutableDataRef dest
, CFDataRef auth_data
, CFDataRef acm_context
,
80 SecAccessControlRef access_control
, CFErrorRef
*error
);
81 bool ks_decrypt_acl(aks_ref_key_t ref_key
, CFDataRef encrypted_data
, CFMutableDataRef dest
,
82 CFDataRef acm_context
, CFDataRef caller_access_groups
,
83 SecAccessControlRef access_control
, CFErrorRef
*error
);
84 bool ks_delete_acl(aks_ref_key_t ref_key
, CFDataRef encrypted_data
,
85 CFDataRef acm_context
, CFDataRef caller_access_groups
,
86 SecAccessControlRef access_control
, CFErrorRef
*error
);
87 const void* ks_ref_key_get_external_data(keybag_handle_t keybag
, CFDataRef key_data
,
88 aks_ref_key_t
*ref_key
, size_t *external_data_len
, CFErrorRef
*error
);
89 bool ks_separate_data_and_key(CFDictionaryRef blob_dict
, CFDataRef
*ed_data
, CFDataRef
*key_data
);
91 bool ks_open_keybag(CFDataRef keybag
, CFDataRef password
, keybag_handle_t
*handle
, CFErrorRef
*error
);
92 bool ks_close_keybag(keybag_handle_t keybag
, CFErrorRef
*error
);
96 #endif /* _SECURITYD_SECKEYBAGSUPPORT_H_ */