tem_ruby 0.11.7 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Rakefile +1 -1
- data/bin/tem_stat +2 -2
- data/lib/tem/apdus/lifecycle.rb +15 -0
- data/lib/tem/apdus/tag.rb +2 -2
- data/lib/tem/ecert.rb +1 -1
- data/lib/tem/firmware/tc.cap +0 -0
- data/lib/tem/firmware/uploader.rb +14 -3
- data/lib/tem/toolkit.rb +0 -5
- data/tem_ruby.gemspec +3 -3
- data/test/firmware/test_uploader.rb +6 -0
- data/test/test_driver.rb +12 -6
- metadata +13 -13
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/bin/tem_stat
CHANGED
@@ -14,10 +14,10 @@ Tem.auto_conf
|
|
14
14
|
|
15
15
|
print "Connected to TEM using #{$tem.transport.inspect}\n"
|
16
16
|
begin
|
17
|
-
fw_ver = $tem.
|
17
|
+
fw_ver = $tem.fw_version
|
18
18
|
print "TEM firmware version: #{fw_ver[:major]}.#{fw_ver[:minor]}\n"
|
19
19
|
rescue Exception => e
|
20
|
-
print "Could not read TEM firmware version. Is the TEM
|
20
|
+
print "Could not read TEM firmware version. Is the TEM firmware installed?\n"
|
21
21
|
print "#{e.class.name}: #{e}\n#{e.backtrace.join("\n")}\n"
|
22
22
|
end
|
23
23
|
|
data/lib/tem/apdus/lifecycle.rb
CHANGED
@@ -15,6 +15,21 @@ module Lifecycle
|
|
15
15
|
def kill
|
16
16
|
@transport.iso_apdu(:ins => 0x11)[:status] == 0x9000
|
17
17
|
end
|
18
|
+
|
19
|
+
# The TEM firmware version.
|
20
|
+
#
|
21
|
+
# Returns a hash with the keys +:major+ and +:minor+ whose values are version
|
22
|
+
# numbers.
|
23
|
+
def fw_version
|
24
|
+
raw = @transport.iso_apdu :ins => 0x12
|
25
|
+
return { :major => 0, :minor => 1 } if raw[:status] == 0x6D00
|
26
|
+
if raw[:status] != 0x9000
|
27
|
+
Smartcard::Iso::IsoCardMixin.raise_response_exception raw
|
28
|
+
end
|
29
|
+
|
30
|
+
{ :major => read_tem_byte(raw[:data], 0),
|
31
|
+
:minor => read_tem_byte(raw[:data], 1) }
|
32
|
+
end
|
18
33
|
end
|
19
34
|
|
20
35
|
end # namespace Tem::Apdus
|
data/lib/tem/apdus/tag.rb
CHANGED
@@ -27,8 +27,8 @@ module Tag
|
|
27
27
|
buffer_id = alloc_buffer length
|
28
28
|
begin
|
29
29
|
@transport.iso_apdu! :ins => 0x32, :p1 => buffer_id,
|
30
|
-
|
31
|
-
|
30
|
+
:data => [to_tem_short(offset),
|
31
|
+
to_tem_short(length)].flatten
|
32
32
|
tag_data = read_buffer buffer_id
|
33
33
|
ensure
|
34
34
|
release_buffer buffer_id
|
data/lib/tem/ecert.rb
CHANGED
@@ -8,7 +8,7 @@ module Tem::ECert
|
|
8
8
|
|
9
9
|
# Retrieves the TEM's Endorsement Certificate.
|
10
10
|
def endorsement_cert
|
11
|
-
OpenSSL::X509::Certificate.new get_tag
|
11
|
+
OpenSSL::X509::Certificate.new get_tag.pack('C*')
|
12
12
|
end
|
13
13
|
|
14
14
|
# Retrieves the certificate of the TEM's Manfacturer (CA).
|
data/lib/tem/firmware/tc.cap
CHANGED
Binary file
|
@@ -31,6 +31,19 @@ module Uploader
|
|
31
31
|
@applet_aid = Smartcard::Gp::CapLoader.parse_applets(cap_data).first[:aid]
|
32
32
|
end
|
33
33
|
|
34
|
+
@fw_version = nil
|
35
|
+
# The firmware version in the JavaCard applet.
|
36
|
+
#
|
37
|
+
# Returns a hash with the +:major+ and +:minor+ keys indicating the version
|
38
|
+
# numbers.
|
39
|
+
def self.fw_version
|
40
|
+
return @fw_version if @fw_version
|
41
|
+
|
42
|
+
cap_data = Smartcard::Gp::CapLoader.load_cap cap_file
|
43
|
+
@fw_version =
|
44
|
+
Smartcard::Gp::CapLoader.parse_header(cap_data)[:package][:version]
|
45
|
+
end
|
46
|
+
|
34
47
|
# Uploads the firmware CAP file, removing any old version.
|
35
48
|
#
|
36
49
|
# Note that uploading a new version wipes the firmware's data completely, so
|
@@ -41,9 +54,7 @@ module Uploader
|
|
41
54
|
include Smartcard::Gp::GpCardMixin
|
42
55
|
end
|
43
56
|
transport.install_applet cap_file
|
44
|
-
end
|
45
|
-
|
46
|
-
|
57
|
+
end
|
47
58
|
end # module Tem::Firmware::Uploader
|
48
59
|
|
49
60
|
end # namespace Tem::Firmware
|
data/lib/tem/toolkit.rb
CHANGED
data/tem_ruby.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{tem_ruby}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.12.0"
|
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-10}
|
10
10
|
s.description = %q{TEM (Trusted Execution Module) driver, written in and for ruby.}
|
11
11
|
s.email = %q{victor@costan.us}
|
12
12
|
s.executables = ["tem_bench", "tem_ca", "tem_irb", "tem_proxy", "tem_stat", "tem_upload_fw"]
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.rubyforge_project = %q{tem}
|
19
19
|
s.rubygems_version = %q{1.3.5}
|
20
20
|
s.summary = %q{TEM (Trusted Execution Module) driver, written in and for ruby.}
|
21
|
-
s.test_files = ["test/
|
21
|
+
s.test_files = ["test/test_driver.rb", "test/firmware/test_uploader.rb", "test/test_auto_conf.rb", "test/builders/test_abi_builder.rb", "test/tem_unit/test_tem_emit.rb", "test/tem_unit/test_tem_crypto_asymmetric.rb", "test/tem_unit/test_tem_yaml_secpack.rb", "test/tem_unit/test_tem_alu.rb", "test/tem_unit/test_tem_crypto_hash.rb", "test/tem_unit/test_tem_bound_secpack.rb", "test/tem_unit/test_tem_memory_compare.rb", "test/tem_unit/test_tem_output.rb", "test/tem_unit/test_tem_crypto_random.rb", "test/tem_unit/test_tem_memory.rb", "test/tem_unit/test_tem_branching.rb", "test/tem_unit/test_tem_crypto_pstore.rb", "test/test_exceptions.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -17,11 +17,17 @@ class UploaderTest < Test::Unit::TestCase
|
|
17
17
|
assert_equal [0x19, 0x83, 0x12, 0x29, 0x10, 0xBA, 0xBE], Uploader.applet_aid
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_fw_version
|
21
|
+
assert_equal({:major => 1, :minor => 12}, Uploader.fw_version)
|
22
|
+
end
|
23
|
+
|
20
24
|
def test_upload
|
21
25
|
transport = Smartcard::Iso.auto_transport
|
22
26
|
Uploader.upload_cap transport
|
23
27
|
|
24
28
|
tem = Tem::Session.new transport
|
29
|
+
assert_equal Uploader.fw_version, tem.fw_version,
|
30
|
+
'TEM firmware was not updated to current version'
|
25
31
|
assert tem.activate, "Activation failed (old TEM firmware was not replaced)"
|
26
32
|
end
|
27
33
|
end
|
data/test/test_driver.rb
CHANGED
@@ -2,6 +2,13 @@ require 'test/tem_test_case.rb'
|
|
2
2
|
|
3
3
|
|
4
4
|
class DriverTest < TemTestCase
|
5
|
+
def test_version
|
6
|
+
version = @tem.fw_version
|
7
|
+
assert version[:major].kind_of?(Numeric) &&
|
8
|
+
version[:minor].kind_of?(Numeric),
|
9
|
+
'Firmware version has wrong format'
|
10
|
+
end
|
11
|
+
|
5
12
|
def test_buffers_io
|
6
13
|
garbage = (1...569).map { |i| (i * i * 217 + i * 661 + 393) % 256 }
|
7
14
|
|
@@ -46,13 +53,12 @@ class DriverTest < TemTestCase
|
|
46
53
|
def test_tag
|
47
54
|
garbage = (1...569).map { |i| (i * i * 217 + i * 661 + 393) % 256 }
|
48
55
|
|
49
|
-
assert_raise
|
50
|
-
|
51
|
-
|
52
|
-
assert_equal garbage, @tem.get_tag[2..-1], 'error in posted tag data'
|
56
|
+
assert_raise Smartcard::Iso::ApduError, 'tag returned before being set' do
|
57
|
+
@tem.get_tag
|
58
|
+
end
|
53
59
|
|
54
|
-
|
55
|
-
|
60
|
+
@tem.set_tag garbage
|
61
|
+
assert_equal garbage, @tem.get_tag, 'error in posted tag data'
|
56
62
|
end
|
57
63
|
|
58
64
|
def test_crypto
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tem_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
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-10 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -183,20 +183,20 @@ signing_key:
|
|
183
183
|
specification_version: 3
|
184
184
|
summary: TEM (Trusted Execution Module) driver, written in and for ruby.
|
185
185
|
test_files:
|
186
|
-
- test/
|
186
|
+
- test/test_driver.rb
|
187
187
|
- test/firmware/test_uploader.rb
|
188
|
-
- test/
|
189
|
-
- test/
|
190
|
-
- test/tem_unit/
|
188
|
+
- test/test_auto_conf.rb
|
189
|
+
- test/builders/test_abi_builder.rb
|
190
|
+
- test/tem_unit/test_tem_emit.rb
|
191
191
|
- test/tem_unit/test_tem_crypto_asymmetric.rb
|
192
|
+
- test/tem_unit/test_tem_yaml_secpack.rb
|
193
|
+
- test/tem_unit/test_tem_alu.rb
|
192
194
|
- test/tem_unit/test_tem_crypto_hash.rb
|
193
|
-
- test/tem_unit/
|
194
|
-
- test/tem_unit/test_tem_crypto_random.rb
|
195
|
-
- test/tem_unit/test_tem_emit.rb
|
196
|
-
- test/tem_unit/test_tem_memory.rb
|
195
|
+
- test/tem_unit/test_tem_bound_secpack.rb
|
197
196
|
- test/tem_unit/test_tem_memory_compare.rb
|
198
197
|
- test/tem_unit/test_tem_output.rb
|
199
|
-
- test/tem_unit/
|
200
|
-
- test/
|
201
|
-
- test/
|
198
|
+
- test/tem_unit/test_tem_crypto_random.rb
|
199
|
+
- test/tem_unit/test_tem_memory.rb
|
200
|
+
- test/tem_unit/test_tem_branching.rb
|
201
|
+
- test/tem_unit/test_tem_crypto_pstore.rb
|
202
202
|
- test/test_exceptions.rb
|