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 #[unsafe(method(setAPDUTemplate:))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn setAPDUTemplate(&self, apdu_template: Option<&NSData>);
61
62 /// Offset in bytes within APDU template to mark the location for filling in the PIN.
63 #[unsafe(method(PINByteOffset))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn PINByteOffset(&self) -> NSInteger;
66
67 /// Setter for [`PINByteOffset`][Self::PINByteOffset].
68 #[unsafe(method(setPINByteOffset:))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn setPINByteOffset(&self, pin_byte_offset: NSInteger);
71
72 #[cfg(feature = "TKSmartCard")]
73 /// TKSmartCard to which the formatted APDU gets sent in order to authenticate (used only if 'APDUTemplate' is set).
74 #[unsafe(method(smartCard))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn smartCard(&self) -> Option<Retained<TKSmartCard>>;
77
78 #[cfg(feature = "TKSmartCard")]
79 /// Setter for [`smartCard`][Self::smartCard].
80 #[unsafe(method(setSmartCard:))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn setSmartCard(&self, smart_card: Option<&TKSmartCard>);
83
84 /// 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.
85 #[unsafe(method(PIN))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn PIN(&self) -> Option<Retained<NSString>>;
88
89 /// Setter for [`PIN`][Self::PIN].
90 #[unsafe(method(setPIN:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn setPIN(&self, pin: Option<&NSString>);
93 );
94}
95
96/// Methods declared on superclass `NSObject`.
97#[cfg(feature = "TKToken")]
98impl TKTokenSmartCardPINAuthOperation {
99 extern_methods!(
100 #[unsafe(method(init))]
101 #[unsafe(method_family = init)]
102 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
103
104 #[unsafe(method(new))]
105 #[unsafe(method_family = new)]
106 pub unsafe fn new() -> Retained<Self>;
107 );
108}
109
110extern_class!(
111 /// TKSmartCardTokenSession represents token session based on SmartCard token.
112 ///
113 /// 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.
114 ///
115 /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtokensession?language=objc)
116 #[unsafe(super(TKTokenSession, NSObject))]
117 #[derive(Debug, PartialEq, Eq, Hash)]
118 #[cfg(feature = "TKToken")]
119 pub struct TKSmartCardTokenSession;
120);
121
122#[cfg(feature = "TKToken")]
123extern_conformance!(
124 unsafe impl NSObjectProtocol for TKSmartCardTokenSession {}
125);
126
127#[cfg(feature = "TKToken")]
128impl TKSmartCardTokenSession {
129 extern_methods!(
130 #[cfg(feature = "TKSmartCard")]
131 /// contains TKSmartCard instance with active exclusive session and SmartCard application selected.
132 ///
133 /// 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.
134 ///
135 /// 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.
136 #[unsafe(method(smartCard))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn smartCard(&self) -> Retained<TKSmartCard>;
139 );
140}
141
142/// Methods declared on superclass `TKTokenSession`.
143#[cfg(feature = "TKToken")]
144impl TKSmartCardTokenSession {
145 extern_methods!(
146 /// Parameter `token`: Token instance to which is this session instance bound.
147 #[unsafe(method(initWithToken:))]
148 #[unsafe(method_family = init)]
149 pub unsafe fn initWithToken(this: Allocated<Self>, token: &TKToken) -> Retained<Self>;
150
151 #[unsafe(method(init))]
152 #[unsafe(method_family = init)]
153 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
154 );
155}
156
157/// Methods declared on superclass `NSObject`.
158#[cfg(feature = "TKToken")]
159impl TKSmartCardTokenSession {
160 extern_methods!(
161 #[unsafe(method(new))]
162 #[unsafe(method_family = new)]
163 pub unsafe fn new() -> Retained<Self>;
164 );
165}
166
167extern_class!(
168 /// TKSmartCardToken base class for implementing SmartCard based token.
169 ///
170 /// When implementing SmartCard token extension, subclass TKSmartCardToken and implement TKTokenDelegate on it.
171 ///
172 /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtoken?language=objc)
173 #[unsafe(super(TKToken, NSObject))]
174 #[derive(Debug, PartialEq, Eq, Hash)]
175 #[cfg(feature = "TKToken")]
176 pub struct TKSmartCardToken;
177);
178
179#[cfg(feature = "TKToken")]
180extern_conformance!(
181 unsafe impl NSObjectProtocol for TKSmartCardToken {}
182);
183
184#[cfg(feature = "TKToken")]
185impl TKSmartCardToken {
186 extern_methods!(
187 #[cfg(feature = "TKSmartCard")]
188 /// Initializes token instance with specified attributes.
189 ///
190 /// Parameter `smartCard`: TKSmartCard instance representing connection to SmartCard on which the intance should operate.
191 ///
192 /// Parameter `AID`: ISO7816-4 application ID which is preselected on the card.
193 ///
194 /// Parameter `instanceID`: Unique, persistent identifier of this token. This is typically implemented by some kind of SmartCard serial number.
195 ///
196 /// Parameter `tokenDriver`: associated driver which initiated creation of this token.
197 #[unsafe(method(initWithSmartCard:AID:instanceID:tokenDriver:))]
198 #[unsafe(method_family = init)]
199 pub unsafe fn initWithSmartCard_AID_instanceID_tokenDriver(
200 this: Allocated<Self>,
201 smart_card: &TKSmartCard,
202 aid: Option<&NSData>,
203 instance_id: &NSString,
204 token_driver: &TKSmartCardTokenDriver,
205 ) -> Retained<Self>;
206
207 /// This is AID which is specified in extension's plist NSExtensionAttributes as
208 /// `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
209 /// `com.apple.ctk.aid`is not present, no application is automatically preselected and value of this property is nil.
210 #[unsafe(method(AID))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn AID(&self) -> Option<Retained<NSData>>;
213
214 #[unsafe(method(initWithTokenDriver:instanceID:))]
215 #[unsafe(method_family = init)]
216 pub unsafe fn initWithTokenDriver_instanceID(
217 this: Allocated<Self>,
218 token_driver: &TKTokenDriver,
219 instance_id: &NSString,
220 ) -> Retained<Self>;
221 );
222}
223
224/// Methods declared on superclass `TKToken`.
225#[cfg(feature = "TKToken")]
226impl TKSmartCardToken {
227 extern_methods!(
228 #[unsafe(method(init))]
229 #[unsafe(method_family = init)]
230 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
231 );
232}
233
234/// Methods declared on superclass `NSObject`.
235#[cfg(feature = "TKToken")]
236impl TKSmartCardToken {
237 extern_methods!(
238 #[unsafe(method(new))]
239 #[unsafe(method_family = new)]
240 pub unsafe fn new() -> Retained<Self>;
241 );
242}
243
244extern_class!(
245 /// TKSmartCardTokenDriver represents driver for specific SmartCard type.
246 ///
247 /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtokendriver?language=objc)
248 #[unsafe(super(TKTokenDriver, NSObject))]
249 #[derive(Debug, PartialEq, Eq, Hash)]
250 #[cfg(feature = "TKToken")]
251 pub struct TKSmartCardTokenDriver;
252);
253
254#[cfg(feature = "TKToken")]
255extern_conformance!(
256 unsafe impl NSObjectProtocol for TKSmartCardTokenDriver {}
257);
258
259#[cfg(feature = "TKToken")]
260impl TKSmartCardTokenDriver {
261 extern_methods!();
262}
263
264/// Methods declared on superclass `NSObject`.
265#[cfg(feature = "TKToken")]
266impl TKSmartCardTokenDriver {
267 extern_methods!(
268 #[unsafe(method(init))]
269 #[unsafe(method_family = init)]
270 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
271
272 #[unsafe(method(new))]
273 #[unsafe(method_family = new)]
274 pub unsafe fn new() -> Retained<Self>;
275 );
276}
277
278extern_protocol!(
279 /// TKSmartCardTokenDriverDelegate is used to implement creation of new token instance according to the SmartCard.
280 ///
281 /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardtokendriverdelegate?language=objc)
282 #[cfg(feature = "TKToken")]
283 pub unsafe trait TKSmartCardTokenDriverDelegate: TKTokenDriverDelegate {
284 #[cfg(feature = "TKSmartCard")]
285 /// Called by system when new SmartCard is detected. You must override this method to create a new valid token TKSmartCardToken instance for
286 /// `smartCard.`
287 /// Parameter `smartCard`: Target SmartCard.
288 ///
289 /// Parameter `AID`: ISO7816-4 AID (application ID) which is already selected on the card. If
290 /// `com.apple.ctk.aid`is not present, no application is selected and this parameter is nil.
291 ///
292 /// Parameter `error`: Error details if operation fails.
293 ///
294 /// Returns: Newly created token instance representing
295 /// `smartCard.`If an error occurs or driver decides that it does not want to handle specified smartCard as token, return nil.
296 #[unsafe(method(tokenDriver:createTokenForSmartCard:AID:error:_))]
297 #[unsafe(method_family = none)]
298 unsafe fn tokenDriver_createTokenForSmartCard_AID_error(
299 &self,
300 driver: &TKSmartCardTokenDriver,
301 smart_card: &TKSmartCard,
302 aid: Option<&NSData>,
303 ) -> Result<Retained<TKSmartCardToken>, Retained<NSError>>;
304 }
305);