smartcard 0.4.6-x86-mswin32-60 → 0.4.9-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/BUILD +5 -5
- data/CHANGELOG +6 -0
- data/Manifest +3 -0
- data/Rakefile +4 -1
- data/lib/smartcard.rb +1 -0
- data/lib/smartcard/gp/gp_card_mixin.rb +1 -1
- data/lib/smartcard/iso/apdu_error.rb +43 -0
- data/lib/smartcard/iso/iso_card_mixin.rb +3 -12
- data/lib/smartcard/iso/jcop_remote_server.rb +5 -16
- data/lib/smartcard/iso/jcop_remote_transport.rb +3 -11
- data/lib/smartcard/pcsc.so +0 -0
- data/smartcard.gemspec +14 -5
- data/test/iso/iso_card_mixin_test.rb +8 -1
- data/test/iso/iso_exception_test.rb +36 -0
- metadata +37 -3
data/BUILD
CHANGED
@@ -22,8 +22,8 @@ anything.
|
|
22
22
|
|
23
23
|
You need to install the Developer Tools to get gcc.
|
24
24
|
|
25
|
-
Leopard (OSX 10.5)
|
26
|
-
for CCID readers.
|
25
|
+
Leopard and Snow Leopard (OSX 10.5 / 10.6) include a working PC/SC provider, as
|
26
|
+
well as a good driver for CCID readers.
|
27
27
|
|
28
28
|
Tiger's (OSX 10.4) PC/SC implementation is broken and incomplete, so the Ruby
|
29
29
|
extension code in +smartcard+ has a few hacks to work around that (look for the
|
@@ -35,13 +35,13 @@ don't work:
|
|
35
35
|
* Smartcard::PCSC::Card#control (Tiger's API is broken, the call may not work)
|
36
36
|
|
37
37
|
The developer team doesn't support or test against ports of +gcc+ or +pcsclite+,
|
38
|
-
but we
|
38
|
+
but we welcome patches or success stories.
|
39
39
|
|
40
40
|
== Windows
|
41
41
|
|
42
42
|
A lot of effort has been spent to make Windows builds as easy as possible.
|
43
43
|
+smartcard+ is currently built using a full edition of
|
44
|
-
{Visual Studio
|
44
|
+
{Visual Studio 6.0}[http://msdn.microsoft.com/vstudio/], but all sources
|
45
45
|
indicate that
|
46
46
|
{Visual C++ Express 2005}[http://www.microsoft.com/express/download/]
|
47
47
|
works, as long as you also install a Windows SDK (you're on your own for that).
|
@@ -69,7 +69,7 @@ readers.
|
|
69
69
|
=== Ubuntu
|
70
70
|
|
71
71
|
Installing the following packages (and their dependencies) gets you going on
|
72
|
-
Ubuntu (tested on
|
72
|
+
Ubuntu (tested on 8.04, 8.10, 9.04 and 9.10):
|
73
73
|
* build-essential
|
74
74
|
* libccid
|
75
75
|
* libpcsclite-dev (depends on libpcsclite or libpcsclite1)
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
v0.4.9. Disabled Nagle's algorithm in the remote JCOP transport.
|
2
|
+
|
3
|
+
v0.4.8. Gem dependencies.
|
4
|
+
|
5
|
+
v0.4.7. Custom exception class for APDU responses with error codes.
|
6
|
+
|
1
7
|
v0.4.6. Automatic detection of package AID from CAP in install_applet.
|
2
8
|
|
3
9
|
v0.4.5. More bugfixes in JcopRemoteTransport's ATR forwarding logic.
|
data/Manifest
CHANGED
@@ -22,6 +22,7 @@ lib/smartcard/gp/asn1_ber.rb
|
|
22
22
|
lib/smartcard/gp/cap_loader.rb
|
23
23
|
lib/smartcard/gp/des.rb
|
24
24
|
lib/smartcard/gp/gp_card_mixin.rb
|
25
|
+
lib/smartcard/iso/apdu_error.rb
|
25
26
|
lib/smartcard/iso/auto_configurator.rb
|
26
27
|
lib/smartcard/iso/iso_card_mixin.rb
|
27
28
|
lib/smartcard/iso/jcop_remote_protocol.rb
|
@@ -30,6 +31,7 @@ lib/smartcard/iso/jcop_remote_transport.rb
|
|
30
31
|
lib/smartcard/iso/pcsc_transport.rb
|
31
32
|
lib/smartcard/iso/transport.rb
|
32
33
|
lib/smartcard/pcsc/pcsc_exception.rb
|
34
|
+
smartcard.gemspec
|
33
35
|
test/gp/asn1_ber_test.rb
|
34
36
|
test/gp/cap_loader_test.rb
|
35
37
|
test/gp/des_test.rb
|
@@ -38,6 +40,7 @@ test/gp/hello.apdu
|
|
38
40
|
test/gp/hello.cap
|
39
41
|
test/iso/auto_configurator_test.rb
|
40
42
|
test/iso/iso_card_mixin_test.rb
|
43
|
+
test/iso/iso_exception_test.rb
|
41
44
|
test/iso/jcop_remote_test.rb
|
42
45
|
test/pcsc/containers_test.rb
|
43
46
|
test/pcsc/smoke_test.rb
|
data/Rakefile
CHANGED
@@ -9,7 +9,10 @@ Echoe.new('smartcard') do |p|
|
|
9
9
|
p.email = 'victor@costan.us'
|
10
10
|
p.summary = 'Interface with ISO 7816 smart cards.'
|
11
11
|
p.url = 'http://www.costan.us/smartcard'
|
12
|
-
p.dependencies = ['rubyzip >=0.9.1'
|
12
|
+
p.dependencies = ['rubyzip >=0.9.1',
|
13
|
+
'zerg_support >=0.1.5']
|
14
|
+
p.development_dependencies = ['echoe >=3.2',
|
15
|
+
'flexmock >=0.8.6']
|
13
16
|
|
14
17
|
p.need_tar_gz = !Gem.win_platform?
|
15
18
|
p.need_zip = !Gem.win_platform?
|
data/lib/smartcard.rb
CHANGED
@@ -179,7 +179,7 @@ module GpCardMixin
|
|
179
179
|
raw = iso_apdu :cla => 0x80, :ins => 0xF2, :p1 => scope_byte,
|
180
180
|
:p2 => (first ? 0 : 1), :data => [0x4F, 0x00]
|
181
181
|
if raw[:status] != 0x9000 && raw[:status] != 0x6310
|
182
|
-
Smartcard::Iso::
|
182
|
+
raise Smartcard::Iso::ApduException, raw
|
183
183
|
end
|
184
184
|
|
185
185
|
offset = 0
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Exception indicating an error code in an ISO-7618 response APDU.
|
2
|
+
#
|
3
|
+
# Author:: Victor Costan
|
4
|
+
# Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
|
5
|
+
# License:: MIT
|
6
|
+
|
7
|
+
# :nodoc: namespace
|
8
|
+
module Smartcard::Iso
|
9
|
+
|
10
|
+
|
11
|
+
# Indicates an error code in an ISO-7618 response APDU.
|
12
|
+
#
|
13
|
+
# This exception should be raised if the response obtained from iso_apdu has an
|
14
|
+
# error status. When raising the exception, supply the entire response as the
|
15
|
+
# only argument to raise.
|
16
|
+
#
|
17
|
+
# Usage example:
|
18
|
+
# response = transport.iso_apdu :ins => 0x12
|
19
|
+
# raise Smartcard::Iso::ApduError, response unless response[:status] == 0x9000
|
20
|
+
class ApduError < RuntimeError
|
21
|
+
# The data in the error APDU.
|
22
|
+
attr_accessor :data
|
23
|
+
# The error status.
|
24
|
+
attr_accessor :status
|
25
|
+
|
26
|
+
# Creates a new exception (for raising).
|
27
|
+
#
|
28
|
+
# Args:
|
29
|
+
# response:: the APDU response (hash with +:data+ and +:status+ keys)
|
30
|
+
def initialize(response)
|
31
|
+
@data = response[:data]
|
32
|
+
@status = response[:status]
|
33
|
+
super ApduError.message_for_apdu_response response
|
34
|
+
end
|
35
|
+
|
36
|
+
# Computes the exception message for an APDU response.
|
37
|
+
def self.message_for_apdu_response(response)
|
38
|
+
"ISO-7816 response APDU has error status 0x#{'%04x' % response[:status]}" +
|
39
|
+
" - #{response[:data].map { |ch| '%02x' % ch }.join(' ')}"
|
40
|
+
end
|
41
|
+
end # class Smartcard::Iso::ApduError
|
42
|
+
|
43
|
+
end # namespace Smartcard::Iso
|
@@ -16,7 +16,7 @@ module Smartcard::Iso
|
|
16
16
|
# the APDU data as an array of integers between 0 and 255, and expects a
|
17
17
|
# response in the same format.
|
18
18
|
module IsoCardMixin
|
19
|
-
# APDU exchange with the ISO7816 card, raising an
|
19
|
+
# APDU exchange with the ISO7816 card, raising an ApduError if the return
|
20
20
|
# code is not success (0x9000).
|
21
21
|
#
|
22
22
|
# :call_seq:
|
@@ -24,22 +24,13 @@ module IsoCardMixin
|
|
24
24
|
#
|
25
25
|
# The apdu_data should be in the format expected by
|
26
26
|
# IsoCardMixin#serialize_apdu. Returns the response data, if the response
|
27
|
-
# status indicates success (0x9000). Otherwise, raises an
|
27
|
+
# status indicates success (0x9000). Otherwise, raises an ApduError.
|
28
28
|
def iso_apdu!(apdu_data)
|
29
29
|
response = self.iso_apdu apdu_data
|
30
30
|
return response[:data] if response[:status] == 0x9000
|
31
|
-
|
31
|
+
raise ApduError, response
|
32
32
|
end
|
33
33
|
|
34
|
-
# Raises an exception in response to an error status in an APDU.
|
35
|
-
#
|
36
|
-
# :call_seq:
|
37
|
-
# IsoCardMixin.raise_response_exception(response)
|
38
|
-
def self.raise_response_exception(response)
|
39
|
-
raise "JavaCard response has error status 0x#{'%04x' % response[:status]}" +
|
40
|
-
" - #{response[:data].map { |ch| '%02x' % ch }.join(' ')}"
|
41
|
-
end
|
42
|
-
|
43
34
|
# Performs an APDU exchange with the ISO7816 card.
|
44
35
|
#
|
45
36
|
# :call-seq:
|
@@ -66,8 +66,6 @@ class JcopRemoteServer
|
|
66
66
|
# The options hash supports the following keys:
|
67
67
|
# port:: the port to serve on
|
68
68
|
# ip:: the IP of the interface to serve on (defaults to all interfaces)
|
69
|
-
# reusable:: if set, the serving port can be shared with another
|
70
|
-
# application (REUSEADDR flag will be set on the socket)
|
71
69
|
#
|
72
70
|
# If the |serving_logic| parameter is nil, a serving logic implementation
|
73
71
|
# must be provided when calling JcopRemoteServer#run. The server will crash
|
@@ -126,13 +124,12 @@ class JcopRemoteServer
|
|
126
124
|
end
|
127
125
|
|
128
126
|
# TODO(costan): figure out a way to let serving logic reach this directly.
|
129
|
-
end
|
130
|
-
|
127
|
+
end
|
131
128
|
|
132
129
|
# Creates a socket listening to incoming connections to this server.
|
133
130
|
#
|
134
131
|
# :call-seq:
|
135
|
-
# server.
|
132
|
+
# server.serving_socket(options) -> Socket
|
136
133
|
#
|
137
134
|
# The |options| parameter supports the same keys as the options parameter
|
138
135
|
# of JcopRemoteServer#new.
|
@@ -141,17 +138,9 @@ class JcopRemoteServer
|
|
141
138
|
def serving_socket(options)
|
142
139
|
port = options[:port] || 0
|
143
140
|
interface_ip = options[:ip] || '0.0.0.0'
|
144
|
-
|
145
|
-
|
146
|
-
socket
|
147
|
-
Socket::PF_UNSPEC
|
148
|
-
|
149
|
-
if options[:reusable]
|
150
|
-
socket.setsockopt Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true
|
151
|
-
end
|
152
|
-
socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true
|
153
|
-
socket.bind serving_address
|
154
|
-
socket.listen 5
|
141
|
+
socket = Zerg::Support::SocketFactory.socket :in_addr => interface_ip,
|
142
|
+
:in_port => port, :no_delay => true, :reuse_addr => true
|
143
|
+
socket.listen
|
155
144
|
socket
|
156
145
|
end
|
157
146
|
private :serving_socket
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Copyright:: Copyright (C) 2008 Massachusetts Institute of Technology
|
5
5
|
# License:: MIT
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'zerg_support'
|
8
8
|
|
9
9
|
# :nodoc: namespace
|
10
10
|
module Smartcard::Iso
|
@@ -43,16 +43,8 @@ class JcopRemoteTransport
|
|
43
43
|
# Makes a transport-level connection to the TEM.
|
44
44
|
def connect
|
45
45
|
begin
|
46
|
-
|
47
|
-
|
48
|
-
begin
|
49
|
-
@socket = Socket.new(addr_info[4], addr_info[5], addr_info[6])
|
50
|
-
@socket.connect Socket.pack_sockaddr_in(addr_info[1], addr_info[3])
|
51
|
-
break
|
52
|
-
rescue
|
53
|
-
@socket = nil
|
54
|
-
end
|
55
|
-
end
|
46
|
+
@socket = Zerg::Support::SocketFactory.socket :out_addr => @host,
|
47
|
+
:out_port => @port, :no_delay => true
|
56
48
|
raise 'Connection refused' unless @socket
|
57
49
|
|
58
50
|
# Wait for the card to be inserted.
|
data/lib/smartcard/pcsc.so
CHANGED
Binary file
|
data/smartcard.gemspec
CHANGED
@@ -2,23 +2,23 @@
|
|
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.9"
|
6
6
|
s.platform = %q{x86-mswin32-60}
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.authors = ["Victor Costan"]
|
10
|
-
s.date = %q{2009-11-
|
10
|
+
s.date = %q{2009-11-11}
|
11
11
|
s.description = %q{Interface with ISO 7816 smart cards.}
|
12
12
|
s.email = %q{victor@costan.us}
|
13
|
-
s.extra_rdoc_files = ["BUILD", "CHANGELOG", "LICENSE", "README", "ext/smartcard_pcsc/extconf.rb", "ext/smartcard_pcsc/pcsc.h", "ext/smartcard_pcsc/pcsc_card.c", "ext/smartcard_pcsc/pcsc_constants.c", "ext/smartcard_pcsc/pcsc_context.c", "ext/smartcard_pcsc/pcsc_exception.c", "ext/smartcard_pcsc/pcsc_io_request.c", "ext/smartcard_pcsc/pcsc_main.c", "ext/smartcard_pcsc/pcsc_multi_strings.c", "ext/smartcard_pcsc/pcsc_namespace.c", "ext/smartcard_pcsc/pcsc_reader_states.c", "ext/smartcard_pcsc/pcsc_surrogate_reader.h", "ext/smartcard_pcsc/pcsc_surrogate_wintypes.h", "lib/smartcard.rb", "lib/smartcard/gp/asn1_ber.rb", "lib/smartcard/gp/cap_loader.rb", "lib/smartcard/gp/des.rb", "lib/smartcard/gp/gp_card_mixin.rb", "lib/smartcard/iso/auto_configurator.rb", "lib/smartcard/iso/iso_card_mixin.rb", "lib/smartcard/iso/jcop_remote_protocol.rb", "lib/smartcard/iso/jcop_remote_server.rb", "lib/smartcard/iso/jcop_remote_transport.rb", "lib/smartcard/iso/pcsc_transport.rb", "lib/smartcard/iso/transport.rb", "lib/smartcard/pcsc/pcsc_exception.rb"]
|
14
|
-
s.files = ["BUILD", "CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "ext/smartcard_pcsc/extconf.rb", "ext/smartcard_pcsc/pcsc.h", "ext/smartcard_pcsc/pcsc_card.c", "ext/smartcard_pcsc/pcsc_constants.c", "ext/smartcard_pcsc/pcsc_context.c", "ext/smartcard_pcsc/pcsc_exception.c", "ext/smartcard_pcsc/pcsc_io_request.c", "ext/smartcard_pcsc/pcsc_main.c", "ext/smartcard_pcsc/pcsc_multi_strings.c", "ext/smartcard_pcsc/pcsc_namespace.c", "ext/smartcard_pcsc/pcsc_reader_states.c", "ext/smartcard_pcsc/pcsc_surrogate_reader.h", "ext/smartcard_pcsc/pcsc_surrogate_wintypes.h", "lib/smartcard.rb", "lib/smartcard/gp/asn1_ber.rb", "lib/smartcard/gp/cap_loader.rb", "lib/smartcard/gp/des.rb", "lib/smartcard/gp/gp_card_mixin.rb", "lib/smartcard/iso/auto_configurator.rb", "lib/smartcard/iso/iso_card_mixin.rb", "lib/smartcard/iso/jcop_remote_protocol.rb", "lib/smartcard/iso/jcop_remote_server.rb", "lib/smartcard/iso/jcop_remote_transport.rb", "lib/smartcard/iso/pcsc_transport.rb", "lib/smartcard/iso/transport.rb", "lib/smartcard/pcsc/pcsc_exception.rb", "test/gp/asn1_ber_test.rb", "test/gp/cap_loader_test.rb", "test/gp/des_test.rb", "test/gp/gp_card_mixin_test.rb", "test/gp/hello.apdu", "test/gp/hello.cap", "test/iso/auto_configurator_test.rb", "test/iso/iso_card_mixin_test.rb", "test/iso/jcop_remote_test.rb", "test/pcsc/containers_test.rb", "test/pcsc/smoke_test.rb", "tests/ts_pcsc_ext.rb", "
|
13
|
+
s.extra_rdoc_files = ["BUILD", "CHANGELOG", "LICENSE", "README", "ext/smartcard_pcsc/extconf.rb", "ext/smartcard_pcsc/pcsc.h", "ext/smartcard_pcsc/pcsc_card.c", "ext/smartcard_pcsc/pcsc_constants.c", "ext/smartcard_pcsc/pcsc_context.c", "ext/smartcard_pcsc/pcsc_exception.c", "ext/smartcard_pcsc/pcsc_io_request.c", "ext/smartcard_pcsc/pcsc_main.c", "ext/smartcard_pcsc/pcsc_multi_strings.c", "ext/smartcard_pcsc/pcsc_namespace.c", "ext/smartcard_pcsc/pcsc_reader_states.c", "ext/smartcard_pcsc/pcsc_surrogate_reader.h", "ext/smartcard_pcsc/pcsc_surrogate_wintypes.h", "lib/smartcard.rb", "lib/smartcard/gp/asn1_ber.rb", "lib/smartcard/gp/cap_loader.rb", "lib/smartcard/gp/des.rb", "lib/smartcard/gp/gp_card_mixin.rb", "lib/smartcard/iso/apdu_error.rb", "lib/smartcard/iso/auto_configurator.rb", "lib/smartcard/iso/iso_card_mixin.rb", "lib/smartcard/iso/jcop_remote_protocol.rb", "lib/smartcard/iso/jcop_remote_server.rb", "lib/smartcard/iso/jcop_remote_transport.rb", "lib/smartcard/iso/pcsc_transport.rb", "lib/smartcard/iso/transport.rb", "lib/smartcard/pcsc/pcsc_exception.rb"]
|
14
|
+
s.files = ["BUILD", "CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "ext/smartcard_pcsc/extconf.rb", "ext/smartcard_pcsc/pcsc.h", "ext/smartcard_pcsc/pcsc_card.c", "ext/smartcard_pcsc/pcsc_constants.c", "ext/smartcard_pcsc/pcsc_context.c", "ext/smartcard_pcsc/pcsc_exception.c", "ext/smartcard_pcsc/pcsc_io_request.c", "ext/smartcard_pcsc/pcsc_main.c", "ext/smartcard_pcsc/pcsc_multi_strings.c", "ext/smartcard_pcsc/pcsc_namespace.c", "ext/smartcard_pcsc/pcsc_reader_states.c", "ext/smartcard_pcsc/pcsc_surrogate_reader.h", "ext/smartcard_pcsc/pcsc_surrogate_wintypes.h", "lib/smartcard.rb", "lib/smartcard/gp/asn1_ber.rb", "lib/smartcard/gp/cap_loader.rb", "lib/smartcard/gp/des.rb", "lib/smartcard/gp/gp_card_mixin.rb", "lib/smartcard/iso/apdu_error.rb", "lib/smartcard/iso/auto_configurator.rb", "lib/smartcard/iso/iso_card_mixin.rb", "lib/smartcard/iso/jcop_remote_protocol.rb", "lib/smartcard/iso/jcop_remote_server.rb", "lib/smartcard/iso/jcop_remote_transport.rb", "lib/smartcard/iso/pcsc_transport.rb", "lib/smartcard/iso/transport.rb", "lib/smartcard/pcsc/pcsc_exception.rb", "smartcard.gemspec", "test/gp/asn1_ber_test.rb", "test/gp/cap_loader_test.rb", "test/gp/des_test.rb", "test/gp/gp_card_mixin_test.rb", "test/gp/hello.apdu", "test/gp/hello.cap", "test/iso/auto_configurator_test.rb", "test/iso/iso_card_mixin_test.rb", "test/iso/iso_exception_test.rb", "test/iso/jcop_remote_test.rb", "test/pcsc/containers_test.rb", "test/pcsc/smoke_test.rb", "tests/ts_pcsc_ext.rb", "lib/smartcard/pcsc.so"]
|
15
15
|
s.homepage = %q{http://www.costan.us/smartcard}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Smartcard", "--main", "README"]
|
17
17
|
s.require_paths = ["lib", "ext"]
|
18
18
|
s.rubyforge_project = %q{smartcard}
|
19
19
|
s.rubygems_version = %q{1.3.5}
|
20
20
|
s.summary = %q{Interface with ISO 7816 smart cards.}
|
21
|
-
s.test_files = ["test/gp/asn1_ber_test.rb", "test/gp/cap_loader_test.rb", "test/gp/des_test.rb", "test/gp/gp_card_mixin_test.rb", "test/iso/auto_configurator_test.rb", "test/iso/iso_card_mixin_test.rb", "test/iso/jcop_remote_test.rb", "test/pcsc/containers_test.rb", "test/pcsc/smoke_test.rb"]
|
21
|
+
s.test_files = ["test/gp/asn1_ber_test.rb", "test/gp/cap_loader_test.rb", "test/gp/des_test.rb", "test/gp/gp_card_mixin_test.rb", "test/iso/auto_configurator_test.rb", "test/iso/iso_card_mixin_test.rb", "test/iso/iso_exception_test.rb", "test/iso/jcop_remote_test.rb", "test/pcsc/containers_test.rb", "test/pcsc/smoke_test.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -26,10 +26,19 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.1"])
|
29
|
+
s.add_runtime_dependency(%q<zerg_support>, [">= 0.1.5"])
|
30
|
+
s.add_development_dependency(%q<echoe>, [">= 3.2"])
|
31
|
+
s.add_development_dependency(%q<flexmock>, [">= 0.8.6"])
|
29
32
|
else
|
30
33
|
s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
|
34
|
+
s.add_dependency(%q<zerg_support>, [">= 0.1.5"])
|
35
|
+
s.add_dependency(%q<echoe>, [">= 3.2"])
|
36
|
+
s.add_dependency(%q<flexmock>, [">= 0.8.6"])
|
31
37
|
end
|
32
38
|
else
|
33
39
|
s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
|
40
|
+
s.add_dependency(%q<zerg_support>, [">= 0.1.5"])
|
41
|
+
s.add_dependency(%q<echoe>, [">= 3.2"])
|
42
|
+
s.add_dependency(%q<flexmock>, [">= 0.8.6"])
|
34
43
|
end
|
35
44
|
end
|
@@ -89,8 +89,15 @@ class IsoCardMixinTest < Test::Unit::TestCase
|
|
89
89
|
|
90
90
|
def test_iso_apdu_bang
|
91
91
|
assert_equal [0x67, 0x31], win_mock.iso_apdu!(win_apdu)
|
92
|
-
assert_raise(
|
92
|
+
assert_raise(Smartcard::Iso::ApduError) do
|
93
93
|
lose_mock.iso_apdu!(lose_apdu)
|
94
94
|
end
|
95
|
+
|
96
|
+
begin
|
97
|
+
lose_mock.iso_apdu! lose_apdu
|
98
|
+
rescue Smartcard::Iso::ApduError => e
|
99
|
+
assert_equal [], e.data, 'APDU data in raised error'
|
100
|
+
assert_equal 0x8631, e.status, 'APDU error status in raised error'
|
101
|
+
end
|
95
102
|
end
|
96
103
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Author:: Victor Costan
|
2
|
+
# Copyright:: Copyright (C) 2008 Massachusetts Institute of Technology
|
3
|
+
# License:: MIT
|
4
|
+
|
5
|
+
require 'smartcard'
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'flexmock/test_unit'
|
11
|
+
|
12
|
+
|
13
|
+
class ApduErrorTest < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@response = { :data => [0x31, 0x41, 0x59], :status => 0x6A88 }
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_raise
|
19
|
+
assert_raise Smartcard::Iso::ApduError do
|
20
|
+
raise Smartcard::Iso::ApduError, @response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_contents
|
25
|
+
begin
|
26
|
+
raise Smartcard::Iso::ApduError, @response
|
27
|
+
rescue Smartcard::Iso::ApduError => e
|
28
|
+
assert_equal @response[:status], e.status, 'Error status attribute'
|
29
|
+
assert_equal @response[:data], e.data, 'APDU data attribute'
|
30
|
+
golden_message =
|
31
|
+
'ISO-7816 response APDU has error status 0x6a88 - 31 41 59'
|
32
|
+
assert_equal golden_message, e.message, 'Exception message'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
IsoCardMixin = Smartcard::Iso::IsoCardMixin
|
36
|
+
end
|
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.9
|
5
5
|
platform: x86-mswin32-60
|
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-11 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,36 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.9.1
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: zerg_support
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.5
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: echoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "3.2"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: flexmock
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.6
|
54
|
+
version:
|
25
55
|
description: Interface with ISO 7816 smart cards.
|
26
56
|
email: victor@costan.us
|
27
57
|
executables: []
|
@@ -51,6 +81,7 @@ extra_rdoc_files:
|
|
51
81
|
- lib/smartcard/gp/cap_loader.rb
|
52
82
|
- lib/smartcard/gp/des.rb
|
53
83
|
- lib/smartcard/gp/gp_card_mixin.rb
|
84
|
+
- lib/smartcard/iso/apdu_error.rb
|
54
85
|
- lib/smartcard/iso/auto_configurator.rb
|
55
86
|
- lib/smartcard/iso/iso_card_mixin.rb
|
56
87
|
- lib/smartcard/iso/jcop_remote_protocol.rb
|
@@ -84,6 +115,7 @@ files:
|
|
84
115
|
- lib/smartcard/gp/cap_loader.rb
|
85
116
|
- lib/smartcard/gp/des.rb
|
86
117
|
- lib/smartcard/gp/gp_card_mixin.rb
|
118
|
+
- lib/smartcard/iso/apdu_error.rb
|
87
119
|
- lib/smartcard/iso/auto_configurator.rb
|
88
120
|
- lib/smartcard/iso/iso_card_mixin.rb
|
89
121
|
- lib/smartcard/iso/jcop_remote_protocol.rb
|
@@ -92,6 +124,7 @@ files:
|
|
92
124
|
- lib/smartcard/iso/pcsc_transport.rb
|
93
125
|
- lib/smartcard/iso/transport.rb
|
94
126
|
- lib/smartcard/pcsc/pcsc_exception.rb
|
127
|
+
- smartcard.gemspec
|
95
128
|
- test/gp/asn1_ber_test.rb
|
96
129
|
- test/gp/cap_loader_test.rb
|
97
130
|
- test/gp/des_test.rb
|
@@ -100,11 +133,11 @@ files:
|
|
100
133
|
- test/gp/hello.cap
|
101
134
|
- test/iso/auto_configurator_test.rb
|
102
135
|
- test/iso/iso_card_mixin_test.rb
|
136
|
+
- test/iso/iso_exception_test.rb
|
103
137
|
- test/iso/jcop_remote_test.rb
|
104
138
|
- test/pcsc/containers_test.rb
|
105
139
|
- test/pcsc/smoke_test.rb
|
106
140
|
- tests/ts_pcsc_ext.rb
|
107
|
-
- smartcard.gemspec
|
108
141
|
- lib/smartcard/pcsc.so
|
109
142
|
has_rdoc: true
|
110
143
|
homepage: http://www.costan.us/smartcard
|
@@ -147,6 +180,7 @@ test_files:
|
|
147
180
|
- test/gp/gp_card_mixin_test.rb
|
148
181
|
- test/iso/auto_configurator_test.rb
|
149
182
|
- test/iso/iso_card_mixin_test.rb
|
183
|
+
- test/iso/iso_exception_test.rb
|
150
184
|
- test/iso/jcop_remote_test.rb
|
151
185
|
- test/pcsc/containers_test.rb
|
152
186
|
- test/pcsc/smoke_test.rb
|