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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
//! 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!(
/// Base interface for propagation token's items into the keychain.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychainitem?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TKTokenKeychainItem;
);
extern_conformance!(
unsafe impl NSObjectProtocol for TKTokenKeychainItem {}
);
impl TKTokenKeychainItem {
extern_methods!(
#[cfg(feature = "TKToken")]
/// Initializes item with objectID.
///
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(initWithObjectID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithObjectID(
this: Allocated<Self>,
object_id: &TKTokenObjectID,
) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "TKToken")]
/// object ID for item identification
#[unsafe(method(objectID))]
#[unsafe(method_family = none)]
pub unsafe fn objectID(&self) -> Retained<TKTokenObjectID>;
/// Contains the user-visible label for this item. This property is an equivalent of kSecAttrLabel in SecItem.h
#[unsafe(method(label))]
#[unsafe(method_family = none)]
pub unsafe fn label(&self) -> Option<Retained<NSString>>;
/// Setter for [`label`][Self::label].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setLabel:))]
#[unsafe(method_family = none)]
pub unsafe fn setLabel(&self, label: Option<&NSString>);
#[cfg(feature = "TKToken")]
/// Contains access constraints for this object keyed by TKTOpenOperation wrapped in NSNumber.
#[unsafe(method(constraints))]
#[unsafe(method_family = none)]
pub unsafe fn constraints(
&self,
) -> Option<Retained<NSDictionary<NSNumber, TKTokenOperationConstraint>>>;
#[cfg(feature = "TKToken")]
/// Setter for [`constraints`][Self::constraints].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `constraints` generic should be of the correct type.
#[unsafe(method(setConstraints:))]
#[unsafe(method_family = none)]
pub unsafe fn setConstraints(
&self,
constraints: Option<&NSDictionary<NSNumber, TKTokenOperationConstraint>>,
);
);
}
/// Methods declared on superclass `NSObject`.
impl TKTokenKeychainItem {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// Interface for propagation token's certificates into the keychain.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychaincertificate?language=objc)
#[unsafe(super(TKTokenKeychainItem, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TKTokenKeychainCertificate;
);
extern_conformance!(
unsafe impl NSObjectProtocol for TKTokenKeychainCertificate {}
);
impl TKTokenKeychainCertificate {
extern_methods!(
#[cfg(all(feature = "TKToken", feature = "objc2-security"))]
/// initialize TKTokenKeychainCertificate with data from SecCertificateRef. Use SecCertificateCreateWithData to obtain SecCertificateRef.
/// `constraints`property is initialized indicating that reading of certificate is always allowed, all other operations are disallowed.
///
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(initWithCertificate:objectID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCertificate_objectID(
this: Allocated<Self>,
certificate_ref: &SecCertificate,
object_id: &TKTokenObjectID,
) -> Option<Retained<Self>>;
#[cfg(feature = "TKToken")]
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(initWithObjectID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithObjectID(
this: Allocated<Self>,
object_id: &TKTokenObjectID,
) -> Retained<Self>;
/// Contains DER-encoded representation of an X.509 certificate.
#[unsafe(method(data))]
#[unsafe(method_family = none)]
pub unsafe fn data(&self) -> Retained<NSData>;
);
}
/// Methods declared on superclass `TKTokenKeychainItem`.
impl TKTokenKeychainCertificate {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl TKTokenKeychainCertificate {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// Interface for propagation token's keys into the keychain.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychainkey?language=objc)
#[unsafe(super(TKTokenKeychainItem, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TKTokenKeychainKey;
);
extern_conformance!(
unsafe impl NSObjectProtocol for TKTokenKeychainKey {}
);
impl TKTokenKeychainKey {
extern_methods!(
#[cfg(all(feature = "TKToken", feature = "objc2-security"))]
/// Initialize TKTokenKeychainKey with informations from SecCertificateRef associated with the key. Use SecCertificateCreateWithData to obtain SecCertificateRef. If NULL is passed instead of certificate, all properties of created instance must be initialized manually.
///
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(initWithCertificate:objectID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCertificate_objectID(
this: Allocated<Self>,
certificate_ref: Option<&SecCertificate>,
object_id: &TKTokenObjectID,
) -> Option<Retained<Self>>;
#[cfg(feature = "TKToken")]
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(initWithObjectID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithObjectID(
this: Allocated<Self>,
object_id: &TKTokenObjectID,
) -> Retained<Self>;
/// Type of the key, currently kSecAttrKeyTypeRSA and kSecAttrKeyTypeECSECPrimeRandom is supported). The property is an equivalent to kSecAttrKeyType in SecItem.h
#[unsafe(method(keyType))]
#[unsafe(method_family = none)]
pub unsafe fn keyType(&self) -> Retained<NSString>;
/// Setter for [`keyType`][Self::keyType].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setKeyType:))]
#[unsafe(method_family = none)]
pub unsafe fn setKeyType(&self, key_type: &NSString);
/// Represents private tag data. The property is an equivalent to kSecAttrApplicationTag in SecItem.h
#[unsafe(method(applicationTag))]
#[unsafe(method_family = none)]
pub unsafe fn applicationTag(&self) -> Option<Retained<NSData>>;
/// Setter for [`applicationTag`][Self::applicationTag].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setApplicationTag:))]
#[unsafe(method_family = none)]
pub unsafe fn setApplicationTag(&self, application_tag: Option<&NSData>);
/// Indicates the number of bits in this key. The property is an equivalent to kSecAttrKeySizeInBits in SecItem.h
#[unsafe(method(keySizeInBits))]
#[unsafe(method_family = none)]
pub unsafe fn keySizeInBits(&self) -> NSInteger;
/// Setter for [`keySizeInBits`][Self::keySizeInBits].
#[unsafe(method(setKeySizeInBits:))]
#[unsafe(method_family = none)]
pub unsafe fn setKeySizeInBits(&self, key_size_in_bits: NSInteger);
/// Contains raw public key data for this private key.
#[unsafe(method(publicKeyData))]
#[unsafe(method_family = none)]
pub unsafe fn publicKeyData(&self) -> Option<Retained<NSData>>;
/// Setter for [`publicKeyData`][Self::publicKeyData].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setPublicKeyData:))]
#[unsafe(method_family = none)]
pub unsafe fn setPublicKeyData(&self, public_key_data: Option<&NSData>);
/// SHA1 hash of the raw public key. The property is an equivalent to kSecAttrApplicationLabel in SecItem.h
#[unsafe(method(publicKeyHash))]
#[unsafe(method_family = none)]
pub unsafe fn publicKeyHash(&self) -> Option<Retained<NSData>>;
/// Setter for [`publicKeyHash`][Self::publicKeyHash].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setPublicKeyHash:))]
#[unsafe(method_family = none)]
pub unsafe fn setPublicKeyHash(&self, public_key_hash: Option<&NSData>);
/// Indicates whether this key can be used to decrypt data. The property is an equivalent to kSecAttrCanDecrypt in SecItem.h
#[unsafe(method(canDecrypt))]
#[unsafe(method_family = none)]
pub unsafe fn canDecrypt(&self) -> bool;
/// Setter for [`canDecrypt`][Self::canDecrypt].
#[unsafe(method(setCanDecrypt:))]
#[unsafe(method_family = none)]
pub unsafe fn setCanDecrypt(&self, can_decrypt: bool);
/// Indicates whether this key can be used to create a digital signature. The property is an equivalent to kSecAttrCanSign in SecItem.h
#[unsafe(method(canSign))]
#[unsafe(method_family = none)]
pub unsafe fn canSign(&self) -> bool;
/// Setter for [`canSign`][Self::canSign].
#[unsafe(method(setCanSign:))]
#[unsafe(method_family = none)]
pub unsafe fn setCanSign(&self, can_sign: bool);
/// Indicates whether this key can be used to perform Diffie-Hellman style cryptographic key exchange.
#[unsafe(method(canPerformKeyExchange))]
#[unsafe(method_family = none)]
pub unsafe fn canPerformKeyExchange(&self) -> bool;
/// Setter for [`canPerformKeyExchange`][Self::canPerformKeyExchange].
#[unsafe(method(setCanPerformKeyExchange:))]
#[unsafe(method_family = none)]
pub unsafe fn setCanPerformKeyExchange(&self, can_perform_key_exchange: bool);
/// Indicates whether this key can be used for login in to the system.
#[unsafe(method(isSuitableForLogin))]
#[unsafe(method_family = none)]
pub unsafe fn isSuitableForLogin(&self) -> bool;
/// Setter for [`isSuitableForLogin`][Self::isSuitableForLogin].
#[unsafe(method(setSuitableForLogin:))]
#[unsafe(method_family = none)]
pub unsafe fn setSuitableForLogin(&self, suitable_for_login: bool);
);
}
/// Methods declared on superclass `TKTokenKeychainItem`.
impl TKTokenKeychainKey {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl TKTokenKeychainKey {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// Contains TKTokenKeychainItem instances (keys and certificates) which represent keychain state (i.e. set of items) of specific token.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychaincontents?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TKTokenKeychainContents;
);
extern_conformance!(
unsafe impl NSObjectProtocol for TKTokenKeychainContents {}
);
impl TKTokenKeychainContents {
extern_methods!(
/// Fills keychain with the set of specified items. All items belonging to token are first removed from the keychain and then the keychain is populated with new items.
///
/// Parameter `items`: New items to be stored into the keychain.
#[unsafe(method(fillWithItems:))]
#[unsafe(method_family = none)]
pub unsafe fn fillWithItems(&self, items: &NSArray<TKTokenKeychainItem>);
/// All items related to this token in the keychain.
#[unsafe(method(items))]
#[unsafe(method_family = none)]
pub unsafe fn items(&self) -> Retained<NSArray<TKTokenKeychainItem>>;
#[cfg(feature = "TKToken")]
/// Returns key with specified objectID. Fills error with TKTokenErrorCodeObjectNotFound if no such key exists.
///
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(keyForObjectID:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn keyForObjectID_error(
&self,
object_id: &TKTokenObjectID,
) -> Result<Retained<TKTokenKeychainKey>, Retained<NSError>>;
#[cfg(feature = "TKToken")]
/// Returns certificate with specified objectID. Fills error with TKTokenErrorCodeObjectNotFound if no such certificate exists.
///
/// # Safety
///
/// `object_id` should be of the correct type.
#[unsafe(method(certificateForObjectID:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn certificateForObjectID_error(
&self,
object_id: &TKTokenObjectID,
) -> Result<Retained<TKTokenKeychainCertificate>, Retained<NSError>>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl TKTokenKeychainContents {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}