pub struct SecKey(/* private fields */);Expand description
A type representing an encryption key.
Implementations§
Source§impl SecKey
impl SecKey
Sourcepub fn new(options: &GenerateKeyOptions) -> Result<Self, CFError>
pub fn new(options: &GenerateKeyOptions) -> Result<Self, CFError>
Translates to SecKeyCreateRandomKey
Sourcepub fn generate(attributes: CFDictionary) -> Result<Self, CFError>
👎Deprecated: Use SecKey::new
pub fn generate(attributes: CFDictionary) -> Result<Self, CFError>
Use SecKey::new
Translates to SecKeyCreateRandomKey
GenerateKeyOptions provides a helper to create an attribute CFDictionary.
Sourcepub fn application_label(&self) -> Option<Vec<u8>>
pub fn application_label(&self) -> Option<Vec<u8>>
Returns the programmatic identifier for the key. For keys of class kSecAttrKeyClassPublic and kSecAttrKeyClassPrivate, the value is the hash of the public key.
Sourcepub fn attributes(&self) -> CFDictionary
pub fn attributes(&self) -> CFDictionary
Translates to SecKeyCopyAttributes
Sourcepub fn external_representation(&self) -> Option<CFData>
pub fn external_representation(&self) -> Option<CFData>
Translates to SecKeyCopyExternalRepresentation
Sourcepub fn public_key(&self) -> Option<Self>
pub fn public_key(&self) -> Option<Self>
Translates to SecKeyCopyPublicKey
Sourcepub fn encrypt_data(
&self,
algorithm: Algorithm,
input: &[u8],
) -> Result<Vec<u8>, CFError>
pub fn encrypt_data( &self, algorithm: Algorithm, input: &[u8], ) -> Result<Vec<u8>, CFError>
Encrypts a block of data using a public key and specified algorithm
Sourcepub fn decrypt_data(
&self,
algorithm: Algorithm,
input: &[u8],
) -> Result<Vec<u8>, CFError>
pub fn decrypt_data( &self, algorithm: Algorithm, input: &[u8], ) -> Result<Vec<u8>, CFError>
Decrypts a block of data using a private key and specified algorithm
Sourcepub fn create_signature(
&self,
algorithm: Algorithm,
input: &[u8],
) -> Result<Vec<u8>, CFError>
pub fn create_signature( &self, algorithm: Algorithm, input: &[u8], ) -> Result<Vec<u8>, CFError>
Creates the cryptographic signature for a block of data using a private key and specified algorithm.
Sourcepub fn verify_signature(
&self,
algorithm: Algorithm,
signed_data: &[u8],
signature: &[u8],
) -> Result<bool, CFError>
pub fn verify_signature( &self, algorithm: Algorithm, signed_data: &[u8], signature: &[u8], ) -> Result<bool, CFError>
Verifies the cryptographic signature for a block of data using a public key and specified algorithm.
Trait Implementations§
impl ConcreteCFType for SecKey
impl Eq for SecKey
impl Send for SecKey
impl Sync for SecKey
Source§impl TCFType for SecKey
impl TCFType for SecKey
Source§type Ref = *mut OpaqueSecKeyRef
type Ref = *mut OpaqueSecKeyRef
Source§fn as_concrete_TypeRef(&self) -> SecKeyRef
fn as_concrete_TypeRef(&self) -> SecKeyRef
TypeRef.Source§unsafe fn wrap_under_get_rule(reference: SecKeyRef) -> Self
unsafe fn wrap_under_get_rule(reference: SecKeyRef) -> Self
CFTypeRef subclass. Use this
when following Core Foundation’s “Get Rule”. The reference count is bumped.Source§fn as_CFTypeRef(&self) -> CFTypeRef
fn as_CFTypeRef(&self) -> CFTypeRef
CFTypeRef. The reference count is not adjusted.Source§unsafe fn wrap_under_create_rule(reference: SecKeyRef) -> Self
unsafe fn wrap_under_create_rule(reference: SecKeyRef) -> Self
CFTypeRef subclass. Use this
when following Core Foundation’s “Create Rule”. The reference count is not bumped.Source§fn as_CFType(&self) -> CFType
fn as_CFType(&self) -> CFType
CFType. The reference count is incremented by one.Source§fn into_CFType(self) -> CFTypewhere
Self: Sized,
fn into_CFType(self) -> CFTypewhere
Self: Sized,
CFType. Consumes self and avoids changing the reference
count.Source§fn retain_count(&self) -> isize
fn retain_count(&self) -> isize
Source§fn instance_of<OtherCFType>(&self) -> boolwhere
OtherCFType: TCFType,
fn instance_of<OtherCFType>(&self) -> boolwhere
OtherCFType: TCFType,
true if this value is an instance of another type.