Struct SecKey

Source
#[repr(C)]
pub struct SecKey { /* private fields */ }
Available on crate feature SecBase only.
Expand description

CFType representing a cryptographic key. See SecKey.h for details.

See also Apple’s documentation

Implementations§

Source§

impl SecKey

Source

pub unsafe fn create_pair( keychain_ref: Option<&SecKeychain>, algorithm: CSSM_ALGORITHMS, key_size_in_bits: uint32, context_handle: CSSM_CC_HANDLE, public_key_usage: CSSM_KEYUSE, public_key_attr: uint32, private_key_usage: CSSM_KEYUSE, private_key_attr: uint32, initial_access: Option<&SecAccess>, public_key: *mut *mut SecKey, private_key: *mut *mut SecKey, ) -> i32

👎Deprecated: CSSM is not supported
Available on crate features SecKey and cssmconfig and cssmtype only.

Creates an asymmetric key pair and stores it in a specified keychain.

Parameter keychainRef: A reference to the keychain in which to store the private and public key items. Specify NULL for the default keychain.

Parameter algorithm: An algorithm for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.

Parameter keySizeInBits: A key size for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.

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.

Parameter publicKeyUsage: A bit mask indicating all permitted uses for the new public key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.

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.

Parameter privateKeyUsage: A bit mask indicating all permitted uses for the new private key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.

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.

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.

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.

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.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This API is deprecated for 10.7. Please use the SecKeyGeneratePair API instead.

Source

pub unsafe fn generate( keychain_ref: Option<&SecKeychain>, algorithm: CSSM_ALGORITHMS, key_size_in_bits: uint32, context_handle: CSSM_CC_HANDLE, key_usage: CSSM_KEYUSE, key_attr: uint32, initial_access: Option<&SecAccess>, key_ref: *mut *mut SecKey, ) -> i32

👎Deprecated: CSSM is not supported
Available on crate features SecKey and cssmconfig and cssmtype only.

Creates a symmetric key and optionally stores it in a specified keychain.

Parameter keychainRef: (optional) A reference to the keychain in which to store the generated key. Specify NULL to generate a transient key.

Parameter algorithm: An algorithm for the symmetric key. This parameter is ignored if a valid (non-zero) contextHandle is supplied.

Parameter keySizeInBits: A key size for the key pair. This parameter is ignored if a valid (non-zero) contextHandle is supplied.

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.

Parameter keyUsage: A bit mask indicating all permitted uses for the new key. CSSM_KEYUSE bit mask values are defined in cssmtype.h.

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.

Parameter initialAccess: (optional) A SecAccess object that determines the initial access rights for the key. This parameter is ignored if the keychainRef is NULL.

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.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This API is deprecated for 10.7. Please use the SecKeyGenerateSymmetric API instead.

Source

pub unsafe fn cssm_key(self: &SecKey, cssm_key: NonNull<*const CSSM_KEY>) -> i32

👎Deprecated
Available on crate features SecKey and SecAsn1Types and cssmconfig and cssmtype only.

Returns a pointer to the CSSM_KEY for the given key item reference.

Parameter key: A keychain key item reference. The key item must be of class type kSecPublicKeyItemClass, kSecPrivateKeyItemClass, or kSecSymmetricKeyItemClass.

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.

Returns: A result code. See “Security Error Codes” (SecBase.h).

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.

Source

pub unsafe fn csp_handle( self: &SecKey, csp_handle: NonNull<CSSM_CSP_HANDLE>, ) -> i32

👎Deprecated
Available on crate features SecKey and cssmconfig and cssmtype only.

Returns the CSSM_CSP_HANDLE for the given key reference. The handle is valid until the key reference is released.

Parameter keyRef: A key reference.

Parameter cspHandle: On return, the CSSM_CSP_HANDLE for the given keychain.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This API is deprecated in 10.7. Its use should no longer be needed.

Source

pub unsafe fn credentials( self: &SecKey, operation: CSSM_ACL_AUTHORIZATION_TAG, credential_type: SecCredentialType, out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>, ) -> i32

👎Deprecated
Available on crate features SecKey and SecAsn1Types and cssmconfig and cssmtype only.

For a given key, return a pointer to a CSSM_ACCESS_CREDENTIALS structure which will allow the key to be used.

Parameter keyRef: The key for which a credential is requested.

Parameter operation: The type of operation to be performed with this key. See “Authorization tag type” for defined operations (cssmtype.h).

Parameter credentialType: The type of credential requested.

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.

Returns: A result code. See “Security Error Codes” (SecBase.h).

Source

pub unsafe fn generate_symmetric( parameters: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<SecKey>>

👎Deprecated: No longer supported
Available on crate feature SecKey only.

Generates a random symmetric key with the specified length and algorithm type.

Parameter parameters: A dictionary containing one or more key-value pairs. See the discussion sections below for a complete overview of options.

Parameter error: An optional pointer to a CFErrorRef. This value is set if an error occurred. If not NULL, the caller is responsible for releasing the CFErrorRef.

Returns: On return, a SecKeyRef reference to the symmetric key, or NULL if the key could not be created.

In order to generate a symmetric key, the parameters dictionary must at least contain the following keys:

kSecAttrKeyType with a value of kSecAttrKeyTypeAES or any other kSecAttrKeyType defined in SecItem.h kSecAttrKeySizeInBits with a value being a CFNumberRef containing the requested key size in bits. Example sizes for AES keys are: 128, 192, 256, 512.

To store the generated symmetric key in a keychain, set these keys: kSecUseKeychain (value is a SecKeychainRef) kSecAttrLabel (a user-visible label whose value is a CFStringRef, e.g. “My App’s Encryption Key”) kSecAttrApplicationLabel (a label defined by your application, whose value is a CFDataRef and which can be used to find this key in a subsequent call to SecItemCopyMatching, e.g. “ID-1234567890-9876-0151”)

To specify the generated key’s access control settings, set this key: kSecAttrAccess (value is a SecAccessRef)

The keys below may be optionally set in the parameters dictionary (with a CFBooleanRef value) to override the default usage values:

kSecAttrCanEncrypt (defaults to true if not explicitly specified) kSecAttrCanDecrypt (defaults to true if not explicitly specified) kSecAttrCanWrap (defaults to true if not explicitly specified) kSecAttrCanUnwrap (defaults to true if not explicitly specified)

Source

pub unsafe fn from_data( parameters: &CFDictionary, key_data: &CFData, error: *mut *mut CFError, ) -> Option<CFRetained<SecKey>>

👎Deprecated: No longer supported
Available on crate feature SecKey only.

Creates a symmetric key with the given data and sets the algorithm type specified.

Parameter parameters: A dictionary containing one or more key-value pairs. See the discussion sections below for a complete overview of options.

Returns: On return, a SecKeyRef reference to the symmetric key.

In order to generate a symmetric key the parameters dictionary must at least contain the following keys:

kSecAttrKeyType with a value of kSecAttrKeyTypeAES or any other kSecAttrKeyType defined in SecItem.h

The keys below may be optionally set in the parameters dictionary (with a CFBooleanRef value) to override the default usage values:

kSecAttrCanEncrypt (defaults to true if not explicitly specified) kSecAttrCanDecrypt (defaults to true if not explicitly specified) kSecAttrCanWrap (defaults to true if not explicitly specified) kSecAttrCanUnwrap (defaults to true if not explicitly specified)

Source§

impl SecKey

Source

pub unsafe fn derive_from_password( password: &CFString, parameters: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<SecKey>>

👎Deprecated: No longer supported
Available on crate feature SecKey only.

Derives a symmetric key from a password.

Parameter password: The password from which the keyis to be derived.

Parameter parameters: A dictionary containing one or more key-value pairs.

Parameter error: If the call fails this will contain the error code.

In order to derive a key the parameters dictionary must contain at least contain the following keys: kSecAttrSalt - a CFData for the salt value for mixing in the pseudo-random rounds. kSecAttrPRF - the algorithm to use for the pseudo-random-function. If 0, this defaults to kSecAttrPRFHmacAlgSHA1. Possible values are:

kSecAttrPRFHmacAlgSHA1 kSecAttrPRFHmacAlgSHA224 kSecAttrPRFHmacAlgSHA256 kSecAttrPRFHmacAlgSHA384 kSecAttrPRFHmacAlgSHA512

kSecAttrRounds - the number of rounds to call the pseudo random function. If 0, a count will be computed to average 1/10 of a second. kSecAttrKeySizeInBits with a value being a CFNumberRef containing the requested key size in bits. Example sizes for RSA keys are: 512, 768, 1024, 2048.

Returns: On success a SecKeyRef is returned. On failure this result is NULL and the error parameter contains the reason.

Source

pub unsafe fn wrap_symmetric( self: &SecKey, wrapping_key: &SecKey, parameters: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<CFData>>

👎Deprecated: No longer supported
Available on crate feature SecKey only.

Wraps a symmetric key with a symmetric key.

Parameter keyToWrap: The key which is to be wrapped.

Parameter wrappingKey: The key wrapping key.

Parameter parameters: The parameter list to use for wrapping the key.

Parameter error: If the call fails this will contain the error code.

Returns: On success a CFDataRef is returned. On failure this result is NULL and the error parameter contains the reason.

In order to wrap a key the parameters dictionary may contain the following key: kSecSalt - a CFData for the salt value for the encrypt.

Source

pub unsafe fn unwrap_symmetric( key_to_unwrap: NonNull<*const CFData>, unwrapping_key: &SecKey, parameters: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<SecKey>>

👎Deprecated: No longer supported
Available on crate feature SecKey only.

Unwrap a wrapped symmetric key.

Parameter keyToUnwrap: The wrapped key to unwrap.

Parameter unwrappingKey: The key unwrapping key.

Parameter parameters: The parameter list to use for unwrapping the key.

Parameter error: If the call fails this will contain the error code.

Returns: On success a SecKeyRef is returned. On failure this result is NULL and the error parameter contains the reason.

In order to unwrap a key the parameters dictionary may contain the following key: kSecSalt - a CFData for the salt value for the decrypt.

Source

pub unsafe fn generate_pair( parameters: &CFDictionary, public_key: *mut *mut SecKey, private_key: *mut *mut SecKey, ) -> i32

👎Deprecated: Use SecKeyCreateRandomKey
Available on crate feature SecKey only.

Generate a private/public keypair.

Parameter parameters: A dictionary containing one or more key-value pairs. See the discussion sections below for a complete overview of options.

Parameter publicKey: On return, a SecKeyRef reference to the public key.

Parameter privateKey: On return, a SecKeyRef reference to the private key.

Returns: A result code. See “Security Error Codes” (SecBase.h).

In order to generate a keypair the parameters dictionary must at least contain the following keys:

kSecAttrKeyType with a value of kSecAttrKeyTypeRSA or any other kSecAttrKeyType defined in SecItem.h kSecAttrKeySizeInBits with a value being a CFNumberRef containing the requested key size in bits. Example sizes for RSA keys are: 512, 768, 1024, 2048.

The values below may be set either in the top-level dictionary or in a dictionary that is the value of the kSecPrivateKeyAttrs or kSecPublicKeyAttrs key in the top-level dictionary. Setting these attributes explicitly will override the defaults below. See SecItem.h for detailed information on these attributes including the types of the values.

kSecAttrLabel default NULL kSecUseKeychain default NULL, which specifies the default keychain kSecAttrIsPermanent default false if this key is present and has a Boolean value of true, the key or key pair will be added to the keychain. kSecAttrTokenID default NULL The CFStringRef ID of the token to generate the key or keypair on. This attribute can contain CFStringRef and can be present only in the top-level parameters dictionary. kSecAttrApplicationTag default NULL kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits kSecAttrCanEncrypt default false for private keys, true for public keys kSecAttrCanDecrypt default true for private keys, false for public keys kSecAttrCanDerive default true kSecAttrCanSign default true for private keys, false for public keys kSecAttrCanVerify default false for private keys, true for public keys kSecAttrCanWrap default false for private keys, true for public keys kSecAttrCanUnwrap default true for private keys, false for public keys

NOTE: The function always saves keys in the keychain on macOS and as such attribute kSecAttrIsPermanent is ignored. The function respects attribute kSecAttrIsPermanent on iOS, tvOS and watchOS. It is recommended to use SecKeyCreateRandomKey() which respects kSecAttrIsPermanent on all platforms.

Source

pub unsafe fn new_random_key( parameters: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<SecKey>>

Available on crate feature SecKey only.

Generates a new public/private key pair.

Parameter parameters: A dictionary containing one or more key-value pairs. See the discussion sections below for a complete overview of options.

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: Newly generated private key. To get associated public key, use SecKeyCopyPublicKey().

In order to generate a keypair the parameters dictionary must at least contain the following keys:

kSecAttrKeyType with a value being kSecAttrKeyTypeRSA or any other kSecAttrKeyType defined in SecItem.h kSecAttrKeySizeInBits with a value being a CFNumberRef or CFStringRef containing the requested key size in bits. Example sizes for RSA keys are: 512, 768, 1024, 2048.

The values below may be set either in the top-level dictionary or in a dictionary that is the value of the kSecPrivateKeyAttrs or kSecPublicKeyAttrs key in the top-level dictionary. Setting these attributes explicitly will override the defaults below. See SecItem.h for detailed information on these attributes including the types of the values.

kSecAttrLabel default NULL kSecAttrIsPermanent if this key is present and has a Boolean value of true, the key or key pair will be added to the default keychain. kSecAttrTokenID if this key should be generated on specified token. This attribute can contain CFStringRef and can be present only in the top-level parameters dictionary. kSecAttrApplicationTag default NULL kSecAttrEffectiveKeySize default NULL same as kSecAttrKeySizeInBits kSecAttrCanEncrypt default false for private keys, true for public keys kSecAttrCanDecrypt default true for private keys, false for public keys kSecAttrCanDerive default true kSecAttrCanSign default true for private keys, false for public keys kSecAttrCanVerify default false for private keys, true for public keys kSecAttrCanWrap default false for private keys, true for public keys kSecAttrCanUnwrap default true for private keys, false for public keys

Source

pub unsafe fn with_data( key_data: &CFData, attributes: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<SecKey>>

Available on crate feature SecKey only.

Create a SecKey from a well-defined external representation.

Parameter keyData: CFData representing the key. The format of the data depends on the type of key being created.

Parameter attributes: Dictionary containing attributes describing the key to be imported. The keys in this dictionary are kSecAttr* constants from SecItem.h. Mandatory attributes are: kSecAttrKeyType kSecAttrKeyClass

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: A SecKey object representing the key, or NULL on failure.

This function does not add keys to any keychain, but the SecKey object it returns can be added to keychain using the SecItemAdd function. The requested data format depend on the type of key (kSecAttrKeyType) being created: kSecAttrKeyTypeRSA PKCS#1 format, public key can be also in x509 public key format kSecAttrKeyTypeECSECPrimeRandom ANSI X9.63 format (04 || X || Y [ || K])

Source

pub unsafe fn block_size(self: &SecKey) -> usize

Available on crate feature SecKey only.

Returns block length of the key in bytes.

Parameter key: The key for which the block length is requested.

Returns: The block length of the key in bytes.

If for example key is an RSA key the value returned by this function is the size of the modulus.

Source

pub unsafe fn external_representation( self: &SecKey, error: *mut *mut CFError, ) -> Option<CFRetained<CFData>>

Available on crate feature SecKey only.

Create an external representation for the given key suitable for the key’s type.

Parameter key: The key to be exported.

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: A CFData representing the key in a format suitable for that key type.

This function may fail if the key is not exportable (e.g., bound to a smart card or Secure Enclave). The format in which the key will be exported depends on the type of key: kSecAttrKeyTypeRSA PKCS#1 format kSecAttrKeyTypeECSECPrimeRandom ANSI X9.63 format (04 || X || Y [ || K])

Source

pub unsafe fn attributes(self: &SecKey) -> Option<CFRetained<CFDictionary>>

Available on crate feature SecKey only.

Retrieve keychain attributes of a key.

Parameter key: The key whose attributes are to be retrieved.

Returns: Dictionary containing attributes of the key. The keys that populate this dictionary are defined and discussed in SecItem.h.

The attributes provided by this function are: kSecAttrCanEncrypt kSecAttrCanDecrypt kSecAttrCanDerive kSecAttrCanSign kSecAttrCanVerify kSecAttrKeyClass kSecAttrKeyType kSecAttrKeySizeInBits kSecAttrTokenID kSecAttrApplicationLabel The set of values is not fixed. Future versions may return more values in this dictionary.

Source

pub unsafe fn public_key(self: &SecKey) -> Option<CFRetained<SecKey>>

Available on crate feature SecKey only.

Retrieve the public key from a key pair or private key.

Parameter key: The key from which to retrieve a public key.

Returns: The public key or NULL if public key is not available for specified key.

Fails if key does not contain a public key or no public key can be computed from it.

Source§

impl SecKey

Source

pub unsafe fn signature( self: &SecKey, algorithm: &SecKeyAlgorithm, data_to_sign: &CFData, error: *mut *mut CFError, ) -> Option<CFRetained<CFData>>

Available on crate feature SecKey only.

Given a private key and data to sign, generate a digital signature.

Parameter key: Private key with which to sign.

Parameter algorithm: One of SecKeyAlgorithm constants suitable to generate signature with this key.

Parameter dataToSign: The data to be signed, typically the digest of the actual data.

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: The signature over dataToSign represented as a CFData, or NULL on failure.

Computes digital signature using specified key over input data. The operation algorithm further defines the exact format of input data, operation to be performed and output signature.

Source

pub unsafe fn verify_signature( self: &SecKey, algorithm: &SecKeyAlgorithm, signed_data: &CFData, signature: &CFData, error: *mut *mut CFError, ) -> bool

Available on crate feature SecKey only.

Given a public key, data which has been signed, and a signature, verify the signature.

Parameter key: Public key with which to verify the signature.

Parameter algorithm: One of SecKeyAlgorithm constants suitable to verify signature with this key.

Parameter signedData: The data over which sig is being verified, typically the digest of the actual data.

Parameter signature: The signature to verify.

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: True if the signature was valid, False otherwise.

Verifies digital signature operation using specified key and signed data. The operation algorithm further defines the exact format of input data, signature and operation to be performed.

Source

pub unsafe fn encrypted_data( self: &SecKey, algorithm: &SecKeyAlgorithm, plaintext: &CFData, error: *mut *mut CFError, ) -> Option<CFRetained<CFData>>

Available on crate feature SecKey only.

Encrypt a block of plaintext.

Parameter key: Public key with which to encrypt the data.

Parameter algorithm: One of SecKeyAlgorithm constants suitable to perform encryption with this key.

Parameter plaintext: The data to encrypt. The length and format of the data must conform to chosen algorithm, typically be less or equal to the value returned by SecKeyGetBlockSize().

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: The ciphertext represented as a CFData, or NULL on failure.

Encrypts plaintext data using specified key. The exact type of the operation including the format of input and output data is specified by encryption algorithm.

Source

pub unsafe fn decrypted_data( self: &SecKey, algorithm: &SecKeyAlgorithm, ciphertext: &CFData, error: *mut *mut CFError, ) -> Option<CFRetained<CFData>>

Available on crate feature SecKey only.

Decrypt a block of ciphertext.

Parameter key: Private key with which to decrypt the data.

Parameter algorithm: One of SecKeyAlgorithm constants suitable to perform decryption with this key.

Parameter ciphertext: The data to decrypt. The length and format of the data must conform to chosen algorithm, typically be less or equal to the value returned by SecKeyGetBlockSize().

Parameter error: On error, will be populated with an error object describing the failure. See “Security Error Codes” (SecBase.h).

Returns: The plaintext represented as a CFData, or NULL on failure.

Decrypts ciphertext data using specified key. The exact type of the operation including the format of input and output data is specified by decryption algorithm.

Source§

impl SecKey

Source

pub unsafe fn key_exchange_result( self: &SecKey, algorithm: &SecKeyAlgorithm, public_key: &SecKey, parameters: &CFDictionary, error: *mut *mut CFError, ) -> Option<CFRetained<CFData>>

Available on crate feature SecKey only.

Perform Diffie-Hellman style of key exchange operation, optionally with additional key-derivation steps.

Parameter algorithm: One of SecKeyAlgorithm constants suitable to perform this operation.

Parameter publicKey: Remote party’s public key.

Parameter parameters: Dictionary with parameters, see SecKeyKeyExchangeParameter constants. Used algorithm determines the set of required and optional parameters to be used.

Parameter error: Pointer to an error object on failure. See “Security Error Codes” (SecBase.h).

Returns: Result of key exchange operation as a CFDataRef, or NULL on failure.

Source§

impl SecKey

Source

pub unsafe fn is_algorithm_supported( self: &SecKey, operation: SecKeyOperationType, algorithm: &SecKeyAlgorithm, ) -> bool

Available on crate feature SecKey only.

Checks whether key supports specified algorithm for specified operation.

Parameter key: Key to query

Parameter operation: Operation type for which the key is queried

Parameter algorithm: Algorithm which is queried

Returns: True if key supports specified algorithm for specified operation, False otherwise.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Available on crate feature SecCustomTransform only.

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Available on crate feature SecCustomTransform only.

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AnyObject> for SecKey

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for SecKey

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<SecKey> for SecKey

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for SecKey

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for SecKey

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for SecKey

Available on crate feature SecKey only.
Source§

fn type_id() -> CFTypeID

Returns the type identifier of SecKey instances.

Returns: The CFTypeID of SecKey instances.

Source§

impl Debug for SecKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SecKey

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for SecKey

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for SecKey

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for SecKey

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for SecKey

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for SecKey

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for SecKey

Auto Trait Implementations§

§

impl !Freeze for SecKey

§

impl !RefUnwindSafe for SecKey

§

impl !Send for SecKey

§

impl !Sync for SecKey

§

impl !Unpin for SecKey

§

impl !UnwindSafe for SecKey

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,