tem_ruby 0.11.5 → 0.11.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +10 -5
- data/Rakefile +1 -1
- data/bin/tem_stat +6 -1
- data/bin/tem_upload_fw +31 -0
- data/lib/tem/firmware/tc.cap +0 -0
- data/lib/tem/firmware/uploader.rb +49 -0
- data/lib/tem_ruby.rb +2 -0
- data/tem_ruby.gemspec +8 -8
- data/test/firmware/test_uploader.rb +27 -0
- metadata +19 -10
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
LICENSE
|
3
|
+
Manifest
|
4
|
+
README
|
5
|
+
Rakefile
|
1
6
|
bin/tem_bench
|
2
7
|
bin/tem_ca
|
3
8
|
bin/tem_irb
|
4
9
|
bin/tem_proxy
|
5
10
|
bin/tem_stat
|
6
|
-
|
11
|
+
bin/tem_upload_fw
|
7
12
|
dev_ca/ca_cert.cer
|
8
13
|
dev_ca/ca_cert.pem
|
9
14
|
dev_ca/ca_key.pem
|
@@ -31,6 +36,8 @@ lib/tem/definitions/abi.rb
|
|
31
36
|
lib/tem/definitions/assembler.rb
|
32
37
|
lib/tem/definitions/isa.rb
|
33
38
|
lib/tem/ecert.rb
|
39
|
+
lib/tem/firmware/tc.cap
|
40
|
+
lib/tem/firmware/uploader.rb
|
34
41
|
lib/tem/hive.rb
|
35
42
|
lib/tem/keys/asymmetric.rb
|
36
43
|
lib/tem/keys/key.rb
|
@@ -41,12 +48,10 @@ lib/tem/secpack.rb
|
|
41
48
|
lib/tem/tem.rb
|
42
49
|
lib/tem/toolkit.rb
|
43
50
|
lib/tem_ruby.rb
|
44
|
-
|
45
|
-
Manifest
|
46
|
-
Rakefile
|
47
|
-
README
|
51
|
+
tem_ruby.gemspec
|
48
52
|
test/_test_cert.rb
|
49
53
|
test/builders/test_abi_builder.rb
|
54
|
+
test/firmware/test_uploader.rb
|
50
55
|
test/tem_test_case.rb
|
51
56
|
test/tem_unit/test_tem_alu.rb
|
52
57
|
test/tem_unit/test_tem_bound_secpack.rb
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ Echoe.new('tem_ruby') do |p|
|
|
10
10
|
p.email = 'victor@costan.us'
|
11
11
|
p.summary = 'TEM (Trusted Execution Module) driver, written in and for ruby.'
|
12
12
|
p.url = 'http://tem.rubyforge.org'
|
13
|
-
p.dependencies = ['smartcard >=0.4.
|
13
|
+
p.dependencies = ['smartcard >=0.4.6']
|
14
14
|
|
15
15
|
p.need_tar_gz = !Gem.win_platform?
|
16
16
|
p.need_zip = !Gem.win_platform?
|
data/bin/tem_stat
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Stats the TEM's firmware version, buffers, and keys, and dumps them to stdout.
|
4
|
+
#
|
5
|
+
# Author:: Victor Costan
|
6
|
+
# Copyright:: Copyright (C) 2007 Massachusetts Institute of Technology
|
7
|
+
# License:: MIT
|
2
8
|
|
3
|
-
# spews information about the TEM
|
4
9
|
require 'rubygems'
|
5
10
|
require 'tem_ruby'
|
6
11
|
require 'pp'
|
data/bin/tem_upload_fw
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Uploads TEM firmware to a smartcard.
|
4
|
+
#
|
5
|
+
# Author:: Victor Costan
|
6
|
+
# Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
|
7
|
+
# License:: MIT
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'smartcard'
|
11
|
+
require 'tem_ruby'
|
12
|
+
require 'pp'
|
13
|
+
|
14
|
+
transport = Smartcard::Iso::auto_transport
|
15
|
+
print "Connected to smart-card using #{transport.inspect}\n"
|
16
|
+
begin
|
17
|
+
Tem::Firmware::Uploader.upload_cap transport
|
18
|
+
rescue Exception => e
|
19
|
+
print "Could not upload TEM firmware.\n"
|
20
|
+
print "#{e.class.name}: #{e}\n#{e.backtrace.join("\n")}\n"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
tem = Tem::Session.new transport
|
25
|
+
begin
|
26
|
+
tem.activate
|
27
|
+
pp tem.emit
|
28
|
+
rescue Exception => e
|
29
|
+
print "Could not activate and emit TEM. Firmware might be broken.\n"
|
30
|
+
print "#{e.class.name}: #{e}\n#{e.backtrace.join("\n")}\n"
|
31
|
+
end
|
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# TEM firmware installation and update.
|
2
|
+
#
|
3
|
+
# Author:: Victor Costan
|
4
|
+
# Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
|
5
|
+
# License:: MIT
|
6
|
+
|
7
|
+
# :nodoc: namespace
|
8
|
+
module Tem::Firmware
|
9
|
+
|
10
|
+
|
11
|
+
# Installs and updates
|
12
|
+
module Uploader
|
13
|
+
# Path to the JavaCard CAP file containing the firmware.
|
14
|
+
#
|
15
|
+
# CAP updates can be downloaded directly from the URL below. However, it's
|
16
|
+
# recommended to obtain them by installing a new version of the tem_ruby gem.
|
17
|
+
# The gem is only tested with the firmware bundled with it.
|
18
|
+
#
|
19
|
+
# Update URL: http://rubyforge.org/frs/?group_id=6431
|
20
|
+
def self.cap_file
|
21
|
+
File.join File.dirname(__FILE__), 'tc.cap'
|
22
|
+
end
|
23
|
+
|
24
|
+
@applet_aid = nil
|
25
|
+
# The AID for the firmware's JavaCard applet.
|
26
|
+
def self.applet_aid
|
27
|
+
# Cache expensive operation of unzipping the CAP file.
|
28
|
+
return @applet_aid if @applet_aid
|
29
|
+
|
30
|
+
cap_data = Smartcard::Gp::CapLoader.load_cap cap_file
|
31
|
+
@applet_aid = Smartcard::Gp::CapLoader.parse_applets(cap_data).first[:aid]
|
32
|
+
end
|
33
|
+
|
34
|
+
# Uploads the firmware CAP file, removing any old version.
|
35
|
+
#
|
36
|
+
# Note that uploading a new version wipes the firmware's data completely, so
|
37
|
+
# the TEM will have to be re-emitted, and will have a different endorsement
|
38
|
+
# key.
|
39
|
+
def self.upload_cap(transport)
|
40
|
+
class <<transport
|
41
|
+
include Smartcard::Gp::GpCardMixin
|
42
|
+
end
|
43
|
+
transport.install_applet cap_file
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end # module Tem::Firmware::Uploader
|
48
|
+
|
49
|
+
end # namespace Tem::Firmware
|
data/lib/tem_ruby.rb
CHANGED
data/tem_ruby.gemspec
CHANGED
@@ -2,34 +2,34 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{tem_ruby}
|
5
|
-
s.version = "0.11.
|
5
|
+
s.version = "0.11.6"
|
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
9
|
s.date = %q{2009-11-01}
|
10
10
|
s.description = %q{TEM (Trusted Execution Module) driver, written in and for ruby.}
|
11
11
|
s.email = %q{victor@costan.us}
|
12
|
-
s.executables = ["tem_bench", "tem_ca", "tem_irb", "tem_proxy", "tem_stat"]
|
13
|
-
s.extra_rdoc_files = ["bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "
|
14
|
-
s.files = ["bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "
|
12
|
+
s.executables = ["tem_bench", "tem_ca", "tem_irb", "tem_proxy", "tem_stat", "tem_upload_fw"]
|
13
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "bin/tem_upload_fw", "lib/tem/_cert.rb", "lib/tem/apdus/buffers.rb", "lib/tem/apdus/keys.rb", "lib/tem/apdus/lifecycle.rb", "lib/tem/apdus/tag.rb", "lib/tem/auto_conf.rb", "lib/tem/benchmarks/benchmarks.rb", "lib/tem/benchmarks/blank_bound_secpack.rb", "lib/tem/benchmarks/blank_sec.rb", "lib/tem/benchmarks/devchip_decrypt.rb", "lib/tem/benchmarks/post_buffer.rb", "lib/tem/benchmarks/simple_apdu.rb", "lib/tem/benchmarks/vm_perf.rb", "lib/tem/benchmarks/vm_perf_bound.rb", "lib/tem/builders/abi.rb", "lib/tem/builders/assembler.rb", "lib/tem/builders/crypto.rb", "lib/tem/builders/isa.rb", "lib/tem/ca.rb", "lib/tem/definitions/abi.rb", "lib/tem/definitions/assembler.rb", "lib/tem/definitions/isa.rb", "lib/tem/ecert.rb", "lib/tem/firmware/tc.cap", "lib/tem/firmware/uploader.rb", "lib/tem/hive.rb", "lib/tem/keys/asymmetric.rb", "lib/tem/keys/key.rb", "lib/tem/keys/symmetric.rb", "lib/tem/sec_exec_error.rb", "lib/tem/seclosures.rb", "lib/tem/secpack.rb", "lib/tem/tem.rb", "lib/tem/toolkit.rb", "lib/tem_ruby.rb"]
|
14
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "bin/tem_upload_fw", "dev_ca/ca_cert.cer", "dev_ca/ca_cert.pem", "dev_ca/ca_key.pem", "dev_ca/config.yml", "lib/tem/_cert.rb", "lib/tem/apdus/buffers.rb", "lib/tem/apdus/keys.rb", "lib/tem/apdus/lifecycle.rb", "lib/tem/apdus/tag.rb", "lib/tem/auto_conf.rb", "lib/tem/benchmarks/benchmarks.rb", "lib/tem/benchmarks/blank_bound_secpack.rb", "lib/tem/benchmarks/blank_sec.rb", "lib/tem/benchmarks/devchip_decrypt.rb", "lib/tem/benchmarks/post_buffer.rb", "lib/tem/benchmarks/simple_apdu.rb", "lib/tem/benchmarks/vm_perf.rb", "lib/tem/benchmarks/vm_perf_bound.rb", "lib/tem/builders/abi.rb", "lib/tem/builders/assembler.rb", "lib/tem/builders/crypto.rb", "lib/tem/builders/isa.rb", "lib/tem/ca.rb", "lib/tem/definitions/abi.rb", "lib/tem/definitions/assembler.rb", "lib/tem/definitions/isa.rb", "lib/tem/ecert.rb", "lib/tem/firmware/tc.cap", "lib/tem/firmware/uploader.rb", "lib/tem/hive.rb", "lib/tem/keys/asymmetric.rb", "lib/tem/keys/key.rb", "lib/tem/keys/symmetric.rb", "lib/tem/sec_exec_error.rb", "lib/tem/seclosures.rb", "lib/tem/secpack.rb", "lib/tem/tem.rb", "lib/tem/toolkit.rb", "lib/tem_ruby.rb", "tem_ruby.gemspec", "test/_test_cert.rb", "test/builders/test_abi_builder.rb", "test/firmware/test_uploader.rb", "test/tem_test_case.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"]
|
15
15
|
s.homepage = %q{http://tem.rubyforge.org}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tem_ruby", "--main", "README"]
|
17
17
|
s.require_paths = ["lib"]
|
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/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/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"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
25
|
s.specification_version = 3
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_runtime_dependency(%q<smartcard>, [">= 0.4.
|
28
|
+
s.add_runtime_dependency(%q<smartcard>, [">= 0.4.6"])
|
29
29
|
else
|
30
|
-
s.add_dependency(%q<smartcard>, [">= 0.4.
|
30
|
+
s.add_dependency(%q<smartcard>, [">= 0.4.6"])
|
31
31
|
end
|
32
32
|
else
|
33
|
-
s.add_dependency(%q<smartcard>, [">= 0.4.
|
33
|
+
s.add_dependency(%q<smartcard>, [">= 0.4.6"])
|
34
34
|
end
|
35
35
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'tem_ruby'
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
|
6
|
+
class UploaderTest < Test::Unit::TestCase
|
7
|
+
Uploader = Tem::Firmware::Uploader
|
8
|
+
|
9
|
+
def test_cap_file
|
10
|
+
file = Uploader.cap_file
|
11
|
+
assert file, "Cap_file returned a blank"
|
12
|
+
|
13
|
+
assert Smartcard::Gp::CapLoader.load_cap(file), "Couldn't load CAP file"
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_applet_aid
|
17
|
+
assert_equal [0x19, 0x83, 0x12, 0x29, 0x10, 0xBA, 0xBE], Uploader.applet_aid
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_upload
|
21
|
+
transport = Smartcard::Iso.auto_transport
|
22
|
+
Uploader.upload_cap transport
|
23
|
+
|
24
|
+
tem = Tem::Session.new transport
|
25
|
+
assert tem.activate, "Activation failed (old TEM firmware was not replaced)"
|
26
|
+
end
|
27
|
+
end
|
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.
|
4
|
+
version: 0.11.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.4.
|
23
|
+
version: 0.4.6
|
24
24
|
version:
|
25
25
|
description: TEM (Trusted Execution Module) driver, written in and for ruby.
|
26
26
|
email: victor@costan.us
|
@@ -30,15 +30,19 @@ executables:
|
|
30
30
|
- tem_irb
|
31
31
|
- tem_proxy
|
32
32
|
- tem_stat
|
33
|
+
- tem_upload_fw
|
33
34
|
extensions: []
|
34
35
|
|
35
36
|
extra_rdoc_files:
|
37
|
+
- CHANGELOG
|
38
|
+
- LICENSE
|
39
|
+
- README
|
36
40
|
- bin/tem_bench
|
37
41
|
- bin/tem_ca
|
38
42
|
- bin/tem_irb
|
39
43
|
- bin/tem_proxy
|
40
44
|
- bin/tem_stat
|
41
|
-
-
|
45
|
+
- bin/tem_upload_fw
|
42
46
|
- lib/tem/_cert.rb
|
43
47
|
- lib/tem/apdus/buffers.rb
|
44
48
|
- lib/tem/apdus/keys.rb
|
@@ -62,6 +66,8 @@ extra_rdoc_files:
|
|
62
66
|
- lib/tem/definitions/assembler.rb
|
63
67
|
- lib/tem/definitions/isa.rb
|
64
68
|
- lib/tem/ecert.rb
|
69
|
+
- lib/tem/firmware/tc.cap
|
70
|
+
- lib/tem/firmware/uploader.rb
|
65
71
|
- lib/tem/hive.rb
|
66
72
|
- lib/tem/keys/asymmetric.rb
|
67
73
|
- lib/tem/keys/key.rb
|
@@ -72,15 +78,18 @@ extra_rdoc_files:
|
|
72
78
|
- lib/tem/tem.rb
|
73
79
|
- lib/tem/toolkit.rb
|
74
80
|
- lib/tem_ruby.rb
|
81
|
+
files:
|
82
|
+
- CHANGELOG
|
75
83
|
- LICENSE
|
84
|
+
- Manifest
|
76
85
|
- README
|
77
|
-
|
86
|
+
- Rakefile
|
78
87
|
- bin/tem_bench
|
79
88
|
- bin/tem_ca
|
80
89
|
- bin/tem_irb
|
81
90
|
- bin/tem_proxy
|
82
91
|
- bin/tem_stat
|
83
|
-
-
|
92
|
+
- bin/tem_upload_fw
|
84
93
|
- dev_ca/ca_cert.cer
|
85
94
|
- dev_ca/ca_cert.pem
|
86
95
|
- dev_ca/ca_key.pem
|
@@ -108,6 +117,8 @@ files:
|
|
108
117
|
- lib/tem/definitions/assembler.rb
|
109
118
|
- lib/tem/definitions/isa.rb
|
110
119
|
- lib/tem/ecert.rb
|
120
|
+
- lib/tem/firmware/tc.cap
|
121
|
+
- lib/tem/firmware/uploader.rb
|
111
122
|
- lib/tem/hive.rb
|
112
123
|
- lib/tem/keys/asymmetric.rb
|
113
124
|
- lib/tem/keys/key.rb
|
@@ -118,12 +129,10 @@ files:
|
|
118
129
|
- lib/tem/tem.rb
|
119
130
|
- lib/tem/toolkit.rb
|
120
131
|
- lib/tem_ruby.rb
|
121
|
-
-
|
122
|
-
- Manifest
|
123
|
-
- Rakefile
|
124
|
-
- README
|
132
|
+
- tem_ruby.gemspec
|
125
133
|
- test/_test_cert.rb
|
126
134
|
- test/builders/test_abi_builder.rb
|
135
|
+
- test/firmware/test_uploader.rb
|
127
136
|
- test/tem_test_case.rb
|
128
137
|
- test/tem_unit/test_tem_alu.rb
|
129
138
|
- test/tem_unit/test_tem_bound_secpack.rb
|
@@ -140,7 +149,6 @@ files:
|
|
140
149
|
- test/test_auto_conf.rb
|
141
150
|
- test/test_driver.rb
|
142
151
|
- test/test_exceptions.rb
|
143
|
-
- tem_ruby.gemspec
|
144
152
|
has_rdoc: true
|
145
153
|
homepage: http://tem.rubyforge.org
|
146
154
|
licenses: []
|
@@ -176,6 +184,7 @@ specification_version: 3
|
|
176
184
|
summary: TEM (Trusted Execution Module) driver, written in and for ruby.
|
177
185
|
test_files:
|
178
186
|
- test/builders/test_abi_builder.rb
|
187
|
+
- test/firmware/test_uploader.rb
|
179
188
|
- test/tem_unit/test_tem_alu.rb
|
180
189
|
- test/tem_unit/test_tem_bound_secpack.rb
|
181
190
|
- test/tem_unit/test_tem_branching.rb
|