X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5dd5f9ec28f304ca377c42fd7f711d6cf12b90e1..5c19dc3ae3bd8e40a9c028b0deddd50ff337692c:/OSX/sec/securityd/SecKeybagSupport.h diff --git a/OSX/sec/securityd/SecKeybagSupport.h b/OSX/sec/securityd/SecKeybagSupport.h new file mode 100644 index 00000000..ee240cf2 --- /dev/null +++ b/OSX/sec/securityd/SecKeybagSupport.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2013-2014 Apple Inc. All Rights Reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/*! + @header SecKeybagSupport.h - The thing that does the stuff with the gibli. + */ + +#ifndef _SECURITYD_SECKEYBAGSUPPORT_H_ +#define _SECURITYD_SECKEYBAGSUPPORT_H_ + +#include +#include +#include + +#ifndef USE_KEYSTORE +#define USE_KEYSTORE TARGET_HAS_KEYSTORE +#endif + +#if USE_KEYSTORE +#include +#include +#endif /* USE_KEYSTORE */ + +__BEGIN_DECLS + +// TODO: Get this out of this file +#if USE_KEYSTORE +typedef int32_t keyclass_t; +#else + +/* TODO: this needs to be available in the sim! */ +typedef int32_t keyclass_t; +typedef int32_t key_handle_t; +enum key_classes { + key_class_ak = 6, + key_class_ck, + key_class_dk, + key_class_aku, + key_class_cku, + key_class_dku, + key_class_akpu +}; +#endif /* !USE_KEYSTORE */ + +/* KEYBAG_NONE is private to security and have special meaning. + They should not collide with AppleKeyStore constants, but are only referenced + in here. + */ +#define KEYBAG_NONE (-1) /* Set q_keybag to KEYBAG_NONE to obtain cleartext data. */ +#define KEYBAG_DEVICE (g_keychain_keybag) /* actual keybag used to encrypt items */ +extern keybag_handle_t g_keychain_keybag; + +bool use_hwaes(void); +bool ks_crypt(CFTypeRef operation, keybag_handle_t keybag, + keyclass_t keyclass, uint32_t textLength, const uint8_t *source, keyclass_t *actual_class, + CFMutableDataRef dest, CFErrorRef *error); +#if USE_KEYSTORE +bool ks_encrypt_acl(keybag_handle_t keybag, keyclass_t keyclass, uint32_t textLength, const uint8_t *source, + CFMutableDataRef dest, CFDataRef auth_data, CFDataRef acm_context, + SecAccessControlRef access_control, CFErrorRef *error); +bool ks_decrypt_acl(aks_ref_key_t ref_key, CFDataRef encrypted_data, CFMutableDataRef dest, + CFDataRef acm_context, CFDataRef caller_access_groups, + SecAccessControlRef access_control, CFErrorRef *error); +bool ks_delete_acl(aks_ref_key_t ref_key, CFDataRef encrypted_data, + CFDataRef acm_context, CFDataRef caller_access_groups, + SecAccessControlRef access_control, CFErrorRef *error); +const void* ks_ref_key_get_external_data(keybag_handle_t keybag, CFDataRef key_data, + aks_ref_key_t *ref_key, size_t *external_data_len, CFErrorRef *error); +bool ks_separate_data_and_key(CFDictionaryRef blob_dict, CFDataRef *ed_data, CFDataRef *key_data); +#endif +bool ks_open_keybag(CFDataRef keybag, CFDataRef password, keybag_handle_t *handle, CFErrorRef *error); +bool ks_close_keybag(keybag_handle_t keybag, CFErrorRef *error); + +__END_DECLS + +#endif /* _SECURITYD_SECKEYBAGSUPPORT_H_ */