objc2_security/generated/SecKey.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeykeyclass?language=objc)
12#[deprecated = "No longer supported"]
13pub const kSecKeyKeyClass: c_int = 0;
14/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyprintname?language=objc)
15#[deprecated = "No longer supported"]
16pub const kSecKeyPrintName: c_int = 1;
17/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalias?language=objc)
18#[deprecated = "No longer supported"]
19pub const kSecKeyAlias: c_int = 2;
20/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeypermanent?language=objc)
21#[deprecated = "No longer supported"]
22pub const kSecKeyPermanent: c_int = 3;
23/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyprivate?language=objc)
24#[deprecated = "No longer supported"]
25pub const kSecKeyPrivate: c_int = 4;
26/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeymodifiable?language=objc)
27#[deprecated = "No longer supported"]
28pub const kSecKeyModifiable: c_int = 5;
29/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeylabel?language=objc)
30#[deprecated = "No longer supported"]
31pub const kSecKeyLabel: c_int = 6;
32/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyapplicationtag?language=objc)
33#[deprecated = "No longer supported"]
34pub const kSecKeyApplicationTag: c_int = 7;
35/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeykeycreator?language=objc)
36#[deprecated = "No longer supported"]
37pub const kSecKeyKeyCreator: c_int = 8;
38/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeykeytype?language=objc)
39#[deprecated = "No longer supported"]
40pub const kSecKeyKeyType: c_int = 9;
41/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeykeysizeinbits?language=objc)
42#[deprecated = "No longer supported"]
43pub const kSecKeyKeySizeInBits: c_int = 10;
44/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyeffectivekeysize?language=objc)
45#[deprecated = "No longer supported"]
46pub const kSecKeyEffectiveKeySize: c_int = 11;
47/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeystartdate?language=objc)
48#[deprecated = "No longer supported"]
49pub const kSecKeyStartDate: c_int = 12;
50/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyenddate?language=objc)
51#[deprecated = "No longer supported"]
52pub const kSecKeyEndDate: c_int = 13;
53/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeysensitive?language=objc)
54#[deprecated = "No longer supported"]
55pub const kSecKeySensitive: c_int = 14;
56/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalwayssensitive?language=objc)
57#[deprecated = "No longer supported"]
58pub const kSecKeyAlwaysSensitive: c_int = 15;
59/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyextractable?language=objc)
60#[deprecated = "No longer supported"]
61pub const kSecKeyExtractable: c_int = 16;
62/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyneverextractable?language=objc)
63#[deprecated = "No longer supported"]
64pub const kSecKeyNeverExtractable: c_int = 17;
65/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyencrypt?language=objc)
66#[deprecated = "No longer supported"]
67pub const kSecKeyEncrypt: c_int = 18;
68/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeydecrypt?language=objc)
69#[deprecated = "No longer supported"]
70pub const kSecKeyDecrypt: c_int = 19;
71/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyderive?language=objc)
72#[deprecated = "No longer supported"]
73pub const kSecKeyDerive: c_int = 20;
74/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeysign?language=objc)
75#[deprecated = "No longer supported"]
76pub const kSecKeySign: c_int = 21;
77/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyverify?language=objc)
78#[deprecated = "No longer supported"]
79pub const kSecKeyVerify: c_int = 22;
80/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeysignrecover?language=objc)
81#[deprecated = "No longer supported"]
82pub const kSecKeySignRecover: c_int = 23;
83/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyverifyrecover?language=objc)
84#[deprecated = "No longer supported"]
85pub const kSecKeyVerifyRecover: c_int = 24;
86/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeywrap?language=objc)
87#[deprecated = "No longer supported"]
88pub const kSecKeyWrap: c_int = 25;
89/// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyunwrap?language=objc)
90#[deprecated = "No longer supported"]
91pub const kSecKeyUnwrap: c_int = 26;
92
93/// Determines the type of credential returned by SecKeyGetCredentials.
94///
95/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccredentialtype?language=objc)
96// NS_ENUM
97#[cfg(feature = "cssmconfig")]
98#[deprecated = "No longer supported"]
99#[repr(transparent)]
100#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
101pub struct SecCredentialType(pub uint32);
102#[cfg(feature = "cssmconfig")]
103impl SecCredentialType {
104 #[doc(alias = "kSecCredentialTypeDefault")]
105 #[deprecated = "No longer supported"]
106 pub const Default: Self = Self(0);
107 #[doc(alias = "kSecCredentialTypeWithUI")]
108 #[deprecated = "No longer supported"]
109 pub const WithUI: Self = Self(1);
110 #[doc(alias = "kSecCredentialTypeNoUI")]
111 #[deprecated = "No longer supported"]
112 pub const NoUI: Self = Self(2);
113}
114
115#[cfg(all(feature = "cssmconfig", feature = "objc2"))]
116unsafe impl Encode for SecCredentialType {
117 const ENCODING: Encoding = uint32::ENCODING;
118}
119
120#[cfg(all(feature = "cssmconfig", feature = "objc2"))]
121unsafe impl RefEncode for SecCredentialType {
122 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
123}
124
125/// Supported padding types.
126///
127/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secpadding?language=objc)
128// NS_OPTIONS
129#[deprecated = "Replaced with SecKeyAlgorithm"]
130#[repr(transparent)]
131#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
132pub struct SecPadding(pub u32);
133bitflags::bitflags! {
134 impl SecPadding: u32 {
135 #[doc(alias = "kSecPaddingNone")]
136#[deprecated = "Replaced with SecKeyAlgorithm"]
137 const None = 0;
138 #[doc(alias = "kSecPaddingPKCS1")]
139#[deprecated = "Replaced with SecKeyAlgorithm"]
140 const PKCS1 = 1;
141 #[doc(alias = "kSecPaddingOAEP")]
142#[deprecated = "Replaced with SecKeyAlgorithm"]
143 const OAEP = 2;
144 #[doc(alias = "kSecPaddingSigRaw")]
145#[deprecated = "Replaced with SecKeyAlgorithm"]
146 const SigRaw = 0x4000;
147 #[doc(alias = "kSecPaddingPKCS1MD2")]
148#[deprecated = "Replaced with SecKeyAlgorithm"]
149 const PKCS1MD2 = 0x8000;
150 #[doc(alias = "kSecPaddingPKCS1MD5")]
151#[deprecated = "Replaced with SecKeyAlgorithm"]
152 const PKCS1MD5 = 0x8001;
153 #[doc(alias = "kSecPaddingPKCS1SHA1")]
154#[deprecated = "Replaced with SecKeyAlgorithm"]
155 const PKCS1SHA1 = 0x8002;
156 #[doc(alias = "kSecPaddingPKCS1SHA224")]
157#[deprecated = "Replaced with SecKeyAlgorithm"]
158 const PKCS1SHA224 = 0x8003;
159 #[doc(alias = "kSecPaddingPKCS1SHA256")]
160#[deprecated = "Replaced with SecKeyAlgorithm"]
161 const PKCS1SHA256 = 0x8004;
162 #[doc(alias = "kSecPaddingPKCS1SHA384")]
163#[deprecated = "Replaced with SecKeyAlgorithm"]
164 const PKCS1SHA384 = 0x8005;
165 #[doc(alias = "kSecPaddingPKCS1SHA512")]
166#[deprecated = "Replaced with SecKeyAlgorithm"]
167 const PKCS1SHA512 = 0x8006;
168 }
169}
170
171#[cfg(feature = "objc2")]
172unsafe impl Encode for SecPadding {
173 const ENCODING: Encoding = u32::ENCODING;
174}
175
176#[cfg(feature = "objc2")]
177unsafe impl RefEncode for SecPadding {
178 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
179}
180
181/// Supported key lengths.
182///
183/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeysizes?language=objc)
184// NS_ENUM
185#[deprecated = "No longer supported"]
186#[repr(transparent)]
187#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
188pub struct SecKeySizes(pub u32);
189impl SecKeySizes {
190 #[doc(alias = "kSecDefaultKeySize")]
191 #[deprecated = "No longer supported"]
192 pub const SecDefaultKeySize: Self = Self(0);
193 #[doc(alias = "kSec3DES192")]
194 #[deprecated = "No longer supported"]
195 pub const Sec3DES192: Self = Self(192);
196 #[doc(alias = "kSecAES128")]
197 #[deprecated = "No longer supported"]
198 pub const SecAES128: Self = Self(128);
199 #[doc(alias = "kSecAES192")]
200 #[deprecated = "No longer supported"]
201 pub const SecAES192: Self = Self(192);
202 #[doc(alias = "kSecAES256")]
203 #[deprecated = "No longer supported"]
204 pub const SecAES256: Self = Self(256);
205 #[doc(alias = "kSecp192r1")]
206 #[deprecated = "No longer supported"]
207 pub const Secp192r1: Self = Self(192);
208 #[doc(alias = "kSecp256r1")]
209 #[deprecated = "No longer supported"]
210 pub const Secp256r1: Self = Self(256);
211 #[doc(alias = "kSecp384r1")]
212 #[deprecated = "No longer supported"]
213 pub const Secp384r1: Self = Self(384);
214 #[doc(alias = "kSecp521r1")]
215 #[deprecated = "No longer supported"]
216 pub const Secp521r1: Self = Self(521);
217 #[doc(alias = "kSecRSAMin")]
218 #[deprecated = "No longer supported"]
219 pub const SecRSAMin: Self = Self(1024);
220 #[doc(alias = "kSecRSAMax")]
221 #[deprecated = "No longer supported"]
222 pub const SecRSAMax: Self = Self(4096);
223}
224
225#[cfg(feature = "objc2")]
226unsafe impl Encode for SecKeySizes {
227 const ENCODING: Encoding = u32::ENCODING;
228}
229
230#[cfg(feature = "objc2")]
231unsafe impl RefEncode for SecKeySizes {
232 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
233}
234
235extern "C" {
236 /// Predefined key constants used to get or set values in a dictionary.
237 /// These are used to provide explicit parameters to key generation functions
238 /// when non-default values are desired. See the description of the
239 /// SecKeyGeneratePair API for usage information.
240 ///
241 /// containing attributes specific for the private key to be generated.
242 ///
243 /// containing attributes specific for the public key to be generated.
244 ///
245 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksecprivatekeyattrs?language=objc)
246 pub static kSecPrivateKeyAttrs: &'static CFString;
247}
248
249extern "C" {
250 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpublickeyattrs?language=objc)
251 pub static kSecPublicKeyAttrs: &'static CFString;
252}
253
254#[cfg(feature = "SecBase")]
255unsafe impl ConcreteType for SecKey {
256 /// Returns the type identifier of SecKey instances.
257 ///
258 /// Returns: The CFTypeID of SecKey instances.
259 #[doc(alias = "SecKeyGetTypeID")]
260 #[inline]
261 fn type_id() -> CFTypeID {
262 extern "C-unwind" {
263 fn SecKeyGetTypeID() -> CFTypeID;
264 }
265 unsafe { SecKeyGetTypeID() }
266 }
267}
268
269#[cfg(feature = "SecBase")]
270impl SecKey {
271 /// Creates an asymmetric key pair and stores it in a specified keychain.
272 ///
273 /// Parameter `keychainRef`: A reference to the keychain in which to store the private and public key items. Specify NULL for the default keychain.
274 ///
275 /// Parameter `algorithm`: An algorithm for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
276 ///
277 /// Parameter `keySizeInBits`: A key size for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
278 ///
279 /// Parameter `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.
280 ///
281 /// Parameter `publicKeyUsage`: A bit mask indicating all permitted uses for the new public key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.
282 ///
283 /// Parameter `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.
284 ///
285 /// Parameter `privateKeyUsage`: A bit mask indicating all permitted uses for the new private key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.
286 ///
287 /// Parameter `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.
288 ///
289 /// Parameter `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.
290 ///
291 /// Parameter `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.
292 ///
293 /// Parameter `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.
294 ///
295 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
296 ///
297 /// This API is deprecated for 10.7. Please use the SecKeyGeneratePair API instead.
298 #[doc(alias = "SecKeyCreatePair")]
299 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
300 #[deprecated = "CSSM is not supported"]
301 #[inline]
302 pub unsafe fn create_pair(
303 keychain_ref: Option<&SecKeychain>,
304 algorithm: CSSM_ALGORITHMS,
305 key_size_in_bits: uint32,
306 context_handle: CSSM_CC_HANDLE,
307 public_key_usage: CSSM_KEYUSE,
308 public_key_attr: uint32,
309 private_key_usage: CSSM_KEYUSE,
310 private_key_attr: uint32,
311 initial_access: Option<&SecAccess>,
312 public_key: *mut *mut SecKey,
313 private_key: *mut *mut SecKey,
314 ) -> OSStatus {
315 extern "C-unwind" {
316 fn SecKeyCreatePair(
317 keychain_ref: Option<&SecKeychain>,
318 algorithm: CSSM_ALGORITHMS,
319 key_size_in_bits: uint32,
320 context_handle: CSSM_CC_HANDLE,
321 public_key_usage: CSSM_KEYUSE,
322 public_key_attr: uint32,
323 private_key_usage: CSSM_KEYUSE,
324 private_key_attr: uint32,
325 initial_access: Option<&SecAccess>,
326 public_key: *mut *mut SecKey,
327 private_key: *mut *mut SecKey,
328 ) -> OSStatus;
329 }
330 unsafe {
331 SecKeyCreatePair(
332 keychain_ref,
333 algorithm,
334 key_size_in_bits,
335 context_handle,
336 public_key_usage,
337 public_key_attr,
338 private_key_usage,
339 private_key_attr,
340 initial_access,
341 public_key,
342 private_key,
343 )
344 }
345 }
346
347 /// Creates a symmetric key and optionally stores it in a specified keychain.
348 ///
349 /// Parameter `keychainRef`: (optional) A reference to the keychain in which to store the generated key. Specify NULL to generate a transient key.
350 ///
351 /// Parameter `algorithm`: An algorithm for the symmetric key. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
352 ///
353 /// Parameter `keySizeInBits`: A key size for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.
354 ///
355 /// Parameter `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.
356 ///
357 /// Parameter `keyUsage`: A bit mask indicating all permitted uses for the new key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.
358 ///
359 /// Parameter `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.
360 ///
361 /// Parameter `initialAccess`: (optional) A SecAccess object that determines the initial access rights for the key. This parameter is ignored if the keychainRef is NULL.
362 ///
363 /// Parameter `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.
364 ///
365 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
366 ///
367 /// This API is deprecated for 10.7. Please use the SecKeyGenerateSymmetric API instead.
368 #[doc(alias = "SecKeyGenerate")]
369 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
370 #[deprecated = "CSSM is not supported"]
371 #[inline]
372 pub unsafe fn generate(
373 keychain_ref: Option<&SecKeychain>,
374 algorithm: CSSM_ALGORITHMS,
375 key_size_in_bits: uint32,
376 context_handle: CSSM_CC_HANDLE,
377 key_usage: CSSM_KEYUSE,
378 key_attr: uint32,
379 initial_access: Option<&SecAccess>,
380 key_ref: *mut *mut SecKey,
381 ) -> OSStatus {
382 extern "C-unwind" {
383 fn SecKeyGenerate(
384 keychain_ref: Option<&SecKeychain>,
385 algorithm: CSSM_ALGORITHMS,
386 key_size_in_bits: uint32,
387 context_handle: CSSM_CC_HANDLE,
388 key_usage: CSSM_KEYUSE,
389 key_attr: uint32,
390 initial_access: Option<&SecAccess>,
391 key_ref: *mut *mut SecKey,
392 ) -> OSStatus;
393 }
394 unsafe {
395 SecKeyGenerate(
396 keychain_ref,
397 algorithm,
398 key_size_in_bits,
399 context_handle,
400 key_usage,
401 key_attr,
402 initial_access,
403 key_ref,
404 )
405 }
406 }
407
408 /// Returns a pointer to the CSSM_KEY for the given key item reference.
409 ///
410 /// Parameter `key`: A keychain key item reference. The key item must be of class type kSecPublicKeyItemClass, kSecPrivateKeyItemClass, or kSecSymmetricKeyItemClass.
411 ///
412 /// Parameter `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.
413 ///
414 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
415 ///
416 /// 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.
417 #[doc(alias = "SecKeyGetCSSMKey")]
418 #[cfg(all(
419 feature = "SecAsn1Types",
420 feature = "SecBase",
421 feature = "cssmconfig",
422 feature = "cssmtype"
423 ))]
424 #[deprecated]
425 #[inline]
426 pub unsafe fn cssm_key(self: &SecKey, cssm_key: NonNull<*const CSSM_KEY>) -> OSStatus {
427 extern "C-unwind" {
428 fn SecKeyGetCSSMKey(key: &SecKey, cssm_key: NonNull<*const CSSM_KEY>) -> OSStatus;
429 }
430 unsafe { SecKeyGetCSSMKey(self, cssm_key) }
431 }
432
433 /// Returns the CSSM_CSP_HANDLE for the given key reference. The handle is valid until the key reference is released.
434 ///
435 /// Parameter `keyRef`: A key reference.
436 ///
437 /// Parameter `cspHandle`: On return, the CSSM_CSP_HANDLE for the given keychain.
438 ///
439 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
440 ///
441 /// This API is deprecated in 10.7. Its use should no longer be needed.
442 #[doc(alias = "SecKeyGetCSPHandle")]
443 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
444 #[deprecated]
445 #[inline]
446 pub unsafe fn csp_handle(self: &SecKey, csp_handle: NonNull<CSSM_CSP_HANDLE>) -> OSStatus {
447 extern "C-unwind" {
448 fn SecKeyGetCSPHandle(
449 key_ref: &SecKey,
450 csp_handle: NonNull<CSSM_CSP_HANDLE>,
451 ) -> OSStatus;
452 }
453 unsafe { SecKeyGetCSPHandle(self, csp_handle) }
454 }
455
456 /// For a given key, return a pointer to a CSSM_ACCESS_CREDENTIALS structure which will allow the key to be used.
457 ///
458 /// Parameter `keyRef`: The key for which a credential is requested.
459 ///
460 /// Parameter `operation`: The type of operation to be performed with this key. See "Authorization tag type" for defined operations (cssmtype.h).
461 ///
462 /// Parameter `credentialType`: The type of credential requested.
463 ///
464 /// Parameter `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.
465 ///
466 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
467 #[doc(alias = "SecKeyGetCredentials")]
468 #[cfg(all(
469 feature = "SecAsn1Types",
470 feature = "SecBase",
471 feature = "cssmconfig",
472 feature = "cssmtype"
473 ))]
474 #[deprecated]
475 #[inline]
476 pub unsafe fn credentials(
477 self: &SecKey,
478 operation: CSSM_ACL_AUTHORIZATION_TAG,
479 credential_type: SecCredentialType,
480 out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>,
481 ) -> OSStatus {
482 extern "C-unwind" {
483 fn SecKeyGetCredentials(
484 key_ref: &SecKey,
485 operation: CSSM_ACL_AUTHORIZATION_TAG,
486 credential_type: SecCredentialType,
487 out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>,
488 ) -> OSStatus;
489 }
490 unsafe { SecKeyGetCredentials(self, operation, credential_type, out_credentials) }
491 }
492
493 /// Generates a random symmetric key with the specified length
494 /// and algorithm type.
495 ///
496 ///
497 /// Parameter `parameters`: A dictionary containing one or more key-value pairs.
498 /// See the discussion sections below for a complete overview of options.
499 ///
500 /// Parameter `error`: An optional pointer to a CFErrorRef. This value is set
501 /// if an error occurred. If not NULL, the caller is responsible for
502 /// releasing the CFErrorRef.
503 ///
504 /// Returns: On return, a SecKeyRef reference to the symmetric key, or
505 /// NULL if the key could not be created.
506 ///
507 ///
508 /// In order to generate a symmetric key, the parameters dictionary
509 /// must at least contain the following keys:
510 ///
511 /// kSecAttrKeyType with a value of kSecAttrKeyTypeAES or any other
512 /// kSecAttrKeyType defined in SecItem.h
513 /// kSecAttrKeySizeInBits with a value being a CFNumberRef containing
514 /// the requested key size in bits. Example sizes for AES keys are:
515 /// 128, 192, 256, 512.
516 ///
517 /// To store the generated symmetric key in a keychain, set these keys:
518 /// kSecUseKeychain (value is a SecKeychainRef)
519 /// kSecAttrLabel (a user-visible label whose value is a CFStringRef,
520 /// e.g. "My App's Encryption Key")
521 /// kSecAttrApplicationLabel (a label defined by your application, whose
522 /// value is a CFDataRef and which can be used to find this key in a
523 /// subsequent call to SecItemCopyMatching, e.g. "ID-1234567890-9876-0151")
524 ///
525 /// To specify the generated key's access control settings, set this key:
526 /// kSecAttrAccess (value is a SecAccessRef)
527 ///
528 /// The keys below may be optionally set in the parameters dictionary
529 /// (with a CFBooleanRef value) to override the default usage values:
530 ///
531 /// kSecAttrCanEncrypt (defaults to true if not explicitly specified)
532 /// kSecAttrCanDecrypt (defaults to true if not explicitly specified)
533 /// kSecAttrCanWrap (defaults to true if not explicitly specified)
534 /// kSecAttrCanUnwrap (defaults to true if not explicitly specified)
535 #[doc(alias = "SecKeyGenerateSymmetric")]
536 #[cfg(feature = "SecBase")]
537 #[deprecated = "No longer supported"]
538 #[inline]
539 pub unsafe fn generate_symmetric(
540 parameters: &CFDictionary,
541 error: *mut *mut CFError,
542 ) -> Option<CFRetained<SecKey>> {
543 extern "C-unwind" {
544 fn SecKeyGenerateSymmetric(
545 parameters: &CFDictionary,
546 error: *mut *mut CFError,
547 ) -> Option<NonNull<SecKey>>;
548 }
549 let ret = unsafe { SecKeyGenerateSymmetric(parameters, error) };
550 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
551 }
552
553 /// Creates a symmetric key with the given data and sets the
554 /// algorithm type specified.
555 ///
556 ///
557 /// Parameter `parameters`: A dictionary containing one or more key-value pairs.
558 /// See the discussion sections below for a complete overview of options.
559 ///
560 /// Returns: On return, a SecKeyRef reference to the symmetric key.
561 ///
562 ///
563 /// In order to generate a symmetric key the parameters dictionary must
564 /// at least contain the following keys:
565 ///
566 /// kSecAttrKeyType with a value of kSecAttrKeyTypeAES or any other
567 /// kSecAttrKeyType defined in SecItem.h
568 ///
569 /// The keys below may be optionally set in the parameters dictionary
570 /// (with a CFBooleanRef value) to override the default usage values:
571 ///
572 /// kSecAttrCanEncrypt (defaults to true if not explicitly specified)
573 /// kSecAttrCanDecrypt (defaults to true if not explicitly specified)
574 /// kSecAttrCanWrap (defaults to true if not explicitly specified)
575 /// kSecAttrCanUnwrap (defaults to true if not explicitly specified)
576 #[doc(alias = "SecKeyCreateFromData")]
577 #[cfg(feature = "SecBase")]
578 #[deprecated = "No longer supported"]
579 #[inline]
580 pub unsafe fn from_data(
581 parameters: &CFDictionary,
582 key_data: &CFData,
583 error: *mut *mut CFError,
584 ) -> Option<CFRetained<SecKey>> {
585 extern "C-unwind" {
586 fn SecKeyCreateFromData(
587 parameters: &CFDictionary,
588 key_data: &CFData,
589 error: *mut *mut CFError,
590 ) -> Option<NonNull<SecKey>>;
591 }
592 let ret = unsafe { SecKeyCreateFromData(parameters, key_data, error) };
593 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
594 }
595}
596
597/// Delivers the result from an asynchronous key pair generation.
598///
599/// Parameter `publicKey`: - the public key generated. You must retain publicKey if you wish to use it after your block returns.
600///
601/// Parameter `privateKey`: - the private key generated. You must retain publicKey if you wish to use it after your block returns.
602///
603/// Parameter `error`: - Any errors returned. You must retain error if you wish to use it after your block returns.
604///
605/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeygeneratepairblock?language=objc)
606#[cfg(all(feature = "SecBase", feature = "block2"))]
607pub type SecKeyGeneratePairBlock =
608 *mut block2::DynBlock<dyn Fn(NonNull<SecKey>, NonNull<SecKey>, NonNull<CFError>)>;
609
610#[cfg(feature = "SecBase")]
611impl SecKey {
612 /// Derives a symmetric key from a password.
613 ///
614 ///
615 /// Parameter `password`: The password from which the keyis to be derived.
616 ///
617 /// Parameter `parameters`: A dictionary containing one or more key-value pairs.
618 ///
619 /// Parameter `error`: If the call fails this will contain the error code.
620 ///
621 ///
622 /// In order to derive a key the parameters dictionary must contain at least contain the following keys:
623 /// kSecAttrSalt - a CFData for the salt value for mixing in the pseudo-random rounds.
624 /// kSecAttrPRF - the algorithm to use for the pseudo-random-function.
625 /// If 0, this defaults to kSecAttrPRFHmacAlgSHA1. Possible values are:
626 ///
627 /// kSecAttrPRFHmacAlgSHA1
628 /// kSecAttrPRFHmacAlgSHA224
629 /// kSecAttrPRFHmacAlgSHA256
630 /// kSecAttrPRFHmacAlgSHA384
631 /// kSecAttrPRFHmacAlgSHA512
632 ///
633 /// kSecAttrRounds - the number of rounds to call the pseudo random function.
634 /// If 0, a count will be computed to average 1/10 of a second.
635 /// kSecAttrKeySizeInBits with a value being a CFNumberRef
636 /// containing the requested key size in bits. Example sizes for RSA keys are:
637 /// 512, 768, 1024, 2048.
638 ///
639 ///
640 /// Returns: On success a SecKeyRef is returned. On failure this result is NULL and the
641 /// error parameter contains the reason.
642 #[doc(alias = "SecKeyDeriveFromPassword")]
643 #[cfg(feature = "SecBase")]
644 #[deprecated = "No longer supported"]
645 #[inline]
646 pub unsafe fn derive_from_password(
647 password: &CFString,
648 parameters: &CFDictionary,
649 error: *mut *mut CFError,
650 ) -> Option<CFRetained<SecKey>> {
651 extern "C-unwind" {
652 fn SecKeyDeriveFromPassword(
653 password: &CFString,
654 parameters: &CFDictionary,
655 error: *mut *mut CFError,
656 ) -> Option<NonNull<SecKey>>;
657 }
658 let ret = unsafe { SecKeyDeriveFromPassword(password, parameters, error) };
659 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
660 }
661
662 /// Wraps a symmetric key with a symmetric key.
663 ///
664 ///
665 /// Parameter `keyToWrap`: The key which is to be wrapped.
666 ///
667 /// Parameter `wrappingKey`: The key wrapping key.
668 ///
669 /// Parameter `parameters`: The parameter list to use for wrapping the key.
670 ///
671 /// Parameter `error`: If the call fails this will contain the error code.
672 ///
673 ///
674 /// Returns: On success a CFDataRef is returned. On failure this result is NULL and the
675 /// error parameter contains the reason.
676 ///
677 ///
678 /// In order to wrap a key the parameters dictionary may contain the following key:
679 /// kSecSalt - a CFData for the salt value for the encrypt.
680 #[doc(alias = "SecKeyWrapSymmetric")]
681 #[cfg(feature = "SecBase")]
682 #[deprecated = "No longer supported"]
683 #[inline]
684 pub unsafe fn wrap_symmetric(
685 self: &SecKey,
686 wrapping_key: &SecKey,
687 parameters: &CFDictionary,
688 error: *mut *mut CFError,
689 ) -> Option<CFRetained<CFData>> {
690 extern "C-unwind" {
691 fn SecKeyWrapSymmetric(
692 key_to_wrap: &SecKey,
693 wrapping_key: &SecKey,
694 parameters: &CFDictionary,
695 error: *mut *mut CFError,
696 ) -> Option<NonNull<CFData>>;
697 }
698 let ret = unsafe { SecKeyWrapSymmetric(self, wrapping_key, parameters, error) };
699 ret.map(|ret| unsafe { CFRetained::retain(ret) })
700 }
701
702 /// Unwrap a wrapped symmetric key.
703 ///
704 ///
705 /// Parameter `keyToUnwrap`: The wrapped key to unwrap.
706 ///
707 /// Parameter `unwrappingKey`: The key unwrapping key.
708 ///
709 /// Parameter `parameters`: The parameter list to use for unwrapping the key.
710 ///
711 /// Parameter `error`: If the call fails this will contain the error code.
712 ///
713 ///
714 /// Returns: On success a SecKeyRef is returned. On failure this result is NULL and the
715 /// error parameter contains the reason.
716 ///
717 ///
718 /// In order to unwrap a key the parameters dictionary may contain the following key:
719 /// kSecSalt - a CFData for the salt value for the decrypt.
720 #[doc(alias = "SecKeyUnwrapSymmetric")]
721 #[cfg(feature = "SecBase")]
722 #[deprecated = "No longer supported"]
723 #[inline]
724 pub unsafe fn unwrap_symmetric(
725 key_to_unwrap: NonNull<*const CFData>,
726 unwrapping_key: &SecKey,
727 parameters: &CFDictionary,
728 error: *mut *mut CFError,
729 ) -> Option<CFRetained<SecKey>> {
730 extern "C-unwind" {
731 fn SecKeyUnwrapSymmetric(
732 key_to_unwrap: NonNull<*const CFData>,
733 unwrapping_key: &SecKey,
734 parameters: &CFDictionary,
735 error: *mut *mut CFError,
736 ) -> Option<NonNull<SecKey>>;
737 }
738 let ret =
739 unsafe { SecKeyUnwrapSymmetric(key_to_unwrap, unwrapping_key, parameters, error) };
740 ret.map(|ret| unsafe { CFRetained::retain(ret) })
741 }
742
743 /// Generate a private/public keypair.
744 ///
745 /// Parameter `parameters`: A dictionary containing one or more key-value pairs.
746 /// See the discussion sections below for a complete overview of options.
747 ///
748 /// Parameter `publicKey`: On return, a SecKeyRef reference to the public key.
749 ///
750 /// Parameter `privateKey`: On return, a SecKeyRef reference to the private key.
751 ///
752 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
753 ///
754 ///
755 /// In order to generate a keypair the parameters dictionary must
756 /// at least contain the following keys:
757 ///
758 /// kSecAttrKeyType with a value of kSecAttrKeyTypeRSA or any other
759 /// kSecAttrKeyType defined in SecItem.h
760 /// kSecAttrKeySizeInBits with a value being a CFNumberRef containing
761 /// the requested key size in bits. Example sizes for RSA keys are:
762 /// 512, 768, 1024, 2048.
763 ///
764 /// The values below may be set either in the top-level dictionary or in a
765 /// dictionary that is the value of the kSecPrivateKeyAttrs or
766 /// kSecPublicKeyAttrs key in the top-level dictionary. Setting these
767 /// attributes explicitly will override the defaults below. See SecItem.h
768 /// for detailed information on these attributes including the types of
769 /// the values.
770 ///
771 /// kSecAttrLabel default NULL
772 /// kSecUseKeychain default NULL, which specifies the default keychain
773 /// kSecAttrIsPermanent default false
774 /// if this key is present and has a Boolean value of true, the key or
775 /// key pair will be added to the keychain.
776 /// kSecAttrTokenID default NULL
777 /// The CFStringRef ID of the token to generate the key or keypair on. This
778 /// attribute can contain CFStringRef and can be present only in the top-level
779 /// parameters dictionary.
780 /// kSecAttrApplicationTag default NULL
781 /// kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits
782 /// kSecAttrCanEncrypt default false for private keys, true for public keys
783 /// kSecAttrCanDecrypt default true for private keys, false for public keys
784 /// kSecAttrCanDerive default true
785 /// kSecAttrCanSign default true for private keys, false for public keys
786 /// kSecAttrCanVerify default false for private keys, true for public keys
787 /// kSecAttrCanWrap default false for private keys, true for public keys
788 /// kSecAttrCanUnwrap default true for private keys, false for public keys
789 ///
790 /// NOTE: The function always saves keys in the keychain on macOS and as such attribute
791 /// kSecAttrIsPermanent is ignored. The function respects attribute kSecAttrIsPermanent
792 /// on iOS, tvOS and watchOS.
793 /// It is recommended to use SecKeyCreateRandomKey() which respects kSecAttrIsPermanent
794 /// on all platforms.
795 #[doc(alias = "SecKeyGeneratePair")]
796 #[cfg(feature = "SecBase")]
797 #[deprecated = "Use SecKeyCreateRandomKey"]
798 #[inline]
799 pub unsafe fn generate_pair(
800 parameters: &CFDictionary,
801 public_key: *mut *mut SecKey,
802 private_key: *mut *mut SecKey,
803 ) -> OSStatus {
804 extern "C-unwind" {
805 fn SecKeyGeneratePair(
806 parameters: &CFDictionary,
807 public_key: *mut *mut SecKey,
808 private_key: *mut *mut SecKey,
809 ) -> OSStatus;
810 }
811 unsafe { SecKeyGeneratePair(parameters, public_key, private_key) }
812 }
813
814 /// Generates a new public/private key pair.
815 ///
816 /// Parameter `parameters`: A dictionary containing one or more key-value pairs.
817 /// See the discussion sections below for a complete overview of options.
818 ///
819 /// Parameter `error`: On error, will be populated with an error object describing the failure.
820 /// See "Security Error Codes" (SecBase.h).
821 ///
822 /// Returns: Newly generated private key. To get associated public key, use SecKeyCopyPublicKey().
823 ///
824 /// In order to generate a keypair the parameters dictionary must
825 /// at least contain the following keys:
826 ///
827 /// kSecAttrKeyType with a value being kSecAttrKeyTypeRSA or any other
828 /// kSecAttrKeyType defined in SecItem.h
829 /// kSecAttrKeySizeInBits with a value being a CFNumberRef or CFStringRef
830 /// containing the requested key size in bits. Example sizes for RSA
831 /// keys are: 512, 768, 1024, 2048.
832 ///
833 /// The values below may be set either in the top-level dictionary or in a
834 /// dictionary that is the value of the kSecPrivateKeyAttrs or
835 /// kSecPublicKeyAttrs key in the top-level dictionary. Setting these
836 /// attributes explicitly will override the defaults below. See SecItem.h
837 /// for detailed information on these attributes including the types of
838 /// the values.
839 ///
840 /// kSecAttrLabel default NULL
841 /// kSecAttrIsPermanent if this key is present and has a Boolean value of true,
842 /// the key or key pair will be added to the default keychain.
843 /// kSecAttrTokenID if this key should be generated on specified token. This
844 /// attribute can contain CFStringRef and can be present only in the top-level
845 /// parameters dictionary.
846 /// kSecAttrApplicationTag default NULL
847 /// kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits
848 /// kSecAttrCanEncrypt default false for private keys, true for public keys
849 /// kSecAttrCanDecrypt default true for private keys, false for public keys
850 /// kSecAttrCanDerive default true
851 /// kSecAttrCanSign default true for private keys, false for public keys
852 /// kSecAttrCanVerify default false for private keys, true for public keys
853 /// kSecAttrCanWrap default false for private keys, true for public keys
854 /// kSecAttrCanUnwrap default true for private keys, false for public keys
855 #[doc(alias = "SecKeyCreateRandomKey")]
856 #[cfg(feature = "SecBase")]
857 #[inline]
858 pub unsafe fn new_random_key(
859 parameters: &CFDictionary,
860 error: *mut *mut CFError,
861 ) -> Option<CFRetained<SecKey>> {
862 extern "C-unwind" {
863 fn SecKeyCreateRandomKey(
864 parameters: &CFDictionary,
865 error: *mut *mut CFError,
866 ) -> Option<NonNull<SecKey>>;
867 }
868 let ret = unsafe { SecKeyCreateRandomKey(parameters, error) };
869 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
870 }
871
872 /// Create a SecKey from a well-defined external representation.
873 ///
874 /// Parameter `keyData`: CFData representing the key. The format of the data depends on the type of key being created.
875 ///
876 /// Parameter `attributes`: Dictionary containing attributes describing the key to be imported. The keys in this dictionary
877 /// are kSecAttr* constants from SecItem.h. Mandatory attributes are:
878 /// kSecAttrKeyType
879 /// kSecAttrKeyClass
880 ///
881 /// Parameter `error`: On error, will be populated with an error object describing the failure.
882 /// See "Security Error Codes" (SecBase.h).
883 ///
884 /// Returns: A SecKey object representing the key, or NULL on failure.
885 ///
886 /// This function does not add keys to any keychain, but the SecKey object it returns can be added
887 /// to keychain using the SecItemAdd function.
888 /// The requested data format depend on the type of key (kSecAttrKeyType) being created:
889 /// kSecAttrKeyTypeRSA PKCS#1 format, public key can be also in x509 public key format
890 /// kSecAttrKeyTypeECSECPrimeRandom ANSI X9.63 format (04 || X || Y [ || K])
891 #[doc(alias = "SecKeyCreateWithData")]
892 #[cfg(feature = "SecBase")]
893 #[inline]
894 pub unsafe fn with_data(
895 key_data: &CFData,
896 attributes: &CFDictionary,
897 error: *mut *mut CFError,
898 ) -> Option<CFRetained<SecKey>> {
899 extern "C-unwind" {
900 fn SecKeyCreateWithData(
901 key_data: &CFData,
902 attributes: &CFDictionary,
903 error: *mut *mut CFError,
904 ) -> Option<NonNull<SecKey>>;
905 }
906 let ret = unsafe { SecKeyCreateWithData(key_data, attributes, error) };
907 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
908 }
909
910 /// Returns block length of the key in bytes.
911 ///
912 /// Parameter `key`: The key for which the block length is requested.
913 ///
914 /// Returns: The block length of the key in bytes.
915 ///
916 /// If for example key is an RSA key the value returned by
917 /// this function is the size of the modulus.
918 #[doc(alias = "SecKeyGetBlockSize")]
919 #[cfg(feature = "SecBase")]
920 #[inline]
921 pub unsafe fn block_size(self: &SecKey) -> usize {
922 extern "C-unwind" {
923 fn SecKeyGetBlockSize(key: &SecKey) -> usize;
924 }
925 unsafe { SecKeyGetBlockSize(self) }
926 }
927
928 /// Create an external representation for the given key suitable for the key's type.
929 ///
930 /// Parameter `key`: The key to be exported.
931 ///
932 /// Parameter `error`: On error, will be populated with an error object describing the failure.
933 /// See "Security Error Codes" (SecBase.h).
934 ///
935 /// Returns: A CFData representing the key in a format suitable for that key type.
936 ///
937 /// This function may fail if the key is not exportable (e.g., bound to a smart card or Secure Enclave).
938 /// The format in which the key will be exported depends on the type of key:
939 /// kSecAttrKeyTypeRSA PKCS#1 format
940 /// kSecAttrKeyTypeECSECPrimeRandom ANSI X9.63 format (04 || X || Y [ || K])
941 #[doc(alias = "SecKeyCopyExternalRepresentation")]
942 #[cfg(feature = "SecBase")]
943 #[inline]
944 pub unsafe fn external_representation(
945 self: &SecKey,
946 error: *mut *mut CFError,
947 ) -> Option<CFRetained<CFData>> {
948 extern "C-unwind" {
949 fn SecKeyCopyExternalRepresentation(
950 key: &SecKey,
951 error: *mut *mut CFError,
952 ) -> Option<NonNull<CFData>>;
953 }
954 let ret = unsafe { SecKeyCopyExternalRepresentation(self, error) };
955 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
956 }
957
958 /// Retrieve keychain attributes of a key.
959 ///
960 /// Parameter `key`: The key whose attributes are to be retrieved.
961 ///
962 /// Returns: Dictionary containing attributes of the key. The keys that populate this dictionary are defined
963 /// and discussed in SecItem.h.
964 ///
965 /// The attributes provided by this function are:
966 /// kSecAttrCanEncrypt
967 /// kSecAttrCanDecrypt
968 /// kSecAttrCanDerive
969 /// kSecAttrCanSign
970 /// kSecAttrCanVerify
971 /// kSecAttrKeyClass
972 /// kSecAttrKeyType
973 /// kSecAttrKeySizeInBits
974 /// kSecAttrTokenID
975 /// kSecAttrApplicationLabel
976 /// The set of values is not fixed. Future versions may return more values in this dictionary.
977 #[doc(alias = "SecKeyCopyAttributes")]
978 #[cfg(feature = "SecBase")]
979 #[inline]
980 pub unsafe fn attributes(self: &SecKey) -> Option<CFRetained<CFDictionary>> {
981 extern "C-unwind" {
982 fn SecKeyCopyAttributes(key: &SecKey) -> Option<NonNull<CFDictionary>>;
983 }
984 let ret = unsafe { SecKeyCopyAttributes(self) };
985 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
986 }
987
988 /// Retrieve the public key from a key pair or private key.
989 ///
990 /// Parameter `key`: The key from which to retrieve a public key.
991 ///
992 /// Returns: The public key or NULL if public key is not available for specified key.
993 ///
994 /// Fails if key does not contain a public key or no public key can be computed from it.
995 #[doc(alias = "SecKeyCopyPublicKey")]
996 #[cfg(feature = "SecBase")]
997 #[inline]
998 pub unsafe fn public_key(self: &SecKey) -> Option<CFRetained<SecKey>> {
999 extern "C-unwind" {
1000 fn SecKeyCopyPublicKey(key: &SecKey) -> Option<NonNull<SecKey>>;
1001 }
1002 let ret = unsafe { SecKeyCopyPublicKey(self) };
1003 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1004 }
1005}
1006
1007/// Available algorithms for performing cryptographic operations with SecKey object. String representation
1008/// of constant can be used for logging or debugging purposes, because they contain human readable names of the algorithm.
1009///
1010///
1011/// Raw RSA sign/verify operation, size of input data must be the same as value returned by SecKeyGetBlockSize().
1012///
1013///
1014/// RSA sign/verify operation, assumes that input data is digest and OID and digest algorithm as specified in PKCS# v1.5.
1015/// This algorithm is typically not used directly, instead use algorithm with specified digest, like
1016/// kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256.
1017///
1018///
1019/// RSA signature with PKCS#1 padding, input data must be SHA-1 generated digest.
1020///
1021///
1022/// RSA signature with PKCS#1 padding, input data must be SHA-224 generated digest.
1023///
1024///
1025/// RSA signature with PKCS#1 padding, input data must be SHA-256 generated digest.
1026///
1027///
1028/// RSA signature with PKCS#1 padding, input data must be SHA-384 generated digest.
1029///
1030///
1031/// RSA signature with PKCS#1 padding, input data must be SHA-512 generated digest.
1032///
1033///
1034/// RSA signature with PKCS#1 padding, SHA-1 digest is generated by called function automatically from input data of any size.
1035///
1036///
1037/// RSA signature with PKCS#1 padding, SHA-224 digest is generated by called function automatically from input data of any size.
1038///
1039///
1040/// RSA signature with PKCS#1 padding, SHA-256 digest is generated by called function automatically from input data of any size.
1041///
1042///
1043/// RSA signature with PKCS#1 padding, SHA-384 digest is generated by called function automatically from input data of any size.
1044///
1045///
1046/// RSA signature with PKCS#1 padding, SHA-512 digest is generated by called function automatically from input data of any size.
1047///
1048///
1049/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-1 generated digest.
1050/// PSS padding is calculated using MGF1 with SHA1 and saltLength parameter is set to 20 (SHA-1 output size).
1051///
1052///
1053/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-224 generated digest.
1054/// PSS padding is calculated using MGF1 with SHA224 and saltLength parameter is set to 28 (SHA-224 output size).
1055///
1056///
1057/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-256 generated digest.
1058/// PSS padding is calculated using MGF1 with SHA256 and saltLength parameter is set to 32 (SHA-256 output size).
1059///
1060///
1061/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-384 generated digest.
1062/// PSS padding is calculated using MGF1 with SHA384 and saltLength parameter is set to 48 (SHA-384 output size).
1063///
1064///
1065/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, input data must be SHA-512 generated digest.
1066/// PSS padding is calculated using MGF1 with SHA512 and saltLength parameter is set to 64 (SHA-512 output size).
1067///
1068///
1069/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-1 digest is generated by called function automatically from input data of any size.
1070/// PSS padding is calculated using MGF1 with SHA1 and saltLength parameter is set to 20 (SHA-1 output size).
1071///
1072///
1073/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-224 digest is generated by called function automatically from input data of any size.
1074/// PSS padding is calculated using MGF1 with SHA224 and saltLength parameter is set to 28 (SHA-224 output size).
1075///
1076///
1077/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-256 digest is generated by called function automatically from input data of any size.
1078/// PSS padding is calculated using MGF1 with SHA256 and saltLength parameter is set to 32 (SHA-256 output size).
1079///
1080///
1081/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-384 digest is generated by called function automatically from input data of any size.
1082/// PSS padding is calculated using MGF1 with SHA384 and saltLength parameter is set to 48 (SHA-384 output size).
1083///
1084///
1085/// RSA signature with RSASSA-PSS padding according to PKCS#1 v2.1, SHA-512 digest is generated by called function automatically from input data of any size.
1086/// PSS padding is calculated using MGF1 with SHA512 and saltLength parameter is set to 64 (SHA-512 output size).
1087///
1088///
1089/// ECDSA algorithm, signature is in DER x9.62 encoding, input data must be message digest generated by some hash functions.
1090///
1091///
1092/// ECDSA algorithm, signature is in DER x9.62 encoding, input data must be message digest created by SHA1 algorithm.
1093///
1094///
1095/// ECDSA algorithm, signature is in DER x9.62 encoding, input data must be message digest created by SHA224 algorithm.
1096///
1097///
1098/// ECDSA algorithm, signature is in DER x9.62 encoding, input data must be message digest created by SHA256 algorithm.
1099///
1100///
1101/// ECDSA algorithm, signature is in DER x9.62 encoding, input data must be message digest created by SHA384 algorithm.
1102///
1103///
1104/// ECDSA algorithm, signature is in DER x9.62 encoding, input data must be message digest created by SHA512 algorithm.
1105///
1106///
1107/// ECDSA algorithm, signature is in DER x9.62 encoding, SHA-1 digest is generated by called function automatically from input data of any size.
1108///
1109///
1110/// ECDSA algorithm, signature is in DER x9.62 encoding, SHA-224 digest is generated by called function automatically from input data of any size.
1111///
1112///
1113/// ECDSA algorithm, signature is in DER x9.62 encoding, SHA-256 digest is generated by called function automatically from input data of any size.
1114///
1115///
1116/// ECDSA algorithm, signature is in DER x9.62 encoding, SHA-384 digest is generated by called function automatically from input data of any size.
1117///
1118///
1119/// ECDSA algorithm, signature is in DER x9.62 encoding, SHA-512 digest is generated by called function automatically from input data of any size.
1120///
1121///
1122/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest generated by some hash functions.
1123///
1124///
1125/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest created by SHA1 algorithm.
1126///
1127///
1128/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest created by SHA224 algorithm.
1129///
1130///
1131/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest created by SHA256 algorithm.
1132///
1133///
1134/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest created by SHA384 algorithm.
1135///
1136///
1137/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest created by SHA512 algorithm.
1138///
1139///
1140/// ECDSA algorithm, signature is concatenated r and s, big endian, SHA-1 digest is generated by called function automatically from input data of any size.
1141///
1142///
1143/// ECDSA algorithm, signature is concatenated r and s, big endian, SHA-224 digest is generated by called function automatically from input data of any size.
1144///
1145///
1146/// ECDSA algorithm, signature is concatenated r and s, big endian, SHA-256 digest is generated by called function automatically from input data of any size.
1147///
1148///
1149/// ECDSA algorithm, signature is concatenated r and s, big endian, SHA-384 digest is generated by called function automatically from input data of any size.
1150///
1151///
1152/// ECDSA algorithm, signature is concatenated r and s, big endian, SHA-512 digest is generated by called function automatically from input data of any size.
1153///
1154///
1155/// ECDSA algorithm, signature is concatenated r and s, big endian, input data must be message digest generated by some hash function.
1156/// This is deprecated algorithm, replaced by kSecKeyAlgorithmECDSASignatureDigestRFC4754
1157///
1158///
1159/// Raw RSA encryption or decryption, size of data must match RSA key modulus size. Note that direct
1160/// use of this algorithm without padding is cryptographically very weak, it is important to always introduce
1161/// some kind of padding. Input data size must be less or equal to the key block size and returned block has always
1162/// the same size as block size, as returned by SecKeyGetBlockSize().
1163///
1164///
1165/// RSA encryption or decryption, data is padded using PKCS#1 padding scheme. This algorithm should be used only for
1166/// backward compatibility with existing protocols and data. New implementations should choose cryptographically
1167/// stronger algorithm instead (see kSecKeyAlgorithmRSAEncryptionOAEP). Input data must be at most
1168/// "key block size - 11" bytes long and returned block has always the same size as block size, as returned
1169/// by SecKeyGetBlockSize().
1170///
1171///
1172/// RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA1. Input data must be at most
1173/// "key block size - 42" bytes long and returned block has always the same size as block size, as returned
1174/// by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA1AESGCM to be able to encrypt and decrypt arbitrary long data.
1175///
1176///
1177/// RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA224. Input data must be at most
1178/// "key block size - 58" bytes long and returned block has always the same size as block size, as returned
1179/// by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA224AESGCM to be able to encrypt and decrypt arbitrary long data.
1180///
1181///
1182/// RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA256. Input data must be at most
1183/// "key block size - 66" bytes long and returned block has always the same size as block size, as returned
1184/// by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA256AESGCM to be able to encrypt and decrypt arbitrary long data.
1185///
1186///
1187/// RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA384. Input data must be at most
1188/// "key block size - 98" bytes long and returned block has always the same size as block size, as returned
1189/// by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA384AESGCM to be able to encrypt and decrypt arbitrary long data.
1190///
1191///
1192/// RSA encryption or decryption, data is padded using OAEP padding scheme internally using SHA512. Input data must be at most
1193/// "key block size - 130" bytes long and returned block has always the same size as block size, as returned
1194/// by SecKeyGetBlockSize(). Use kSecKeyAlgorithmRSAEncryptionOAEPSHA512AESGCM to be able to encrypt and decrypt arbitrary long data.
1195///
1196///
1197/// Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1198/// mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1199/// 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1200/// as authentication data for AES-GCM encryption.
1201///
1202///
1203/// Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1204/// mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1205/// 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1206/// as authentication data for AES-GCM encryption.
1207///
1208///
1209/// Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1210/// mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1211/// 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1212/// as authentication data for AES-GCM encryption.
1213///
1214///
1215/// Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1216/// mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1217/// 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1218/// as authentication data for AES-GCM encryption.
1219///
1220///
1221/// Randomly generated AES session key is encrypted by RSA with OAEP padding. User data are encrypted using session key in GCM
1222/// mode with all-zero 16 bytes long IV (initialization vector). Finally 16 byte AES-GCM tag is appended to ciphertext.
1223/// 256bit AES key is used if RSA key is 4096bit or bigger, otherwise 128bit AES key is used. Raw public key data is used
1224/// as authentication data for AES-GCM encryption.
1225///
1226///
1227/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM in new code.
1228/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA1. AES Key size
1229/// is 128bit for EC keys
1230/// <
1231/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1232/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1233///
1234///
1235/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA224AESGCM in new code.
1236/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224. AES Key size
1237/// is 128bit for EC keys
1238/// <
1239/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1240/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1241///
1242///
1243/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM in new code.
1244/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256. AES Key size
1245/// is 128bit for EC keys
1246/// <
1247/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1248/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1249///
1250///
1251/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA384AESGCM in new code.
1252/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384. AES Key size
1253/// is 128bit for EC keys
1254/// <
1255/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1256/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1257///
1258///
1259/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA512AESGCM in new code.
1260/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512. AES Key size
1261/// is 128bit for EC keys
1262/// <
1263/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1264/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1265///
1266///
1267/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM in new code.
1268/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA1. AES Key size
1269/// is 128bit for EC keys
1270/// <
1271/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1272/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1273///
1274///
1275/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA224AESGCM in new code.
1276/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224. AES Key size
1277/// is 128bit for EC keys
1278/// <
1279/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1280/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1281///
1282///
1283/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM in new code.
1284/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256. AES Key size
1285/// is 128bit for EC keys
1286/// <
1287/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1288/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1289///
1290///
1291/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA384AESGCM in new code.
1292/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384. AES Key size
1293/// is 128bit for EC keys
1294/// <
1295/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1296/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1297///
1298///
1299/// Legacy ECIES encryption or decryption, use kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM in new code.
1300/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512. AES Key size
1301/// is 128bit for EC keys
1302/// <
1303/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1304/// AES-GCM uses 16 bytes long TAG and all-zero 16 byte long IV (initialization vector).
1305///
1306///
1307/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1308/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224. AES Key size
1309/// is 128bit for EC keys
1310/// <
1311/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1312/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1313/// of KDF output.
1314///
1315///
1316/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1317/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256. AES Key size
1318/// is 128bit for EC keys
1319/// <
1320/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1321/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1322/// of KDF output.
1323///
1324///
1325/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1326/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384. AES Key size
1327/// is 128bit for EC keys
1328/// <
1329/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1330/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1331/// of KDF output.
1332///
1333///
1334/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1335/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512. AES Key size
1336/// is 128bit for EC keys
1337/// <
1338/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1339/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1340/// of KDF output.
1341///
1342///
1343/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1344/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224. AES Key size
1345/// is 128bit for EC keys
1346/// <
1347/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1348/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1349/// of KDF output.
1350///
1351///
1352/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1353/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256. AES Key size
1354/// is 128bit for EC keys
1355/// <
1356/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1357/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1358/// of KDF output.
1359///
1360///
1361/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1362/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384. AES Key size
1363/// is 128bit for EC keys
1364/// <
1365/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1366/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1367/// of KDF output.
1368///
1369///
1370/// ECIES encryption or decryption. This algorithm does not limit the size of the message to be encrypted or decrypted.
1371/// Encryption is done using AES-GCM with key negotiated by kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512. AES Key size
1372/// is 128bit for EC keys
1373/// <
1374/// =256bit and 256bit for bigger EC keys. Ephemeral public key data is used as sharedInfo for KDF.
1375/// AES-GCM uses 16 bytes long TAG, AES key is first half of KDF output and 16 byte long IV (initialization vector) is second half
1376/// of KDF output.
1377///
1378///
1379/// Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys.
1380/// This algorithm does not accept any parameters, length of output raw shared secret is given by the length of the key.
1381///
1382///
1383/// Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1384/// and apply ANSI X9.63 KDF with SHA1 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1385/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1386///
1387///
1388/// Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1389/// and apply ANSI X9.63 KDF with SHA224 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1390/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1391///
1392///
1393/// Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1394/// and apply ANSI X9.63 KDF with SHA256 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1395/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1396///
1397///
1398/// Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1399/// and apply ANSI X9.63 KDF with SHA384 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1400/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1401///
1402///
1403/// Compute shared secret using ECDH cofactor algorithm, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1404/// and apply ANSI X9.63 KDF with SHA512 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1405/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1406///
1407///
1408/// Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys.
1409/// This algorithm does not accept any parameters, length of output raw shared secret is given by the length of the key.
1410///
1411///
1412/// Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1413/// and apply ANSI X9.63 KDF with SHA1 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1414/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1415///
1416///
1417/// Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1418/// and apply ANSI X9.63 KDF with SHA224 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1419/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1420///
1421///
1422/// Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1423/// and apply ANSI X9.63 KDF with SHA256 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1424/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1425///
1426///
1427/// Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1428/// and apply ANSI X9.63 KDF with SHA384 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1429/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1430///
1431///
1432/// Compute shared secret using ECDH algorithm without cofactor, suitable only for kSecAttrKeyTypeECSECPrimeRandom keys
1433/// and apply ANSI X9.63 KDF with SHA512 as hashing function. Requires kSecKeyKeyExchangeParameterRequestedSize and allows
1434/// kSecKeyKeyExchangeParameterSharedInfo parameters to be used.
1435///
1436/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeyalgorithm?language=objc)
1437// NS_TYPED_ENUM
1438pub type SecKeyAlgorithm = CFString;
1439
1440extern "C" {
1441 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignatureraw?language=objc)
1442 pub static kSecKeyAlgorithmRSASignatureRaw: &'static SecKeyAlgorithm;
1443}
1444
1445extern "C" {
1446 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpkcs1v15raw?language=objc)
1447 pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15Raw: &'static SecKeyAlgorithm;
1448}
1449
1450extern "C" {
1451 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpkcs1v15sha1?language=objc)
1452 pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1: &'static SecKeyAlgorithm;
1453}
1454
1455extern "C" {
1456 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpkcs1v15sha224?language=objc)
1457 pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA224: &'static SecKeyAlgorithm;
1458}
1459
1460extern "C" {
1461 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpkcs1v15sha256?language=objc)
1462 pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256: &'static SecKeyAlgorithm;
1463}
1464
1465extern "C" {
1466 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpkcs1v15sha384?language=objc)
1467 pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384: &'static SecKeyAlgorithm;
1468}
1469
1470extern "C" {
1471 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpkcs1v15sha512?language=objc)
1472 pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512: &'static SecKeyAlgorithm;
1473}
1474
1475extern "C" {
1476 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepkcs1v15sha1?language=objc)
1477 pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA1: &'static SecKeyAlgorithm;
1478}
1479
1480extern "C" {
1481 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepkcs1v15sha224?language=objc)
1482 pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA224: &'static SecKeyAlgorithm;
1483}
1484
1485extern "C" {
1486 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepkcs1v15sha256?language=objc)
1487 pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA256: &'static SecKeyAlgorithm;
1488}
1489
1490extern "C" {
1491 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepkcs1v15sha384?language=objc)
1492 pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA384: &'static SecKeyAlgorithm;
1493}
1494
1495extern "C" {
1496 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepkcs1v15sha512?language=objc)
1497 pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA512: &'static SecKeyAlgorithm;
1498}
1499
1500extern "C" {
1501 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpsssha1?language=objc)
1502 pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA1: &'static SecKeyAlgorithm;
1503}
1504
1505extern "C" {
1506 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpsssha224?language=objc)
1507 pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA224: &'static SecKeyAlgorithm;
1508}
1509
1510extern "C" {
1511 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpsssha256?language=objc)
1512 pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA256: &'static SecKeyAlgorithm;
1513}
1514
1515extern "C" {
1516 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpsssha384?language=objc)
1517 pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA384: &'static SecKeyAlgorithm;
1518}
1519
1520extern "C" {
1521 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturedigestpsssha512?language=objc)
1522 pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA512: &'static SecKeyAlgorithm;
1523}
1524
1525extern "C" {
1526 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepsssha1?language=objc)
1527 pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA1: &'static SecKeyAlgorithm;
1528}
1529
1530extern "C" {
1531 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepsssha224?language=objc)
1532 pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA224: &'static SecKeyAlgorithm;
1533}
1534
1535extern "C" {
1536 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepsssha256?language=objc)
1537 pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA256: &'static SecKeyAlgorithm;
1538}
1539
1540extern "C" {
1541 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepsssha384?language=objc)
1542 pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA384: &'static SecKeyAlgorithm;
1543}
1544
1545extern "C" {
1546 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsasignaturemessagepsssha512?language=objc)
1547 pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA512: &'static SecKeyAlgorithm;
1548}
1549
1550extern "C" {
1551 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestx962?language=objc)
1552 pub static kSecKeyAlgorithmECDSASignatureDigestX962: &'static SecKeyAlgorithm;
1553}
1554
1555extern "C" {
1556 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestx962sha1?language=objc)
1557 pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA1: &'static SecKeyAlgorithm;
1558}
1559
1560extern "C" {
1561 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestx962sha224?language=objc)
1562 pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA224: &'static SecKeyAlgorithm;
1563}
1564
1565extern "C" {
1566 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestx962sha256?language=objc)
1567 pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA256: &'static SecKeyAlgorithm;
1568}
1569
1570extern "C" {
1571 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestx962sha384?language=objc)
1572 pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA384: &'static SecKeyAlgorithm;
1573}
1574
1575extern "C" {
1576 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestx962sha512?language=objc)
1577 pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA512: &'static SecKeyAlgorithm;
1578}
1579
1580extern "C" {
1581 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagex962sha1?language=objc)
1582 pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA1: &'static SecKeyAlgorithm;
1583}
1584
1585extern "C" {
1586 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagex962sha224?language=objc)
1587 pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA224: &'static SecKeyAlgorithm;
1588}
1589
1590extern "C" {
1591 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagex962sha256?language=objc)
1592 pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA256: &'static SecKeyAlgorithm;
1593}
1594
1595extern "C" {
1596 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagex962sha384?language=objc)
1597 pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA384: &'static SecKeyAlgorithm;
1598}
1599
1600extern "C" {
1601 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagex962sha512?language=objc)
1602 pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA512: &'static SecKeyAlgorithm;
1603}
1604
1605extern "C" {
1606 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestrfc4754?language=objc)
1607 pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754: &'static SecKeyAlgorithm;
1608}
1609
1610extern "C" {
1611 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestrfc4754sha1?language=objc)
1612 pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA1: &'static SecKeyAlgorithm;
1613}
1614
1615extern "C" {
1616 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestrfc4754sha224?language=objc)
1617 pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA224: &'static SecKeyAlgorithm;
1618}
1619
1620extern "C" {
1621 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestrfc4754sha256?language=objc)
1622 pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA256: &'static SecKeyAlgorithm;
1623}
1624
1625extern "C" {
1626 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestrfc4754sha384?language=objc)
1627 pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA384: &'static SecKeyAlgorithm;
1628}
1629
1630extern "C" {
1631 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturedigestrfc4754sha512?language=objc)
1632 pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA512: &'static SecKeyAlgorithm;
1633}
1634
1635extern "C" {
1636 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagerfc4754sha1?language=objc)
1637 pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA1: &'static SecKeyAlgorithm;
1638}
1639
1640extern "C" {
1641 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagerfc4754sha224?language=objc)
1642 pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA224: &'static SecKeyAlgorithm;
1643}
1644
1645extern "C" {
1646 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagerfc4754sha256?language=objc)
1647 pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA256: &'static SecKeyAlgorithm;
1648}
1649
1650extern "C" {
1651 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagerfc4754sha384?language=objc)
1652 pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA384: &'static SecKeyAlgorithm;
1653}
1654
1655extern "C" {
1656 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturemessagerfc4754sha512?language=objc)
1657 pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA512: &'static SecKeyAlgorithm;
1658}
1659
1660extern "C" {
1661 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdsasignaturerfc4754?language=objc)
1662 pub static kSecKeyAlgorithmECDSASignatureRFC4754: &'static SecKeyAlgorithm;
1663}
1664
1665extern "C" {
1666 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionraw?language=objc)
1667 pub static kSecKeyAlgorithmRSAEncryptionRaw: &'static SecKeyAlgorithm;
1668}
1669
1670extern "C" {
1671 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionpkcs1?language=objc)
1672 pub static kSecKeyAlgorithmRSAEncryptionPKCS1: &'static SecKeyAlgorithm;
1673}
1674
1675extern "C" {
1676 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha1?language=objc)
1677 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA1: &'static SecKeyAlgorithm;
1678}
1679
1680extern "C" {
1681 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha224?language=objc)
1682 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA224: &'static SecKeyAlgorithm;
1683}
1684
1685extern "C" {
1686 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha256?language=objc)
1687 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA256: &'static SecKeyAlgorithm;
1688}
1689
1690extern "C" {
1691 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha384?language=objc)
1692 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA384: &'static SecKeyAlgorithm;
1693}
1694
1695extern "C" {
1696 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha512?language=objc)
1697 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA512: &'static SecKeyAlgorithm;
1698}
1699
1700extern "C" {
1701 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha1aesgcm?language=objc)
1702 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA1AESGCM: &'static SecKeyAlgorithm;
1703}
1704
1705extern "C" {
1706 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha224aesgcm?language=objc)
1707 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA224AESGCM: &'static SecKeyAlgorithm;
1708}
1709
1710extern "C" {
1711 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha256aesgcm?language=objc)
1712 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA256AESGCM: &'static SecKeyAlgorithm;
1713}
1714
1715extern "C" {
1716 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha384aesgcm?language=objc)
1717 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA384AESGCM: &'static SecKeyAlgorithm;
1718}
1719
1720extern "C" {
1721 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmrsaencryptionoaepsha512aesgcm?language=objc)
1722 pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA512AESGCM: &'static SecKeyAlgorithm;
1723}
1724
1725extern "C" {
1726 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardx963sha1aesgcm?language=objc)
1727 pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA1AESGCM: &'static SecKeyAlgorithm;
1728}
1729
1730extern "C" {
1731 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardx963sha224aesgcm?language=objc)
1732 pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA224AESGCM: &'static SecKeyAlgorithm;
1733}
1734
1735extern "C" {
1736 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardx963sha256aesgcm?language=objc)
1737 pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA256AESGCM: &'static SecKeyAlgorithm;
1738}
1739
1740extern "C" {
1741 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardx963sha384aesgcm?language=objc)
1742 pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA384AESGCM: &'static SecKeyAlgorithm;
1743}
1744
1745extern "C" {
1746 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardx963sha512aesgcm?language=objc)
1747 pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA512AESGCM: &'static SecKeyAlgorithm;
1748}
1749
1750extern "C" {
1751 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorx963sha1aesgcm?language=objc)
1752 pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA1AESGCM: &'static SecKeyAlgorithm;
1753}
1754
1755extern "C" {
1756 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorx963sha224aesgcm?language=objc)
1757 pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA224AESGCM: &'static SecKeyAlgorithm;
1758}
1759
1760extern "C" {
1761 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorx963sha256aesgcm?language=objc)
1762 pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA256AESGCM: &'static SecKeyAlgorithm;
1763}
1764
1765extern "C" {
1766 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorx963sha384aesgcm?language=objc)
1767 pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA384AESGCM: &'static SecKeyAlgorithm;
1768}
1769
1770extern "C" {
1771 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorx963sha512aesgcm?language=objc)
1772 pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA512AESGCM: &'static SecKeyAlgorithm;
1773}
1774
1775extern "C" {
1776 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardvariableivx963sha224aesgcm?language=objc)
1777 pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA224AESGCM:
1778 &'static SecKeyAlgorithm;
1779}
1780
1781extern "C" {
1782 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardvariableivx963sha256aesgcm?language=objc)
1783 pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM:
1784 &'static SecKeyAlgorithm;
1785}
1786
1787extern "C" {
1788 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardvariableivx963sha384aesgcm?language=objc)
1789 pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA384AESGCM:
1790 &'static SecKeyAlgorithm;
1791}
1792
1793extern "C" {
1794 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptionstandardvariableivx963sha512aesgcm?language=objc)
1795 pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA512AESGCM:
1796 &'static SecKeyAlgorithm;
1797}
1798
1799extern "C" {
1800 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorvariableivx963sha224aesgcm?language=objc)
1801 pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA224AESGCM:
1802 &'static SecKeyAlgorithm;
1803}
1804
1805extern "C" {
1806 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorvariableivx963sha256aesgcm?language=objc)
1807 pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM:
1808 &'static SecKeyAlgorithm;
1809}
1810
1811extern "C" {
1812 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorvariableivx963sha384aesgcm?language=objc)
1813 pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA384AESGCM:
1814 &'static SecKeyAlgorithm;
1815}
1816
1817extern "C" {
1818 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmeciesencryptioncofactorvariableivx963sha512aesgcm?language=objc)
1819 pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM:
1820 &'static SecKeyAlgorithm;
1821}
1822
1823extern "C" {
1824 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangestandard?language=objc)
1825 pub static kSecKeyAlgorithmECDHKeyExchangeStandard: &'static SecKeyAlgorithm;
1826}
1827
1828extern "C" {
1829 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangestandardx963sha1?language=objc)
1830 pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA1: &'static SecKeyAlgorithm;
1831}
1832
1833extern "C" {
1834 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangestandardx963sha224?language=objc)
1835 pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224: &'static SecKeyAlgorithm;
1836}
1837
1838extern "C" {
1839 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangestandardx963sha256?language=objc)
1840 pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256: &'static SecKeyAlgorithm;
1841}
1842
1843extern "C" {
1844 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangestandardx963sha384?language=objc)
1845 pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384: &'static SecKeyAlgorithm;
1846}
1847
1848extern "C" {
1849 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangestandardx963sha512?language=objc)
1850 pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512: &'static SecKeyAlgorithm;
1851}
1852
1853extern "C" {
1854 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangecofactor?language=objc)
1855 pub static kSecKeyAlgorithmECDHKeyExchangeCofactor: &'static SecKeyAlgorithm;
1856}
1857
1858extern "C" {
1859 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangecofactorx963sha1?language=objc)
1860 pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA1: &'static SecKeyAlgorithm;
1861}
1862
1863extern "C" {
1864 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangecofactorx963sha224?language=objc)
1865 pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224: &'static SecKeyAlgorithm;
1866}
1867
1868extern "C" {
1869 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangecofactorx963sha256?language=objc)
1870 pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256: &'static SecKeyAlgorithm;
1871}
1872
1873extern "C" {
1874 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangecofactorx963sha384?language=objc)
1875 pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384: &'static SecKeyAlgorithm;
1876}
1877
1878extern "C" {
1879 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyalgorithmecdhkeyexchangecofactorx963sha512?language=objc)
1880 pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512: &'static SecKeyAlgorithm;
1881}
1882
1883#[cfg(feature = "SecBase")]
1884impl SecKey {
1885 /// Given a private key and data to sign, generate a digital signature.
1886 ///
1887 /// Parameter `key`: Private key with which to sign.
1888 ///
1889 /// Parameter `algorithm`: One of SecKeyAlgorithm constants suitable to generate signature with this key.
1890 ///
1891 /// Parameter `dataToSign`: The data to be signed, typically the digest of the actual data.
1892 ///
1893 /// Parameter `error`: On error, will be populated with an error object describing the failure.
1894 /// See "Security Error Codes" (SecBase.h).
1895 ///
1896 /// Returns: The signature over dataToSign represented as a CFData, or NULL on failure.
1897 ///
1898 /// Computes digital signature using specified key over input data. The operation algorithm
1899 /// further defines the exact format of input data, operation to be performed and output signature.
1900 #[doc(alias = "SecKeyCreateSignature")]
1901 #[cfg(feature = "SecBase")]
1902 #[inline]
1903 pub unsafe fn signature(
1904 self: &SecKey,
1905 algorithm: &SecKeyAlgorithm,
1906 data_to_sign: &CFData,
1907 error: *mut *mut CFError,
1908 ) -> Option<CFRetained<CFData>> {
1909 extern "C-unwind" {
1910 fn SecKeyCreateSignature(
1911 key: &SecKey,
1912 algorithm: &SecKeyAlgorithm,
1913 data_to_sign: &CFData,
1914 error: *mut *mut CFError,
1915 ) -> Option<NonNull<CFData>>;
1916 }
1917 let ret = unsafe { SecKeyCreateSignature(self, algorithm, data_to_sign, error) };
1918 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1919 }
1920
1921 /// Given a public key, data which has been signed, and a signature, verify the signature.
1922 ///
1923 /// Parameter `key`: Public key with which to verify the signature.
1924 ///
1925 /// Parameter `algorithm`: One of SecKeyAlgorithm constants suitable to verify signature with this key.
1926 ///
1927 /// Parameter `signedData`: The data over which sig is being verified, typically the digest of the actual data.
1928 ///
1929 /// Parameter `signature`: The signature to verify.
1930 ///
1931 /// Parameter `error`: On error, will be populated with an error object describing the failure.
1932 /// See "Security Error Codes" (SecBase.h).
1933 ///
1934 /// Returns: True if the signature was valid, False otherwise.
1935 ///
1936 /// Verifies digital signature operation using specified key and signed data. The operation algorithm
1937 /// further defines the exact format of input data, signature and operation to be performed.
1938 #[doc(alias = "SecKeyVerifySignature")]
1939 #[cfg(feature = "SecBase")]
1940 #[inline]
1941 pub unsafe fn verify_signature(
1942 self: &SecKey,
1943 algorithm: &SecKeyAlgorithm,
1944 signed_data: &CFData,
1945 signature: &CFData,
1946 error: *mut *mut CFError,
1947 ) -> bool {
1948 extern "C-unwind" {
1949 fn SecKeyVerifySignature(
1950 key: &SecKey,
1951 algorithm: &SecKeyAlgorithm,
1952 signed_data: &CFData,
1953 signature: &CFData,
1954 error: *mut *mut CFError,
1955 ) -> Boolean;
1956 }
1957 let ret = unsafe { SecKeyVerifySignature(self, algorithm, signed_data, signature, error) };
1958 ret != 0
1959 }
1960
1961 /// Encrypt a block of plaintext.
1962 ///
1963 /// Parameter `key`: Public key with which to encrypt the data.
1964 ///
1965 /// Parameter `algorithm`: One of SecKeyAlgorithm constants suitable to perform encryption with this key.
1966 ///
1967 /// Parameter `plaintext`: The data to encrypt. The length and format of the data must conform to chosen algorithm,
1968 /// typically be less or equal to the value returned by SecKeyGetBlockSize().
1969 ///
1970 /// Parameter `error`: On error, will be populated with an error object describing the failure.
1971 /// See "Security Error Codes" (SecBase.h).
1972 ///
1973 /// Returns: The ciphertext represented as a CFData, or NULL on failure.
1974 ///
1975 /// Encrypts plaintext data using specified key. The exact type of the operation including the format
1976 /// of input and output data is specified by encryption algorithm.
1977 #[doc(alias = "SecKeyCreateEncryptedData")]
1978 #[cfg(feature = "SecBase")]
1979 #[inline]
1980 pub unsafe fn encrypted_data(
1981 self: &SecKey,
1982 algorithm: &SecKeyAlgorithm,
1983 plaintext: &CFData,
1984 error: *mut *mut CFError,
1985 ) -> Option<CFRetained<CFData>> {
1986 extern "C-unwind" {
1987 fn SecKeyCreateEncryptedData(
1988 key: &SecKey,
1989 algorithm: &SecKeyAlgorithm,
1990 plaintext: &CFData,
1991 error: *mut *mut CFError,
1992 ) -> Option<NonNull<CFData>>;
1993 }
1994 let ret = unsafe { SecKeyCreateEncryptedData(self, algorithm, plaintext, error) };
1995 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1996 }
1997
1998 /// Decrypt a block of ciphertext.
1999 ///
2000 /// Parameter `key`: Private key with which to decrypt the data.
2001 ///
2002 /// Parameter `algorithm`: One of SecKeyAlgorithm constants suitable to perform decryption with this key.
2003 ///
2004 /// Parameter `ciphertext`: The data to decrypt. The length and format of the data must conform to chosen algorithm,
2005 /// typically be less or equal to the value returned by SecKeyGetBlockSize().
2006 ///
2007 /// Parameter `error`: On error, will be populated with an error object describing the failure.
2008 /// See "Security Error Codes" (SecBase.h).
2009 ///
2010 /// Returns: The plaintext represented as a CFData, or NULL on failure.
2011 ///
2012 /// Decrypts ciphertext data using specified key. The exact type of the operation including the format
2013 /// of input and output data is specified by decryption algorithm.
2014 #[doc(alias = "SecKeyCreateDecryptedData")]
2015 #[cfg(feature = "SecBase")]
2016 #[inline]
2017 pub unsafe fn decrypted_data(
2018 self: &SecKey,
2019 algorithm: &SecKeyAlgorithm,
2020 ciphertext: &CFData,
2021 error: *mut *mut CFError,
2022 ) -> Option<CFRetained<CFData>> {
2023 extern "C-unwind" {
2024 fn SecKeyCreateDecryptedData(
2025 key: &SecKey,
2026 algorithm: &SecKeyAlgorithm,
2027 ciphertext: &CFData,
2028 error: *mut *mut CFError,
2029 ) -> Option<NonNull<CFData>>;
2030 }
2031 let ret = unsafe { SecKeyCreateDecryptedData(self, algorithm, ciphertext, error) };
2032 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2033 }
2034}
2035
2036/// for KDF (key derivation function).
2037///
2038/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeykeyexchangeparameter?language=objc)
2039// NS_TYPED_ENUM
2040pub type SecKeyKeyExchangeParameter = CFString;
2041
2042extern "C" {
2043 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeykeyexchangeparameterrequestedsize?language=objc)
2044 pub static kSecKeyKeyExchangeParameterRequestedSize: &'static SecKeyKeyExchangeParameter;
2045}
2046
2047extern "C" {
2048 /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeykeyexchangeparametersharedinfo?language=objc)
2049 pub static kSecKeyKeyExchangeParameterSharedInfo: &'static SecKeyKeyExchangeParameter;
2050}
2051
2052#[cfg(feature = "SecBase")]
2053impl SecKey {
2054 /// Perform Diffie-Hellman style of key exchange operation, optionally with additional key-derivation steps.
2055 ///
2056 /// Parameter `algorithm`: One of SecKeyAlgorithm constants suitable to perform this operation.
2057 ///
2058 /// Parameter `publicKey`: Remote party's public key.
2059 ///
2060 /// Parameter `parameters`: Dictionary with parameters, see SecKeyKeyExchangeParameter constants. Used algorithm
2061 /// determines the set of required and optional parameters to be used.
2062 ///
2063 /// Parameter `error`: Pointer to an error object on failure.
2064 /// See "Security Error Codes" (SecBase.h).
2065 ///
2066 /// Returns: Result of key exchange operation as a CFDataRef, or NULL on failure.
2067 #[doc(alias = "SecKeyCopyKeyExchangeResult")]
2068 #[cfg(feature = "SecBase")]
2069 #[inline]
2070 pub unsafe fn key_exchange_result(
2071 self: &SecKey,
2072 algorithm: &SecKeyAlgorithm,
2073 public_key: &SecKey,
2074 parameters: &CFDictionary,
2075 error: *mut *mut CFError,
2076 ) -> Option<CFRetained<CFData>> {
2077 extern "C-unwind" {
2078 fn SecKeyCopyKeyExchangeResult(
2079 private_key: &SecKey,
2080 algorithm: &SecKeyAlgorithm,
2081 public_key: &SecKey,
2082 parameters: &CFDictionary,
2083 error: *mut *mut CFError,
2084 ) -> Option<NonNull<CFData>>;
2085 }
2086 let ret =
2087 unsafe { SecKeyCopyKeyExchangeResult(self, algorithm, public_key, parameters, error) };
2088 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2089 }
2090}
2091
2092/// Defines types of cryptographic operations available with SecKey instance.
2093///
2094///
2095/// Represents SecKeyCreateSignature()
2096///
2097///
2098/// Represents SecKeyVerifySignature()
2099///
2100///
2101/// Represents SecKeyCreateEncryptedData()
2102///
2103///
2104/// Represents SecKeyCreateDecryptedData()
2105///
2106///
2107/// Represents SecKeyCopyKeyExchangeResult()
2108///
2109/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeyoperationtype?language=objc)
2110// NS_ENUM
2111#[repr(transparent)]
2112#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2113pub struct SecKeyOperationType(pub CFIndex);
2114impl SecKeyOperationType {
2115 #[doc(alias = "kSecKeyOperationTypeSign")]
2116 pub const Sign: Self = Self(0);
2117 #[doc(alias = "kSecKeyOperationTypeVerify")]
2118 pub const Verify: Self = Self(1);
2119 #[doc(alias = "kSecKeyOperationTypeEncrypt")]
2120 pub const Encrypt: Self = Self(2);
2121 #[doc(alias = "kSecKeyOperationTypeDecrypt")]
2122 pub const Decrypt: Self = Self(3);
2123 #[doc(alias = "kSecKeyOperationTypeKeyExchange")]
2124 pub const KeyExchange: Self = Self(4);
2125}
2126
2127#[cfg(feature = "objc2")]
2128unsafe impl Encode for SecKeyOperationType {
2129 const ENCODING: Encoding = CFIndex::ENCODING;
2130}
2131
2132#[cfg(feature = "objc2")]
2133unsafe impl RefEncode for SecKeyOperationType {
2134 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2135}
2136
2137#[cfg(feature = "SecBase")]
2138impl SecKey {
2139 /// Checks whether key supports specified algorithm for specified operation.
2140 ///
2141 /// Parameter `key`: Key to query
2142 ///
2143 /// Parameter `operation`: Operation type for which the key is queried
2144 ///
2145 /// Parameter `algorithm`: Algorithm which is queried
2146 ///
2147 /// Returns: True if key supports specified algorithm for specified operation, False otherwise.
2148 #[doc(alias = "SecKeyIsAlgorithmSupported")]
2149 #[cfg(feature = "SecBase")]
2150 #[inline]
2151 pub unsafe fn is_algorithm_supported(
2152 self: &SecKey,
2153 operation: SecKeyOperationType,
2154 algorithm: &SecKeyAlgorithm,
2155 ) -> bool {
2156 extern "C-unwind" {
2157 fn SecKeyIsAlgorithmSupported(
2158 key: &SecKey,
2159 operation: SecKeyOperationType,
2160 algorithm: &SecKeyAlgorithm,
2161 ) -> Boolean;
2162 }
2163 let ret = unsafe { SecKeyIsAlgorithmSupported(self, operation, algorithm) };
2164 ret != 0
2165 }
2166}
2167
2168extern "C-unwind" {
2169 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
2170 #[deprecated = "renamed to `SecKey::create_pair`"]
2171 pub fn SecKeyCreatePair(
2172 keychain_ref: Option<&SecKeychain>,
2173 algorithm: CSSM_ALGORITHMS,
2174 key_size_in_bits: uint32,
2175 context_handle: CSSM_CC_HANDLE,
2176 public_key_usage: CSSM_KEYUSE,
2177 public_key_attr: uint32,
2178 private_key_usage: CSSM_KEYUSE,
2179 private_key_attr: uint32,
2180 initial_access: Option<&SecAccess>,
2181 public_key: *mut *mut SecKey,
2182 private_key: *mut *mut SecKey,
2183 ) -> OSStatus;
2184}
2185
2186extern "C-unwind" {
2187 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
2188 #[deprecated = "renamed to `SecKey::generate`"]
2189 pub fn SecKeyGenerate(
2190 keychain_ref: Option<&SecKeychain>,
2191 algorithm: CSSM_ALGORITHMS,
2192 key_size_in_bits: uint32,
2193 context_handle: CSSM_CC_HANDLE,
2194 key_usage: CSSM_KEYUSE,
2195 key_attr: uint32,
2196 initial_access: Option<&SecAccess>,
2197 key_ref: *mut *mut SecKey,
2198 ) -> OSStatus;
2199}
2200
2201extern "C-unwind" {
2202 #[cfg(all(
2203 feature = "SecAsn1Types",
2204 feature = "SecBase",
2205 feature = "cssmconfig",
2206 feature = "cssmtype"
2207 ))]
2208 #[deprecated = "renamed to `SecKey::cssm_key`"]
2209 pub fn SecKeyGetCSSMKey(key: &SecKey, cssm_key: NonNull<*const CSSM_KEY>) -> OSStatus;
2210}
2211
2212extern "C-unwind" {
2213 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
2214 #[deprecated = "renamed to `SecKey::csp_handle`"]
2215 pub fn SecKeyGetCSPHandle(key_ref: &SecKey, csp_handle: NonNull<CSSM_CSP_HANDLE>) -> OSStatus;
2216}
2217
2218extern "C-unwind" {
2219 #[cfg(all(
2220 feature = "SecAsn1Types",
2221 feature = "SecBase",
2222 feature = "cssmconfig",
2223 feature = "cssmtype"
2224 ))]
2225 #[deprecated = "renamed to `SecKey::credentials`"]
2226 pub fn SecKeyGetCredentials(
2227 key_ref: &SecKey,
2228 operation: CSSM_ACL_AUTHORIZATION_TAG,
2229 credential_type: SecCredentialType,
2230 out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>,
2231 ) -> OSStatus;
2232}
2233
2234#[cfg(feature = "SecBase")]
2235#[deprecated = "renamed to `SecKey::generate_symmetric`"]
2236#[inline]
2237pub unsafe extern "C-unwind" fn SecKeyGenerateSymmetric(
2238 parameters: &CFDictionary,
2239 error: *mut *mut CFError,
2240) -> Option<CFRetained<SecKey>> {
2241 extern "C-unwind" {
2242 fn SecKeyGenerateSymmetric(
2243 parameters: &CFDictionary,
2244 error: *mut *mut CFError,
2245 ) -> Option<NonNull<SecKey>>;
2246 }
2247 let ret = unsafe { SecKeyGenerateSymmetric(parameters, error) };
2248 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2249}
2250
2251#[cfg(feature = "SecBase")]
2252#[deprecated = "renamed to `SecKey::from_data`"]
2253#[inline]
2254pub unsafe extern "C-unwind" fn SecKeyCreateFromData(
2255 parameters: &CFDictionary,
2256 key_data: &CFData,
2257 error: *mut *mut CFError,
2258) -> Option<CFRetained<SecKey>> {
2259 extern "C-unwind" {
2260 fn SecKeyCreateFromData(
2261 parameters: &CFDictionary,
2262 key_data: &CFData,
2263 error: *mut *mut CFError,
2264 ) -> Option<NonNull<SecKey>>;
2265 }
2266 let ret = unsafe { SecKeyCreateFromData(parameters, key_data, error) };
2267 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2268}
2269
2270#[cfg(feature = "SecBase")]
2271#[deprecated = "renamed to `SecKey::derive_from_password`"]
2272#[inline]
2273pub unsafe extern "C-unwind" fn SecKeyDeriveFromPassword(
2274 password: &CFString,
2275 parameters: &CFDictionary,
2276 error: *mut *mut CFError,
2277) -> Option<CFRetained<SecKey>> {
2278 extern "C-unwind" {
2279 fn SecKeyDeriveFromPassword(
2280 password: &CFString,
2281 parameters: &CFDictionary,
2282 error: *mut *mut CFError,
2283 ) -> Option<NonNull<SecKey>>;
2284 }
2285 let ret = unsafe { SecKeyDeriveFromPassword(password, parameters, error) };
2286 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2287}
2288
2289#[cfg(feature = "SecBase")]
2290#[deprecated = "renamed to `SecKey::wrap_symmetric`"]
2291#[inline]
2292pub unsafe extern "C-unwind" fn SecKeyWrapSymmetric(
2293 key_to_wrap: &SecKey,
2294 wrapping_key: &SecKey,
2295 parameters: &CFDictionary,
2296 error: *mut *mut CFError,
2297) -> Option<CFRetained<CFData>> {
2298 extern "C-unwind" {
2299 fn SecKeyWrapSymmetric(
2300 key_to_wrap: &SecKey,
2301 wrapping_key: &SecKey,
2302 parameters: &CFDictionary,
2303 error: *mut *mut CFError,
2304 ) -> Option<NonNull<CFData>>;
2305 }
2306 let ret = unsafe { SecKeyWrapSymmetric(key_to_wrap, wrapping_key, parameters, error) };
2307 ret.map(|ret| unsafe { CFRetained::retain(ret) })
2308}
2309
2310#[cfg(feature = "SecBase")]
2311#[deprecated = "renamed to `SecKey::unwrap_symmetric`"]
2312#[inline]
2313pub unsafe extern "C-unwind" fn SecKeyUnwrapSymmetric(
2314 key_to_unwrap: NonNull<*const CFData>,
2315 unwrapping_key: &SecKey,
2316 parameters: &CFDictionary,
2317 error: *mut *mut CFError,
2318) -> Option<CFRetained<SecKey>> {
2319 extern "C-unwind" {
2320 fn SecKeyUnwrapSymmetric(
2321 key_to_unwrap: NonNull<*const CFData>,
2322 unwrapping_key: &SecKey,
2323 parameters: &CFDictionary,
2324 error: *mut *mut CFError,
2325 ) -> Option<NonNull<SecKey>>;
2326 }
2327 let ret = unsafe { SecKeyUnwrapSymmetric(key_to_unwrap, unwrapping_key, parameters, error) };
2328 ret.map(|ret| unsafe { CFRetained::retain(ret) })
2329}
2330
2331extern "C-unwind" {
2332 #[cfg(feature = "SecBase")]
2333 #[deprecated = "renamed to `SecKey::generate_pair`"]
2334 pub fn SecKeyGeneratePair(
2335 parameters: &CFDictionary,
2336 public_key: *mut *mut SecKey,
2337 private_key: *mut *mut SecKey,
2338 ) -> OSStatus;
2339}
2340
2341#[cfg(feature = "SecBase")]
2342#[deprecated = "renamed to `SecKey::new_random_key`"]
2343#[inline]
2344pub unsafe extern "C-unwind" fn SecKeyCreateRandomKey(
2345 parameters: &CFDictionary,
2346 error: *mut *mut CFError,
2347) -> Option<CFRetained<SecKey>> {
2348 extern "C-unwind" {
2349 fn SecKeyCreateRandomKey(
2350 parameters: &CFDictionary,
2351 error: *mut *mut CFError,
2352 ) -> Option<NonNull<SecKey>>;
2353 }
2354 let ret = unsafe { SecKeyCreateRandomKey(parameters, error) };
2355 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2356}
2357
2358#[cfg(feature = "SecBase")]
2359#[deprecated = "renamed to `SecKey::with_data`"]
2360#[inline]
2361pub unsafe extern "C-unwind" fn SecKeyCreateWithData(
2362 key_data: &CFData,
2363 attributes: &CFDictionary,
2364 error: *mut *mut CFError,
2365) -> Option<CFRetained<SecKey>> {
2366 extern "C-unwind" {
2367 fn SecKeyCreateWithData(
2368 key_data: &CFData,
2369 attributes: &CFDictionary,
2370 error: *mut *mut CFError,
2371 ) -> Option<NonNull<SecKey>>;
2372 }
2373 let ret = unsafe { SecKeyCreateWithData(key_data, attributes, error) };
2374 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2375}
2376
2377extern "C-unwind" {
2378 #[cfg(feature = "SecBase")]
2379 #[deprecated = "renamed to `SecKey::block_size`"]
2380 pub fn SecKeyGetBlockSize(key: &SecKey) -> usize;
2381}
2382
2383#[cfg(feature = "SecBase")]
2384#[deprecated = "renamed to `SecKey::external_representation`"]
2385#[inline]
2386pub unsafe extern "C-unwind" fn SecKeyCopyExternalRepresentation(
2387 key: &SecKey,
2388 error: *mut *mut CFError,
2389) -> Option<CFRetained<CFData>> {
2390 extern "C-unwind" {
2391 fn SecKeyCopyExternalRepresentation(
2392 key: &SecKey,
2393 error: *mut *mut CFError,
2394 ) -> Option<NonNull<CFData>>;
2395 }
2396 let ret = unsafe { SecKeyCopyExternalRepresentation(key, error) };
2397 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2398}
2399
2400#[cfg(feature = "SecBase")]
2401#[deprecated = "renamed to `SecKey::attributes`"]
2402#[inline]
2403pub unsafe extern "C-unwind" fn SecKeyCopyAttributes(
2404 key: &SecKey,
2405) -> Option<CFRetained<CFDictionary>> {
2406 extern "C-unwind" {
2407 fn SecKeyCopyAttributes(key: &SecKey) -> Option<NonNull<CFDictionary>>;
2408 }
2409 let ret = unsafe { SecKeyCopyAttributes(key) };
2410 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2411}
2412
2413#[cfg(feature = "SecBase")]
2414#[deprecated = "renamed to `SecKey::public_key`"]
2415#[inline]
2416pub unsafe extern "C-unwind" fn SecKeyCopyPublicKey(key: &SecKey) -> Option<CFRetained<SecKey>> {
2417 extern "C-unwind" {
2418 fn SecKeyCopyPublicKey(key: &SecKey) -> Option<NonNull<SecKey>>;
2419 }
2420 let ret = unsafe { SecKeyCopyPublicKey(key) };
2421 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2422}
2423
2424#[cfg(feature = "SecBase")]
2425#[deprecated = "renamed to `SecKey::signature`"]
2426#[inline]
2427pub unsafe extern "C-unwind" fn SecKeyCreateSignature(
2428 key: &SecKey,
2429 algorithm: &SecKeyAlgorithm,
2430 data_to_sign: &CFData,
2431 error: *mut *mut CFError,
2432) -> Option<CFRetained<CFData>> {
2433 extern "C-unwind" {
2434 fn SecKeyCreateSignature(
2435 key: &SecKey,
2436 algorithm: &SecKeyAlgorithm,
2437 data_to_sign: &CFData,
2438 error: *mut *mut CFError,
2439 ) -> Option<NonNull<CFData>>;
2440 }
2441 let ret = unsafe { SecKeyCreateSignature(key, algorithm, data_to_sign, error) };
2442 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2443}
2444
2445#[cfg(feature = "SecBase")]
2446#[deprecated = "renamed to `SecKey::verify_signature`"]
2447#[inline]
2448pub unsafe extern "C-unwind" fn SecKeyVerifySignature(
2449 key: &SecKey,
2450 algorithm: &SecKeyAlgorithm,
2451 signed_data: &CFData,
2452 signature: &CFData,
2453 error: *mut *mut CFError,
2454) -> bool {
2455 extern "C-unwind" {
2456 fn SecKeyVerifySignature(
2457 key: &SecKey,
2458 algorithm: &SecKeyAlgorithm,
2459 signed_data: &CFData,
2460 signature: &CFData,
2461 error: *mut *mut CFError,
2462 ) -> Boolean;
2463 }
2464 let ret = unsafe { SecKeyVerifySignature(key, algorithm, signed_data, signature, error) };
2465 ret != 0
2466}
2467
2468#[cfg(feature = "SecBase")]
2469#[deprecated = "renamed to `SecKey::encrypted_data`"]
2470#[inline]
2471pub unsafe extern "C-unwind" fn SecKeyCreateEncryptedData(
2472 key: &SecKey,
2473 algorithm: &SecKeyAlgorithm,
2474 plaintext: &CFData,
2475 error: *mut *mut CFError,
2476) -> Option<CFRetained<CFData>> {
2477 extern "C-unwind" {
2478 fn SecKeyCreateEncryptedData(
2479 key: &SecKey,
2480 algorithm: &SecKeyAlgorithm,
2481 plaintext: &CFData,
2482 error: *mut *mut CFError,
2483 ) -> Option<NonNull<CFData>>;
2484 }
2485 let ret = unsafe { SecKeyCreateEncryptedData(key, algorithm, plaintext, error) };
2486 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2487}
2488
2489#[cfg(feature = "SecBase")]
2490#[deprecated = "renamed to `SecKey::decrypted_data`"]
2491#[inline]
2492pub unsafe extern "C-unwind" fn SecKeyCreateDecryptedData(
2493 key: &SecKey,
2494 algorithm: &SecKeyAlgorithm,
2495 ciphertext: &CFData,
2496 error: *mut *mut CFError,
2497) -> Option<CFRetained<CFData>> {
2498 extern "C-unwind" {
2499 fn SecKeyCreateDecryptedData(
2500 key: &SecKey,
2501 algorithm: &SecKeyAlgorithm,
2502 ciphertext: &CFData,
2503 error: *mut *mut CFError,
2504 ) -> Option<NonNull<CFData>>;
2505 }
2506 let ret = unsafe { SecKeyCreateDecryptedData(key, algorithm, ciphertext, error) };
2507 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2508}
2509
2510#[cfg(feature = "SecBase")]
2511#[deprecated = "renamed to `SecKey::key_exchange_result`"]
2512#[inline]
2513pub unsafe extern "C-unwind" fn SecKeyCopyKeyExchangeResult(
2514 private_key: &SecKey,
2515 algorithm: &SecKeyAlgorithm,
2516 public_key: &SecKey,
2517 parameters: &CFDictionary,
2518 error: *mut *mut CFError,
2519) -> Option<CFRetained<CFData>> {
2520 extern "C-unwind" {
2521 fn SecKeyCopyKeyExchangeResult(
2522 private_key: &SecKey,
2523 algorithm: &SecKeyAlgorithm,
2524 public_key: &SecKey,
2525 parameters: &CFDictionary,
2526 error: *mut *mut CFError,
2527 ) -> Option<NonNull<CFData>>;
2528 }
2529 let ret = unsafe {
2530 SecKeyCopyKeyExchangeResult(private_key, algorithm, public_key, parameters, error)
2531 };
2532 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
2533}
2534
2535#[cfg(feature = "SecBase")]
2536#[deprecated = "renamed to `SecKey::is_algorithm_supported`"]
2537#[inline]
2538pub unsafe extern "C-unwind" fn SecKeyIsAlgorithmSupported(
2539 key: &SecKey,
2540 operation: SecKeyOperationType,
2541 algorithm: &SecKeyAlgorithm,
2542) -> bool {
2543 extern "C-unwind" {
2544 fn SecKeyIsAlgorithmSupported(
2545 key: &SecKey,
2546 operation: SecKeyOperationType,
2547 algorithm: &SecKeyAlgorithm,
2548 ) -> Boolean;
2549 }
2550 let ret = unsafe { SecKeyIsAlgorithmSupported(key, operation, algorithm) };
2551 ret != 0
2552}