objc2_crypto_token_kit/generated/
TKTokenKeychainItem.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    /// Base interface for propagation token's items into the keychain.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychainitem?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct TKTokenKeychainItem;
19);
20
21extern_conformance!(
22    unsafe impl NSObjectProtocol for TKTokenKeychainItem {}
23);
24
25impl TKTokenKeychainItem {
26    extern_methods!(
27        #[cfg(feature = "TKToken")]
28        /// Initializes item with objectID.
29        ///
30        /// # Safety
31        ///
32        /// `object_id` should be of the correct type.
33        #[unsafe(method(initWithObjectID:))]
34        #[unsafe(method_family = init)]
35        pub unsafe fn initWithObjectID(
36            this: Allocated<Self>,
37            object_id: &TKTokenObjectID,
38        ) -> Retained<Self>;
39
40        #[unsafe(method(init))]
41        #[unsafe(method_family = init)]
42        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
43
44        #[cfg(feature = "TKToken")]
45        /// object ID for item identification
46        #[unsafe(method(objectID))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn objectID(&self) -> Retained<TKTokenObjectID>;
49
50        /// Contains the user-visible label for this item.  This property is an equivalent of kSecAttrLabel in SecItem.h
51        #[unsafe(method(label))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn label(&self) -> Option<Retained<NSString>>;
54
55        /// Setter for [`label`][Self::label].
56        ///
57        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
58        #[unsafe(method(setLabel:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn setLabel(&self, label: Option<&NSString>);
61
62        #[cfg(feature = "TKToken")]
63        /// Contains access constraints for this object keyed by TKTOpenOperation wrapped in NSNumber.
64        #[unsafe(method(constraints))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn constraints(
67            &self,
68        ) -> Option<Retained<NSDictionary<NSNumber, TKTokenOperationConstraint>>>;
69
70        #[cfg(feature = "TKToken")]
71        /// Setter for [`constraints`][Self::constraints].
72        ///
73        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
74        ///
75        /// # Safety
76        ///
77        /// `constraints` generic should be of the correct type.
78        #[unsafe(method(setConstraints:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setConstraints(
81            &self,
82            constraints: Option<&NSDictionary<NSNumber, TKTokenOperationConstraint>>,
83        );
84    );
85}
86
87/// Methods declared on superclass `NSObject`.
88impl TKTokenKeychainItem {
89    extern_methods!(
90        #[unsafe(method(new))]
91        #[unsafe(method_family = new)]
92        pub unsafe fn new() -> Retained<Self>;
93    );
94}
95
96extern_class!(
97    /// Interface for propagation token's certificates into the keychain.
98    ///
99    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychaincertificate?language=objc)
100    #[unsafe(super(TKTokenKeychainItem, NSObject))]
101    #[derive(Debug, PartialEq, Eq, Hash)]
102    pub struct TKTokenKeychainCertificate;
103);
104
105extern_conformance!(
106    unsafe impl NSObjectProtocol for TKTokenKeychainCertificate {}
107);
108
109impl TKTokenKeychainCertificate {
110    extern_methods!(
111        #[cfg(all(feature = "TKToken", feature = "objc2-security"))]
112        /// initialize TKTokenKeychainCertificate with data from SecCertificateRef.  Use SecCertificateCreateWithData to obtain SecCertificateRef.
113        /// `constraints`property is initialized indicating that reading of certificate is always allowed, all other operations are disallowed.
114        ///
115        /// # Safety
116        ///
117        /// `object_id` should be of the correct type.
118        #[unsafe(method(initWithCertificate:objectID:))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn initWithCertificate_objectID(
121            this: Allocated<Self>,
122            certificate_ref: &SecCertificate,
123            object_id: &TKTokenObjectID,
124        ) -> Option<Retained<Self>>;
125
126        #[cfg(feature = "TKToken")]
127        /// # Safety
128        ///
129        /// `object_id` should be of the correct type.
130        #[unsafe(method(initWithObjectID:))]
131        #[unsafe(method_family = init)]
132        pub unsafe fn initWithObjectID(
133            this: Allocated<Self>,
134            object_id: &TKTokenObjectID,
135        ) -> Retained<Self>;
136
137        /// Contains DER-encoded representation of an X.509 certificate.
138        #[unsafe(method(data))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn data(&self) -> Retained<NSData>;
141    );
142}
143
144/// Methods declared on superclass `TKTokenKeychainItem`.
145impl TKTokenKeychainCertificate {
146    extern_methods!(
147        #[unsafe(method(init))]
148        #[unsafe(method_family = init)]
149        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
150    );
151}
152
153/// Methods declared on superclass `NSObject`.
154impl TKTokenKeychainCertificate {
155    extern_methods!(
156        #[unsafe(method(new))]
157        #[unsafe(method_family = new)]
158        pub unsafe fn new() -> Retained<Self>;
159    );
160}
161
162extern_class!(
163    /// Interface for propagation token's keys into the keychain.
164    ///
165    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychainkey?language=objc)
166    #[unsafe(super(TKTokenKeychainItem, NSObject))]
167    #[derive(Debug, PartialEq, Eq, Hash)]
168    pub struct TKTokenKeychainKey;
169);
170
171extern_conformance!(
172    unsafe impl NSObjectProtocol for TKTokenKeychainKey {}
173);
174
175impl TKTokenKeychainKey {
176    extern_methods!(
177        #[cfg(all(feature = "TKToken", feature = "objc2-security"))]
178        /// 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.
179        ///
180        /// # Safety
181        ///
182        /// `object_id` should be of the correct type.
183        #[unsafe(method(initWithCertificate:objectID:))]
184        #[unsafe(method_family = init)]
185        pub unsafe fn initWithCertificate_objectID(
186            this: Allocated<Self>,
187            certificate_ref: Option<&SecCertificate>,
188            object_id: &TKTokenObjectID,
189        ) -> Option<Retained<Self>>;
190
191        #[cfg(feature = "TKToken")]
192        /// # Safety
193        ///
194        /// `object_id` should be of the correct type.
195        #[unsafe(method(initWithObjectID:))]
196        #[unsafe(method_family = init)]
197        pub unsafe fn initWithObjectID(
198            this: Allocated<Self>,
199            object_id: &TKTokenObjectID,
200        ) -> Retained<Self>;
201
202        /// Type of the key, currently kSecAttrKeyTypeRSA and kSecAttrKeyTypeECSECPrimeRandom is supported).  The property is an equivalent to kSecAttrKeyType in SecItem.h
203        #[unsafe(method(keyType))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn keyType(&self) -> Retained<NSString>;
206
207        /// Setter for [`keyType`][Self::keyType].
208        ///
209        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
210        #[unsafe(method(setKeyType:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn setKeyType(&self, key_type: &NSString);
213
214        /// Represents private tag data.  The property is an equivalent to kSecAttrApplicationTag in SecItem.h
215        #[unsafe(method(applicationTag))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn applicationTag(&self) -> Option<Retained<NSData>>;
218
219        /// Setter for [`applicationTag`][Self::applicationTag].
220        ///
221        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
222        #[unsafe(method(setApplicationTag:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setApplicationTag(&self, application_tag: Option<&NSData>);
225
226        /// Indicates the number of bits in this key.  The property is an equivalent to kSecAttrKeySizeInBits in SecItem.h
227        #[unsafe(method(keySizeInBits))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn keySizeInBits(&self) -> NSInteger;
230
231        /// Setter for [`keySizeInBits`][Self::keySizeInBits].
232        #[unsafe(method(setKeySizeInBits:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setKeySizeInBits(&self, key_size_in_bits: NSInteger);
235
236        /// Contains raw public key data for this private key.
237        #[unsafe(method(publicKeyData))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn publicKeyData(&self) -> Option<Retained<NSData>>;
240
241        /// Setter for [`publicKeyData`][Self::publicKeyData].
242        ///
243        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
244        #[unsafe(method(setPublicKeyData:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setPublicKeyData(&self, public_key_data: Option<&NSData>);
247
248        /// SHA1 hash of the raw public key.  The property is an equivalent to kSecAttrApplicationLabel in SecItem.h
249        #[unsafe(method(publicKeyHash))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn publicKeyHash(&self) -> Option<Retained<NSData>>;
252
253        /// Setter for [`publicKeyHash`][Self::publicKeyHash].
254        ///
255        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
256        #[unsafe(method(setPublicKeyHash:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn setPublicKeyHash(&self, public_key_hash: Option<&NSData>);
259
260        /// Indicates whether this key can be used to decrypt data.  The property is an equivalent to kSecAttrCanDecrypt in SecItem.h
261        #[unsafe(method(canDecrypt))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn canDecrypt(&self) -> bool;
264
265        /// Setter for [`canDecrypt`][Self::canDecrypt].
266        #[unsafe(method(setCanDecrypt:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn setCanDecrypt(&self, can_decrypt: bool);
269
270        /// Indicates whether this key can be used to create a digital signature.  The property is an equivalent to kSecAttrCanSign in SecItem.h
271        #[unsafe(method(canSign))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn canSign(&self) -> bool;
274
275        /// Setter for [`canSign`][Self::canSign].
276        #[unsafe(method(setCanSign:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setCanSign(&self, can_sign: bool);
279
280        /// Indicates whether this key can be used to perform Diffie-Hellman style cryptographic key exchange.
281        #[unsafe(method(canPerformKeyExchange))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn canPerformKeyExchange(&self) -> bool;
284
285        /// Setter for [`canPerformKeyExchange`][Self::canPerformKeyExchange].
286        #[unsafe(method(setCanPerformKeyExchange:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn setCanPerformKeyExchange(&self, can_perform_key_exchange: bool);
289
290        /// Indicates whether this key can be used for login in to the system.
291        #[unsafe(method(isSuitableForLogin))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn isSuitableForLogin(&self) -> bool;
294
295        /// Setter for [`isSuitableForLogin`][Self::isSuitableForLogin].
296        #[unsafe(method(setSuitableForLogin:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setSuitableForLogin(&self, suitable_for_login: bool);
299    );
300}
301
302/// Methods declared on superclass `TKTokenKeychainItem`.
303impl TKTokenKeychainKey {
304    extern_methods!(
305        #[unsafe(method(init))]
306        #[unsafe(method_family = init)]
307        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
308    );
309}
310
311/// Methods declared on superclass `NSObject`.
312impl TKTokenKeychainKey {
313    extern_methods!(
314        #[unsafe(method(new))]
315        #[unsafe(method_family = new)]
316        pub unsafe fn new() -> Retained<Self>;
317    );
318}
319
320extern_class!(
321    /// Contains TKTokenKeychainItem instances (keys and certificates) which represent keychain state (i.e. set of items) of specific token.
322    ///
323    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeychaincontents?language=objc)
324    #[unsafe(super(NSObject))]
325    #[derive(Debug, PartialEq, Eq, Hash)]
326    pub struct TKTokenKeychainContents;
327);
328
329extern_conformance!(
330    unsafe impl NSObjectProtocol for TKTokenKeychainContents {}
331);
332
333impl TKTokenKeychainContents {
334    extern_methods!(
335        /// 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.
336        ///
337        /// Parameter `items`: New items to be stored into the keychain.
338        #[unsafe(method(fillWithItems:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn fillWithItems(&self, items: &NSArray<TKTokenKeychainItem>);
341
342        /// All items related to this token in the keychain.
343        #[unsafe(method(items))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn items(&self) -> Retained<NSArray<TKTokenKeychainItem>>;
346
347        #[cfg(feature = "TKToken")]
348        /// Returns key with specified objectID.  Fills error with TKTokenErrorCodeObjectNotFound if no such key exists.
349        ///
350        /// # Safety
351        ///
352        /// `object_id` should be of the correct type.
353        #[unsafe(method(keyForObjectID:error:_))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn keyForObjectID_error(
356            &self,
357            object_id: &TKTokenObjectID,
358        ) -> Result<Retained<TKTokenKeychainKey>, Retained<NSError>>;
359
360        #[cfg(feature = "TKToken")]
361        /// Returns certificate with specified objectID.  Fills error with TKTokenErrorCodeObjectNotFound if no such certificate exists.
362        ///
363        /// # Safety
364        ///
365        /// `object_id` should be of the correct type.
366        #[unsafe(method(certificateForObjectID:error:_))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn certificateForObjectID_error(
369            &self,
370            object_id: &TKTokenObjectID,
371        ) -> Result<Retained<TKTokenKeychainCertificate>, Retained<NSError>>;
372
373        #[unsafe(method(init))]
374        #[unsafe(method_family = init)]
375        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
376    );
377}
378
379/// Methods declared on superclass `NSObject`.
380impl TKTokenKeychainContents {
381    extern_methods!(
382        #[unsafe(method(new))]
383        #[unsafe(method_family = new)]
384        pub unsafe fn new() -> Retained<Self>;
385    );
386}