smartcard 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/smartcard/gp/gp_card_mixin.rb +5 -2
- data/lib/smartcard/iso/apdu_error.rb +1 -1
- data/smartcard.gemspec +2 -2
- data/test/gp/gp_card_mixin_test.rb +19 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -35,9 +35,12 @@ module GpCardMixin
|
|
35
35
|
app_data
|
36
36
|
end
|
37
37
|
|
38
|
-
# The
|
38
|
+
# The application ID of the GlobalPlatform card manager.
|
39
39
|
def gp_card_manager_aid
|
40
|
-
|
40
|
+
unless instance_variable_defined? :@gp_card_manager_aid
|
41
|
+
@gp_card_manager_aid = select_application([])[:aid]
|
42
|
+
end
|
43
|
+
@gp_card_manager_aid
|
41
44
|
end
|
42
45
|
|
43
46
|
# Issues a GlobalPlatform INITIALIZE UPDATE command.
|
@@ -30,7 +30,7 @@ class ApduError < RuntimeError
|
|
30
30
|
def initialize(response)
|
31
31
|
@data = response[:data]
|
32
32
|
@status = response[:status]
|
33
|
-
super ApduError.message_for_apdu_response
|
33
|
+
super ApduError.message_for_apdu_response(response)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Computes the exception message for an APDU response.
|
data/smartcard.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{smartcard}
|
5
|
-
s.version = "0.4.
|
5
|
+
s.version = "0.4.10"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Victor Costan"]
|
9
|
-
s.date = %q{2009-11-
|
9
|
+
s.date = %q{2009-11-12}
|
10
10
|
s.description = %q{Interface with ISO 7816 smart cards.}
|
11
11
|
s.email = %q{victor@costan.us}
|
12
12
|
s.extensions = ["ext/smartcard_pcsc/extconf.rb"]
|
@@ -30,6 +30,20 @@ class GpCardMixinTest < Test::Unit::TestCase
|
|
30
30
|
@max_apdu_length = 0x0F
|
31
31
|
end
|
32
32
|
|
33
|
+
def mock_card_manager_query(channel_mock)
|
34
|
+
flexmock(channel_mock).should_receive(:exchange_apdu).
|
35
|
+
with([0x00, 0xA4, 0x04, 0x00, 0x00, 0x00]).
|
36
|
+
and_return([0x6F, 16, 0x84, 8, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
|
37
|
+
0x00, 0xA5, 4, 0x9F, 0x65, 1, 0x0F, 0x90, 0x00])
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_gp_card_manager_aid
|
41
|
+
mock = MixinWrapper.new
|
42
|
+
mock_card_manager_query mock
|
43
|
+
golden = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00]
|
44
|
+
assert_equal golden, mock.gp_card_manager_aid
|
45
|
+
end
|
46
|
+
|
33
47
|
def mock_card_manager_select(channel_mock)
|
34
48
|
flexmock(channel_mock).should_receive(:exchange_apdu).
|
35
49
|
with([0x00, 0xA4, 0x04, 0x00, 0x08, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x00,
|
@@ -40,13 +54,14 @@ class GpCardMixinTest < Test::Unit::TestCase
|
|
40
54
|
|
41
55
|
def test_select_application
|
42
56
|
mock = MixinWrapper.new
|
57
|
+
mock_card_manager_query mock
|
43
58
|
mock_card_manager_select mock
|
44
59
|
app_data = mock.select_application mock.gp_card_manager_aid
|
45
60
|
|
46
61
|
golden = { :aid => mock.gp_card_manager_aid, :max_apdu_length => 0x0F }
|
47
62
|
assert_equal golden, app_data
|
48
63
|
end
|
49
|
-
|
64
|
+
|
50
65
|
def mock_channel_setup(channel_mock)
|
51
66
|
flexmock(channel_mock).should_receive(:exchange_apdu).
|
52
67
|
with([0x80, 0x50, 0x00, 0x00, 0x08, 0x20, 0xBB, 0xE0, 0x4A, 0x1C, 0x6B,
|
@@ -129,6 +144,7 @@ class GpCardMixinTest < Test::Unit::TestCase
|
|
129
144
|
|
130
145
|
def test_gp_applications
|
131
146
|
mock = MixinWrapper.new
|
147
|
+
mock_card_manager_query mock
|
132
148
|
mock_card_manager_select mock
|
133
149
|
mock_channel_setup mock
|
134
150
|
mock_channel_lock mock
|
@@ -156,6 +172,7 @@ class GpCardMixinTest < Test::Unit::TestCase
|
|
156
172
|
|
157
173
|
def test_delete_application
|
158
174
|
mock = MixinWrapper.new
|
175
|
+
mock_card_manager_query mock
|
159
176
|
mock_card_manager_select mock
|
160
177
|
mock_channel_setup mock
|
161
178
|
mock_channel_lock mock
|
@@ -167,6 +184,7 @@ class GpCardMixinTest < Test::Unit::TestCase
|
|
167
184
|
|
168
185
|
def test_gp_install_load
|
169
186
|
mock = MixinWrapper.new
|
187
|
+
mock_card_manager_query mock
|
170
188
|
flexmock(mock).should_receive(:exchange_apdu).
|
171
189
|
with([0x80, 0xE6, 0x02, 0x00, 0x14, 0x07, 0x19, 0x83, 0x12, 0x29, 0x10,
|
172
190
|
0xFA, 0xCE, 0x08, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartcard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-12 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|