//! 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!(
    /// The public part of an asymmetric key pair
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/localauthentication/lapublickey?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct LAPublicKey;
);

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

impl LAPublicKey {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Exports public key bytes.
        ///
        /// Parameter `handler`: Completion handler with the raw bytes of the public key or an error on failure
        #[unsafe(method(exportBytesWithCompletion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn exportBytesWithCompletion(
            &self,
            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
        );

        #[cfg(all(feature = "block2", feature = "objc2-security"))]
        /// Encrypts the given data
        ///
        /// Parameter `data`: The data to encrypt.
        ///
        /// Parameter `algorithm`: A
        /// `SecKeyAlgorithm`suitable for encrypting with this key –e.g:
        /// `kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM`.
        ///
        /// Parameter `handler`: Completion handler with the ciphertext or an error on failure.
        #[unsafe(method(encryptData:secKeyAlgorithm:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn encryptData_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 encryption with the key.
        ///
        /// Parameter `algorithm`: Cryptographic algorithm
        ///
        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
        #[unsafe(method(canEncryptUsingSecKeyAlgorithm:))]
        #[unsafe(method_family = none)]
        pub unsafe fn canEncryptUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;

        #[cfg(all(feature = "block2", feature = "objc2-security"))]
        /// Verifies a digital signature for the given data.
        ///
        /// Parameter `signedData`: The signed data.
        ///
        /// Parameter `signature`: The signature of the given data.
        ///
        /// Parameter `algorithm`: One of
        /// `SecKeyAlgorithm`suitable for verifying signatures with this key –e.g:
        /// `kSecKeyAlgorithmECDSASignatureMessageX962SHA256`
        /// Parameter `handler`: Completion hadnler with the signature of given data or an error on failure.
        #[unsafe(method(verifyData:signature:secKeyAlgorithm:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn verifyData_signature_secKeyAlgorithm_completion(
            &self,
            signed_data: &NSData,
            signature: &NSData,
            algorithm: &SecKeyAlgorithm,
            handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

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

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

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