1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! 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>;
);
}