objc2_crypto_token_kit/generated/
TKSmartCardToken.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
8use crate::*;
9
10extern_class!(
11    /// Context of a SmartCard PIN authentication operation.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokensmartcardpinauthoperation?language=objc)
14    #[unsafe(super(TKTokenAuthOperation, NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    #[cfg(feature = "TKToken")]
17    pub struct TKTokenSmartCardPINAuthOperation;
18);
19
20#[cfg(feature = "TKToken")]
21extern_conformance!(
22    unsafe impl NSCoding for TKTokenSmartCardPINAuthOperation {}
23);
24
25#[cfg(feature = "TKToken")]
26extern_conformance!(
27    unsafe impl NSObjectProtocol for TKTokenSmartCardPINAuthOperation {}
28);
29
30#[cfg(feature = "TKToken")]
31extern_conformance!(
32    unsafe impl NSSecureCoding for TKTokenSmartCardPINAuthOperation {}
33);
34
35#[cfg(feature = "TKToken")]
36impl TKTokenSmartCardPINAuthOperation {
37    extern_methods!(
38        #[cfg(feature = "TKSmartCard")]
39        /// PIN formatting properties.
40        ///
41        /// Note: The property is initialized with a default instance of TKSmartCardPINFormat.
42        #[unsafe(method(PINFormat))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn PINFormat(&self) -> Retained<TKSmartCardPINFormat>;
45
46        #[cfg(feature = "TKSmartCard")]
47        /// Setter for [`PINFormat`][Self::PINFormat].
48        #[unsafe(method(setPINFormat:))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn setPINFormat(&self, pin_format: &TKSmartCardPINFormat);
51
52        /// APDU template into which PIN gets filled in. If set to nil, the system will not attempt to authenticate by sending the formatted APDU to the SmartCard, but rather the token itself is expected to perform the authentication.  It is preferred to provide APDUTemplate if possible, because it allows using hardware PINPad for secure PIN entry (provided that the reader has one).
53        #[unsafe(method(APDUTemplate))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn APDUTemplate(&self) -> Option<Retained<NSData>>;
56
57        /// Setter for [`APDUTemplate`][Self::APDUTemplate].
58        ///
59        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
60        #[unsafe(method(setAPDUTemplate:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn setAPDUTemplate(&self, apdu_template: Option<&NSData>);
63
64        /// Offset in bytes within APDU template to mark the location for filling in the PIN.
65        #[unsafe(method(PINByteOffset))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn PINByteOffset(&self) -> NSInteger;
68
69        /// Setter for [`PINByteOffset`][Self::PINByteOffset].
70        #[unsafe(method(setPINByteOffset:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setPINByteOffset(&self, pin_byte_offset: NSInteger);
73
74        #[cfg(feature = "TKSmartCard")]
75        /// TKSmartCard to which the formatted APDU gets sent in order to authenticate (used only if 'APDUTemplate' is set).
76        #[unsafe(method(smartCard))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn smartCard(&self) -> Option<Retained<TKSmartCard>>;
79
80        #[cfg(feature = "TKSmartCard")]
81        /// Setter for [`smartCard`][Self::smartCard].
82        #[unsafe(method(setSmartCard:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setSmartCard(&self, smart_card: Option<&TKSmartCard>);
85
86        /// PIN value which will be set when 'finishWithError:' gets triggered.  Note that the PIN is not set in case that APDUTemplate was set.  In this case, PIN was already sent to the card using specified template.
87        #[unsafe(method(PIN))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn PIN(&self) -> Option<Retained<NSString>>;
90
91        /// Setter for [`PIN`][Self::PIN].
92        ///
93        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
94        #[unsafe(method(setPIN:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn setPIN(&self, pin: Option<&NSString>);
97    );
98}
99
100/// Methods declared on superclass `NSObject`.
101#[cfg(feature = "TKToken")]
102impl TKTokenSmartCardPINAuthOperation {
103    extern_methods!(
104        #[unsafe(method(init))]
105        #[unsafe(method_family = init)]
106        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
107
108        #[unsafe(method(new))]
109        #[unsafe(method_family = new)]
110        pub unsafe fn new() -> Retained<Self>;
111    );
112}
113
114extern_class!(
115    /// TKSmartCardTokenSession represents token session based on SmartCard token.
116    ///
117    /// When implementing SmartCard token extension, subclass TKSmartCardTokenSession and implement TKTokenSessionDelegate on it.  Use #token property to get access and send APDUs to the underlying SmartCard.
118    ///
119    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtokensession?language=objc)
120    #[unsafe(super(TKTokenSession, NSObject))]
121    #[derive(Debug, PartialEq, Eq, Hash)]
122    #[cfg(feature = "TKToken")]
123    pub struct TKSmartCardTokenSession;
124);
125
126#[cfg(feature = "TKToken")]
127extern_conformance!(
128    unsafe impl NSObjectProtocol for TKSmartCardTokenSession {}
129);
130
131#[cfg(feature = "TKToken")]
132impl TKSmartCardTokenSession {
133    extern_methods!(
134        #[cfg(feature = "TKSmartCard")]
135        /// contains TKSmartCard instance with active exclusive session and SmartCard application selected.
136        ///
137        /// This property can be accessed only when handling one of the methods of TKTokenSessionDelegate protocol.  If associated token has set AID property, then the returned card has opened exclusive session to the card and the application is already selected.  Therefore there is no need to call -[TKSmartCard beginSessionWithReply:]) on returned SmartCard instance in such case and system will take care of terminating session when current token request servicing is finished,  -[TKSmartCard endSession] must not be called either.
138        ///
139        /// You can store any kind of context state information representing state of the card into smartCard.context property.  This property will be automatically set to nil if the card is reset or accessed by different TKSmartCard instance (possibly in another process).  Checking TKSmartCard.context property for previously stored value can be used to avoid potentially costly restoring of SmartCard state before performing the operation.
140        #[deprecated]
141        #[unsafe(method(smartCard))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn smartCard(&self) -> Retained<TKSmartCard>;
144
145        #[cfg(feature = "TKSmartCard")]
146        /// Returns a TKSmartCard instance with an active exclusive session and the SmartCard application selected. Replaces the deprecated
147        /// `smartCard`property.
148        ///
149        /// The TKSmartCard object is only accessible within the methods of the TKTokenSessionDelegate protocol. If the associated token has an AID set, the returned card will have an exclusive session already opened and the specified application selected. In this scenario: Do not call -[TKSmartCard beginSessionWithReply:]) on the returned SmartCard instance. The system manages the session lifecycle and will terminate it automatically when the current token request servicing is finished. Do not call -[TKSmartCard endSession]. You can use the `smartCard.context` property to store any context-specific state information related to the card. This property is automatically set to `nil` if the card is reset or accessed by a different TKSmartCard instance (potentially in another process). Before performing an operation, check the `TKSmartCard.context` property for a previously stored value. This can help you avoid potentially costly restoration of the SmartCard state if it's already available.
150        ///
151        /// Parameter `error`: An NSError object containing details if the operation fails.
152        #[unsafe(method(getSmartCardWithError:_))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn getSmartCardWithError(
155            &self,
156        ) -> Result<Retained<TKSmartCard>, Retained<NSError>>;
157    );
158}
159
160/// Methods declared on superclass `TKTokenSession`.
161#[cfg(feature = "TKToken")]
162impl TKSmartCardTokenSession {
163    extern_methods!(
164        /// Parameter `token`: Token instance to which is this session instance bound.
165        #[unsafe(method(initWithToken:))]
166        #[unsafe(method_family = init)]
167        pub unsafe fn initWithToken(this: Allocated<Self>, token: &TKToken) -> Retained<Self>;
168
169        #[unsafe(method(init))]
170        #[unsafe(method_family = init)]
171        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
172    );
173}
174
175/// Methods declared on superclass `NSObject`.
176#[cfg(feature = "TKToken")]
177impl TKSmartCardTokenSession {
178    extern_methods!(
179        #[unsafe(method(new))]
180        #[unsafe(method_family = new)]
181        pub unsafe fn new() -> Retained<Self>;
182    );
183}
184
185extern_class!(
186    /// TKSmartCardToken base class for implementing SmartCard based token.
187    ///
188    /// When implementing SmartCard token extension, subclass TKSmartCardToken and implement TKTokenDelegate on it.
189    ///
190    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtoken?language=objc)
191    #[unsafe(super(TKToken, NSObject))]
192    #[derive(Debug, PartialEq, Eq, Hash)]
193    #[cfg(feature = "TKToken")]
194    pub struct TKSmartCardToken;
195);
196
197#[cfg(feature = "TKToken")]
198extern_conformance!(
199    unsafe impl NSObjectProtocol for TKSmartCardToken {}
200);
201
202#[cfg(feature = "TKToken")]
203impl TKSmartCardToken {
204    extern_methods!(
205        #[cfg(feature = "TKSmartCard")]
206        /// Initializes token instance with specified attributes.
207        ///
208        /// Parameter `smartCard`: TKSmartCard instance representing connection to SmartCard on which the intance should operate.
209        ///
210        /// Parameter `AID`: ISO7816-4 application ID which is preselected on the card.
211        ///
212        /// Parameter `instanceID`: Unique, persistent identifier of this token.  This is typically implemented by some kind of SmartCard serial number.
213        ///
214        /// Parameter `tokenDriver`: associated driver which initiated creation of this token.
215        #[unsafe(method(initWithSmartCard:AID:instanceID:tokenDriver:))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn initWithSmartCard_AID_instanceID_tokenDriver(
218            this: Allocated<Self>,
219            smart_card: &TKSmartCard,
220            aid: Option<&NSData>,
221            instance_id: &NSString,
222            token_driver: &TKSmartCardTokenDriver,
223        ) -> Retained<Self>;
224
225        /// This is AID which is specified in extension's plist NSExtensionAttributes as
226        /// `com.apple.ctk.aid`attribute. If the attribute specifies array of multiple AIDs, this parameter represents AID which was found on the card and is already preselected.  If
227        /// `com.apple.ctk.aid`is not present, no application is automatically preselected and value of this property is nil.
228        #[unsafe(method(AID))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn AID(&self) -> Option<Retained<NSData>>;
231
232        #[unsafe(method(initWithTokenDriver:instanceID:))]
233        #[unsafe(method_family = init)]
234        pub unsafe fn initWithTokenDriver_instanceID(
235            this: Allocated<Self>,
236            token_driver: &TKTokenDriver,
237            instance_id: &NSString,
238        ) -> Retained<Self>;
239    );
240}
241
242/// Methods declared on superclass `TKToken`.
243#[cfg(feature = "TKToken")]
244impl TKSmartCardToken {
245    extern_methods!(
246        #[unsafe(method(init))]
247        #[unsafe(method_family = init)]
248        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
249    );
250}
251
252/// Methods declared on superclass `NSObject`.
253#[cfg(feature = "TKToken")]
254impl TKSmartCardToken {
255    extern_methods!(
256        #[unsafe(method(new))]
257        #[unsafe(method_family = new)]
258        pub unsafe fn new() -> Retained<Self>;
259    );
260}
261
262extern_class!(
263    /// TKSmartCardTokenDriver represents driver for specific SmartCard type.
264    ///
265    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtokendriver?language=objc)
266    #[unsafe(super(TKTokenDriver, NSObject))]
267    #[derive(Debug, PartialEq, Eq, Hash)]
268    #[cfg(feature = "TKToken")]
269    pub struct TKSmartCardTokenDriver;
270);
271
272#[cfg(feature = "TKToken")]
273extern_conformance!(
274    unsafe impl NSObjectProtocol for TKSmartCardTokenDriver {}
275);
276
277#[cfg(feature = "TKToken")]
278impl TKSmartCardTokenDriver {
279    extern_methods!();
280}
281
282/// Methods declared on superclass `NSObject`.
283#[cfg(feature = "TKToken")]
284impl TKSmartCardTokenDriver {
285    extern_methods!(
286        #[unsafe(method(init))]
287        #[unsafe(method_family = init)]
288        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
289
290        #[unsafe(method(new))]
291        #[unsafe(method_family = new)]
292        pub unsafe fn new() -> Retained<Self>;
293    );
294}
295
296extern_protocol!(
297    /// TKSmartCardTokenDriverDelegate is used to implement creation of new token instance according to the SmartCard.
298    ///
299    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtokendriverdelegate?language=objc)
300    #[cfg(feature = "TKToken")]
301    pub unsafe trait TKSmartCardTokenDriverDelegate: TKTokenDriverDelegate {
302        #[cfg(feature = "TKSmartCard")]
303        /// Called by system when new SmartCard is detected.  You must override this method to create a new valid token TKSmartCardToken instance for
304        /// `smartCard.`
305        /// Parameter `smartCard`: Target SmartCard.
306        ///
307        /// Parameter `AID`: ISO7816-4 AID (application ID) which is already selected on the card.  If
308        /// `com.apple.ctk.aid`is not present, no application is selected and this parameter is nil.
309        ///
310        /// Parameter `error`: Error details if operation fails.
311        ///
312        /// Returns: Newly created token instance representing
313        /// `smartCard.`If an error occurs or driver decides that it does not want to handle specified smartCard as token, return nil.
314        #[unsafe(method(tokenDriver:createTokenForSmartCard:AID:error:_))]
315        #[unsafe(method_family = none)]
316        unsafe fn tokenDriver_createTokenForSmartCard_AID_error(
317            &self,
318            driver: &TKSmartCardTokenDriver,
319            smart_card: &TKSmartCard,
320            aid: Option<&NSData>,
321        ) -> Result<Retained<TKSmartCardToken>, Retained<NSError>>;
322    }
323);