costan-tem_ruby 0.11 → 0.11.1

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.11.1. Added cmp (synonim for sub) to the ISA definition.
2
+
1
3
  v0.11. Procedure calls (fw 1.11) and improved TEM exception information dump.
2
4
 
3
5
  v0.10.3. Fixed benchmarking via the tem_bench binary.
@@ -5,6 +5,7 @@ module Tem::Isa
5
5
  isa.instruction 0x10, :add
6
6
  # 2 ST -> 1 ST
7
7
  isa.instruction 0x11, :sub
8
+ isa.instruction 0x11, :cmp
8
9
  # 2 ST -> 1 ST
9
10
  isa.instruction 0x12, :mul
10
11
  # 2 ST -> 1 ST
@@ -111,16 +111,27 @@ class Tem::SecPack
111
111
  end
112
112
  end
113
113
 
114
- # Methods for interacting with the plaintext content of a SECpack.
115
-
116
- def set_value(label, abi_type, value)
114
+ # Methods for interacting with the plaintext content of a SECpack.
115
+
116
+ def get_bytes(label, byte_count)
117
+ expand_extra_bytes
118
+ raise "Unknown label #{label}" unless addr = @labels[label]
119
+ bytes = @body[addr, byte_count]
120
+ #trim_extra_bytes
121
+ bytes
122
+ end
123
+
124
+ def set_bytes(label, bytes)
117
125
  expand_extra_bytes
118
126
  raise "Unknown label #{label}" unless addr = @labels[label]
119
- bytes = Tem::Abi.send :"to_#{abi_type}", value
120
127
  @body[addr, bytes.length] = bytes
121
128
  #trim_extra_bytes
122
129
  end
123
130
 
131
+ def set_value(label, abi_type, value)
132
+ set_bytes label, Tem::Abi.send(:"to_#{abi_type}", value)
133
+ end
134
+
124
135
  def get_value(label, abi_type)
125
136
  expand_extra_bytes
126
137
  raise "Unknown label #{label}" unless addr = @labels[label]
@@ -2,7 +2,7 @@
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.1"
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"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
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
- s.rubygems_version = %q{1.3.3}
19
+ s.rubygems_version = %q{1.3.4}
20
20
  s.summary = %q{TEM (Trusted Execution Module) driver, written in and for ruby.}
21
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_driver.rb", "test/test_exceptions.rb", "test/transport/test_auto_configurator.rb", "test/transport/test_java_card_mixin.rb", "test/transport/test_jcop_remote.rb"]
22
22
 
@@ -42,8 +42,18 @@ module TemBoundSecpackTestCase
42
42
  assert_equal 0, bound_sec.get_value(:plain, :tem_ushort),
43
43
  'SecPack plaintext corrupted during binding'
44
44
 
45
- bound_sec.set_value :mess_place, :tem_ubyte,
46
- bound_sec.get_value(:mess_place, :tem_ubyte) + 1
45
+ # HACK: cheating knowing that yaml_roundtrip will be false and true to
46
+ # test both set_value/get_value and set_bytes/get_bytes
47
+ if yaml_roundtrip
48
+ bound_sec.set_value :mess_place, :tem_ubyte,
49
+ bound_sec.get_value(:mess_place, :tem_ubyte) + 1
50
+ else
51
+ bytes = bound_sec.get_bytes(:mess_place, 4)
52
+ bytes[0] += 1
53
+ assert_equal 4, bytes.length, "get_bytes didn't find 4 bytes to mess with"
54
+ bound_sec.set_bytes :mess_place, bytes
55
+ end
56
+
47
57
  assert_raise(RuntimeError, "secpack validation isn't working") do
48
58
  @tem.execute bound_sec
49
59
  end
@@ -14,7 +14,7 @@ class TemBranchingTest < TemTestCase
14
14
  s.dupn :n => 1
15
15
  s.outb
16
16
  s.ldbc 1
17
- s.sub
17
+ s.cmp
18
18
  s.dupn :n=> 1
19
19
  s.jae :to => :test_loop
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: costan-tem_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.11"
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan