objc2-local-authentication 0.3.2

Bindings to the LocalAuthentication framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-security")]
use objc2_security::*;

use crate::*;

extern_class!(
    /// Managed Private Key.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/localauthentication/laprivatekey?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct LAPrivateKey;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for LAPrivateKey {}
);

impl LAPrivateKey {
    extern_methods!(
        #[cfg(feature = "LAPublicKey")]
        /// Offers the public key counterpart of a
        /// `LAPrivateKey`instance
        #[unsafe(method(publicKey))]
        #[unsafe(method_family = none)]
        pub unsafe fn publicKey(&self) -> Retained<LAPublicKey>;

        #[cfg(all(feature = "block2", feature = "objc2-security"))]
        /// Generates a digital signature for the given data.
        ///
        /// Parameter `data`: The data to be signed, typically the digest of the actual data.
        ///
        /// Parameter `algorithm`: A
        /// `SecKeyAlgorithm`suitable for generating signatures with this key – e.g:
        /// `kSecKeyAlgorithmECDSASignatureMessageX962SHA256`
        /// Parameter `handler`: Completion handler with the signature of given data or an error on failure.
        ///
        /// # Safety
        ///
        /// `handler` block must be sendable.
        #[unsafe(method(signData:secKeyAlgorithm:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn signData_secKeyAlgorithm_completion(
            &self,
            data: &NSData,
            algorithm: &SecKeyAlgorithm,
            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
        );

        #[cfg(feature = "objc2-security")]
        /// Checks if the the provided algorithm can be used for signing data
        ///
        /// Parameter `algorithm`: Cryptographic algorithm
        ///
        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
        #[unsafe(method(canSignUsingSecKeyAlgorithm:))]
        #[unsafe(method_family = none)]
        pub unsafe fn canSignUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;

        #[cfg(all(feature = "block2", feature = "objc2-security"))]
        /// Decrypts the given ciphertext
        ///
        /// Parameter `data`: 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 `algorithm`: A
        /// `SecKeyAlgorithm`suitable for decrypting data with this key –e.g:
        /// `kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM`
        /// Parameter `handler`: Completion handler with plaintext or an error on failure.
        ///
        /// # Safety
        ///
        /// `handler` block must be sendable.
        #[unsafe(method(decryptData:secKeyAlgorithm:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn decryptData_secKeyAlgorithm_completion(
            &self,
            data: &NSData,
            algorithm: &SecKeyAlgorithm,
            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
        );

        #[cfg(feature = "objc2-security")]
        /// Checks if the the provided algorithm can be used for decryption
        ///
        /// Parameter `algorithm`: Cryptographic algorithm
        ///
        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
        #[unsafe(method(canDecryptUsingSecKeyAlgorithm:))]
        #[unsafe(method_family = none)]
        pub unsafe fn canDecryptUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;

        #[cfg(all(feature = "block2", feature = "objc2-security"))]
        /// Performs a Diffie-Hellman style key exchange operation
        ///
        /// Parameter `publicKey`: Remote party's public key.
        ///
        /// Parameter `algorithm`: A
        /// `SecKeyAlgorithm`suitable for performing a key exchange with this key –e.g:
        /// `kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256`
        /// Parameter `parameters`: Dictionary with parameters, see
        /// `SecKeyKeyExchangeParameter`constants.  Used algorithm determines the set of required and optional parameters to be used.
        ///
        /// Parameter `handler`: Completion handler with the result of the key exchange or an error on failure.
        ///
        /// # Safety
        ///
        /// - `parameters` generic should be of the correct type.
        /// - `handler` block must be sendable.
        #[unsafe(method(exchangeKeysWithPublicKey:secKeyAlgorithm:secKeyParameters:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn exchangeKeysWithPublicKey_secKeyAlgorithm_secKeyParameters_completion(
            &self,
            public_key: &NSData,
            algorithm: &SecKeyAlgorithm,
            parameters: &NSDictionary,
            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
        );

        #[cfg(feature = "objc2-security")]
        /// Checks if the the provided algorithm can be used for performing key exchanges
        ///
        /// Parameter `algorithm`: Cryptographic algorithm
        ///
        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
        #[unsafe(method(canExchangeKeysUsingSecKeyAlgorithm:))]
        #[unsafe(method_family = none)]
        pub unsafe fn canExchangeKeysUsingSecKeyAlgorithm(
            &self,
            algorithm: &SecKeyAlgorithm,
        ) -> bool;

        /// Clients cannot create
        /// `LAPrivateKey`instances directly. They typically obtain them from a
        /// `LAPersistedRight`instance.
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        /// Clients cannot create
        /// `LAPrivateKey`instances directly. They typically obtain them from a
        /// `LAPersistedRight`instance.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}