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