smartcard 0.4.11 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,160 @@
1
+ # Connects Ruby to the PC/SC resource manager (wraps SCARDCONTEXT).
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module Smartcard::PCSC
9
+
10
+
11
+ # Connects Ruby to the PC/SC resource manager.
12
+ class Context
13
+ # Creates an application context connecting to the PC/SC resource manager.
14
+ #
15
+ # A context is required to access every piece of PC/SC functionality.
16
+ #
17
+ # Args:
18
+ # scope:: the scope of the smart-card connection; valid values are :system,
19
+ # :user, and :terminal (see the SCARD_SCOPE_ constants in the PC/SC
20
+ # API)
21
+ def initialize(scope = :system)
22
+ handle_ptr = FFILib::WordPtr.new
23
+ status = FFILib.establish_context scope, nil, nil, handle_ptr
24
+ raise Smartcard::PCSC::Exception, status unless status == :success
25
+
26
+ @_handle = handle_ptr[:value]
27
+ end
28
+
29
+ # Releases this PC/SC context.
30
+ #
31
+ # Future calls to this context's methods will raise errors.
32
+ #
33
+ # Returns the now-released PC/SC context.
34
+ def release
35
+ return unless @_handle
36
+ status = FFILib.release_context @_handle
37
+ raise Smartcard::PCSC::Exception, status unless status == :success
38
+
39
+ @_handle = nil
40
+ self
41
+ end
42
+
43
+ # Returns +true+ if this PC/SC context is still valid, and +false+ otherwise.
44
+ def valid?
45
+ FFILib.is_valid_context(@_handle) == :success
46
+ end
47
+
48
+ # An array containing the currently available reader groups on the system.
49
+ def reader_groups
50
+ # Get the length of the readers concatenated string.
51
+ length_ptr = FFILib::WordPtr.new
52
+ status = FFILib.list_reader_groups @_handle, nil, length_ptr
53
+ raise Smartcard::PCSC::Exception, status unless status == :success
54
+
55
+ # Get the readers concatenated string.
56
+ combined_length = length_ptr[:value]
57
+ groups_ptr = FFI::MemoryPointer.new :char, combined_length
58
+ begin
59
+ status = FFILib.list_reader_groups @_handle, groups_ptr, length_ptr
60
+ raise Smartcard::PCSC::Exception, status unless status == :success
61
+
62
+ Context.decode_multi_string groups_ptr
63
+ ensure
64
+ groups_ptr.free
65
+ end
66
+ end
67
+
68
+ # An array containing the currently available readers in the system.
69
+ #
70
+ # Args:
71
+ # groups:: restrict the readers array to the given groups
72
+ def readers(groups = [])
73
+ groups_string = groups.join("\0") + "\0\0"
74
+ groups_ptr = FFI::MemoryPointer.from_string groups_string
75
+
76
+ # Get the length of the readers concatenated string.
77
+ length_ptr = FFILib::WordPtr.new
78
+ begin
79
+ status = FFILib.list_readers @_handle, groups_ptr, nil, length_ptr
80
+ raise Smartcard::PCSC::Exception, status unless status == :success
81
+
82
+ # Get the readers concatenated string.
83
+ combined_length = length_ptr[:value]
84
+ readers_ptr = FFI::MemoryPointer.new :char, combined_length
85
+ begin
86
+ status = FFILib.list_readers @_handle, groups_ptr, readers_ptr,
87
+ length_ptr
88
+ raise Smartcard::PCSC::Exception, status unless status == :success
89
+
90
+ Context.decode_multi_string readers_ptr
91
+ ensure
92
+ readers_ptr.free
93
+ end
94
+ ensure
95
+ groups_ptr.free
96
+ end
97
+ end
98
+
99
+ # Queries smart-card readers, blocking until a state change occurs.
100
+ #
101
+ # Args:
102
+ # queries:: Smartcard::PCSC::ReaderStateQueries instance
103
+ # timeout:: maximum ammount of time (in milliseconds) to block; the default
104
+ # value blocks forever
105
+ #
106
+ # The method blocks until the state of one of the queried readers becomes
107
+ # different from the query's current_state. The new state is stored in the
108
+ # query's event_state.
109
+ def wait_for_status_change(queries, timeout = FFILib::Consts::INFINITE)
110
+ status = FFILib.get_status_change @_handle, timeout, queries._buffer,
111
+ queries.length
112
+ raise Smartcard::PCSC::Exception, status unless status == :success
113
+
114
+ queries
115
+ end
116
+
117
+ # Establishes a connection to the card in a PC/SC reader.
118
+ #
119
+ # The first connection will power up the card and perform a reset on it.
120
+ #
121
+ # Args:
122
+ # context:: the Smartcard::PCSC::Context for the PC/SC resource manager
123
+ # reader_name:: friendly name of the reader to connect to; reader names can
124
+ # be obtained from Smartcard::PCSC::Context#readers
125
+ # sharing_mode:: whether a shared or exclusive lock will be requested on the
126
+ # reader; the possible values are +:shared+, +:exclusive+ and
127
+ # +:direct+ (see the SCARD_SHARE_ constants in the PC/SC API)
128
+ # preferred_protocols:: the desired communication protocol; the possible
129
+ # values are +:t0+, +:t1+, +:t15+, +:raw+, and +:any+
130
+ # (see the SCARD_PROTOCOL_ constants in the PC/SC API)
131
+ def card(reader_name, sharing_mode = :exclusive, preferred_protocols = :any)
132
+ Card.new self, reader_name, sharing_mode, preferred_protocols
133
+ end
134
+
135
+ # Turns a multi-string (concatenated C strings) into an array of Ruby strings.
136
+ #
137
+ # Args:
138
+ # strings_ptr:: FFI::Pointer to the buffer containing the multi-string
139
+ def self.decode_multi_string(strings_ptr)
140
+ strings_bytes = strings_ptr.get_bytes 0, strings_ptr.size
141
+ strings, next_string = [], ''
142
+ strings_bytes.each_byte do |byte|
143
+ if byte.ord == 0
144
+ break if next_string == ''
145
+ strings << next_string
146
+ next_string = ''
147
+ else
148
+ next_string << byte
149
+ end
150
+ end
151
+ strings
152
+ end
153
+
154
+ # The low-level _SCARDCONTEXT_ data.
155
+ #
156
+ # This should not be used by client code.
157
+ attr_reader :_handle
158
+ end # class Smartcard::PCSC::Context
159
+
160
+ end # namespace Smartcard::PCSC
@@ -0,0 +1,327 @@
1
+ # Automatically generated by tasks/ffi_codegen.rb
2
+
3
+ # :nodoc: namespace
4
+ module Smartcard::PCSC
5
+
6
+ # :nodoc: auto-generated
7
+ module FFILib
8
+ # Constant values extracted from headers.
9
+ module Consts
10
+ SCARD_E_NOT_TRANSACTED = 0x80100016
11
+ SCARD_E_FILE_NOT_FOUND = 0x80100024
12
+ SCARD_E_WRITE_TOO_MANY = 0x80100028
13
+ SCARD_E_NO_READERS_AVAILABLE = 0x8010002E
14
+ SCARD_E_NOT_READY = 0x80100010
15
+ SCARD_E_READER_UNAVAILABLE = 0x80100017
16
+ SCARD_E_SERVER_TOO_BUSY = 0x80100031
17
+ SCARD_W_REMOVED_CARD = 0x80100069
18
+ SCARD_W_SECURITY_VIOLATION = 0x8010006A
19
+ SCARD_E_INVALID_PARAMETER = 0x80100004
20
+ SCARD_E_NO_MEMORY = 0x80100006
21
+ SCARD_E_TIMEOUT = 0x8010000A
22
+ SCARD_W_EOF = 0x8010006D
23
+ SCARD_E_SHARING_VIOLATION = 0x8010000B
24
+ SCARD_E_SYSTEM_CANCELLED = 0x80100012
25
+ SCARD_E_INVALID_ATR = 0x80100015
26
+ SCARD_E_DIR_NOT_FOUND = 0x80100023
27
+ SCARD_E_NO_ACCESS = 0x80100027
28
+ SCARD_E_INVALID_TARGET = 0x80100005
29
+ SCARD_E_DUPLICATE_READER = 0x8010001B
30
+ SCARD_E_NO_SERVICE = 0x8010001D
31
+ SCARD_E_SERVICE_STOPPED = 0x8010001E
32
+ SCARD_W_CARD_NOT_AUTHENTICATED = 0x8010006F
33
+ SCARD_E_UNSUPPORTED_FEATURE = 0x8010001F
34
+ SCARD_S_SUCCESS = 0x00000000
35
+ SCARD_E_NO_KEY_CONTAINER = 0x80100030
36
+ SCARD_W_CANCELLED_BY_USER = 0x8010006E
37
+ SCARD_E_CANT_DISPOSE = 0x8010000E
38
+ SCARD_E_READER_UNSUPPORTED = 0x8010001A
39
+ SCARD_E_CARD_UNSUPPORTED = 0x8010001C
40
+ SCARD_W_CHV_BLOCKED = 0x8010006C
41
+ SCARD_E_CANCELLED = 0x80100002
42
+ SCARD_E_UNKNOWN_READER = 0x80100009
43
+ SCARD_E_PROTO_MISMATCH = 0x8010000F
44
+ SCARD_E_UNEXPECTED = 0x8010001F
45
+ SCARD_E_CERTIFICATE_UNAVAILABLE = 0x8010002D
46
+ SCARD_E_INVALID_HANDLE = 0x80100003
47
+ SCARD_E_INSUFFICIENT_BUFFER = 0x80100008
48
+ SCARD_E_NO_SMARTCARD = 0x8010000C
49
+ SCARD_E_INVALID_VALUE = 0x80100011
50
+ SCARD_E_ICC_INSTALLATION = 0x80100020
51
+ SCARD_E_ICC_CREATEORDER = 0x80100021
52
+ SCARD_E_NO_FILE = 0x80100026
53
+ SCARD_E_BAD_SEEK = 0x80100029
54
+ SCARD_E_UNKNOWN_RES_MNG = 0x8010002B
55
+ SCARD_E_COMM_DATA_LOST = 0x8010002F
56
+ SCARD_W_UNPOWERED_CARD = 0x80100067
57
+ SCARD_W_RESET_CARD = 0x80100068
58
+ SCARD_E_UNKNOWN_CARD = 0x8010000D
59
+ SCARD_E_PCI_TOO_SMALL = 0x80100019
60
+ SCARD_E_NO_DIR = 0x80100025
61
+ SCARD_E_NO_SUCH_CERTIFICATE = 0x8010002C
62
+ SCARD_W_WRONG_CHV = 0x8010006B
63
+ SCARD_E_INVALID_CHV = 0x8010002A
64
+ SCARD_W_UNSUPPORTED_CARD = 0x80100065
65
+ SCARD_W_UNRESPONSIVE_CARD = 0x80100066
66
+ SCARD_W_INSERTED_CARD = 0x8010006A
67
+ SCARD_SCOPE_USER = 0x00000000
68
+ SCARD_SCOPE_SYSTEM = 0x00000002
69
+ SCARD_SCOPE_TERMINAL = 0x00000001
70
+ SCARD_PROTOCOL_RAW = 0x00000004
71
+ SCARD_PROTOCOL_T0 = 0x00000001
72
+ SCARD_PROTOCOL_T1 = 0x00000002
73
+ SCARD_PROTOCOL_ANY = 0x00000003
74
+ SCARD_PROTOCOL_T15 = 0x00000008
75
+ SCARD_PROTOCOL_UNDEFINED = 0x00000000
76
+ SCARD_PROTOCOL_UNSET = 0x00000000
77
+ SCARD_SHARE_EXCLUSIVE = 0x00000001
78
+ SCARD_SHARE_SHARED = 0x00000002
79
+ SCARD_SHARE_DIRECT = 0x00000003
80
+ SCARD_LEAVE_CARD = 0x00000000
81
+ SCARD_RESET_CARD = 0x00000001
82
+ SCARD_EJECT_CARD = 0x00000003
83
+ SCARD_UNPOWER_CARD = 0x00000002
84
+ SCARD_ATTR_USER_AUTH_INPUT_DEVICE = 0x00050142
85
+ SCARD_ATTR_CURRENT_W = 0x00080206
86
+ SCARD_ATTR_ICC_TYPE_PER_ATR = 0x00090304
87
+ SCARD_ATTR_ESC_CANCEL = 0x0007A003
88
+ SCARD_ATTR_MAX_CLK = 0x00030122
89
+ SCARD_ATTR_CHANNEL_ID = 0x00020110
90
+ SCARD_ATTR_CURRENT_PROTOCOL_TYPE = 0x00080201
91
+ SCARD_ATTR_CURRENT_N = 0x00080205
92
+ SCARD_ATTR_CURRENT_BWT = 0x00080209
93
+ SCARD_ATTR_EXTENDED_BWT = 0x0008020C
94
+ SCARD_ATTR_ICC_INTERFACE_STATUS = 0x00090301
95
+ SCARD_ATTR_ESC_AUTHREQUEST = 0x0007A005
96
+ SCARD_ATTR_SUPRESS_T1_IFS_REQUEST = 0x7FFF0007
97
+ SCARD_ATTR_MAX_IFSD = 0x00030125
98
+ SCARD_ATTR_CURRENT_D = 0x00080204
99
+ SCARD_ATTR_CURRENT_CWT = 0x0008020A
100
+ SCARD_ATTR_CURRENT_IO_STATE = 0x00090302
101
+ SCARD_ATTR_DEVICE_FRIENDLY_NAME_A = 0x7FFF0003
102
+ SCARD_ATTR_SYNC_PROTOCOL_TYPES = 0x00030126
103
+ SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE = 0x00050140
104
+ SCARD_ATTR_MAXINPUT = 0x0007A007
105
+ SCARD_ATTR_DEVICE_FRIENDLY_NAME_W = 0x7FFF0005
106
+ SCARD_ATTR_VENDOR_IFD_TYPE = 0x00010101
107
+ SCARD_ATTR_VENDOR_IFD_VERSION = 0x00010102
108
+ SCARD_ATTR_CURRENT_CLK = 0x00080202
109
+ SCARD_ATTR_CURRENT_F = 0x00080203
110
+ SCARD_ATTR_ICC_PRESENCE = 0x00090300
111
+ SCARD_ATTR_DEVICE_UNIT = 0x7FFF0001
112
+ SCARD_ATTR_VENDOR_IFD_SERIAL_NO = 0x00010103
113
+ SCARD_ATTR_CHARACTERISTICS = 0x00060150
114
+ SCARD_ATTR_CURRENT_EBC_ENCODING = 0x0008020B
115
+ SCARD_ATTR_DEVICE_IN_USE = 0x7FFF0002
116
+ SCARD_ATTR_DEVICE_SYSTEM_NAME = 0x7FFF0004
117
+ SCARD_ATTR_VENDOR_NAME = 0x00010100
118
+ SCARD_ATTR_DEFAULT_DATA_RATE = 0x00030123
119
+ SCARD_ATTR_ATR_STRING = 0x00090303
120
+ SCARD_ATTR_MAX_DATA_RATE = 0x00030124
121
+ SCARD_ATTR_DEVICE_SYSTEM_NAME_A = 0x7FFF0004
122
+ SCARD_ATTR_DEVICE_SYSTEM_NAME_W = 0x7FFF0006
123
+ SCARD_ATTR_ASYNC_PROTOCOL_TYPES = 0x00030120
124
+ SCARD_ATTR_DEFAULT_CLK = 0x00030121
125
+ SCARD_ATTR_POWER_MGMT_SUPPORT = 0x00040131
126
+ SCARD_ATTR_CURRENT_IFSC = 0x00080207
127
+ SCARD_ATTR_CURRENT_IFSD = 0x00080208
128
+ SCARD_ATTR_ESC_RESET = 0x0007A000
129
+ SCARD_ATTR_DEVICE_FRIENDLY_NAME = 0x7FFF0003
130
+ SCARD_STATE_UNKNOWN = 0x00000004
131
+ SCARD_STATE_EXCLUSIVE = 0x00000080
132
+ SCARD_STATE_CHANGED = 0x00000002
133
+ SCARD_STATE_EMPTY = 0x00000010
134
+ SCARD_STATE_UNPOWERED = 0x00000400
135
+ SCARD_STATE_INUSE = 0x00000100
136
+ SCARD_STATE_UNAWARE = 0x00000000
137
+ SCARD_STATE_ATRMATCH = 0x00000040
138
+ SCARD_STATE_MUTE = 0x00000200
139
+ SCARD_STATE_IGNORE = 0x00000001
140
+ SCARD_STATE_UNAVAILABLE = 0x00000008
141
+ SCARD_STATE_PRESENT = 0x00000020
142
+ SCARD_PRESENT = 0x00000004
143
+ SCARD_SWALLOWED = 0x00000008
144
+ SCARD_ABSENT = 0x00000002
145
+ SCARD_SPECIFIC = 0x00000040
146
+ SCARD_UNKNOWN = 0x00000001
147
+ SCARD_AUTOALLOCATE = 0xFFFFFFFF
148
+ SCARD_POWERED = 0x00000010
149
+ SCARD_NEGOTIABLE = 0x00000020
150
+ MAX_ATR_SIZE = 0x00000021
151
+ INFINITE = 0xFFFFFFFF
152
+ end # module Smartcard::PCSC::FFILib::Consts
153
+
154
+ # Error codes returned by the PCSC functions.
155
+ Status = enum [
156
+ :not_transacted, Consts::SCARD_E_NOT_TRANSACTED,
157
+ :file_not_found, Consts::SCARD_E_FILE_NOT_FOUND,
158
+ :write_too_many, Consts::SCARD_E_WRITE_TOO_MANY,
159
+ :no_readers_available, Consts::SCARD_E_NO_READERS_AVAILABLE,
160
+ :not_ready, Consts::SCARD_E_NOT_READY,
161
+ :reader_unavailable, Consts::SCARD_E_READER_UNAVAILABLE,
162
+ :server_too_busy, Consts::SCARD_E_SERVER_TOO_BUSY,
163
+ :removed_card, Consts::SCARD_W_REMOVED_CARD,
164
+ :security_violation, Consts::SCARD_W_SECURITY_VIOLATION,
165
+ :invalid_parameter, Consts::SCARD_E_INVALID_PARAMETER,
166
+ :no_memory, Consts::SCARD_E_NO_MEMORY,
167
+ :timeout, Consts::SCARD_E_TIMEOUT,
168
+ :eof, Consts::SCARD_W_EOF,
169
+ :sharing_violation, Consts::SCARD_E_SHARING_VIOLATION,
170
+ :system_cancelled, Consts::SCARD_E_SYSTEM_CANCELLED,
171
+ :invalid_atr, Consts::SCARD_E_INVALID_ATR,
172
+ :dir_not_found, Consts::SCARD_E_DIR_NOT_FOUND,
173
+ :no_access, Consts::SCARD_E_NO_ACCESS,
174
+ :invalid_target, Consts::SCARD_E_INVALID_TARGET,
175
+ :duplicate_reader, Consts::SCARD_E_DUPLICATE_READER,
176
+ :no_service, Consts::SCARD_E_NO_SERVICE,
177
+ :service_stopped, Consts::SCARD_E_SERVICE_STOPPED,
178
+ :card_not_authenticated, Consts::SCARD_W_CARD_NOT_AUTHENTICATED,
179
+ :unsupported_feature, Consts::SCARD_E_UNSUPPORTED_FEATURE,
180
+ :success, Consts::SCARD_S_SUCCESS,
181
+ :no_key_container, Consts::SCARD_E_NO_KEY_CONTAINER,
182
+ :cancelled_by_user, Consts::SCARD_W_CANCELLED_BY_USER,
183
+ :cant_dispose, Consts::SCARD_E_CANT_DISPOSE,
184
+ :reader_unsupported, Consts::SCARD_E_READER_UNSUPPORTED,
185
+ :card_unsupported, Consts::SCARD_E_CARD_UNSUPPORTED,
186
+ :chv_blocked, Consts::SCARD_W_CHV_BLOCKED,
187
+ :cancelled, Consts::SCARD_E_CANCELLED,
188
+ :unknown_reader, Consts::SCARD_E_UNKNOWN_READER,
189
+ :proto_mismatch, Consts::SCARD_E_PROTO_MISMATCH,
190
+ :unexpected, Consts::SCARD_E_UNEXPECTED,
191
+ :certificate_unavailable, Consts::SCARD_E_CERTIFICATE_UNAVAILABLE,
192
+ :invalid_handle, Consts::SCARD_E_INVALID_HANDLE,
193
+ :insufficient_buffer, Consts::SCARD_E_INSUFFICIENT_BUFFER,
194
+ :no_smartcard, Consts::SCARD_E_NO_SMARTCARD,
195
+ :invalid_value, Consts::SCARD_E_INVALID_VALUE,
196
+ :icc_installation, Consts::SCARD_E_ICC_INSTALLATION,
197
+ :icc_createorder, Consts::SCARD_E_ICC_CREATEORDER,
198
+ :no_file, Consts::SCARD_E_NO_FILE,
199
+ :bad_seek, Consts::SCARD_E_BAD_SEEK,
200
+ :unknown_res_mng, Consts::SCARD_E_UNKNOWN_RES_MNG,
201
+ :comm_data_lost, Consts::SCARD_E_COMM_DATA_LOST,
202
+ :unpowered_card, Consts::SCARD_W_UNPOWERED_CARD,
203
+ :reset_card, Consts::SCARD_W_RESET_CARD,
204
+ :unknown_card, Consts::SCARD_E_UNKNOWN_CARD,
205
+ :pci_too_small, Consts::SCARD_E_PCI_TOO_SMALL,
206
+ :no_dir, Consts::SCARD_E_NO_DIR,
207
+ :no_such_certificate, Consts::SCARD_E_NO_SUCH_CERTIFICATE,
208
+ :wrong_chv, Consts::SCARD_W_WRONG_CHV,
209
+ :invalid_chv, Consts::SCARD_E_INVALID_CHV,
210
+ :unsupported_card, Consts::SCARD_W_UNSUPPORTED_CARD,
211
+ :unresponsive_card, Consts::SCARD_W_UNRESPONSIVE_CARD,
212
+ :inserted_card, Consts::SCARD_W_INSERTED_CARD,
213
+ ]
214
+
215
+ # Values for the context's scope.
216
+ Scope = enum [
217
+ :user, Consts::SCARD_SCOPE_USER,
218
+ :system, Consts::SCARD_SCOPE_SYSTEM,
219
+ :terminal, Consts::SCARD_SCOPE_TERMINAL,
220
+ ]
221
+
222
+ # Smart-card communication protocols.
223
+ Protocol = enum [
224
+ :raw, Consts::SCARD_PROTOCOL_RAW,
225
+ :t0, Consts::SCARD_PROTOCOL_T0,
226
+ :t1, Consts::SCARD_PROTOCOL_T1,
227
+ :any, Consts::SCARD_PROTOCOL_ANY,
228
+ :t15, Consts::SCARD_PROTOCOL_T15,
229
+ :undefined, Consts::SCARD_PROTOCOL_UNDEFINED,
230
+ :unset, Consts::SCARD_PROTOCOL_UNSET,
231
+ ]
232
+
233
+ # Smart-card sharing modes.
234
+ Share = enum [
235
+ :exclusive, Consts::SCARD_SHARE_EXCLUSIVE,
236
+ :shared, Consts::SCARD_SHARE_SHARED,
237
+ :direct, Consts::SCARD_SHARE_DIRECT,
238
+ ]
239
+
240
+ # Smart-card dispositions.
241
+ Disposition = enum [
242
+ :leave, Consts::SCARD_LEAVE_CARD,
243
+ :reset, Consts::SCARD_RESET_CARD,
244
+ :eject, Consts::SCARD_EJECT_CARD,
245
+ :unpower, Consts::SCARD_UNPOWER_CARD,
246
+ ]
247
+
248
+ # Smart-card reader attributes.
249
+ Attribute = enum [
250
+ :user_auth_input_device, Consts::SCARD_ATTR_USER_AUTH_INPUT_DEVICE,
251
+ :current_w, Consts::SCARD_ATTR_CURRENT_W,
252
+ :icc_type_per_atr, Consts::SCARD_ATTR_ICC_TYPE_PER_ATR,
253
+ :esc_cancel, Consts::SCARD_ATTR_ESC_CANCEL,
254
+ :max_clk, Consts::SCARD_ATTR_MAX_CLK,
255
+ :channel_id, Consts::SCARD_ATTR_CHANNEL_ID,
256
+ :current_protocol_type, Consts::SCARD_ATTR_CURRENT_PROTOCOL_TYPE,
257
+ :current_n, Consts::SCARD_ATTR_CURRENT_N,
258
+ :current_bwt, Consts::SCARD_ATTR_CURRENT_BWT,
259
+ :extended_bwt, Consts::SCARD_ATTR_EXTENDED_BWT,
260
+ :icc_interface_status, Consts::SCARD_ATTR_ICC_INTERFACE_STATUS,
261
+ :esc_authrequest, Consts::SCARD_ATTR_ESC_AUTHREQUEST,
262
+ :supress_t1_ifs_request, Consts::SCARD_ATTR_SUPRESS_T1_IFS_REQUEST,
263
+ :max_ifsd, Consts::SCARD_ATTR_MAX_IFSD,
264
+ :current_d, Consts::SCARD_ATTR_CURRENT_D,
265
+ :current_cwt, Consts::SCARD_ATTR_CURRENT_CWT,
266
+ :current_io_state, Consts::SCARD_ATTR_CURRENT_IO_STATE,
267
+ :device_friendly_name_a, Consts::SCARD_ATTR_DEVICE_FRIENDLY_NAME_A,
268
+ :sync_protocol_types, Consts::SCARD_ATTR_SYNC_PROTOCOL_TYPES,
269
+ :user_to_card_auth_device, Consts::SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE,
270
+ :maxinput, Consts::SCARD_ATTR_MAXINPUT,
271
+ :device_friendly_name_w, Consts::SCARD_ATTR_DEVICE_FRIENDLY_NAME_W,
272
+ :vendor_ifd_type, Consts::SCARD_ATTR_VENDOR_IFD_TYPE,
273
+ :vendor_ifd_version, Consts::SCARD_ATTR_VENDOR_IFD_VERSION,
274
+ :current_clk, Consts::SCARD_ATTR_CURRENT_CLK,
275
+ :current_f, Consts::SCARD_ATTR_CURRENT_F,
276
+ :icc_presence, Consts::SCARD_ATTR_ICC_PRESENCE,
277
+ :device_unit, Consts::SCARD_ATTR_DEVICE_UNIT,
278
+ :vendor_ifd_serial_no, Consts::SCARD_ATTR_VENDOR_IFD_SERIAL_NO,
279
+ :characteristics, Consts::SCARD_ATTR_CHARACTERISTICS,
280
+ :current_ebc_encoding, Consts::SCARD_ATTR_CURRENT_EBC_ENCODING,
281
+ :device_in_use, Consts::SCARD_ATTR_DEVICE_IN_USE,
282
+ :device_system_name, Consts::SCARD_ATTR_DEVICE_SYSTEM_NAME,
283
+ :vendor_name, Consts::SCARD_ATTR_VENDOR_NAME,
284
+ :default_data_rate, Consts::SCARD_ATTR_DEFAULT_DATA_RATE,
285
+ :atr_string, Consts::SCARD_ATTR_ATR_STRING,
286
+ :max_data_rate, Consts::SCARD_ATTR_MAX_DATA_RATE,
287
+ :device_system_name_a, Consts::SCARD_ATTR_DEVICE_SYSTEM_NAME_A,
288
+ :device_system_name_w, Consts::SCARD_ATTR_DEVICE_SYSTEM_NAME_W,
289
+ :async_protocol_types, Consts::SCARD_ATTR_ASYNC_PROTOCOL_TYPES,
290
+ :default_clk, Consts::SCARD_ATTR_DEFAULT_CLK,
291
+ :power_mgmt_support, Consts::SCARD_ATTR_POWER_MGMT_SUPPORT,
292
+ :current_ifsc, Consts::SCARD_ATTR_CURRENT_IFSC,
293
+ :current_ifsd, Consts::SCARD_ATTR_CURRENT_IFSD,
294
+ :esc_reset, Consts::SCARD_ATTR_ESC_RESET,
295
+ :device_friendly_name, Consts::SCARD_ATTR_DEVICE_FRIENDLY_NAME,
296
+ ]
297
+
298
+ # Smart-card states.
299
+ CardState = enum [
300
+ :unknown, Consts::SCARD_STATE_UNKNOWN,
301
+ :exclusive, Consts::SCARD_STATE_EXCLUSIVE,
302
+ :changed, Consts::SCARD_STATE_CHANGED,
303
+ :empty, Consts::SCARD_STATE_EMPTY,
304
+ :unpowered, Consts::SCARD_STATE_UNPOWERED,
305
+ :inuse, Consts::SCARD_STATE_INUSE,
306
+ :unaware, Consts::SCARD_STATE_UNAWARE,
307
+ :atrmatch, Consts::SCARD_STATE_ATRMATCH,
308
+ :mute, Consts::SCARD_STATE_MUTE,
309
+ :ignore, Consts::SCARD_STATE_IGNORE,
310
+ :unavailable, Consts::SCARD_STATE_UNAVAILABLE,
311
+ :present, Consts::SCARD_STATE_PRESENT,
312
+ ]
313
+
314
+ # Smart-card reader states.
315
+ State = enum [
316
+ :present, Consts::SCARD_PRESENT,
317
+ :swallowed, Consts::SCARD_SWALLOWED,
318
+ :absent, Consts::SCARD_ABSENT,
319
+ :specific, Consts::SCARD_SPECIFIC,
320
+ :unknown, Consts::SCARD_UNKNOWN,
321
+ :autoallocate, Consts::SCARD_AUTOALLOCATE,
322
+ :powered, Consts::SCARD_POWERED,
323
+ :negotiable, Consts::SCARD_NEGOTIABLE,
324
+ ]
325
+
326
+ end # module Smartcard::PCSC::FFILib
327
+ end # namespace Smartcard::PCSC