objc2-security 0.3.2

Bindings to the Security framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2_core_foundation::*;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseckeyattributename?language=objc)
    pub static kSecKeyAttributeName: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecsignatureattributename?language=objc)
    pub static kSecSignatureAttributeName: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecinputisattributename?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecInputIsAttributeName: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecinputisplaintext?language=objc)
    pub static kSecInputIsPlainText: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecinputisdigest?language=objc)
    pub static kSecInputIsDigest: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecinputisraw?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecInputIsRaw: &'static CFString;
}

/// Creates a sign computation object.
///
/// Parameter `key`: A SecKey with the private key used for signing.
///
/// Parameter `error`: A pointer to a CFErrorRef.  This pointer will be set
/// if an error occurred.  This value may be NULL if you
/// do not want an error returned.
///
/// Returns: A pointer to a SecTransformRef object.  This object must
/// be released with CFRelease when you are done with
/// it.  This function will return NULL if an error
/// occurred.
///
/// This function creates a transform which computes a
/// cryptographic signature.   The InputIS defaults to kSecInputIsPlainText,
/// and the DigestType and DigestLength default to something appropriate for
/// the type of key you have supplied.
///
/// # Safety
///
/// `error` must be a valid pointer or null.
#[cfg(all(feature = "SecBase", feature = "SecTransform"))]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecSignTransformCreate(
    key: &SecKey,
    error: *mut *mut CFError,
) -> Option<CFRetained<SecTransform>> {
    extern "C-unwind" {
        fn SecSignTransformCreate(
            key: &SecKey,
            error: *mut *mut CFError,
        ) -> Option<NonNull<SecTransform>>;
    }
    let ret = unsafe { SecSignTransformCreate(key, error) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

/// Creates a verify computation object.
///
/// Parameter `key`: A SecKey with the public key used for signing.
///
/// Parameter `signature`: A CFDataRef with the signature.   This value may be
/// NULL, and you may connect a transform to kSecTransformSignatureAttributeName
/// to supply it from another signature.
///
/// Parameter `error`: A pointer to a CFErrorRef.  This pointer will be set
/// if an error occurred.  This value may be NULL if you
/// do not want an error returned.
///
/// Returns: A pointer to a SecTransformRef object.  This object must
/// be released with CFRelease when you are done with
/// it.  This function will return NULL if an error
/// occurred.
///
/// This function creates a transform which verifies a
/// cryptographic signature.  The InputIS defaults to kSecInputIsPlainText,
/// and the DigestType and DigestLength default to something appropriate for
/// the type of key you have supplied.
///
/// # Safety
///
/// `error` must be a valid pointer or null.
#[cfg(all(feature = "SecBase", feature = "SecTransform"))]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecVerifyTransformCreate(
    key: &SecKey,
    signature: Option<&CFData>,
    error: *mut *mut CFError,
) -> Option<CFRetained<SecTransform>> {
    extern "C-unwind" {
        fn SecVerifyTransformCreate(
            key: &SecKey,
            signature: Option<&CFData>,
            error: *mut *mut CFError,
        ) -> Option<NonNull<SecTransform>>;
    }
    let ret = unsafe { SecVerifyTransformCreate(key, signature, error) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}