smartware 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dddf32a584b18a74383d3c9af10514be4d99308e
4
+ data.tar.gz: 6d3ff0e9a3f7db8ad32b5289458e32029e0bc707
5
+ SHA512:
6
+ metadata.gz: 9c3ecd875a3496a23e8bc97d49773518fe0d249becf12cbf626ef4fb197d3e7dd6d2c51da3bc10778b18d9d0b55a871d0cb5d09e08798130e504dee23e3f9e66
7
+ data.tar.gz: a897ca6d6461396a6441b5545d9834f6c47a84dac598f7dd04e1535479782282689f1f8b4b5f75f130ab72c5343cbdc5f41358f76e6bdff7dc453011d8705519
@@ -29,7 +29,9 @@ module Smartware
29
29
  protected
30
30
 
31
31
  def check_dsr!
32
- if @io.dsr == 0
32
+ dsr = @io.dsr != 0 rescue true
33
+
34
+ if !dsr
33
35
  if @ready_for_commands
34
36
  Logging.logger.debug "SZZT: DSR low detected"
35
37
 
@@ -62,10 +62,11 @@ module Smartware
62
62
  }
63
63
 
64
64
  # Authentication data
65
- UID = "0000000000000000"
65
+ UID = "\x11" * 8
66
66
 
67
67
  # Keys
68
- KEY_TMK = 0x00
68
+ KEY_TMK = 0x20
69
+ KEY_TPK = 0x30
69
70
  KEY_IMK = 0x80
70
71
 
71
72
  # Key types, etc
@@ -192,11 +193,11 @@ module Smartware
192
193
  control MISC, ENABLE_INPUT
193
194
 
194
195
  when Interface::PinPad::INPUT_PIN
195
- tpk = 0x40 + 8 * options[:key_set]
196
+ raise "unsupported key set" unless options[:key_set] == 0
196
197
  @plain_input = false
197
198
  @auto_stop = options[:length]
198
199
 
199
- start_pin_input tpk, options[:format], 0, options[:length],
200
+ start_pin_input KEY_TPK, options[:format], 0, options[:length],
200
201
  options[:pan]
201
202
 
202
203
  else
@@ -211,23 +212,10 @@ module Smartware
211
212
  @input_event.call :cancel
212
213
  end
213
214
 
214
- def start_pin_input(key, format, hint_code, length, pan)
215
- raise "unsupported PIN block format" unless PIN_TYPE_MAP.include? format
216
-
217
- safe_command(START_PIN_INPUT,
218
- sprintf("%02X%c%d%02d%s",
219
- key,
220
- PIN_TYPE_MAP[format],
221
- hint_code,
222
- length,
223
- pan))
224
- end
225
-
226
215
  def load_working_keys(set, tpk_under_tmk)
227
- raise "unsupported key set" unless (0..7).include? set
216
+ raise "unsupported key set" unless set == 0
228
217
 
229
- tpk = 0x40 + 8 * set
230
- tpk_verify = load_encrypted_key tpk, KEY_TMK, KEY_TYPE_TPK, nil,
218
+ tpk_verify = load_encrypted_key KEY_TPK, KEY_TMK, KEY_TYPE_TPK, nil,
231
219
  tpk_under_tmk
232
220
 
233
221
  return tpk_verify
@@ -236,8 +224,6 @@ module Smartware
236
224
  def get_pin
237
225
  response = safe_command GET_PIN_VALUE
238
226
 
239
- p response
240
-
241
227
  [
242
228
  response.slice(1, 2).to_i, # Track
243
229
  response.slice(3, 2).to_i, # Length
@@ -247,6 +233,18 @@ module Smartware
247
233
 
248
234
  private
249
235
 
236
+ def start_pin_input(key, format, hint_code, length, pan)
237
+ raise "unsupported PIN block format" unless PIN_TYPE_MAP.include? format
238
+
239
+ safe_command(START_PIN_INPUT,
240
+ sprintf("%02X%c%d%02d%s",
241
+ key,
242
+ PIN_TYPE_MAP[format],
243
+ hint_code,
244
+ length,
245
+ pan))
246
+ end
247
+
250
248
  def calculate_response(challenge, key)
251
249
  cipher = OpenSSL::Cipher.new('DES-ECB')
252
250
  cipher.encrypt
@@ -272,7 +270,7 @@ module Smartware
272
270
  KEY_LENGTH_TRIPLE
273
271
 
274
272
  else
275
- raise "unsupported key length: #{data.bytes}"
273
+ raise "unsupported key length: #{data.length}"
276
274
  end
277
275
  end
278
276
 
@@ -406,21 +404,14 @@ module Smartware
406
404
  restart
407
405
  =end
408
406
  else
409
- [0x10, 0x20, 0x30].each do |key|
410
- p key
411
- begin
412
- random = auth AUTH_GET_CHALLENGE, "0000000000000000"
413
- challenge = auth key, random
414
- response = calculate_response challenge, UID
415
- check = calculate_response response, UID
416
- verify = auth AUTH_WITH_TMK, response
417
- raise ZT588Error, "verification failed" if check != verify
418
- Logging.logger.debug "ZT588: authenticated"
419
-
420
- break
421
- rescue => e
422
- p e
423
- end
407
+ begin
408
+ random = auth AUTH_GET_CHALLENGE, "0000000000000000"
409
+ challenge = auth KEY_TMK, random
410
+ response = calculate_response challenge, UID
411
+ check = calculate_response response, UID
412
+ verify = auth AUTH_WITH_TMK, response
413
+ raise ZT588Error, "verification failed" if check != verify
414
+ Logging.logger.debug "ZT588: authenticated"
424
415
  end
425
416
 
426
417
  @device_ready.call
@@ -113,10 +113,13 @@ module Smartware
113
113
  end
114
114
  end
115
115
  rescue CardReaderError => e
116
- Logging.logger.error "Card reader error: #{e}"
116
+ Logging.logger.error "Card reader error: #{e}" unless @state == :failure
117
117
 
118
- @device.eject rescue nil
119
- @device.accepting = false rescue nil
118
+ begin
119
+ @device.eject
120
+ @device.accepting = false
121
+ rescue CardReaderError => e
122
+ end
120
123
 
121
124
  @state = :failure
122
125
  update_status :error, e.code
@@ -1,3 +1,3 @@
1
1
  module Smartware
2
- VERSION = "0.4.11"
2
+ VERSION = "0.4.12"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
5
- prerelease:
4
+ version: 0.4.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Evgeni Sudarchikov
@@ -11,182 +10,160 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-02-17 00:00:00.000000000 Z
13
+ date: 2013-03-12 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: smartkiosk-common
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - '>='
22
20
  - !ruby/object:Gem::Version
23
21
  version: 0.0.2
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - '>='
30
27
  - !ruby/object:Gem::Version
31
28
  version: 0.0.2
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: serialport
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - '>='
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0'
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - '>='
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: cmux
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - '>='
54
48
  - !ruby/object:Gem::Version
55
49
  version: 0.0.2
56
50
  type: :runtime
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - '>='
62
55
  - !ruby/object:Gem::Version
63
56
  version: 0.0.2
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: trollop
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
- - - ! '>='
61
+ - - '>='
70
62
  - !ruby/object:Gem::Version
71
63
  version: '0'
72
64
  type: :runtime
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
- - - ! '>='
68
+ - - '>='
78
69
  - !ruby/object:Gem::Version
79
70
  version: '0'
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: activesupport
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
- - - ! '>='
75
+ - - '>='
86
76
  - !ruby/object:Gem::Version
87
77
  version: '0'
88
78
  type: :runtime
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
- - - ! '>='
82
+ - - '>='
94
83
  - !ruby/object:Gem::Version
95
84
  version: '0'
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: redcarpet
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
- - - ! '>='
89
+ - - '>='
102
90
  - !ruby/object:Gem::Version
103
91
  version: '0'
104
92
  type: :runtime
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
- - - ! '>='
96
+ - - '>='
110
97
  - !ruby/object:Gem::Version
111
98
  version: '0'
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: digest-crc
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
- - - ! '>='
103
+ - - '>='
118
104
  - !ruby/object:Gem::Version
119
105
  version: '0'
120
106
  type: :runtime
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
- - - ! '>='
110
+ - - '>='
126
111
  - !ruby/object:Gem::Version
127
112
  version: '0'
128
113
  - !ruby/object:Gem::Dependency
129
114
  name: eventmachine
130
115
  requirement: !ruby/object:Gem::Requirement
131
- none: false
132
116
  requirements:
133
- - - ! '>='
117
+ - - '>='
134
118
  - !ruby/object:Gem::Version
135
119
  version: '0'
136
120
  type: :runtime
137
121
  prerelease: false
138
122
  version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
123
  requirements:
141
- - - ! '>='
124
+ - - '>='
142
125
  - !ruby/object:Gem::Version
143
126
  version: '0'
144
127
  - !ruby/object:Gem::Dependency
145
128
  name: chunky_png
146
129
  requirement: !ruby/object:Gem::Requirement
147
- none: false
148
130
  requirements:
149
- - - ! '>='
131
+ - - '>='
150
132
  - !ruby/object:Gem::Version
151
133
  version: '0'
152
134
  type: :runtime
153
135
  prerelease: false
154
136
  version_requirements: !ruby/object:Gem::Requirement
155
- none: false
156
137
  requirements:
157
- - - ! '>='
138
+ - - '>='
158
139
  - !ruby/object:Gem::Version
159
140
  version: '0'
160
141
  - !ruby/object:Gem::Dependency
161
142
  name: oily_png
162
143
  requirement: !ruby/object:Gem::Requirement
163
- none: false
164
144
  requirements:
165
- - - ! '>='
145
+ - - '>='
166
146
  - !ruby/object:Gem::Version
167
147
  version: '0'
168
148
  type: :runtime
169
149
  prerelease: false
170
150
  version_requirements: !ruby/object:Gem::Requirement
171
- none: false
172
151
  requirements:
173
- - - ! '>='
152
+ - - '>='
174
153
  - !ruby/object:Gem::Version
175
154
  version: '0'
176
155
  - !ruby/object:Gem::Dependency
177
156
  name: redis
178
157
  requirement: !ruby/object:Gem::Requirement
179
- none: false
180
158
  requirements:
181
- - - ! '>='
159
+ - - '>='
182
160
  - !ruby/object:Gem::Version
183
161
  version: '0'
184
162
  type: :runtime
185
163
  prerelease: false
186
164
  version_requirements: !ruby/object:Gem::Requirement
187
- none: false
188
165
  requirements:
189
- - - ! '>='
166
+ - - '>='
190
167
  - !ruby/object:Gem::Version
191
168
  version: '0'
192
169
  description: Smartware is the Smartkiosk hardware control daemon
@@ -249,26 +226,26 @@ files:
249
226
  - smartware.gemspec
250
227
  homepage: https://github.com/smartkiosk/smartware
251
228
  licenses: []
229
+ metadata: {}
252
230
  post_install_message:
253
231
  rdoc_options: []
254
232
  require_paths:
255
233
  - lib
256
234
  required_ruby_version: !ruby/object:Gem::Requirement
257
- none: false
258
235
  requirements:
259
- - - ! '>='
236
+ - - '>='
260
237
  - !ruby/object:Gem::Version
261
238
  version: '0'
262
239
  required_rubygems_version: !ruby/object:Gem::Requirement
263
- none: false
264
240
  requirements:
265
- - - ! '>='
241
+ - - '>='
266
242
  - !ruby/object:Gem::Version
267
243
  version: '0'
268
244
  requirements: []
269
245
  rubyforge_project:
270
- rubygems_version: 1.8.25
246
+ rubygems_version: 2.0.0
271
247
  signing_key:
272
- specification_version: 3
248
+ specification_version: 4
273
249
  summary: Smartware is the Smartkiosk hardware control daemon
274
250
  test_files: []
251
+ has_rdoc: