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 ///
44 /// # Safety
45 ///
46 /// `handler` block must be sendable.
47 #[unsafe(method(signData:secKeyAlgorithm:completion:))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn signData_secKeyAlgorithm_completion(
50 &self,
51 data: &NSData,
52 algorithm: &SecKeyAlgorithm,
53 handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
54 );
55
56 #[cfg(feature = "objc2-security")]
57 /// Checks if the the provided algorithm can be used for signing data
58 ///
59 /// Parameter `algorithm`: Cryptographic algorithm
60 ///
61 /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
62 #[unsafe(method(canSignUsingSecKeyAlgorithm:))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn canSignUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;
65
66 #[cfg(all(feature = "block2", feature = "objc2-security"))]
67 /// Decrypts the given ciphertext
68 ///
69 /// Parameter `data`: The data to decrypt. The length and format of the data must conform to chosen algorithm,
70 /// typically be less or equal to the value returned by SecKeyGetBlockSize().
71 ///
72 /// Parameter `algorithm`: A
73 /// `SecKeyAlgorithm`suitable for decrypting data with this key –e.g:
74 /// `kSecKeyAlgorithmECIESEncryptionStandardVariableIVX963SHA256AESGCM`
75 /// Parameter `handler`: Completion handler with plaintext or an error on failure.
76 ///
77 /// # Safety
78 ///
79 /// `handler` block must be sendable.
80 #[unsafe(method(decryptData:secKeyAlgorithm:completion:))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn decryptData_secKeyAlgorithm_completion(
83 &self,
84 data: &NSData,
85 algorithm: &SecKeyAlgorithm,
86 handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
87 );
88
89 #[cfg(feature = "objc2-security")]
90 /// Checks if the the provided algorithm can be used for decryption
91 ///
92 /// Parameter `algorithm`: Cryptographic algorithm
93 ///
94 /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
95 #[unsafe(method(canDecryptUsingSecKeyAlgorithm:))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn canDecryptUsingSecKeyAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;
98
99 #[cfg(all(feature = "block2", feature = "objc2-security"))]
100 /// Performs a Diffie-Hellman style key exchange operation
101 ///
102 /// Parameter `publicKey`: Remote party's public key.
103 ///
104 /// Parameter `algorithm`: A
105 /// `SecKeyAlgorithm`suitable for performing a key exchange with this key –e.g:
106 /// `kSecKeyAlgorithmECDHKeyExchangeCofactorX963SHA256`
107 /// Parameter `parameters`: Dictionary with parameters, see
108 /// `SecKeyKeyExchangeParameter`constants. Used algorithm determines the set of required and optional parameters to be used.
109 ///
110 /// Parameter `handler`: Completion handler with the result of the key exchange or an error on failure.
111 ///
112 /// # Safety
113 ///
114 /// - `parameters` generic should be of the correct type.
115 /// - `handler` block must be sendable.
116 #[unsafe(method(exchangeKeysWithPublicKey:secKeyAlgorithm:secKeyParameters:completion:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn exchangeKeysWithPublicKey_secKeyAlgorithm_secKeyParameters_completion(
119 &self,
120 public_key: &NSData,
121 algorithm: &SecKeyAlgorithm,
122 parameters: &NSDictionary,
123 handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
124 );
125
126 #[cfg(feature = "objc2-security")]
127 /// Checks if the the provided algorithm can be used for performing key exchanges
128 ///
129 /// Parameter `algorithm`: Cryptographic algorithm
130 ///
131 /// Returns: `YES`in case the key supports the provided algorithm with the specified operation.
132 #[unsafe(method(canExchangeKeysUsingSecKeyAlgorithm:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn canExchangeKeysUsingSecKeyAlgorithm(
135 &self,
136 algorithm: &SecKeyAlgorithm,
137 ) -> bool;
138
139 /// Clients cannot create
140 /// `LAPrivateKey`instances directly. They typically obtain them from a
141 /// `LAPersistedRight`instance.
142 #[unsafe(method(new))]
143 #[unsafe(method_family = new)]
144 pub unsafe fn new() -> Retained<Self>;
145
146 /// Clients cannot create
147 /// `LAPrivateKey`instances directly. They typically obtain them from a
148 /// `LAPersistedRight`instance.
149 #[unsafe(method(init))]
150 #[unsafe(method_family = init)]
151 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
152 );
153}