objc2_local_authentication/generated/
LAPrivateKey.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-security")]
8use objc2_security::*;
9
10use crate::*;
11
12extern_class!(
13    /// Managed Private Key.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/localauthentication/laprivatekey?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct LAPrivateKey;
19);
20
21extern_conformance!(
22    unsafe impl NSObjectProtocol for LAPrivateKey {}
23);
24
25impl LAPrivateKey {
26    extern_methods!(
27        #[cfg(feature = "LAPublicKey")]
28        /// Offers the public key counterpart of a
29        /// `LAPrivateKey`instance
30        #[unsafe(method(publicKey))]
31        #[unsafe(method_family = none)]
32        pub unsafe fn publicKey(&self) -> Retained<LAPublicKey>;
33
34        #[cfg(all(feature = "block2", feature = "objc2-security"))]
35        /// Generates a digital signature for the given data.
36        ///
37        /// Parameter `data`: The data to be signed, typically the digest of the actual data.
38        ///
39        /// Parameter `algorithm`: A
40        /// `SecKeyAlgorithm`suitable for generating signatures with this key – e.g:
41        /// `kSecKeyAlgorithmECDSASignatureMessageX962SHA256`
42        /// Parameter `handler`: Completion handler with the signature of given data or an error on failure.
43        #[unsafe(method(signData:secKeyAlgorithm:completion:))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn signData_secKeyAlgorithm_completion(
46            &self,
47            data: &NSData,
48            algorithm: &SecKeyAlgorithm,
49            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
50        );
51
52        #[cfg(feature = "objc2-security")]
53        /// Checks if the the provided algorithm can be used for signing data
54        ///
55        /// Parameter `algorithm`: Cryptographic algorithm
56        ///
57        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
58        #[unsafe(method(canSignUsingSecKeyAlgorithm:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn canSignUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;
61
62        #[cfg(all(feature = "block2", feature = "objc2-security"))]
63        /// Decrypts the given ciphertext
64        ///
65        /// Parameter `data`: The data to decrypt. The length and format of the data must conform to chosen algorithm,
66        /// typically be less or equal to the value returned by SecKeyGetBlockSize().
67        ///
68        /// Parameter `algorithm`: A
69        /// `SecKeyAlgorithm`suitable for decrypting data with this key –e.g:
70        /// `kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM`
71        /// Parameter `handler`: Completion handler with plaintext or an error on failure.
72        #[unsafe(method(decryptData:secKeyAlgorithm:completion:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn decryptData_secKeyAlgorithm_completion(
75            &self,
76            data: &NSData,
77            algorithm: &SecKeyAlgorithm,
78            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
79        );
80
81        #[cfg(feature = "objc2-security")]
82        /// Checks if the the provided algorithm can be used for decryption
83        ///
84        /// Parameter `algorithm`: Cryptographic algorithm
85        ///
86        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
87        #[unsafe(method(canDecryptUsingSecKeyAlgorithm:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn canDecryptUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;
90
91        #[cfg(all(feature = "block2", feature = "objc2-security"))]
92        /// Performs a Diffie-Hellman style key exchange operation
93        ///
94        /// Parameter `publicKey`: Remote party's public key.
95        ///
96        /// Parameter `algorithm`: A
97        /// `SecKeyAlgorithm`suitable for performing a key exchange with this key –e.g:
98        /// `kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256`
99        /// Parameter `parameters`: Dictionary with parameters, see
100        /// `SecKeyKeyExchangeParameter`constants.  Used algorithm determines the set of required and optional parameters to be used.
101        ///
102        /// Parameter `handler`: Completion handler with the result of the key exchange or an error on failure.
103        #[unsafe(method(exchangeKeysWithPublicKey:secKeyAlgorithm:secKeyParameters:completion:))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn exchangeKeysWithPublicKey_secKeyAlgorithm_secKeyParameters_completion(
106            &self,
107            public_key: &NSData,
108            algorithm: &SecKeyAlgorithm,
109            parameters: &NSDictionary,
110            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
111        );
112
113        #[cfg(feature = "objc2-security")]
114        /// Checks if the the provided algorithm can be used for performing key exchanges
115        ///
116        /// Parameter `algorithm`: Cryptographic algorithm
117        ///
118        /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
119        #[unsafe(method(canExchangeKeysUsingSecKeyAlgorithm:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn canExchangeKeysUsingSecKeyAlgorithm(
122            &self,
123            algorithm: &SecKeyAlgorithm,
124        ) -> bool;
125
126        /// Clients cannot create
127        /// `LAPrivateKey`instances directly. They typically obtain them from a
128        /// `LAPersistedRight`instance.
129        #[unsafe(method(new))]
130        #[unsafe(method_family = new)]
131        pub unsafe fn new() -> Retained<Self>;
132
133        /// Clients cannot create
134        /// `LAPrivateKey`instances directly. They typically obtain them from a
135        /// `LAPersistedRight`instance.
136        #[unsafe(method(init))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
139    );
140}