]> git.saurik.com Git - apple/security.git/blob - keychain/SecKey.h
Security-58286.1.32.tar.gz
[apple/security.git] / keychain / SecKey.h
1 /*
2 * Copyright (c) 2006-2014,2016 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 /*!
25 @header SecKey
26 The functions provided in SecKey.h implement and manage a particular
27 type of keychain item that represents a key. A key can be stored in a
28 keychain, but a key can also be a transient object.
29
30 On OSX, you can use a SecKey as a SecKeychainItem in most functions.
31 */
32
33 #ifndef _SECURITY_SECKEY_H_
34 #define _SECURITY_SECKEY_H_
35
36 #include <Availability.h>
37 #include <Security/SecBase.h>
38 #include <CoreFoundation/CoreFoundation.h>
39 #include <dispatch/dispatch.h>
40 #include <sys/types.h>
41
42 #if SEC_OS_OSX
43 #include <Security/SecAccess.h>
44 #include <Security/cssmtype.h>
45 #endif /* SEC_OS_OSX */
46
47 __BEGIN_DECLS
48
49 CF_ASSUME_NONNULL_BEGIN
50 CF_IMPLICIT_BRIDGING_ENABLED
51
52 #if SEC_OS_OSX
53 /*!
54 @enum KeyItemAttributeConstants
55 @abstract Specifies keychain item attributes for keys.
56 @constant kSecKeyKeyClass type uint32 (CSSM_KEYCLASS), value
57 is one of CSSM_KEYCLASS_PUBLIC_KEY, CSSM_KEYCLASS_PRIVATE_KEY
58 or CSSM_KEYCLASS_SESSION_KEY.
59 @constant kSecKeyPrintName type blob, human readable name of
60 the key. Same as kSecLabelItemAttr for normal keychain items.
61 @constant kSecKeyAlias type blob, currently unused.
62 @constant kSecKeyPermanent type uint32, value is nonzero iff
63 this key is permanent (stored in some keychain). This is always
64 1.
65 @constant kSecKeyPrivate type uint32, value is nonzero iff this
66 key is protected by a user login or a password, or both.
67 @constant kSecKeyModifiable type uint32, value is nonzero iff
68 attributes of this key can be modified.
69 @constant kSecKeyLabel type blob, for private and public keys
70 this contains the hash of the public key. This is used to
71 associate certificates and keys. Its value matches the value
72 of the kSecPublicKeyHashItemAttr of a certificate and it's used
73 to construct an identity from a certificate and a key.
74 For symmetric keys this is whatever the creator of the key
75 passed in during the generate key call.
76 @constant kSecKeyApplicationTag type blob, currently unused.
77 @constant kSecKeyKeyCreator type data, the data points to a
78 CSSM_GUID structure representing the moduleid of the csp owning
79 this key.
80 @constant kSecKeyKeyType type uint32, value is a CSSM_ALGORITHMS
81 representing the algorithm associated with this key.
82 @constant kSecKeyKeySizeInBits type uint32, value is the number
83 of bits in this key.
84 @constant kSecKeyEffectiveKeySize type uint32, value is the
85 effective number of bits in this key. For example a des key
86 has a kSecKeyKeySizeInBits of 64 but a kSecKeyEffectiveKeySize
87 of 56.
88 @constant kSecKeyStartDate type CSSM_DATE. Earliest date from
89 which this key may be used. If the value is all zeros or not
90 present, no restriction applies.
91 @constant kSecKeyEndDate type CSSM_DATE. Latest date at
92 which this key may be used. If the value is all zeros or not
93 present, no restriction applies.
94 @constant kSecKeySensitive type uint32, iff value is nonzero
95 this key cannot be wrapped with CSSM_ALGID_NONE.
96 @constant kSecKeyAlwaysSensitive type uint32, value is nonzero
97 iff this key has always been marked sensitive.
98 @constant kSecKeyExtractable type uint32, value is nonzero iff
99 this key can be wrapped.
100 @constant kSecKeyNeverExtractable type uint32, value is nonzero
101 iff this key was never marked extractable.
102 @constant kSecKeyEncrypt type uint32, value is nonzero iff this
103 key can be used in an encrypt operation.
104 @constant kSecKeyDecrypt type uint32, value is nonzero iff this
105 key can be used in a decrypt operation.
106 @constant kSecKeyDerive type uint32, value is nonzero iff this
107 key can be used in a deriveKey operation.
108 @constant kSecKeySign type uint32, value is nonzero iff this
109 key can be used in a sign operation.
110 @constant kSecKeyVerify type uint32, value is nonzero iff this
111 key can be used in a verify operation.
112 @constant kSecKeySignRecover type uint32.
113 @constant kSecKeyVerifyRecover type uint32.
114 key can unwrap other keys.
115 @constant kSecKeyWrap type uint32, value is nonzero iff this
116 key can wrap other keys.
117 @constant kSecKeyUnwrap type uint32, value is nonzero iff this
118 key can unwrap other keys.
119 @discussion
120 The use of these enumerations has been deprecated. Please
121 use the equivalent items defined in SecItem.h
122 @@@.
123 */
124 CF_ENUM(int)
125 {
126 kSecKeyKeyClass = 0,
127 kSecKeyPrintName = 1,
128 kSecKeyAlias = 2,
129 kSecKeyPermanent = 3,
130 kSecKeyPrivate = 4,
131 kSecKeyModifiable = 5,
132 kSecKeyLabel = 6,
133 kSecKeyApplicationTag = 7,
134 kSecKeyKeyCreator = 8,
135 kSecKeyKeyType = 9,
136 kSecKeyKeySizeInBits = 10,
137 kSecKeyEffectiveKeySize = 11,
138 kSecKeyStartDate = 12,
139 kSecKeyEndDate = 13,
140 kSecKeySensitive = 14,
141 kSecKeyAlwaysSensitive = 15,
142 kSecKeyExtractable = 16,
143 kSecKeyNeverExtractable = 17,
144 kSecKeyEncrypt = 18,
145 kSecKeyDecrypt = 19,
146 kSecKeyDerive = 20,
147 kSecKeySign = 21,
148 kSecKeyVerify = 22,
149 kSecKeySignRecover = 23,
150 kSecKeyVerifyRecover = 24,
151 kSecKeyWrap = 25,
152 kSecKeyUnwrap = 26
153 };
154
155 /*!
156 @enum SecCredentialType
157 @abstract Determines the type of credential returned by SecKeyGetCredentials.
158 @constant kSecCredentialTypeWithUI Operations with this key are allowed to present UI if required.
159 @constant kSecCredentialTypeNoUI Operations with this key are not allowed to present UI, and will fail if UI is required.
160 @constant kSecCredentialTypeDefault The default setting for determining whether to present UI is used. This setting can be changed with a call to SecKeychainSetUserInteractionAllowed.
161 */
162 typedef CF_ENUM(uint32, SecCredentialType)
163 {
164 kSecCredentialTypeDefault = 0,
165 kSecCredentialTypeWithUI,
166 kSecCredentialTypeNoUI
167 };
168 #endif /* SEC_OS_OSX */
169
170 /*!
171 @typedef SecPadding
172 @abstract Supported padding types.
173 */
174 typedef CF_OPTIONS(uint32_t, SecPadding)
175 {
176 kSecPaddingNone = 0,
177 kSecPaddingPKCS1 = 1,
178 kSecPaddingOAEP = 2, // __OSX_UNAVAILABLE __IOS_AVAILABLE(2.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0),
179
180 /* For SecKeyRawSign/SecKeyRawVerify only,
181 ECDSA signature is raw byte format {r,s}, big endian.
182 First half is r, second half is s */
183 kSecPaddingSigRaw = 0x4000,
184
185 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is an MD2
186 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
187 of the underlying RSA operation. */
188 kSecPaddingPKCS1MD2 = 0x8000, // __OSX_DEPRECATED(10.0, 10.12, "MD2 is deprecated") __IOS_DEPRECATED(2.0, 5.0, "MD2 is deprecated") __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE,
189
190 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is an MD5
191 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
192 of the underlying RSA operation. */
193 kSecPaddingPKCS1MD5 = 0x8001, // __OSX_DEPRECATED(10.0, 10.12, "MD5 is deprecated") __IOS_DEPRECATED(2.0, 5.0, "MD5 is deprecated") __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE,
194
195 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is a SHA1
196 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
197 of the underlying RSA operation. */
198 kSecPaddingPKCS1SHA1 = 0x8002,
199
200 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is a SHA224
201 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
202 of the underlying RSA operation. */
203 kSecPaddingPKCS1SHA224 = 0x8003, // __OSX_UNAVAILABLE __IOS_AVAILABLE(2.0),
204
205 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is a SHA256
206 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
207 of the underlying RSA operation. */
208 kSecPaddingPKCS1SHA256 = 0x8004, // __OSX_UNAVAILABLE __IOS_AVAILABLE(2.0),
209
210 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is a SHA384
211 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
212 of the underlying RSA operation. */
213 kSecPaddingPKCS1SHA384 = 0x8005, // __OSX_UNAVAILABLE __IOS_AVAILABLE(2.0),
214
215 /* For SecKeyRawSign/SecKeyRawVerify only, data to be signed is a SHA512
216 hash; standard ASN.1 padding will be done, as well as PKCS1 padding
217 of the underlying RSA operation. */
218 kSecPaddingPKCS1SHA512 = 0x8006, // __OSX_UNAVAILABLE __IOS_AVAILABLE(2.0),
219 };
220
221 #if SEC_OS_OSX
222 /*!
223 @typedef SecKeySizes
224 @abstract Supported key lengths.
225 */
226 typedef CF_ENUM(uint32_t, SecKeySizes)
227 {
228 kSecDefaultKeySize = 0,
229
230 // Symmetric Keysizes - default is currently kSecAES128 for AES.
231 kSec3DES192 = 192,
232 kSecAES128 = 128,
233 kSecAES192 = 192,
234 kSecAES256 = 256,
235
236 // Supported ECC Keys for Suite-B from RFC 4492 section 5.1.1.
237 // default is currently kSecp256r1
238 kSecp192r1 = 192,
239 kSecp256r1 = 256,
240 kSecp384r1 = 384,
241 kSecp521r1 = 521, // Yes, 521
242
243 // Boundaries for RSA KeySizes - default is currently 2048
244 // RSA keysizes must be multiples of 8
245 kSecRSAMin = 1024,
246 kSecRSAMax = 4096
247 };
248 #endif /* SEC_OS_OSX */
249
250 /*!
251 @enum Key Parameter Constants
252 @discussion Predefined key constants used to get or set values in a dictionary.
253 These are used to provide explicit parameters to key generation functions
254 when non-default values are desired. See the description of the
255 SecKeyGeneratePair API for usage information.
256 @constant kSecPrivateKeyAttrs The value for this key is a CFDictionaryRef
257 containing attributes specific for the private key to be generated.
258 @constant kSecPublicKeyAttrs The value for this key is a CFDictionaryRef
259 containing attributes specific for the public key to be generated.
260 */
261 extern const CFStringRef kSecPrivateKeyAttrs
262 __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_2_0);
263 extern const CFStringRef kSecPublicKeyAttrs
264 __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_2_0);
265
266 /*!
267 @function SecKeyGetTypeID
268 @abstract Returns the type identifier of SecKey instances.
269 @result The CFTypeID of SecKey instances.
270 */
271 CFTypeID SecKeyGetTypeID(void)
272 __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0);
273
274
275 #if SEC_OS_OSX
276 /*!
277 @function SecKeyCreatePair
278 @abstract Creates an asymmetric key pair and stores it in a specified keychain.
279 @param keychainRef A reference to the keychain in which to store the private and public key items. Specify NULL for the default keychain.
280 @param algorithm An algorithm for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
281 @param keySizeInBits A key size for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
282 @param contextHandle (optional) A CSSM_CC_HANDLE, or 0. If this argument is supplied, the algorithm and keySizeInBits parameters are ignored. If extra parameters are needed to generate a key (some algorithms require this), you should create a context using CSSM_CSP_CreateKeyGenContext, using the CSPHandle obtained by calling SecKeychainGetCSPHandle. Then use CSSM_UpdateContextAttributes to add parameters, and dispose of the context using CSSM_DeleteContext after calling this function.
283 @param publicKeyUsage A bit mask indicating all permitted uses for the new public key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.
284 @param publicKeyAttr A bit mask defining attribute values for the new public key. The bit mask values are equivalent to a CSSM_KEYATTR_FLAGS and are defined in cssmtype.h.
285 @param privateKeyUsage A bit mask indicating all permitted uses for the new private key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.
286 @param privateKeyAttr A bit mask defining attribute values for the new private key. The bit mask values are equivalent to a CSSM_KEYATTR_FLAGS and are defined in cssmtype.h.
287 @param initialAccess (optional) A SecAccess object that determines the initial access rights to the private key. The public key is given "any/any" access rights by default.
288 @param publicKey (optional) On return, the keychain item reference of the generated public key. Use the SecKeyGetCSSMKey function to obtain the CSSM_KEY. The caller must call CFRelease on this value if it is returned. Pass NULL if a reference to this key is not required.
289 @param privateKey (optional) On return, the keychain item reference of the generated private key. Use the SecKeyGetCSSMKey function to obtain the CSSM_KEY. The caller must call CFRelease on this value if it is returned. Pass NULL if a reference to this key is not required.
290 @result A result code. See "Security Error Codes" (SecBase.h).
291 @discussion This API is deprecated for 10.7. Please use the SecKeyGeneratePair API instead.
292 */
293 OSStatus SecKeyCreatePair(
294 SecKeychainRef _Nullable keychainRef,
295 CSSM_ALGORITHMS algorithm,
296 uint32 keySizeInBits,
297 CSSM_CC_HANDLE contextHandle,
298 CSSM_KEYUSE publicKeyUsage,
299 uint32 publicKeyAttr,
300 CSSM_KEYUSE privateKeyUsage,
301 uint32 privateKeyAttr,
302 SecAccessRef _Nullable initialAccess,
303 SecKeyRef* _Nullable CF_RETURNS_RETAINED publicKey,
304 SecKeyRef* _Nullable CF_RETURNS_RETAINED privateKey)
305 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
306
307 /*!
308 @function SecKeyGenerate
309 @abstract Creates a symmetric key and optionally stores it in a specified keychain.
310 @param keychainRef (optional) A reference to the keychain in which to store the generated key. Specify NULL to generate a transient key.
311 @param algorithm An algorithm for the symmetric key. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
312 @param keySizeInBits A key size for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
313 @param contextHandle (optional) A CSSM_CC_HANDLE, or 0. If this argument is supplied, the algorithm and keySizeInBits parameters are ignored. If extra parameters are needed to generate a key (some algorithms require this), you should create a context using CSSM_CSP_CreateKeyGenContext, using the CSPHandle obtained by calling SecKeychainGetCSPHandle. Then use CSSM_UpdateContextAttributes to add parameters, and dispose of the context using CSSM_DeleteContext after calling this function.
314 @param keyUsage A bit mask indicating all permitted uses for the new key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.
315 @param keyAttr A bit mask defining attribute values for the new key. The bit mask values are equivalent to a CSSM_KEYATTR_FLAGS and are defined in cssmtype.h.
316 @param initialAccess (optional) A SecAccess object that determines the initial access rights for the key. This parameter is ignored if the keychainRef is NULL.
317 @param keyRef On return, a reference to the generated key. Use the SecKeyGetCSSMKey function to obtain the CSSM_KEY. The caller must call CFRelease on this value if it is returned.
318 @result A result code. See "Security Error Codes" (SecBase.h).
319 @discussion This API is deprecated for 10.7. Please use the SecKeyGenerateSymmetric API instead.
320 */
321 OSStatus SecKeyGenerate(
322 SecKeychainRef _Nullable keychainRef,
323 CSSM_ALGORITHMS algorithm,
324 uint32 keySizeInBits,
325 CSSM_CC_HANDLE contextHandle,
326 CSSM_KEYUSE keyUsage,
327 uint32 keyAttr,
328 SecAccessRef _Nullable initialAccess,
329 SecKeyRef* _Nullable CF_RETURNS_RETAINED keyRef)
330 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
331
332 /*!
333 @function SecKeyGetCSSMKey
334 @abstract Returns a pointer to the CSSM_KEY for the given key item reference.
335 @param key A keychain key item reference. The key item must be of class type kSecPublicKeyItemClass, kSecPrivateKeyItemClass, or kSecSymmetricKeyItemClass.
336 @param cssmKey On return, a pointer to a CSSM_KEY structure for the given key. This pointer remains valid until the key reference is released. The caller should not attempt to modify or free this data.
337 @result A result code. See "Security Error Codes" (SecBase.h).
338 @discussion The CSSM_KEY is valid until the key item reference is released. This API is deprecated in 10.7. Its use should no longer be needed.
339 */
340 OSStatus SecKeyGetCSSMKey(SecKeyRef key, const CSSM_KEY * _Nullable * __nonnull cssmKey)
341 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;;
342
343 /*!
344 @function SecKeyGetCSPHandle
345 @abstract Returns the CSSM_CSP_HANDLE for the given key reference. The handle is valid until the key reference is released.
346 @param keyRef A key reference.
347 @param cspHandle On return, the CSSM_CSP_HANDLE for the given keychain.
348 @result A result code. See "Security Error Codes" (SecBase.h).
349 @discussion This API is deprecated in 10.7. Its use should no longer be needed.
350 */
351 OSStatus SecKeyGetCSPHandle(SecKeyRef keyRef, CSSM_CSP_HANDLE *cspHandle)
352 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
353
354 /*!
355 @function SecKeyGetCredentials
356 @abstract For a given key, return a pointer to a CSSM_ACCESS_CREDENTIALS structure which will allow the key to be used.
357 @param keyRef The key for which a credential is requested.
358 @param operation The type of operation to be performed with this key. See "Authorization tag type" for defined operations (cssmtype.h).
359 @param credentialType The type of credential requested.
360 @param outCredentials On return, a pointer to a CSSM_ACCESS_CREDENTIALS structure. This pointer remains valid until the key reference is released. The caller should not attempt to modify or free this data.
361 @result A result code. See "Security Error Codes" (SecBase.h).
362 */
363 OSStatus SecKeyGetCredentials(
364 SecKeyRef keyRef,
365 CSSM_ACL_AUTHORIZATION_TAG operation,
366 SecCredentialType credentialType,
367 const CSSM_ACCESS_CREDENTIALS * _Nullable * __nonnull outCredentials)
368 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
369
370 /*!
371 @function SecKeyGenerateSymmetric
372 @abstract Generates a random symmetric key with the specified length
373 and algorithm type.
374
375 @param parameters A dictionary containing one or more key-value pairs.
376 See the discussion sections below for a complete overview of options.
377 @param error An optional pointer to a CFErrorRef. This value is set
378 if an error occurred. If not NULL, the caller is responsible for
379 releasing the CFErrorRef.
380 @result On return, a SecKeyRef reference to the symmetric key, or
381 NULL if the key could not be created.
382
383 @discussion In order to generate a symmetric key, the parameters dictionary
384 must at least contain the following keys:
385
386 * kSecAttrKeyType with a value of kSecAttrKeyTypeAES or any other
387 kSecAttrKeyType defined in SecItem.h
388 * kSecAttrKeySizeInBits with a value being a CFNumberRef containing
389 the requested key size in bits. Example sizes for AES keys are:
390 128, 192, 256, 512.
391
392 To store the generated symmetric key in a keychain, set these keys:
393 * kSecUseKeychain (value is a SecKeychainRef)
394 * kSecAttrLabel (a user-visible label whose value is a CFStringRef,
395 e.g. "My App's Encryption Key")
396 * kSecAttrApplicationLabel (a label defined by your application, whose
397 value is a CFDataRef and which can be used to find this key in a
398 subsequent call to SecItemCopyMatching, e.g. "ID-1234567890-9876-0151")
399
400 To specify the generated key's access control settings, set this key:
401 * kSecAttrAccess (value is a SecAccessRef)
402
403 The keys below may be optionally set in the parameters dictionary
404 (with a CFBooleanRef value) to override the default usage values:
405
406 * kSecAttrCanEncrypt (defaults to true if not explicitly specified)
407 * kSecAttrCanDecrypt (defaults to true if not explicitly specified)
408 * kSecAttrCanWrap (defaults to true if not explicitly specified)
409 * kSecAttrCanUnwrap (defaults to true if not explicitly specified)
410
411 */
412 _Nullable CF_RETURNS_RETAINED
413 SecKeyRef SecKeyGenerateSymmetric(CFDictionaryRef parameters, CFErrorRef *error)
414 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
415
416 /*!
417 @function SecKeyCreateFromData
418 @abstract Creates a symmetric key with the given data and sets the
419 algorithm type specified.
420
421 @param parameters A dictionary containing one or more key-value pairs.
422 See the discussion sections below for a complete overview of options.
423 @result On return, a SecKeyRef reference to the symmetric key.
424
425 @discussion In order to generate a symmetric key the parameters dictionary must
426 at least contain the following keys:
427
428 * kSecAttrKeyType with a value of kSecAttrKeyTypeAES or any other
429 kSecAttrKeyType defined in SecItem.h
430
431 The keys below may be optionally set in the parameters dictionary
432 (with a CFBooleanRef value) to override the default usage values:
433
434 * kSecAttrCanEncrypt (defaults to true if not explicitly specified)
435 * kSecAttrCanDecrypt (defaults to true if not explicitly specified)
436 * kSecAttrCanWrap (defaults to true if not explicitly specified)
437 * kSecAttrCanUnwrap (defaults to true if not explicitly specified)
438
439 */
440 _Nullable
441 SecKeyRef SecKeyCreateFromData(CFDictionaryRef parameters,
442 CFDataRef keyData, CFErrorRef *error)
443 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
444
445
446 #ifdef __BLOCKS__
447 /*!
448 @typedef SecKeyGeneratePairBlock
449 @abstract Delivers the result from an asynchronous key pair generation.
450 @param publicKey - the public key generated. You must retain publicKey if you wish to use it after your block returns.
451 @param privateKey - the private key generated. You must retain publicKey if you wish to use it after your block returns.
452 @param error - Any errors returned. You must retain error if you wish to use it after your block returns.
453 */
454
455 typedef void (^SecKeyGeneratePairBlock)(SecKeyRef publicKey, SecKeyRef privateKey, CFErrorRef error);
456
457 /*!
458 @function SecKeyGeneratePairAsync
459 @abstract Generate a private/public keypair returning the values in a callback.
460 @param parameters A dictionary containing one or more key-value pairs.
461 @param deliveryQueue A dispatch queue to be used to deliver the results.
462 @param result A callback function to result when the operation has completed.
463
464 @discussion In order to generate a keypair the parameters dictionary must
465 at least contain the following keys:
466
467 * kSecAttrKeyType with a value being kSecAttrKeyTypeRSA or any other
468 kSecAttrKeyType defined in SecItem.h
469 * kSecAttrKeySizeInBits with a value being a CFNumberRef or CFStringRef
470 containing the requested key size in bits. Example sizes for RSA
471 keys are: 512, 768, 1024, 2048.
472
473 Setting the following attributes explicitly will override the defaults below.
474 See SecItem.h for detailed information on these attributes including the types
475 of the values.
476
477 * kSecAttrLabel default NULL
478 * kSecAttrIsPermanent if this key is present and has a Boolean
479 value of true, the key or key pair will be added to the default
480 keychain.
481 * kSecAttrApplicationTag default NULL
482 * kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits
483 * kSecAttrCanEncrypt default false for private keys, true for public keys
484 * kSecAttrCanDecrypt default true for private keys, false for public keys
485 * kSecAttrCanDerive default true
486 * kSecAttrCanSign default true for private keys, false for public keys
487 * kSecAttrCanVerify default false for private keys, true for public keys
488 * kSecAttrCanWrap default false for private keys, true for public keys
489 * kSecAttrCanUnwrap default true for private keys, false for public keys
490
491 */
492 void SecKeyGeneratePairAsync(CFDictionaryRef parameters,
493 dispatch_queue_t deliveryQueue, SecKeyGeneratePairBlock result)
494 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
495
496 #endif /* __BLOCKS__ */
497
498 // Derive, Wrap, and Unwrap
499
500 /*!
501 @function SecKeyDeriveFromPassword
502 @abstract Derives a symmetric key from a password.
503
504 @param password The password from which the keyis to be derived.
505 @param parameters A dictionary containing one or more key-value pairs.
506 @param error If the call fails this will contain the error code.
507
508 @discussion In order to derive a key the parameters dictionary must contain at least contain the following keys:
509 * kSecAttrSalt - a CFData for the salt value for mixing in the pseudo-random rounds.
510 * kSecAttrPRF - the algorithm to use for the pseudo-random-function.
511 If 0, this defaults to kSecAttrPRFHmacAlgSHA1. Possible values are:
512
513 * kSecAttrPRFHmacAlgSHA1
514 * kSecAttrPRFHmacAlgSHA224
515 * kSecAttrPRFHmacAlgSHA256
516 * kSecAttrPRFHmacAlgSHA384
517 * kSecAttrPRFHmacAlgSHA512
518
519 * kSecAttrRounds - the number of rounds to call the pseudo random function.
520 If 0, a count will be computed to average 1/10 of a second.
521 * kSecAttrKeySizeInBits with a value being a CFNumberRef
522 containing the requested key size in bits. Example sizes for RSA keys are:
523 512, 768, 1024, 2048.
524
525 @result On success a SecKeyRef is returned. On failure this result is NULL and the
526 error parameter contains the reason.
527
528 */
529 _Nullable CF_RETURNS_RETAINED
530 SecKeyRef SecKeyDeriveFromPassword(CFStringRef password,
531 CFDictionaryRef parameters, CFErrorRef *error)
532 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
533
534 /*!
535 @function SecKeyWrapSymmetric
536 @abstract Wraps a symmetric key with a symmetric key.
537
538 @param keyToWrap The key which is to be wrapped.
539 @param wrappingKey The key wrapping key.
540 @param parameters The parameter list to use for wrapping the key.
541 @param error If the call fails this will contain the error code.
542
543 @result On success a CFDataRef is returned. On failure this result is NULL and the
544 error parameter contains the reason.
545
546 @discussion In order to wrap a key the parameters dictionary may contain the following key:
547 * kSecSalt - a CFData for the salt value for the encrypt.
548
549 */
550 _Nullable
551 CFDataRef SecKeyWrapSymmetric(SecKeyRef keyToWrap,
552 SecKeyRef wrappingKey, CFDictionaryRef parameters, CFErrorRef *error)
553 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
554
555 /*!
556 @function SecKeyUnwrapSymmetric
557 @abstract Unwrap a wrapped symmetric key.
558
559 @param keyToUnwrap The wrapped key to unwrap.
560 @param unwrappingKey The key unwrapping key.
561 @param parameters The parameter list to use for unwrapping the key.
562 @param error If the call fails this will contain the error code.
563
564 @result On success a SecKeyRef is returned. On failure this result is NULL and the
565 error parameter contains the reason.
566
567 @discussion In order to unwrap a key the parameters dictionary may contain the following key:
568 * kSecSalt - a CFData for the salt value for the decrypt.
569
570 */
571 _Nullable
572 SecKeyRef SecKeyUnwrapSymmetric(CFDataRef _Nullable * __nonnull keyToUnwrap,
573 SecKeyRef unwrappingKey, CFDictionaryRef parameters, CFErrorRef *error)
574 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
575
576 #endif /* SEC_OS_OSX */
577
578 /*!
579 @function SecKeyGeneratePair
580 @abstract Generate a private/public keypair.
581 @param parameters A dictionary containing one or more key-value pairs.
582 See the discussion sections below for a complete overview of options.
583 @param publicKey On return, a SecKeyRef reference to the public key.
584 @param privateKey On return, a SecKeyRef reference to the private key.
585 @result A result code. See "Security Error Codes" (SecBase.h).
586
587 @discussion In order to generate a keypair the parameters dictionary must
588 at least contain the following keys:
589
590 * kSecAttrKeyType with a value of kSecAttrKeyTypeRSA or any other
591 kSecAttrKeyType defined in SecItem.h
592 * kSecAttrKeySizeInBits with a value being a CFNumberRef containing
593 the requested key size in bits. Example sizes for RSA keys are:
594 512, 768, 1024, 2048.
595
596 The values below may be set either in the top-level dictionary or in a
597 dictionary that is the value of the kSecPrivateKeyAttrs or
598 kSecPublicKeyAttrs key in the top-level dictionary. Setting these
599 attributes explicitly will override the defaults below. See SecItem.h
600 for detailed information on these attributes including the types of
601 the values.
602
603 * kSecAttrLabel default NULL
604 * kSecUseKeychain default NULL, which specifies the default keychain
605 * kSecAttrIsPermanent default false
606 if this key is present and has a Boolean value of true, the key or
607 key pair will be added to the keychain.
608 * kSecAttrTokenID default NULL
609 The CFStringRef ID of the token to generate the key or keypair on. This
610 attribute can contain CFStringRef and can be present only in the top-level
611 parameters dictionary.
612 * kSecAttrApplicationTag default NULL
613 * kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits
614 * kSecAttrCanEncrypt default false for private keys, true for public keys
615 * kSecAttrCanDecrypt default true for private keys, false for public keys
616 * kSecAttrCanDerive default true
617 * kSecAttrCanSign default true for private keys, false for public keys
618 * kSecAttrCanVerify default false for private keys, true for public keys
619 * kSecAttrCanWrap default false for private keys, true for public keys
620 * kSecAttrCanUnwrap default true for private keys, false for public keys
621
622 NOTE: The function always saves keys in the keychain on macOS and as such attribute
623 kSecAttrIsPermanent is ignored. The function respects attribute kSecAttrIsPermanent
624 on iOS, tvOS and watchOS.
625 It is recommended to use SecKeyCreateRandomKey() which respects kSecAttrIsPermanent
626 on all platforms.
627 */
628 OSStatus SecKeyGeneratePair(CFDictionaryRef parameters,
629 SecKeyRef * _Nullable CF_RETURNS_RETAINED publicKey, SecKeyRef * _Nullable CF_RETURNS_RETAINED privateKey)
630 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_2_0);
631
632
633 #if SEC_OS_IPHONE
634 /*!
635 @function SecKeyRawSign
636 @abstract Given a private key and data to sign, generate a digital
637 signature.
638 @param key Private key with which to sign.
639 @param padding See Padding Types above, typically kSecPaddingPKCS1SHA1.
640 @param dataToSign The data to be signed, typically the digest of the
641 actual data.
642 @param dataToSignLen Length of dataToSign in bytes.
643 @param sig Pointer to buffer in which the signature will be returned.
644 @param sigLen IN/OUT maximum length of sig buffer on input, actualy
645 length of sig on output.
646 @result A result code. See "Security Error Codes" (SecBase.h).
647 @discussion If the padding argument is kSecPaddingPKCS1, PKCS1 padding
648 will be performed prior to signing. If this argument is kSecPaddingNone,
649 the incoming data will be signed "as is".
650
651 When PKCS1 padding is performed, the maximum length of data that can
652 be signed is the value returned by SecKeyGetBlockSize() - 11.
653
654 NOTE: The behavior this function with kSecPaddingNone is undefined if the
655 first byte of dataToSign is zero; there is no way to verify leading zeroes
656 as they are discarded during the calculation.
657
658 If you want to generate a proper PKCS1 style signature with DER encoding
659 of the digest type - and the dataToSign is a SHA1 digest - use
660 kSecPaddingPKCS1SHA1.
661 */
662 OSStatus SecKeyRawSign(
663 SecKeyRef key,
664 SecPadding padding,
665 const uint8_t *dataToSign,
666 size_t dataToSignLen,
667 uint8_t *sig,
668 size_t *sigLen)
669 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_2_0);
670
671
672 /*!
673 @function SecKeyRawVerify
674 @abstract Given a public key, data which has been signed, and a signature,
675 verify the signature.
676 @param key Public key with which to verify the signature.
677 @param padding See Padding Types above, typically kSecPaddingPKCS1SHA1.
678 @param signedData The data over which sig is being verified, typically
679 the digest of the actual data.
680 @param signedDataLen Length of signedData in bytes.
681 @param sig Pointer to the signature to verify.
682 @param sigLen Length of sig in bytes.
683 @result A result code. See "Security Error Codes" (SecBase.h).
684 @discussion If the padding argument is kSecPaddingPKCS1, PKCS1 padding
685 will be checked during verification. If this argument is kSecPaddingNone,
686 the incoming data will be compared directly to sig.
687
688 If you are verifying a proper PKCS1-style signature, with DER encoding
689 of the digest type - and the signedData is a SHA1 digest - use
690 kSecPaddingPKCS1SHA1.
691 */
692 OSStatus SecKeyRawVerify(
693 SecKeyRef key,
694 SecPadding padding,
695 const uint8_t *signedData,
696 size_t signedDataLen,
697 const uint8_t *sig,
698 size_t sigLen)
699 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_2_0);
700
701
702 /*!
703 @function SecKeyEncrypt
704 @abstract Encrypt a block of plaintext.
705 @param key Public key with which to encrypt the data.
706 @param padding See Padding Types above, typically kSecPaddingPKCS1.
707 @param plainText The data to encrypt.
708 @param plainTextLen Length of plainText in bytes, this must be less
709 or equal to the value returned by SecKeyGetBlockSize().
710 @param cipherText Pointer to the output buffer.
711 @param cipherTextLen On input, specifies how much space is available at
712 cipherText; on return, it is the actual number of cipherText bytes written.
713 @result A result code. See "Security Error Codes" (SecBase.h).
714 @discussion If the padding argument is kSecPaddingPKCS1 or kSecPaddingOAEP,
715 PKCS1 (respectively kSecPaddingOAEP) padding will be performed prior to encryption.
716 If this argument is kSecPaddingNone, the incoming data will be encrypted "as is".
717 kSecPaddingOAEP is the recommended value. Other value are not recommended
718 for security reason (Padding attack or malleability).
719
720 When PKCS1 padding is performed, the maximum length of data that can
721 be encrypted is the value returned by SecKeyGetBlockSize() - 11.
722
723 When memory usage is a critical issue, note that the input buffer
724 (plainText) can be the same as the output buffer (cipherText).
725 */
726 OSStatus SecKeyEncrypt(
727 SecKeyRef key,
728 SecPadding padding,
729 const uint8_t *plainText,
730 size_t plainTextLen,
731 uint8_t *cipherText,
732 size_t *cipherTextLen)
733 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_2_0);
734
735
736 /*!
737 @function SecKeyDecrypt
738 @abstract Decrypt a block of ciphertext.
739 @param key Private key with which to decrypt the data.
740 @param padding See Padding Types above, typically kSecPaddingPKCS1.
741 @param cipherText The data to decrypt.
742 @param cipherTextLen Length of cipherText in bytes, this must be less
743 or equal to the value returned by SecKeyGetBlockSize().
744 @param plainText Pointer to the output buffer.
745 @param plainTextLen On input, specifies how much space is available at
746 plainText; on return, it is the actual number of plainText bytes written.
747 @result A result code. See "Security Error Codes" (SecBase.h).
748 @discussion If the padding argument is kSecPaddingPKCS1 or kSecPaddingOAEP,
749 the corresponding padding will be removed after decryption.
750 If this argument is kSecPaddingNone, the decrypted data will be returned "as is".
751
752 When memory usage is a critical issue, note that the input buffer
753 (plainText) can be the same as the output buffer (cipherText).
754 */
755 OSStatus SecKeyDecrypt(
756 SecKeyRef key, /* Private key */
757 SecPadding padding, /* kSecPaddingNone,
758 kSecPaddingPKCS1,
759 kSecPaddingOAEP */
760 const uint8_t *cipherText,
761 size_t cipherTextLen, /* length of cipherText */
762 uint8_t *plainText,
763 size_t *plainTextLen) /* IN/OUT */
764 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_2_0);
765
766 #endif // SEC_OS_IPHONE
767
768 /*!
769 @function SecKeyCreateRandomKey
770 @abstract Generates a new public/private key pair.
771 @param parameters A dictionary containing one or more key-value pairs.
772 See the discussion sections below for a complete overview of options.
773 @param error On error, will be populated with an error object describing the failure.
774 See "Security Error Codes" (SecBase.h).
775 @return Newly generated private key. To get associated public key, use SecKeyCopyPublicKey().
776 @discussion In order to generate a keypair the parameters dictionary must
777 at least contain the following keys:
778
779 * kSecAttrKeyType with a value being kSecAttrKeyTypeRSA or any other
780 kSecAttrKeyType defined in SecItem.h
781 * kSecAttrKeySizeInBits with a value being a CFNumberRef or CFStringRef
782 containing the requested key size in bits. Example sizes for RSA
783 keys are: 512, 768, 1024, 2048.
784
785 The values below may be set either in the top-level dictionary or in a
786 dictionary that is the value of the kSecPrivateKeyAttrs or
787 kSecPublicKeyAttrs key in the top-level dictionary. Setting these
788 attributes explicitly will override the defaults below. See SecItem.h
789 for detailed information on these attributes including the types of
790 the values.
791
792 * kSecAttrLabel default NULL
793 * kSecAttrIsPermanent if this key is present and has a Boolean value of true,
794 the key or key pair will be added to the default keychain.
795 * kSecAttrTokenID if this key should be generated on specified token. This
796 attribute can contain CFStringRef and can be present only in the top-level
797 parameters dictionary.
798 * kSecAttrApplicationTag default NULL
799 * kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits
800 * kSecAttrCanEncrypt default false for private keys, true for public keys
801 * kSecAttrCanDecrypt default true for private keys, false for public keys
802 * kSecAttrCanDerive default true
803 * kSecAttrCanSign default true for private keys, false for public keys
804 * kSecAttrCanVerify default false for private keys, true for public keys
805 * kSecAttrCanWrap default false for private keys, true for public keys
806 * kSecAttrCanUnwrap default true for private keys, false for public keys
807 */
808 SecKeyRef _Nullable SecKeyCreateRandomKey(CFDictionaryRef parameters, CFErrorRef *error)
809 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
810
811 /*!
812 @function SecKeyCreateWithData
813 @abstract Create a SecKey from a well-defined external representation.
814 @param keyData CFData representing the key. The format of the data depends on the type of key being created.
815 @param attributes Dictionary containing attributes describing the key to be imported. The keys in this dictionary
816 are kSecAttr* constants from SecItem.h. Mandatory attributes are:
817 * kSecAttrKeyType
818 * kSecAttrKeyClass
819 @param error On error, will be populated with an error object describing the failure.
820 See "Security Error Codes" (SecBase.h).
821 @result A SecKey object representing the key, or NULL on failure.
822 @discussion This function does not add keys to any keychain, but the SecKey object it returns can be added
823 to keychain using the SecItemAdd function.
824 The requested data format depend on the type of key (kSecAttrKeyType) being created:
825 * kSecAttrKeyTypeRSA PKCS#1 format, public key can be also in x509 public key format
826 * kSecAttrKeyTypeECSECPrimeRandom ANSI X9.63 format (04 || X || Y [ || K])
827 */
828 SecKeyRef _Nullable SecKeyCreateWithData(CFDataRef keyData, CFDictionaryRef attributes, CFErrorRef *error)
829 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
830
831 /*!
832 @function SecKeyGetBlockSize
833 @abstract Decrypt a block of ciphertext.
834 @param key The key for which the block length is requested.
835 @result The block length of the key in bytes.
836 @discussion If for example key is an RSA key the value returned by
837 this function is the size of the modulus.
838 */
839 size_t SecKeyGetBlockSize(SecKeyRef key)
840 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_2_0);
841
842 /*!
843 @function SecKeyCopyExternalRepresentation
844 @abstract Create an external representation for the given key suitable for the key's type.
845 @param key The key to be exported.
846 @param error On error, will be populated with an error object describing the failure.
847 See "Security Error Codes" (SecBase.h).
848 @result A CFData representing the key in a format suitable for that key type.
849 @discussion This function may fail if the key is not exportable (e.g., bound to a smart card or Secure Enclave).
850 The format in which the key will be exported depends on the type of key:
851 * kSecAttrKeyTypeRSA PKCS#1 format
852 * kSecAttrKeyTypeECSECPrimeRandom ANSI X9.63 format (04 || X || Y [ || K])
853 */
854 CFDataRef _Nullable SecKeyCopyExternalRepresentation(SecKeyRef key, CFErrorRef *error)
855 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
856
857 /*!
858 @function SecKeyCopyAttributes
859 @abstract Retrieve keychain attributes of a key.
860 @param key The key whose attributes are to be retrieved.
861 @result Dictionary containing attributes of the key. The keys that populate this dictionary are defined
862 and discussed in SecItem.h.
863 @discussion The attributes provided by this function are:
864 * kSecAttrCanEncrypt
865 * kSecAttrCanDecrypt
866 * kSecAttrCanDerive
867 * kSecAttrCanSign
868 * kSecAttrCanVerify
869 * kSecAttrKeyClass
870 * kSecAttrKeyType
871 * kSecAttrKeySizeInBits
872 * kSecAttrTokenID
873 * kSecAttrApplicationLabel
874 Other values returned in that dictionary are RFU.
875 */
876 CFDictionaryRef _Nullable SecKeyCopyAttributes(SecKeyRef key)
877 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
878
879 /*!
880 @function SecKeyCopyPublicKey
881 @abstract Retrieve the public key from a key pair or private key.
882 @param key The key from which to retrieve a public key.
883 @result The public key or NULL if public key is not available for specified key.
884 @discussion Fails if key does not contain a public key or no public key can be computed from it.
885 */
886 SecKeyRef _Nullable SecKeyCopyPublicKey(SecKeyRef key)
887 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
888
889 /*!
890 @enum SecKeyAlgorithm
891 @abstract Available algorithms for performing cryptographic operations with SecKey object. String representation
892 of constant can be used for logging or debugging purposes, because they contain human readable names of the algorithm.
893
894 @constant kSecKeyAlgorithmRSASignatureRaw
895 Raw RSA sign/verify operation, size of input data must be the same as value returned by SecKeyGetBlockSize().
896
897 @constant kSecKeyAlgorithmRSASignatureDigestPKCS1v15Raw
898 RSA sign/verify operation, assumes that input data is digest and OID and digest algorithm as specified in PKCS# v1.5.
899 This algorithm is typically not used directly, instead use algorithm with specified digest, like
900 kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256.
901
902 @constant kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1
903 RSA signature with PKCS#1 padding, input data must be SHA-1 generated digest.
904
905 @constant kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA224
906 RSA signature with PKCS#1 padding, input data must be SHA-224 generated digest.
907
908 @constant kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256
909 RSA signature with PKCS#1 padding, input data must be SHA-256 generated digest.
910
911 @constant kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384
912 RSA signature with PKCS#1 padding, input data must be SHA-384 generated digest.
913
914 @constant kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512
915 RSA signature with PKCS#1 padding, input data must be SHA-512 generated digest.
916
917 @constant kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA1
918 RSA signature with PKCS#1 padding, SHA-1 digest is generated from input data of any size.
919
920 @constant kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA224
921 RSA signature with PKCS#1 padding, SHA-224 digest is generated from input data of any size.
922
923 @constant kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA256
924 RSA signature with PKCS#1 padding, SHA-256 digest is generated from input data of any size.
925
926 @constant kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA384
927 RSA signature with PKCS#1 padding, SHA-384 digest is generated from input data of any size.
928
929 @constant kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA512
930 RSA signature with PKCS#1 padding, SHA-512 digest is generated from input data of any size.
931
932 @constant kSecKeyAlgorithmRSASignatureDigestPSSSHA1
933 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-1 generated digest.
934 PSS padding is calculated using MGF1 with SHA1 and saltLength parameter is set to 20 (SHA-1 output size).
935
936 @constant kSecKeyAlgorithmRSASignatureDigestPSSSHA224
937 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-224 generated digest.
938 PSS padding is calculated using MGF1 with SHA224 and saltLength parameter is set to 28 (SHA-224 output size).
939
940 @constant kSecKeyAlgorithmRSASignatureDigestPSSSHA256
941 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-256 generated digest.
942 PSS padding is calculated using MGF1 with SHA256 and saltLength parameter is set to 32 (SHA-256 output size).
943
944 @constant kSecKeyAlgorithmRSASignatureDigestPSSSHA384
945 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-384 generated digest.
946 PSS padding is calculated using MGF1 with SHA384 and saltLength parameter is set to 48 (SHA-384 output size).
947
948 @constant kSecKeyAlgorithmRSASignatureDigestPSSSHA512
949 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-512 generated digest.
950 PSS padding is calculated using MGF1 with SHA512 and saltLength parameter is set to 64 (SHA-512 output size).
951
952 @constant kSecKeyAlgorithmRSASignatureMessagePSSSHA1
953 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-1 digest is generated from input data of any size.
954 PSS padding is calculated using MGF1 with SHA1 and saltLength parameter is set to 20 (SHA-1 output size).
955
956 @constant kSecKeyAlgorithmRSASignatureMessagePSSSHA224
957 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-224 digest is generated from input data of any size.
958 PSS padding is calculated using MGF1 with SHA224 and saltLength parameter is set to 28 (SHA-224 output size).
959
960 @constant kSecKeyAlgorithmRSASignatureMessagePSSSHA256
961 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-256 digest is generated from input data of any size.
962 PSS padding is calculated using MGF1 with SHA256 and saltLength parameter is set to 32 (SHA-256 output size).
963
964 @constant kSecKeyAlgorithmRSASignatureMessagePSSSHA384
965 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-384 digest is generated from input data of any size.
966 PSS padding is calculated using MGF1 with SHA384 and saltLength parameter is set to 48 (SHA-384 output size).
967
968 @constant kSecKeyAlgorithmRSASignatureMessagePSSSHA512
969 RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-512 digest is generated from input data of any size.
970 PSS padding is calculated using MGF1 with SHA512 and saltLength parameter is set to 64 (SHA-512 output size).
971
972 @constant kSecKeyAlgorithmECDSASignatureRFC4754
973 ECDSA algorithm, signature is concatenated r and s, big endian, data is message digest.
974
975 @constant kSecKeyAlgorithmECDSASignatureDigestX962
976 ECDSA algorithm, signature is in DER x9.62 encoding, input data is message digest.
977
978 @constant kSecKeyAlgorithmECDSASignatureDigestX962SHA1
979 ECDSA algorithm, signature is in DER x9.62 encoding, input data is message digest created by SHA1 algorithm.
980
981 @constant kSecKeyAlgorithmECDSASignatureDigestX962SHA1
982 ECDSA algorithm, signature is in DER x9.62 encoding, input data is message digest created by SHA224 algorithm.
983
984 @constant kSecKeyAlgorithmECDSASignatureDigestX962SHA1
985 ECDSA algorithm, signature is in DER x9.62 encoding, input data is message digest created by SHA256 algorithm.
986
987 @constant kSecKeyAlgorithmECDSASignatureDigestX962SHA1
988 ECDSA algorithm, signature is in DER x9.62 encoding, input data is message digest created by SHA384 algorithm.
989
990 @constant kSecKeyAlgorithmECDSASignatureDigestX962SHA1
991 ECDSA algorithm, signature is in DER x9.62 encoding, input data is message digest created by SHA512 algorithm.
992
993 @constant kSecKeyAlgorithmECDSASignatureMessageX962SHA1
994 ECDSA algorithm, signature is in DER x9.62 encoding, SHA-1 digest is generated from input data of any size.
995
996 @constant kSecKeyAlgorithmECDSASignatureMessageX962SHA224
997 ECDSA algorithm, signature is in DER x9.62 encoding, SHA-224 digest is generated from input data of any size.
998
999 @constant kSecKeyAlgorithmECDSASignatureMessageX962SHA256
1000 ECDSA algorithm, signature is in DER x9.62 encoding, SHA-256 digest is generated from input data of any size.
1001
1002 @constant kSecKeyAlgorithmECDSASignatureMessageX962SHA384
1003 ECDSA algorithm, signature is in DER x9.62 encoding, SHA-384 digest is generated from input data of any size.
1004
1005 @constant kSecKeyAlgorithmECDSASignatureMessageX962SHA512
1006 ECDSA algorithm, signature is in DER x9.62 encoding, SHA-512 digest is generated from input data of any size.
1007
1008 @constant kSecKeyAlgorithmRSAEncryptionRaw
1009 Raw RSA encryption or decryption, size of data must match RSA key modulus size. Note that direct
1010 use of this algorithm without padding is cryptographically very weak, it is important to always introduce
1011 some kind of padding. Input data size must be less or equal to the key block size and returned block has always
1012 the same size as block size, as returned by SecKeyGetBlockSize().
1013
1014 @constant kSecKeyAlgorithmRSAEncryptionPKCS1
1015 RSA encryption or decryption, data is padded using PKCS#1 padding scheme. This algorithm should be used only for
1016 backward compatibility with existing protocols and data. New implementations should choose cryptographically
1017 stronger algorithm instead (see kSecKeyAlgorithmRSAEncryptionOAEP). Input data must be at most
1018 "key block size - 11" bytes long and returned block has always the same size as block size, as returned
1019 by SecKeyGetBlockSize().
1020
1021 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA1
1022 RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA1. Input data must be at most
1023 "key block size - 42" bytes long and returned block has always the same size as block size, as returned
1024 by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA1AESGCM to be able to encrypt and decrypt arbitrary long data.
1025
1026 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA224
1027 RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA224. Input data must be at most
1028 "key block size - 58" bytes long and returned block has always the same size as block size, as returned
1029 by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA224AESGCM to be able to encrypt and decrypt arbitrary long data.
1030
1031 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA256
1032 RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA256. Input data must be at most
1033 "key block size - 66" bytes long and returned block has always the same size as block size, as returned
1034 by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA256AESGCM to be able to encrypt and decrypt arbitrary long data.
1035
1036 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA384
1037 RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA384. Input data must be at most
1038 "key block size - 98" bytes long and returned block has always the same size as block size, as returned
1039 by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA384AESGCM to be able to encrypt and decrypt arbitrary long data.
1040
1041 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA512
1042 RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA512. Input data must be at most
1043 "key block size - 130" bytes long and returned block has always the same size as block size, as returned
1044 by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA512AESGCM to be able to encrypt and decrypt arbitrary long data.
1045
1046 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA1AESGCM
1047 Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1048 mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1049 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1050 as authentication data for AES-GCM encryption.
1051
1052 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA224AESGCM
1053 Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1054 mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1055 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1056 as authentication data for AES-GCM encryption.
1057
1058 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA256AESGCM
1059 Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1060 mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1061 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1062 as authentication data for AES-GCM encryption.
1063
1064 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA384AESGCM
1065 Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1066 mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1067 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1068 as authentication data for AES-GCM encryption.
1069
1070 @constant kSecKeyAlgorithmRSAEncryptionOAEPSHA512AESGCM
1071 Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1072 mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1073 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1074 as authentication data for AES-GCM encryption.
1075
1076 @constant kSecKeyAlgorithmECIESEncryptionStandardX963SHA1AESGCM
1077 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM in new code.
1078 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA1. AES Key size
1079 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1080 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1081 all-zero 16 byte long IV (initialization vector).
1082
1083 @constant kSecKeyAlgorithmECIESEncryptionStandardX963SHA224AESGCM
1084 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA224AESGCM in new code.
1085 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224. AES Key size
1086 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1087 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1088 all-zero 16 byte long IV (initialization vector).
1089
1090 @constant kSecKeyAlgorithmECIESEncryptionStandardX963SHA256AESGCM
1091 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM in new code.
1092 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256. AES Key size
1093 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1094 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1095 all-zero 16 byte long IV (initialization vector).
1096
1097 @constant kSecKeyAlgorithmECIESEncryptionStandardX963SHA384AESGCM
1098 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA384AESGCM in new code.
1099 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384. AES Key size
1100 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1101 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1102 all-zero 16 byte long IV (initialization vector).
1103
1104 @constant kSecKeyAlgorithmECIESEncryptionStandardX963SHA512AESGCM
1105 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA512AESGCM in new code.
1106 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512. AES Key size
1107 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1108 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1109 all-zero 16 byte long IV (initialization vector).
1110
1111 @constant kSecKeyAlgorithmECIESEncryptionCofactorX963SHA1AESGCM
1112 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM in new code.
1113 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA1. AES Key size
1114 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1115 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1116 all-zero 16 byte long IV (initialization vector).
1117
1118 @constant kSecKeyAlgorithmECIESEncryptionCofactorX963SHA224AESGCM
1119 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA224AESGCM in new code.
1120 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224. AES Key size
1121 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1122 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1123 all-zero 16 byte long IV (initialization vector).
1124
1125 @constant kSecKeyAlgorithmECIESEncryptionCofactorX963SHA256AESGCM
1126 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM in new code.
1127 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256. AES Key size
1128 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1129 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1130 all-zero 16 byte long IV (initialization vector).
1131
1132 @constant kSecKeyAlgorithmECIESEncryptionCofactorX963SHA384AESGCM
1133 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA384AESGCM in new code.
1134 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384. AES Key size
1135 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1136 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1137 all-zero 16 byte long IV (initialization vector).
1138
1139 @constant kSecKeyAlgorithmECIESEncryptionCofactorX963SHA512AESGCM
1140 Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM in new code.
1141 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512. AES Key size
1142 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1143 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG and
1144 all-zero 16 byte long IV (initialization vector).
1145
1146 @constant kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA224AESGCM
1147 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1148 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224. AES Key size
1149 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1150 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1151 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1152
1153 @constant kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM
1154 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1155 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256. AES Key size
1156 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1157 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1158 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1159
1160 @constant kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA384AESGCM
1161 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1162 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384. AES Key size
1163 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1164 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1165 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1166
1167 @constant kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA512AESGCM
1168 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1169 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512. AES Key size
1170 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1171 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1172 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1173
1174 @constant kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA224AESGCM
1175 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1176 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224. AES Key size
1177 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1178 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1179 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1180
1181 @constant kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM
1182 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1183 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256. AES Key size
1184 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1185 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1186 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1187
1188 @constant kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA384AESGCM
1189 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1190 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384. AES Key size
1191 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1192 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1193 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1194
1195 @constant kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM
1196 ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1197 Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512. AES Key size
1198 is 128bit for EC keys <=256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF,
1199 and static public key data is used as authenticationData for AES-GCM processing. AES-GCM uses 16 bytes long TAG, AES key
1200 is first half of KDF output and 16 byte long IV (initialization vector) is second half of KDF output.
1201
1202 @constant kSecKeyAlgorithmECDHKeyExchangeCofactor
1203 Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys.
1204 This algorithm does not accept any parameters, length of output raw shared secret is given by the length of the key.
1205
1206 @constant kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA1
1207 Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1208 and apply ANSI X9.63 KDF with SHA1 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1209 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1210
1211 @constant kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224
1212 Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1213 and apply ANSI X9.63 KDF with SHA224 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1214 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1215
1216 @constant kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256
1217 Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1218 and apply ANSI X9.63 KDF with SHA256 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1219 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1220
1221 @constant kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384
1222 Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1223 and apply ANSI X9.63 KDF with SHA384 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1224 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1225
1226 @constant kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512
1227 Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1228 and apply ANSI X9.63 KDF with SHA512 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1229 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1230
1231 @constant kSecKeyAlgorithmECDHKeyExchangeStandard
1232 Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys.
1233 This algorithm does not accept any parameters, length of output raw shared secret is given by the length of the key.
1234
1235 @constant kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA1
1236 Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1237 and apply ANSI X9.63 KDF with SHA1 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1238 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1239
1240 @constant kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224
1241 Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1242 and apply ANSI X9.63 KDF with SHA224 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1243 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1244
1245 @constant kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256
1246 Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1247 and apply ANSI X9.63 KDF with SHA256 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1248 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1249
1250 @constant kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384
1251 Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1252 and apply ANSI X9.63 KDF with SHA384 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1253 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1254
1255 @constant kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512
1256 Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1257 and apply ANSI X9.63 KDF with SHA512 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1258 kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1259 */
1260
1261 typedef CFStringRef SecKeyAlgorithm CF_STRING_ENUM
1262 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1263
1264 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureRaw
1265 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1266
1267 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPKCS1v15Raw
1268 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1269
1270 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1
1271 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1272 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA224
1273 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1274 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256
1275 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1276 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384
1277 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1278 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512
1279 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1280
1281 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA1
1282 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1283 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA224
1284 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1285 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA256
1286 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1287 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA384
1288 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1289 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA512
1290 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1291
1292 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA1
1293 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1294 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA224
1295 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1296 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA256
1297 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1298 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA384
1299 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1300 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA512
1301 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1302
1303 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePSSSHA1
1304 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1305 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePSSSHA224
1306 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1307 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePSSSHA256
1308 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1309 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePSSSHA384
1310 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1311 extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePSSSHA512
1312 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1313
1314 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureRFC4754
1315 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1316
1317 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureDigestX962
1318 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1319 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureDigestX962SHA1
1320 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1321 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureDigestX962SHA224
1322 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1323 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureDigestX962SHA256
1324 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1325 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureDigestX962SHA384
1326 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1327 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureDigestX962SHA512
1328 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1329
1330 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureMessageX962SHA1
1331 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1332 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureMessageX962SHA224
1333 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1334 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureMessageX962SHA256
1335 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1336 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureMessageX962SHA384
1337 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1338 extern const SecKeyAlgorithm kSecKeyAlgorithmECDSASignatureMessageX962SHA512
1339 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1340
1341 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionRaw
1342 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1343 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionPKCS1
1344 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1345 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA1
1346 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1347 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA224
1348 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1349 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA256
1350 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1351 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA384
1352 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1353 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA512
1354 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1355
1356 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA1AESGCM
1357 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1358 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA224AESGCM
1359 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1360 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA256AESGCM
1361 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1362 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA384AESGCM
1363 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1364 extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA512AESGCM
1365 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1366
1367 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardX963SHA1AESGCM
1368 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1369 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardX963SHA224AESGCM
1370 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1371 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardX963SHA256AESGCM
1372 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1373 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardX963SHA384AESGCM
1374 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1375 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardX963SHA512AESGCM
1376 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1377
1378 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorX963SHA1AESGCM
1379 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1380 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorX963SHA224AESGCM
1381 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1382 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorX963SHA256AESGCM
1383 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1384 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorX963SHA384AESGCM
1385 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1386 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorX963SHA512AESGCM
1387 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1388
1389 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA224AESGCM
1390 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1391 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM
1392 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1393 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA384AESGCM
1394 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1395 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA512AESGCM
1396 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1397
1398 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA224AESGCM
1399 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1400 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM
1401 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1402 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA384AESGCM
1403 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1404 extern const SecKeyAlgorithm kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM
1405 __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0);
1406
1407 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeStandard
1408 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1409 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA1
1410 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1411 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224
1412 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1413 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256
1414 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1415 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384
1416 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1417 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512
1418 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1419
1420 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeCofactor
1421 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1422 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA1
1423 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1424 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224
1425 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1426 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256
1427 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1428 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384
1429 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1430 extern const SecKeyAlgorithm kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512
1431 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1432
1433 /*!
1434 @function SecKeyCreateSignature
1435 @abstract Given a private key and data to sign, generate a digital signature.
1436 @param key Private key with which to sign.
1437 @param algorithm One of SecKeyAlgorithm constants suitable to generate signature with this key.
1438 @param dataToSign The data to be signed, typically the digest of the actual data.
1439 @param error On error, will be populated with an error object describing the failure.
1440 See "Security Error Codes" (SecBase.h).
1441 @result The signature over dataToSign represented as a CFData, or NULL on failure.
1442 @discussion Computes digital signature using specified key over input data. The operation algorithm
1443 further defines the exact format of input data, operation to be performed and output signature.
1444 */
1445 CFDataRef _Nullable SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error)
1446 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1447
1448 /*!
1449 @function SecKeyVerifySignature
1450 @abstract Given a public key, data which has been signed, and a signature, verify the signature.
1451 @param key Public key with which to verify the signature.
1452 @param algorithm One of SecKeyAlgorithm constants suitable to verify signature with this key.
1453 @param signedData The data over which sig is being verified, typically the digest of the actual data.
1454 @param signature The signature to verify.
1455 @param error On error, will be populated with an error object describing the failure.
1456 See "Security Error Codes" (SecBase.h).
1457 @result True if the signature was valid, False otherwise.
1458 @discussion Verifies digital signature operation using specified key and signed data. The operation algorithm
1459 further defines the exact format of input data, signature and operation to be performed.
1460 */
1461 Boolean SecKeyVerifySignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef signedData, CFDataRef signature, CFErrorRef *error)
1462 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1463
1464 /*!
1465 @function SecKeyCreateEncryptedData
1466 @abstract Encrypt a block of plaintext.
1467 @param key Public key with which to encrypt the data.
1468 @param algorithm One of SecKeyAlgorithm constants suitable to perform encryption with this key.
1469 @param plaintext The data to encrypt. The length and format of the data must conform to chosen algorithm,
1470 typically be less or equal to the value returned by SecKeyGetBlockSize().
1471 @param error On error, will be populated with an error object describing the failure.
1472 See "Security Error Codes" (SecBase.h).
1473 @result The ciphertext represented as a CFData, or NULL on failure.
1474 @discussion Encrypts plaintext data using specified key. The exact type of the operation including the format
1475 of input and output data is specified by encryption algorithm.
1476 */
1477 CFDataRef _Nullable SecKeyCreateEncryptedData(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef plaintext,
1478 CFErrorRef *error)
1479 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1480
1481 /*!
1482 @function SecKeyCreateDecryptedData
1483 @abstract Decrypt a block of ciphertext.
1484 @param key Private key with which to decrypt the data.
1485 @param algorithm One of SecKeyAlgorithm constants suitable to perform decryption with this key.
1486 @param ciphertext The data to decrypt. The length and format of the data must conform to chosen algorithm,
1487 typically be less or equal to the value returned by SecKeyGetBlockSize().
1488 @param error On error, will be populated with an error object describing the failure.
1489 See "Security Error Codes" (SecBase.h).
1490 @result The plaintext represented as a CFData, or NULL on failure.
1491 @discussion Decrypts ciphertext data using specified key. The exact type of the operation including the format
1492 of input and output data is specified by decryption algorithm.
1493 */
1494 CFDataRef _Nullable SecKeyCreateDecryptedData(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef ciphertext,
1495 CFErrorRef *error)
1496 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1497
1498 /*!
1499 @enum SecKeyKeyExchangeParameter SecKey Key Exchange parameters
1500 @constant kSecKeyKeyExchangeParameterRequestedSize Contains CFNumberRef with requested result size in bytes.
1501 @constant kSecKeyKeyExchangeParameterSharedInfo Contains CFDataRef with additional shared info
1502 for KDF (key derivation function).
1503 */
1504 typedef CFStringRef SecKeyKeyExchangeParameter CF_STRING_ENUM
1505 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1506 extern const SecKeyKeyExchangeParameter kSecKeyKeyExchangeParameterRequestedSize
1507 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1508 extern const SecKeyKeyExchangeParameter kSecKeyKeyExchangeParameterSharedInfo
1509 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1510
1511 /*!
1512 @function SecKeyCopyKeyExchangeResult
1513 @abstract Perform Diffie-Hellman style of key exchange operation, optionally with additional key-derivation steps.
1514 @param algorithm One of SecKeyAlgorithm constants suitable to perform this operation.
1515 @param publicKey Remote party's public key.
1516 @param parameters Dictionary with parameters, see SecKeyKeyExchangeParameter constants. Used algorithm
1517 determines the set of required and optional parameters to be used.
1518 @param error Pointer to an error object on failure.
1519 See "Security Error Codes" (SecBase.h).
1520 @result Result of key exchange operation as a CFDataRef, or NULL on failure.
1521 */
1522 CFDataRef _Nullable SecKeyCopyKeyExchangeResult(SecKeyRef privateKey, SecKeyAlgorithm algorithm, SecKeyRef publicKey, CFDictionaryRef parameters, CFErrorRef *error)
1523 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1524
1525 /*!
1526 @enum SecKeyOperationType
1527 @abstract Defines types of cryptographic operations available with SecKey instance.
1528
1529 @constant kSecKeyOperationTypeSign
1530 Represents SecKeyCreateSignature()
1531
1532 @constant kSecKeyOperationTypeVerify
1533 Represents SecKeyVerifySignature()
1534
1535 @constant kSecKeyOperationTypeEncrypt
1536 Represents SecKeyCreateEncryptedData()
1537
1538 @constant kSecKeyOperationTypeDecrypt
1539 Represents SecKeyCreateDecryptedData()
1540
1541 @constant kSecKeyOperationTypeKeyExchange
1542 Represents SecKeyCopyKeyExchangeResult()
1543 */
1544 typedef CF_ENUM(CFIndex, SecKeyOperationType) {
1545 kSecKeyOperationTypeSign = 0,
1546 kSecKeyOperationTypeVerify = 1,
1547 kSecKeyOperationTypeEncrypt = 2,
1548 kSecKeyOperationTypeDecrypt = 3,
1549 kSecKeyOperationTypeKeyExchange = 4,
1550 } __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1551
1552 /*!
1553 @function SecKeyIsAlgorithmSupported
1554 @abstract Checks whether key supports specified algorithm for specified operation.
1555 @param key Key to query
1556 @param operation Operation type for which the key is queried
1557 @param algorithm Algorithm which is queried
1558 @return True if key supports specified algorithm for specified operation, False otherwise.
1559 */
1560 Boolean SecKeyIsAlgorithmSupported(SecKeyRef key, SecKeyOperationType operation, SecKeyAlgorithm algorithm)
1561 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
1562
1563 CF_IMPLICIT_BRIDGING_DISABLED
1564 CF_ASSUME_NONNULL_END
1565
1566 __END_DECLS
1567
1568 #endif /* !_SECURITY_SECKEY_H_ */