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
//! 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::*;
use crate::*;
/// Bitmask of available SmartCard protocols.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardprotocol?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct TKSmartCardProtocol(pub NSUInteger);
bitflags::bitflags! {
impl TKSmartCardProtocol: NSUInteger {
#[doc(alias = "TKSmartCardProtocolNone")]
const None = 0;
#[doc(alias = "TKSmartCardProtocolT0")]
const T0 = 1<<0;
#[doc(alias = "TKSmartCardProtocolT1")]
const T1 = 1<<1;
#[doc(alias = "TKSmartCardProtocolT15")]
const T15 = 1<<15;
#[doc(alias = "TKSmartCardProtocolAny")]
const Any = (1<<16)-1;
}
}
unsafe impl Encode for TKSmartCardProtocol {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for TKSmartCardProtocol {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// Represents single interface-bytes group of ATR.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardatrinterfacegroup?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TKSmartCardATRInterfaceGroup;
);
extern_conformance!(
unsafe impl NSObjectProtocol for TKSmartCardATRInterfaceGroup {}
);
impl TKSmartCardATRInterfaceGroup {
extern_methods!(
/// TA interface byte of ATR group, or nil if TA is not present.
#[unsafe(method(TA))]
#[unsafe(method_family = none)]
pub unsafe fn TA(&self) -> Option<Retained<NSNumber>>;
/// TB interface byte of ATR group, or nil if TB is not present.
#[unsafe(method(TB))]
#[unsafe(method_family = none)]
pub unsafe fn TB(&self) -> Option<Retained<NSNumber>>;
/// TC interface byte of ATR group, or nil if TC is not present.
#[unsafe(method(TC))]
#[unsafe(method_family = none)]
pub unsafe fn TC(&self) -> Option<Retained<NSNumber>>;
/// Protocol number for this group. First group (global) has protocol unassigned, contains nil.
#[unsafe(method(protocol))]
#[unsafe(method_family = none)]
pub unsafe fn protocol(&self) -> Option<Retained<NSNumber>>;
);
}
/// Methods declared on superclass `NSObject`.
impl TKSmartCardATRInterfaceGroup {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// Represents parsed SmartCard ATR. Provides routine for parsing byte stream or NSData with binary ATR and accessors to parsed ATR parts.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardatr?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TKSmartCardATR;
);
extern_conformance!(
unsafe impl NSObjectProtocol for TKSmartCardATR {}
);
impl TKSmartCardATR {
extern_methods!(
/// Parses ATR from binary data block
///
/// Parameter `bytes`: Data containing full valid ATR
///
/// Returns: Parsed ATR instance, or nil when #bytes do not contain valid ATR.
#[unsafe(method(initWithBytes:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithBytes(
this: Allocated<Self>,
bytes: &NSData,
) -> Option<Retained<Self>>;
#[cfg(feature = "block2")]
/// Parses ATR from stream.
///
/// Parameter `source`: Provides one byte of ATR from the stream or -1 in case of an error
///
/// Returns: Parsed ATR instance, or nil when #source method failed or an invalid ATR is detected
#[unsafe(method(initWithSource:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithSource(
this: Allocated<Self>,
source: &block2::DynBlock<dyn Fn() -> c_int>,
) -> Option<Retained<Self>>;
/// Full ATR as string of bytes
#[unsafe(method(bytes))]
#[unsafe(method_family = none)]
pub unsafe fn bytes(&self) -> Retained<NSData>;
/// Array of NSNumber of protocols indicated in ATR, in the correct order (i.e. the default protocol comes first), duplicates sorted out.
#[unsafe(method(protocols))]
#[unsafe(method_family = none)]
pub unsafe fn protocols(&self) -> Retained<NSArray<NSNumber>>;
/// Retrieves interface group with specified index.
///
/// Parameter `index`: Index of the requested interface group. Indexing conforms to ISO7816-3, i.e. starts from 1.
///
/// Returns: Interface group with given index, or nil of no such group was present.
#[unsafe(method(interfaceGroupAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn interfaceGroupAtIndex(
&self,
index: NSInteger,
) -> Option<Retained<TKSmartCardATRInterfaceGroup>>;
/// Parameter `protocol`: Protocol number for which the interface group is requested.
#[unsafe(method(interfaceGroupForProtocol:))]
#[unsafe(method_family = none)]
pub unsafe fn interfaceGroupForProtocol(
&self,
protocol: TKSmartCardProtocol,
) -> Option<Retained<TKSmartCardATRInterfaceGroup>>;
/// Just historical bytes of ATR, without Tck and interface bytes.
#[unsafe(method(historicalBytes))]
#[unsafe(method_family = none)]
pub unsafe fn historicalBytes(&self) -> Retained<NSData>;
#[cfg(feature = "TKTLVRecord")]
/// An array of TKCompactTLVRecord instances with TLV records parsed from historical bytes. If historical bytes are
/// not structured using Compact TLV encoding, nil is returned.
///
/// Note: In case that ATR historical bytes begin with 0x00, the last three bytes (status indicator) are automatically
/// appended into the returned records as if historical bytes would begin with 0x80 and 0x8 record is present
/// in historical bytes.
#[unsafe(method(historicalRecords))]
#[unsafe(method_family = none)]
pub unsafe fn historicalRecords(&self) -> Option<Retained<NSArray<TKCompactTLVRecord>>>;
);
}
/// Methods declared on superclass `NSObject`.
impl TKSmartCardATR {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}