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 CHANGED
@@ -1,3 +1,5 @@
1
+ v0.12.0. Direct version checking in the TEM (fw 1.12) and firmware upload files.
2
+
1
3
  v0.11.7. Fixed edge case in SEClosure execution exception handling.
2
4
 
3
5
  v0.11.6. Firmware uploading logic, and the new tem_upload_fw binary.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ gem 'echoe'
3
3
  require 'echoe'
4
4
 
5
5
  Echoe.new('tem_ruby') do |p|
6
- p.project = 'tem' # rubyforge project
6
+ p.project = 'tem' # rubyforge project
7
7
  p.docs_host = "costan@rubyforge.org:/var/www/gforge-projects/tem/rdoc/"
8
8
 
9
9
  p.author = 'Victor Costan'
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.tk_firmware_ver
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 emitted?\n"
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
 
@@ -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
- :data => [to_tem_short(offset),
31
- to_tem_short(length)].flatten
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[2..-1].pack('C*')
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).
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
@@ -1,9 +1,4 @@
1
1
  module Tem::Toolkit
2
- def tk_firmware_ver
3
- tag = get_tag
4
- return { :major => read_tem_ubyte(tag, 0), :minor => read_tem_ubyte(tag, 1) }
5
- end
6
-
7
2
  def tk_gen_key(type = :asymmetric, authz = nil)
8
3
  gen_sec = assemble do |s|
9
4
  s.ldbc authz.nil? ? 24 : 4
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.11.7"
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-01}
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/builders/test_abi_builder.rb", "test/firmware/test_uploader.rb", "test/tem_unit/test_tem_alu.rb", "test/tem_unit/test_tem_bound_secpack.rb", "test/tem_unit/test_tem_branching.rb", "test/tem_unit/test_tem_crypto_asymmetric.rb", "test/tem_unit/test_tem_crypto_hash.rb", "test/tem_unit/test_tem_crypto_pstore.rb", "test/tem_unit/test_tem_crypto_random.rb", "test/tem_unit/test_tem_emit.rb", "test/tem_unit/test_tem_memory.rb", "test/tem_unit/test_tem_memory_compare.rb", "test/tem_unit/test_tem_output.rb", "test/tem_unit/test_tem_yaml_secpack.rb", "test/test_auto_conf.rb", "test/test_driver.rb", "test/test_exceptions.rb"]
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(RuntimeError, 'tag returned before being set') { @tem.get_tag }
50
-
51
- @tem.set_tag(garbage)
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
- fwver = @tem.tk_firmware_ver
55
- assert fwver[:major].kind_of?(Numeric) && fwver[:minor].kind_of?(Numeric), 'error in tag-backed firmware version'
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.11.7
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-01 01:00:00 -04:00
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/builders/test_abi_builder.rb
186
+ - test/test_driver.rb
187
187
  - test/firmware/test_uploader.rb
188
- - test/tem_unit/test_tem_alu.rb
189
- - test/tem_unit/test_tem_bound_secpack.rb
190
- - test/tem_unit/test_tem_branching.rb
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/test_tem_crypto_pstore.rb
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/test_tem_yaml_secpack.rb
200
- - test/test_auto_conf.rb
201
- - test/test_driver.rb
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