use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[deprecated = "No longer supported"]
pub const kSecKeyKeyClass: c_int = 0;
#[deprecated = "No longer supported"]
pub const kSecKeyPrintName: c_int = 1;
#[deprecated = "No longer supported"]
pub const kSecKeyAlias: c_int = 2;
#[deprecated = "No longer supported"]
pub const kSecKeyPermanent: c_int = 3;
#[deprecated = "No longer supported"]
pub const kSecKeyPrivate: c_int = 4;
#[deprecated = "No longer supported"]
pub const kSecKeyModifiable: c_int = 5;
#[deprecated = "No longer supported"]
pub const kSecKeyLabel: c_int = 6;
#[deprecated = "No longer supported"]
pub const kSecKeyApplicationTag: c_int = 7;
#[deprecated = "No longer supported"]
pub const kSecKeyKeyCreator: c_int = 8;
#[deprecated = "No longer supported"]
pub const kSecKeyKeyType: c_int = 9;
#[deprecated = "No longer supported"]
pub const kSecKeyKeySizeInBits: c_int = 10;
#[deprecated = "No longer supported"]
pub const kSecKeyEffectiveKeySize: c_int = 11;
#[deprecated = "No longer supported"]
pub const kSecKeyStartDate: c_int = 12;
#[deprecated = "No longer supported"]
pub const kSecKeyEndDate: c_int = 13;
#[deprecated = "No longer supported"]
pub const kSecKeySensitive: c_int = 14;
#[deprecated = "No longer supported"]
pub const kSecKeyAlwaysSensitive: c_int = 15;
#[deprecated = "No longer supported"]
pub const kSecKeyExtractable: c_int = 16;
#[deprecated = "No longer supported"]
pub const kSecKeyNeverExtractable: c_int = 17;
#[deprecated = "No longer supported"]
pub const kSecKeyEncrypt: c_int = 18;
#[deprecated = "No longer supported"]
pub const kSecKeyDecrypt: c_int = 19;
#[deprecated = "No longer supported"]
pub const kSecKeyDerive: c_int = 20;
#[deprecated = "No longer supported"]
pub const kSecKeySign: c_int = 21;
#[deprecated = "No longer supported"]
pub const kSecKeyVerify: c_int = 22;
#[deprecated = "No longer supported"]
pub const kSecKeySignRecover: c_int = 23;
#[deprecated = "No longer supported"]
pub const kSecKeyVerifyRecover: c_int = 24;
#[deprecated = "No longer supported"]
pub const kSecKeyWrap: c_int = 25;
#[deprecated = "No longer supported"]
pub const kSecKeyUnwrap: c_int = 26;
#[cfg(feature = "cssmconfig")]
#[deprecated = "No longer supported"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecCredentialType(pub uint32);
#[cfg(feature = "cssmconfig")]
impl SecCredentialType {
#[doc(alias = "kSecCredentialTypeDefault")]
#[deprecated = "No longer supported"]
pub const Default: Self = Self(0);
#[doc(alias = "kSecCredentialTypeWithUI")]
#[deprecated = "No longer supported"]
pub const WithUI: Self = Self(1);
#[doc(alias = "kSecCredentialTypeNoUI")]
#[deprecated = "No longer supported"]
pub const NoUI: Self = Self(2);
}
#[cfg(all(feature = "cssmconfig", feature = "objc2"))]
unsafe impl Encode for SecCredentialType {
const ENCODING: Encoding = uint32::ENCODING;
}
#[cfg(all(feature = "cssmconfig", feature = "objc2"))]
unsafe impl RefEncode for SecCredentialType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[deprecated = "Replaced with SecKeyAlgorithm"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecPadding(pub u32);
bitflags::bitflags! {
impl SecPadding: u32 {
#[doc(alias = "kSecPaddingNone")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const None = 0;
#[doc(alias = "kSecPaddingPKCS1")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1 = 1;
#[doc(alias = "kSecPaddingOAEP")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const OAEP = 2;
#[doc(alias = "kSecPaddingSigRaw")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const SigRaw = 0x4000;
#[doc(alias = "kSecPaddingPKCS1MD2")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1MD2 = 0x8000;
#[doc(alias = "kSecPaddingPKCS1MD5")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1MD5 = 0x8001;
#[doc(alias = "kSecPaddingPKCS1SHA1")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1SHA1 = 0x8002;
#[doc(alias = "kSecPaddingPKCS1SHA224")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1SHA224 = 0x8003;
#[doc(alias = "kSecPaddingPKCS1SHA256")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1SHA256 = 0x8004;
#[doc(alias = "kSecPaddingPKCS1SHA384")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1SHA384 = 0x8005;
#[doc(alias = "kSecPaddingPKCS1SHA512")]
#[deprecated = "Replaced with SecKeyAlgorithm"]
const PKCS1SHA512 = 0x8006;
}
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecPadding {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecPadding {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[deprecated = "No longer supported"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecKeySizes(pub u32);
impl SecKeySizes {
#[doc(alias = "kSecDefaultKeySize")]
#[deprecated = "No longer supported"]
pub const SecDefaultKeySize: Self = Self(0);
#[doc(alias = "kSec3DES192")]
#[deprecated = "No longer supported"]
pub const Sec3DES192: Self = Self(192);
#[doc(alias = "kSecAES128")]
#[deprecated = "No longer supported"]
pub const SecAES128: Self = Self(128);
#[doc(alias = "kSecAES192")]
#[deprecated = "No longer supported"]
pub const SecAES192: Self = Self(192);
#[doc(alias = "kSecAES256")]
#[deprecated = "No longer supported"]
pub const SecAES256: Self = Self(256);
#[doc(alias = "kSecp192r1")]
#[deprecated = "No longer supported"]
pub const Secp192r1: Self = Self(192);
#[doc(alias = "kSecp256r1")]
#[deprecated = "No longer supported"]
pub const Secp256r1: Self = Self(256);
#[doc(alias = "kSecp384r1")]
#[deprecated = "No longer supported"]
pub const Secp384r1: Self = Self(384);
#[doc(alias = "kSecp521r1")]
#[deprecated = "No longer supported"]
pub const Secp521r1: Self = Self(521);
#[doc(alias = "kSecRSAMin")]
#[deprecated = "No longer supported"]
pub const SecRSAMin: Self = Self(1024);
#[doc(alias = "kSecRSAMax")]
#[deprecated = "No longer supported"]
pub const SecRSAMax: Self = Self(4096);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecKeySizes {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecKeySizes {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static kSecPrivateKeyAttrs: &'static CFString;
}
extern "C" {
pub static kSecPublicKeyAttrs: &'static CFString;
}
#[cfg(feature = "SecBase")]
unsafe impl ConcreteType for SecKey {
#[doc(alias = "SecKeyGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn SecKeyGetTypeID() -> CFTypeID;
}
unsafe { SecKeyGetTypeID() }
}
}
#[cfg(feature = "SecBase")]
impl SecKey {
#[doc(alias = "SecKeyCreatePair")]
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "CSSM is not supported"]
#[inline]
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,
) -> OSStatus {
extern "C-unwind" {
fn SecKeyCreatePair(
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,
) -> OSStatus;
}
unsafe {
SecKeyCreatePair(
keychain_ref,
algorithm,
key_size_in_bits,
context_handle,
public_key_usage,
public_key_attr,
private_key_usage,
private_key_attr,
initial_access,
public_key,
private_key,
)
}
}
#[doc(alias = "SecKeyGenerate")]
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "CSSM is not supported"]
#[inline]
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,
) -> OSStatus {
extern "C-unwind" {
fn SecKeyGenerate(
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,
) -> OSStatus;
}
unsafe {
SecKeyGenerate(
keychain_ref,
algorithm,
key_size_in_bits,
context_handle,
key_usage,
key_attr,
initial_access,
key_ref,
)
}
}
#[doc(alias = "SecKeyGetCSSMKey")]
#[cfg(all(
feature = "SecAsn1Types",
feature = "SecBase",
feature = "cssmconfig",
feature = "cssmtype"
))]
#[deprecated]
#[inline]
pub unsafe fn cssm_key(&self, cssm_key: NonNull<*const CSSM_KEY>) -> OSStatus {
extern "C-unwind" {
fn SecKeyGetCSSMKey(key: &SecKey, cssm_key: NonNull<*const CSSM_KEY>) -> OSStatus;
}
unsafe { SecKeyGetCSSMKey(self, cssm_key) }
}
#[doc(alias = "SecKeyGetCSPHandle")]
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated]
#[inline]
pub unsafe fn csp_handle(&self, csp_handle: NonNull<CSSM_CSP_HANDLE>) -> OSStatus {
extern "C-unwind" {
fn SecKeyGetCSPHandle(
key_ref: &SecKey,
csp_handle: NonNull<CSSM_CSP_HANDLE>,
) -> OSStatus;
}
unsafe { SecKeyGetCSPHandle(self, csp_handle) }
}
#[doc(alias = "SecKeyGetCredentials")]
#[cfg(all(
feature = "SecAsn1Types",
feature = "SecBase",
feature = "cssmconfig",
feature = "cssmtype"
))]
#[deprecated]
#[inline]
pub unsafe fn credentials(
&self,
operation: CSSM_ACL_AUTHORIZATION_TAG,
credential_type: SecCredentialType,
out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeyGetCredentials(
key_ref: &SecKey,
operation: CSSM_ACL_AUTHORIZATION_TAG,
credential_type: SecCredentialType,
out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>,
) -> OSStatus;
}
unsafe { SecKeyGetCredentials(self, operation, credential_type, out_credentials) }
}
#[doc(alias = "SecKeyGenerateSymmetric")]
#[cfg(feature = "SecBase")]
#[deprecated = "No longer supported"]
#[inline]
pub unsafe fn generate_symmetric(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyGenerateSymmetric(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyGenerateSymmetric(parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyCreateFromData")]
#[cfg(feature = "SecBase")]
#[deprecated = "No longer supported"]
#[inline]
pub unsafe fn from_data(
parameters: &CFDictionary,
key_data: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCreateFromData(
parameters: &CFDictionary,
key_data: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCreateFromData(parameters, key_data, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
}
#[cfg(all(feature = "SecBase", feature = "block2"))]
pub type SecKeyGeneratePairBlock =
*mut block2::DynBlock<dyn Fn(NonNull<SecKey>, NonNull<SecKey>, NonNull<CFError>)>;
#[cfg(feature = "SecBase")]
impl SecKey {
#[doc(alias = "SecKeyDeriveFromPassword")]
#[cfg(feature = "SecBase")]
#[deprecated = "No longer supported"]
#[inline]
pub unsafe fn derive_from_password(
password: &CFString,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyDeriveFromPassword(
password: &CFString,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyDeriveFromPassword(password, parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyWrapSymmetric")]
#[cfg(feature = "SecBase")]
#[deprecated = "No longer supported"]
#[inline]
pub unsafe fn wrap_symmetric(
&self,
wrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyWrapSymmetric(
key_to_wrap: &SecKey,
wrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyWrapSymmetric(self, wrapping_key, parameters, error) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[doc(alias = "SecKeyUnwrapSymmetric")]
#[cfg(feature = "SecBase")]
#[deprecated = "No longer supported"]
#[inline]
pub unsafe fn unwrap_symmetric(
key_to_unwrap: NonNull<*const CFData>,
unwrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyUnwrapSymmetric(
key_to_unwrap: NonNull<*const CFData>,
unwrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret =
unsafe { SecKeyUnwrapSymmetric(key_to_unwrap, unwrapping_key, parameters, error) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[doc(alias = "SecKeyGeneratePair")]
#[cfg(feature = "SecBase")]
#[deprecated = "Use SecKeyCreateRandomKey"]
#[inline]
pub unsafe fn generate_pair(
parameters: &CFDictionary,
public_key: *mut *mut SecKey,
private_key: *mut *mut SecKey,
) -> OSStatus {
extern "C-unwind" {
fn SecKeyGeneratePair(
parameters: &CFDictionary,
public_key: *mut *mut SecKey,
private_key: *mut *mut SecKey,
) -> OSStatus;
}
unsafe { SecKeyGeneratePair(parameters, public_key, private_key) }
}
#[doc(alias = "SecKeyCreateRandomKey")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn new_random_key(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCreateRandomKey(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCreateRandomKey(parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyCreateWithData")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn with_data(
key_data: &CFData,
attributes: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCreateWithData(
key_data: &CFData,
attributes: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCreateWithData(key_data, attributes, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyGetBlockSize")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn block_size(&self) -> usize {
extern "C-unwind" {
fn SecKeyGetBlockSize(key: &SecKey) -> usize;
}
unsafe { SecKeyGetBlockSize(self) }
}
#[doc(alias = "SecKeyCopyExternalRepresentation")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn external_representation(
&self,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCopyExternalRepresentation(
key: &SecKey,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCopyExternalRepresentation(self, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyCopyAttributes")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn attributes(&self) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn SecKeyCopyAttributes(key: &SecKey) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { SecKeyCopyAttributes(self) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyCopyPublicKey")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn public_key(&self) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCopyPublicKey(key: &SecKey) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCopyPublicKey(self) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
}
pub type SecKeyAlgorithm = CFString;
extern "C" {
pub static kSecKeyAlgorithmRSASignatureRaw: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15Raw: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureDigestPSSSHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSASignatureMessagePSSSHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestX962: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageX962SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureDigestRFC4754SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDSASignatureMessageRFC4754SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
#[deprecated]
pub static kSecKeyAlgorithmECDSASignatureRFC4754: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionRaw: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionPKCS1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA1AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA224AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA256AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA384AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmRSAEncryptionOAEPSHA512AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA1AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA224AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA256AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA384AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardX963SHA512AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA1AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA224AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA256AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA384AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorX963SHA512AESGCM: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA224AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA384AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA512AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA224AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA256AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA384AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECIESEncryptionCofactorVariableIVX963SHA512AESGCM:
&'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeStandard: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeStandardX963SHA512: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeCofactor: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA1: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA224: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA384: &'static SecKeyAlgorithm;
}
extern "C" {
pub static kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA512: &'static SecKeyAlgorithm;
}
#[cfg(feature = "SecBase")]
impl SecKey {
#[doc(alias = "SecKeyCreateSignature")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn signature(
&self,
algorithm: &SecKeyAlgorithm,
data_to_sign: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCreateSignature(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
data_to_sign: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCreateSignature(self, algorithm, data_to_sign, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyVerifySignature")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn verify_signature(
&self,
algorithm: &SecKeyAlgorithm,
signed_data: &CFData,
signature: &CFData,
error: *mut *mut CFError,
) -> bool {
extern "C-unwind" {
fn SecKeyVerifySignature(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
signed_data: &CFData,
signature: &CFData,
error: *mut *mut CFError,
) -> Boolean;
}
let ret = unsafe { SecKeyVerifySignature(self, algorithm, signed_data, signature, error) };
ret != 0
}
#[doc(alias = "SecKeyCreateEncryptedData")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn encrypted_data(
&self,
algorithm: &SecKeyAlgorithm,
plaintext: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCreateEncryptedData(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
plaintext: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCreateEncryptedData(self, algorithm, plaintext, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "SecKeyCreateDecryptedData")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn decrypted_data(
&self,
algorithm: &SecKeyAlgorithm,
ciphertext: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCreateDecryptedData(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
ciphertext: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCreateDecryptedData(self, algorithm, ciphertext, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
}
pub type SecKeyKeyExchangeParameter = CFString;
extern "C" {
pub static kSecKeyKeyExchangeParameterRequestedSize: &'static SecKeyKeyExchangeParameter;
}
extern "C" {
pub static kSecKeyKeyExchangeParameterSharedInfo: &'static SecKeyKeyExchangeParameter;
}
#[cfg(feature = "SecBase")]
impl SecKey {
#[doc(alias = "SecKeyCopyKeyExchangeResult")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn key_exchange_result(
&self,
algorithm: &SecKeyAlgorithm,
public_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCopyKeyExchangeResult(
private_key: &SecKey,
algorithm: &SecKeyAlgorithm,
public_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret =
unsafe { SecKeyCopyKeyExchangeResult(self, algorithm, public_key, parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecKeyOperationType(pub CFIndex);
impl SecKeyOperationType {
#[doc(alias = "kSecKeyOperationTypeSign")]
pub const Sign: Self = Self(0);
#[doc(alias = "kSecKeyOperationTypeVerify")]
pub const Verify: Self = Self(1);
#[doc(alias = "kSecKeyOperationTypeEncrypt")]
pub const Encrypt: Self = Self(2);
#[doc(alias = "kSecKeyOperationTypeDecrypt")]
pub const Decrypt: Self = Self(3);
#[doc(alias = "kSecKeyOperationTypeKeyExchange")]
pub const KeyExchange: Self = Self(4);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecKeyOperationType {
const ENCODING: Encoding = CFIndex::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecKeyOperationType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "SecBase")]
impl SecKey {
#[doc(alias = "SecKeyIsAlgorithmSupported")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn is_algorithm_supported(
&self,
operation: SecKeyOperationType,
algorithm: &SecKeyAlgorithm,
) -> bool {
extern "C-unwind" {
fn SecKeyIsAlgorithmSupported(
key: &SecKey,
operation: SecKeyOperationType,
algorithm: &SecKeyAlgorithm,
) -> Boolean;
}
let ret = unsafe { SecKeyIsAlgorithmSupported(self, operation, algorithm) };
ret != 0
}
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "renamed to `SecKey::create_pair`"]
pub fn SecKeyCreatePair(
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,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "renamed to `SecKey::generate`"]
pub fn SecKeyGenerate(
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,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(
feature = "SecAsn1Types",
feature = "SecBase",
feature = "cssmconfig",
feature = "cssmtype"
))]
#[deprecated = "renamed to `SecKey::cssm_key`"]
pub fn SecKeyGetCSSMKey(key: &SecKey, cssm_key: NonNull<*const CSSM_KEY>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "renamed to `SecKey::csp_handle`"]
pub fn SecKeyGetCSPHandle(key_ref: &SecKey, csp_handle: NonNull<CSSM_CSP_HANDLE>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(
feature = "SecAsn1Types",
feature = "SecBase",
feature = "cssmconfig",
feature = "cssmtype"
))]
#[deprecated = "renamed to `SecKey::credentials`"]
pub fn SecKeyGetCredentials(
key_ref: &SecKey,
operation: CSSM_ACL_AUTHORIZATION_TAG,
credential_type: SecCredentialType,
out_credentials: NonNull<*const CSSM_ACCESS_CREDENTIALS>,
) -> OSStatus;
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::generate_symmetric`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyGenerateSymmetric(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyGenerateSymmetric(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyGenerateSymmetric(parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::from_data`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCreateFromData(
parameters: &CFDictionary,
key_data: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCreateFromData(
parameters: &CFDictionary,
key_data: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCreateFromData(parameters, key_data, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::derive_from_password`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyDeriveFromPassword(
password: &CFString,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyDeriveFromPassword(
password: &CFString,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyDeriveFromPassword(password, parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::wrap_symmetric`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyWrapSymmetric(
key_to_wrap: &SecKey,
wrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyWrapSymmetric(
key_to_wrap: &SecKey,
wrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyWrapSymmetric(key_to_wrap, wrapping_key, parameters, error) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::unwrap_symmetric`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyUnwrapSymmetric(
key_to_unwrap: NonNull<*const CFData>,
unwrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyUnwrapSymmetric(
key_to_unwrap: NonNull<*const CFData>,
unwrapping_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyUnwrapSymmetric(key_to_unwrap, unwrapping_key, parameters, error) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::generate_pair`"]
pub fn SecKeyGeneratePair(
parameters: &CFDictionary,
public_key: *mut *mut SecKey,
private_key: *mut *mut SecKey,
) -> OSStatus;
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::new_random_key`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCreateRandomKey(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCreateRandomKey(
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCreateRandomKey(parameters, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::with_data`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCreateWithData(
key_data: &CFData,
attributes: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCreateWithData(
key_data: &CFData,
attributes: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCreateWithData(key_data, attributes, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::block_size`"]
pub fn SecKeyGetBlockSize(key: &SecKey) -> usize;
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::external_representation`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCopyExternalRepresentation(
key: &SecKey,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCopyExternalRepresentation(
key: &SecKey,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCopyExternalRepresentation(key, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::attributes`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCopyAttributes(
key: &SecKey,
) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn SecKeyCopyAttributes(key: &SecKey) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { SecKeyCopyAttributes(key) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::public_key`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCopyPublicKey(key: &SecKey) -> Option<CFRetained<SecKey>> {
extern "C-unwind" {
fn SecKeyCopyPublicKey(key: &SecKey) -> Option<NonNull<SecKey>>;
}
let ret = unsafe { SecKeyCopyPublicKey(key) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::signature`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCreateSignature(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
data_to_sign: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCreateSignature(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
data_to_sign: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCreateSignature(key, algorithm, data_to_sign, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::verify_signature`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyVerifySignature(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
signed_data: &CFData,
signature: &CFData,
error: *mut *mut CFError,
) -> bool {
extern "C-unwind" {
fn SecKeyVerifySignature(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
signed_data: &CFData,
signature: &CFData,
error: *mut *mut CFError,
) -> Boolean;
}
let ret = unsafe { SecKeyVerifySignature(key, algorithm, signed_data, signature, error) };
ret != 0
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::encrypted_data`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCreateEncryptedData(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
plaintext: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCreateEncryptedData(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
plaintext: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCreateEncryptedData(key, algorithm, plaintext, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::decrypted_data`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCreateDecryptedData(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
ciphertext: &CFData,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCreateDecryptedData(
key: &SecKey,
algorithm: &SecKeyAlgorithm,
ciphertext: &CFData,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe { SecKeyCreateDecryptedData(key, algorithm, ciphertext, error) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::key_exchange_result`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyCopyKeyExchangeResult(
private_key: &SecKey,
algorithm: &SecKeyAlgorithm,
public_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<CFRetained<CFData>> {
extern "C-unwind" {
fn SecKeyCopyKeyExchangeResult(
private_key: &SecKey,
algorithm: &SecKeyAlgorithm,
public_key: &SecKey,
parameters: &CFDictionary,
error: *mut *mut CFError,
) -> Option<NonNull<CFData>>;
}
let ret = unsafe {
SecKeyCopyKeyExchangeResult(private_key, algorithm, public_key, parameters, error)
};
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKey::is_algorithm_supported`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeyIsAlgorithmSupported(
key: &SecKey,
operation: SecKeyOperationType,
algorithm: &SecKeyAlgorithm,
) -> bool {
extern "C-unwind" {
fn SecKeyIsAlgorithmSupported(
key: &SecKey,
operation: SecKeyOperationType,
algorithm: &SecKeyAlgorithm,
) -> Boolean;
}
let ret = unsafe { SecKeyIsAlgorithmSupported(key, operation, algorithm) };
ret != 0
}