tem_ruby 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +11 -6
- data/lib/tem/{buffers.rb → apdus/buffers.rb} +6 -1
- data/lib/tem/{keys.rb → apdus/keys.rb} +9 -4
- data/lib/tem/{lifecycle.rb → apdus/lifecycle.rb} +6 -1
- data/lib/tem/{tag.rb → apdus/tag.rb} +6 -1
- data/lib/tem/builders/abi.rb +482 -0
- data/lib/tem/builders/crypto.rb +115 -0
- data/lib/tem/definitions/abi.rb +67 -0
- data/lib/tem/ecert.rb +1 -1
- data/lib/tem/keys/asymmetric.rb +116 -0
- data/lib/tem/keys/key.rb +48 -0
- data/lib/tem/keys/symmetric.rb +47 -0
- data/lib/tem/sec_assembler.rb +1 -2
- data/lib/tem/secpack.rb +5 -4
- data/lib/tem/tem.rb +5 -5
- data/lib/tem/toolkit.rb +2 -1
- data/lib/tem_ruby.rb +14 -6
- data/tem_ruby.gemspec +7 -11
- data/test/builders/test_abi_builder.rb +298 -0
- data/test/test_driver.rb +4 -4
- data/test/test_tem.rb +4 -3
- metadata +28 -26
- data/lib/tem/abi.rb +0 -55
- data/lib/tem/crypto_abi.rb +0 -264
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
|
4
|
+
# :nodoc: namespace
|
5
|
+
module Tem::Builders
|
6
|
+
|
7
|
+
# Builder class and namespace for the cryptography builder.
|
8
|
+
class Crypto < Abi
|
9
|
+
# Creates a builder targeting a module / class.
|
10
|
+
#
|
11
|
+
# The given parameter should be a class or module
|
12
|
+
def self.define_crypto(class_or_module) # :yields: crypto
|
13
|
+
yield new(class_or_module)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Defines the methods for handling an asymmetric (public/private) key.
|
17
|
+
#
|
18
|
+
# ssl_class should be a class in OpenSSL::PKey. privkey_abi_type and
|
19
|
+
# pubkey_abi_type should be ABI types similar to those produced by
|
20
|
+
# packed_variable_length_numbers.
|
21
|
+
#
|
22
|
+
# The following methods are defined for a type named 'name':
|
23
|
+
# * read_private_name(array, offset) -> key
|
24
|
+
# * to_private_name(key) -> array
|
25
|
+
# * private_name_class -> Class
|
26
|
+
# * read_public_name(array, offset) -> key
|
27
|
+
# * to_public_name(key) -> array
|
28
|
+
# * public_name_class -> Class
|
29
|
+
def asymmetric_key(name, ssl_class, privkey_abi_type, pubkey_abi_type,
|
30
|
+
hooks = {})
|
31
|
+
object_wrapper "private_#{name}", ssl_class, [privkey_abi_type, nil],
|
32
|
+
:read => hooks[:read_private] || hooks[:read],
|
33
|
+
:to => hooks[:to_private] || hooks[:to],
|
34
|
+
:new => hooks[:new_private] || hooks[:new] ||
|
35
|
+
lambda { |k| ssl_class.new }
|
36
|
+
object_wrapper "public_#{name}", ssl_class, [pubkey_abi_type, nil],
|
37
|
+
:read => hooks[:read_public] || hooks[:read],
|
38
|
+
:to => hooks[:to_public] || hooks[:to],
|
39
|
+
:new => hooks[:new_private] || hooks[:new] ||
|
40
|
+
lambda { |k| ssl_class.new }
|
41
|
+
end
|
42
|
+
|
43
|
+
# Defines the methods for a symmetric key.
|
44
|
+
#
|
45
|
+
# cipher_class should be a class in OpenSSL::Cipher. key_abi_type should be
|
46
|
+
# an ABI type similar to that produced by fixed_string.
|
47
|
+
#
|
48
|
+
# The following methods are defined for a type named 'name':
|
49
|
+
# * read_name(array, offset) -> object
|
50
|
+
# * to_name(object) -> array
|
51
|
+
# * name_class -> Class
|
52
|
+
def symmetric_key(name, cipher_class, cipher_name, key_abi_type, hooks = {})
|
53
|
+
object_wrapper name, cipher_class, [key_abi_type, :key],
|
54
|
+
:new => lambda { |klass|
|
55
|
+
k = klass.new cipher_name
|
56
|
+
|
57
|
+
unless k.respond_to? :key
|
58
|
+
# Some ciphers don't give back the key that they receive.
|
59
|
+
# We need to synthesize that.
|
60
|
+
class << k
|
61
|
+
def key=(new_key)
|
62
|
+
super
|
63
|
+
@_key = new_key
|
64
|
+
end
|
65
|
+
def key
|
66
|
+
@_key
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
# Defines the methods for a cryptographic hash function.
|
74
|
+
#
|
75
|
+
# digest_class should be an object similar to the classes in the Digest
|
76
|
+
# name-space. Specifically, it should implement the digest method.
|
77
|
+
#
|
78
|
+
# The following methods are defined for a type named 'name':
|
79
|
+
# * name(array | String) -> array
|
80
|
+
# * name_length -> number
|
81
|
+
# * name_digest_class -> Class
|
82
|
+
def crypto_hash(name, digest_class)
|
83
|
+
digest_length = digest_class.digest('').length
|
84
|
+
|
85
|
+
defines = Proc.new do
|
86
|
+
define_method :"#{name}" do |data|
|
87
|
+
data = data.pack 'C*' unless data.kind_of? String
|
88
|
+
digest_class.digest(data).unpack 'C*'
|
89
|
+
end
|
90
|
+
define_method(:"#{name}_digest_class") { digest_class }
|
91
|
+
define_method(:"#{name}_length") { digest_length }
|
92
|
+
end
|
93
|
+
|
94
|
+
@target.class_eval &defines
|
95
|
+
(class << @target; self; end).module_eval &defines
|
96
|
+
end
|
97
|
+
end # class Crypto
|
98
|
+
|
99
|
+
|
100
|
+
# Implementation code for the Crypto methods.
|
101
|
+
module Crypto::Impl
|
102
|
+
def self.key_from_array(array, offset, ssl_class, abi_type)
|
103
|
+
key = ssl_class.new
|
104
|
+
numbers = self.send :"read_#{abi_type}", array, offset
|
105
|
+
numbers.each { |k, v| key.send :"#{k}=", v }
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.key_to_array(key, abi_type)
|
109
|
+
components = self.send :"#{abi_type}_components"
|
110
|
+
numbers = Hash[*(components.map { |c| [c, key.send(c.to_sym) ]}.flatten)]
|
111
|
+
self.send :"to_#{abi_type}", numbers
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end # namespace Tem::Builders
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'digest/sha1'
|
3
|
+
|
4
|
+
|
5
|
+
module Tem::Abi
|
6
|
+
Tem::Builders::Abi.define_abi self do |abi|
|
7
|
+
abi.fixed_length_number :tem_byte, 1, :signed => true, :big_endian => true
|
8
|
+
abi.fixed_length_number :tem_ubyte, 1, :signed => false, :big_endian => true
|
9
|
+
abi.fixed_length_number :tem_short, 2, :signed => true, :big_endian => true
|
10
|
+
abi.fixed_length_number :tem_ushort, 2, :signed => false,
|
11
|
+
:big_endian => true
|
12
|
+
abi.fixed_length_number :tem_ps_addr, 20, :signed => false,
|
13
|
+
:big_endian => true
|
14
|
+
abi.fixed_length_number :tem_ps_value, 20, :signed => false,
|
15
|
+
:big_endian => true
|
16
|
+
|
17
|
+
abi.packed_variable_length_numbers :tem_privrsa_numbers, :tem_ushort,
|
18
|
+
[:p, :q, :dmp1, :dmq1, :iqmp], :signed => false, :big_endian => true
|
19
|
+
abi.packed_variable_length_numbers :tem_pubrsa_numbers, :tem_ushort,
|
20
|
+
[:e, :n], :signed => false, :big_endian => true
|
21
|
+
abi.fixed_length_string :tem_aes_key_string, 16
|
22
|
+
end
|
23
|
+
|
24
|
+
Tem::Builders::Crypto.define_crypto self do |crypto|
|
25
|
+
crypto.crypto_hash :tem_hash, Digest::SHA1
|
26
|
+
|
27
|
+
crypto.asymmetric_key :tem_rsa, Tem::Keys::Asymmetric, :tem_privrsa_numbers,
|
28
|
+
:tem_pubrsa_numbers, :new => lambda { |key| OpenSSL::PKey::RSA.new },
|
29
|
+
:to => lambda { |k| k.ssl_key },
|
30
|
+
:read_public => lambda { |key| Tem::Keys::Asymmetric.new key },
|
31
|
+
:read_private => lambda { |key|
|
32
|
+
# a bit of math to rebuild the public key
|
33
|
+
key.n = key.p * key.q
|
34
|
+
p1, q1 = key.p - 1, key.q - 1
|
35
|
+
p1q1 = p1 * q1
|
36
|
+
# HACK(costan): I haven't figured out how to restore d from dmp1 and
|
37
|
+
# dmq1, so I'm betting on the fact that e must be a small prime.
|
38
|
+
emp1 = key.dmp1.mod_inverse p1
|
39
|
+
emq1 = key.dmq1.mod_inverse q1
|
40
|
+
key.e = (emp1 < emq1) ? emp1 : emq1
|
41
|
+
key.d = key.e.mod_inverse p1q1
|
42
|
+
Tem::Keys::Asymmetric.new key
|
43
|
+
}
|
44
|
+
|
45
|
+
crypto.symmetric_key :tem_aes_key, Tem::Keys::Symmetric, nil,
|
46
|
+
:tem_aes_key_string,
|
47
|
+
:new => lambda { |k| OpenSSL::Cipher::AES.new 'ECB' },
|
48
|
+
:read => lambda { |k| Tem::Keys::Symmetric.new k },
|
49
|
+
:to => lambda { |k| k.ssl_key }
|
50
|
+
|
51
|
+
crypto.conditional_wrapper :tem_key, 1,
|
52
|
+
[{:tag => [0x99], :type => :tem_key,
|
53
|
+
:class => Tem::Keys::Symmetric },
|
54
|
+
{:tag => [0xAA], :type => :public_tem_rsa,
|
55
|
+
:class => Tem::Keys::Asymmetric,
|
56
|
+
:predicate => lambda { |k| k.ssl_key.kind_of?(OpenSSL::PKey::RSA) &&
|
57
|
+
k.is_public? } },
|
58
|
+
{:tag => [0x55], :type => :private_tem_rsa,
|
59
|
+
:class => Tem::Keys::Asymmetric,
|
60
|
+
:predicate => lambda { |k| k.ssl_key.kind_of?(OpenSSL::PKey::RSA) } }]
|
61
|
+
end
|
62
|
+
|
63
|
+
# For convenience, include the Abi methods in Tem::Session's namespace.
|
64
|
+
def self.included(klass)
|
65
|
+
klass.extend Tem::Abi
|
66
|
+
end
|
67
|
+
end # module Tem::Abi
|
data/lib/tem/ecert.rb
CHANGED
@@ -0,0 +1,116 @@
|
|
1
|
+
# :nodoc: namespace
|
2
|
+
module Tem::Keys
|
3
|
+
|
4
|
+
# Wraps a TEM asymmetric key, e.g. an RSA key.
|
5
|
+
class Asymmetric < Tem::Key
|
6
|
+
def self.new_from_array(array)
|
7
|
+
self.new(OpenSSL::PKey::RSA.new(array[0]), *array[1..-1])
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.new_from_yaml_str(yaml_str)
|
11
|
+
array = YAML.load yaml_str
|
12
|
+
new_from_array array
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_array
|
16
|
+
[@ssl_key.to_pem, @padding_type]
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_yaml_str
|
20
|
+
self.to_array.to_yaml.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
# Generate a pair of asymmetric keys.
|
24
|
+
def self.generate_pair
|
25
|
+
ssl_key = OpenSSL::PKey::RSA.generate(2048, 65537)
|
26
|
+
new_pair_from_ssl_key ssl_key
|
27
|
+
end
|
28
|
+
|
29
|
+
# Creates a pair of asymmetric keys wrapping an OpenSSL private key.
|
30
|
+
def self.new_pair_from_ssl_key(ssl_key)
|
31
|
+
{ :public => Tem::Keys::Asymmetric.new(ssl_key.public_key),
|
32
|
+
:private => Tem::Keys::Asymmetric.new(ssl_key) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(ssl_key, padding_type = :pkcs1)
|
36
|
+
super ssl_key
|
37
|
+
@is_public = !ssl_key.d
|
38
|
+
@padding_type = padding_type
|
39
|
+
|
40
|
+
case padding_type
|
41
|
+
when :oaep
|
42
|
+
@padding_id = OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING
|
43
|
+
@padding_bytes = 42
|
44
|
+
when :pkcs1
|
45
|
+
@padding_id = OpenSSL::PKey::RSA::PKCS1_PADDING
|
46
|
+
@padding_bytes = 11
|
47
|
+
else
|
48
|
+
raise "Unknown padding type #{padding_type}\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
@size = 0
|
52
|
+
n = @is_public ? @ssl_key.n : (@ssl_key.p * @ssl_key.q)
|
53
|
+
while n != 0 do
|
54
|
+
@size += 1
|
55
|
+
n >>= 8
|
56
|
+
end
|
57
|
+
end
|
58
|
+
public_class_method :new
|
59
|
+
|
60
|
+
def is_public?
|
61
|
+
@is_public
|
62
|
+
end
|
63
|
+
|
64
|
+
def encrypt(data)
|
65
|
+
encrypt_or_decrypt data, @size - @padding_bytes,
|
66
|
+
@is_public ? :public_encrypt : :private_encrypt
|
67
|
+
end
|
68
|
+
|
69
|
+
def decrypt(data)
|
70
|
+
encrypt_or_decrypt data, @size,
|
71
|
+
@is_public ? :public_decrypt : :private_decrypt
|
72
|
+
end
|
73
|
+
|
74
|
+
def sign(data)
|
75
|
+
data = data.pack 'C*' if data.respond_to? :pack
|
76
|
+
# PKCS1-padding is forced in by openssl... sigh!
|
77
|
+
out_data = @ssl_key.sign OpenSSL::Digest::SHA1.new, data
|
78
|
+
data.respond_to?(:pack) ? out_data : out_data.unpack('C*')
|
79
|
+
end
|
80
|
+
|
81
|
+
def verify(data, signature)
|
82
|
+
data = data.pack 'C*' if data.respond_to? :pack
|
83
|
+
signature = signature.pack 'C*' if signature.respond_to? :pack
|
84
|
+
# PKCS1-padding is forced in by openssl... sigh!
|
85
|
+
@ssl_key.verify OpenSSL::Digest::SHA1.new, signature, data
|
86
|
+
end
|
87
|
+
|
88
|
+
def encrypt_or_decrypt(data, in_size, op)
|
89
|
+
chug_data(data, in_size) { |block| @ssl_key.send op, block, @padding_id }
|
90
|
+
end
|
91
|
+
private :encrypt_or_decrypt
|
92
|
+
|
93
|
+
def chug_data(data, in_size, &chug_block)
|
94
|
+
output = data.class.new
|
95
|
+
i = 0
|
96
|
+
while i < data.length do
|
97
|
+
block_size = (data.length - i < in_size) ? data.length - i : in_size
|
98
|
+
if data.kind_of? String
|
99
|
+
block = data[i...(i+block_size)]
|
100
|
+
else
|
101
|
+
block = data[i...(i+block_size)].pack('C*')
|
102
|
+
end
|
103
|
+
o_block = yield block
|
104
|
+
if data.kind_of? String
|
105
|
+
output += o_block
|
106
|
+
else
|
107
|
+
output += o_block.unpack('C*')
|
108
|
+
end
|
109
|
+
i += block_size
|
110
|
+
end
|
111
|
+
return output
|
112
|
+
end
|
113
|
+
private :chug_data
|
114
|
+
end
|
115
|
+
|
116
|
+
end # namespace Tem::Keys
|
data/lib/tem/keys/key.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Base class for the TEM keys.
|
2
|
+
#
|
3
|
+
# This class consists of stubs describing the interface implemented by
|
4
|
+
# subclasses.
|
5
|
+
class Tem::Key
|
6
|
+
# The OpenSSL key wrapped by this TEM key.
|
7
|
+
attr_reader :ssl_key
|
8
|
+
|
9
|
+
# Creates a new key based on an OpenSSL key.
|
10
|
+
def initialize(ssl_key)
|
11
|
+
@ssl_key = ssl_key
|
12
|
+
end
|
13
|
+
# This class should not be instantiated directly.
|
14
|
+
private_class_method :new
|
15
|
+
|
16
|
+
# Serializes this key to the TEM ABI format.
|
17
|
+
def to_tem_key
|
18
|
+
Tem::Abi.to_tem_key self
|
19
|
+
end
|
20
|
+
|
21
|
+
# Encrypts a block of data into a TEM-friendly format.
|
22
|
+
def encrypt(data)
|
23
|
+
raise "TEM Key class #{self.class.name} didn't implement encrypt"
|
24
|
+
end
|
25
|
+
|
26
|
+
def decrypt(data)
|
27
|
+
raise "TEM Key class #{self.class.name} didn't implement decrypt"
|
28
|
+
end
|
29
|
+
|
30
|
+
def sign(data)
|
31
|
+
raise "TEM Key class #{self.class.name} didn't implement sign"
|
32
|
+
end
|
33
|
+
|
34
|
+
def verify(data)
|
35
|
+
raise "TEM Key class #{self.class.name} didn't implement verify"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a new TEM key wrapper from a SSL key
|
39
|
+
def self.new_from_ssl_key(ssl_key)
|
40
|
+
if ssl_key.kind_of? OpenSSL::PKey::PKey
|
41
|
+
Tem::Keys::Asymmetric.new ssl_key
|
42
|
+
elsif ssl_key.kind_of? OpenSSL::Cipher::Cipher
|
43
|
+
Tem::Keys::Symmetric.new ssl_key
|
44
|
+
else
|
45
|
+
raise "Can't handle keys of class #{ssl_key.class}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# :nodoc: namespace
|
2
|
+
module Tem::Keys
|
3
|
+
|
4
|
+
# Wraps a TEM symmetric key, e.g. an AES key.
|
5
|
+
class Symmetric < Tem::Key
|
6
|
+
@@cipher_mode = 'ECB'
|
7
|
+
|
8
|
+
# Generates a new symmetric key.
|
9
|
+
def self.generate
|
10
|
+
cipher = OpenSSL::Cipher::AES128.new @@cipher_mode
|
11
|
+
key = cipher.random_key
|
12
|
+
self.new key
|
13
|
+
end
|
14
|
+
|
15
|
+
# Creates a new symmetric key based on an OpenSSL Cipher instance, augmented
|
16
|
+
# with a key accessor.
|
17
|
+
def initialize(ssl_key)
|
18
|
+
super ssl_key
|
19
|
+
@key = ssl_key.key
|
20
|
+
@cipher_class = ssl_key.class
|
21
|
+
end
|
22
|
+
public_class_method :new
|
23
|
+
|
24
|
+
def encrypt_or_decrypt(data, do_encrypt)
|
25
|
+
cipher = @cipher_class.new @@cipher_mode
|
26
|
+
do_encrypt ? cipher.encrypt : cipher.decrypt
|
27
|
+
cipher.key = @key
|
28
|
+
cipher.iv = "\0" * 16
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def encrypt(data)
|
33
|
+
cipher.encrypt_or_decrypt data, true
|
34
|
+
end
|
35
|
+
|
36
|
+
def decrypt(data)
|
37
|
+
cipher.encrypt_or_decrypt data, false
|
38
|
+
end
|
39
|
+
|
40
|
+
def sign(data)
|
41
|
+
end
|
42
|
+
|
43
|
+
def verify(data)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end # namespace Tem::Keys
|
data/lib/tem/sec_assembler.rb
CHANGED
@@ -56,7 +56,7 @@ class Tem::SecAssembler
|
|
56
56
|
if @body[i].kind_of? Hash
|
57
57
|
raise "label #{@body[i][:label]} undefined" if (!@body[i][:label].nil? and @labels[@body[i][:label]].nil?)
|
58
58
|
addr = @body[i][:label].nil? ? @body[i][:address] : @labels[@body[i][:label]]
|
59
|
-
q = @body[i][:relative] ? (@tem_klass.send "
|
59
|
+
q = @body[i][:relative] ? (@tem_klass.send "signed_to_tem_#{@body[i][:type]}".to_sym, addr - i - @body[i][:relative]) :
|
60
60
|
(@tem_klass.send "to_tem_#{@body[i][:type]}".to_sym, addr)
|
61
61
|
@body[i, q.length] = *q
|
62
62
|
end
|
@@ -88,4 +88,3 @@ class Tem::SecAssembler
|
|
88
88
|
@extra_bytes = extra_bytes
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
data/lib/tem/secpack.rb
CHANGED
@@ -27,7 +27,7 @@ class Tem::SecPack
|
|
27
27
|
|
28
28
|
def initialize(args)
|
29
29
|
@tem_klass = args[:tem_class]
|
30
|
-
@@serialized_members.map { |m| self.instance_variable_set
|
30
|
+
@@serialized_members.map { |m| self.instance_variable_set "@#{m}", args[m] }
|
31
31
|
@bound ||= false
|
32
32
|
end
|
33
33
|
|
@@ -37,8 +37,9 @@ class Tem::SecPack
|
|
37
37
|
|
38
38
|
def tem_header
|
39
39
|
# TODO: use 0x0100 (no tracing) depending on options
|
40
|
-
hh = [0x0101, @signed_bytes, @encrypted_bytes, @extra_bytes, @sp,
|
41
|
-
|
40
|
+
hh = [0x0101, @signed_bytes || 0, @encrypted_bytes || 0, @extra_bytes, @sp,
|
41
|
+
@ep].map { |n| @tem_klass.to_tem_ushort n }.flatten
|
42
|
+
hh += Array.new((@tem_klass.tem_hash [0]).length - hh.length, 0)
|
42
43
|
return hh
|
43
44
|
end
|
44
45
|
|
@@ -49,7 +50,7 @@ class Tem::SecPack
|
|
49
50
|
@signed_bytes = encrypt_from
|
50
51
|
@encrypted_bytes = plaintext_from - encrypt_from
|
51
52
|
|
52
|
-
secpack_sig = @tem_klass.
|
53
|
+
secpack_sig = @tem_klass.tem_hash [tem_header, @body[0...plaintext_from]].flatten
|
53
54
|
crypt = public_key.encrypt [@body[encrypt_from...plaintext_from], secpack_sig].flatten
|
54
55
|
@body = [@body[0...encrypt_from], crypt, @body[plaintext_from..-1]].flatten
|
55
56
|
|
data/lib/tem/tem.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
class Tem::Session
|
2
2
|
include Tem::Abi
|
3
|
-
include Tem::Buffers
|
3
|
+
include Tem::Apdus::Buffers
|
4
|
+
include Tem::Apdus::Keys
|
5
|
+
include Tem::Apdus::Lifecycle
|
6
|
+
include Tem::Apdus::Tag
|
7
|
+
|
4
8
|
include Tem::CA
|
5
|
-
include Tem::CryptoAbi
|
6
9
|
include Tem::ECert
|
7
|
-
include Tem::Keys
|
8
|
-
include Tem::Lifecycle
|
9
10
|
include Tem::SeClosures
|
10
|
-
include Tem::Tag
|
11
11
|
include Tem::Toolkit
|
12
12
|
|
13
13
|
CAPPLET_AID = [0x19, 0x83, 0x12, 0x29, 0x10, 0xBA, 0xBE]
|
data/lib/tem/toolkit.rb
CHANGED
@@ -34,7 +34,8 @@ module Tem::Toolkit
|
|
34
34
|
|
35
35
|
kp_buffer = execute gen_sec
|
36
36
|
keys_offset = authz.nil? ? 20 : 0
|
37
|
-
k1id
|
37
|
+
k1id = read_tem_ushort kp_buffer, keys_offset
|
38
|
+
k2id = read_tem_ushort kp_buffer, keys_offset + 2
|
38
39
|
if type == :asymmetric
|
39
40
|
return_val = { :pubk_id => k1id, :privk_id => k2id }
|
40
41
|
else
|
data/lib/tem_ruby.rb
CHANGED
@@ -18,20 +18,28 @@ require 'tem/transport/jcop_remote_transport.rb'
|
|
18
18
|
require 'tem/transport/jcop_remote_server.rb'
|
19
19
|
require 'tem/transport/auto_configurator.rb'
|
20
20
|
|
21
|
-
require 'tem/
|
21
|
+
require 'tem/keys/key.rb'
|
22
|
+
require 'tem/keys/asymmetric.rb'
|
23
|
+
require 'tem/keys/symmetric.rb'
|
24
|
+
|
25
|
+
require 'tem/builders/abi.rb'
|
26
|
+
require 'tem/builders/crypto.rb'
|
27
|
+
|
28
|
+
require 'tem/definitions/abi.rb'
|
29
|
+
|
22
30
|
require 'tem/auto_conf.rb'
|
23
|
-
require 'tem/buffers.rb'
|
31
|
+
require 'tem/apdus/buffers.rb'
|
32
|
+
require 'tem/apdus/keys.rb'
|
33
|
+
require 'tem/apdus/lifecycle.rb'
|
34
|
+
require 'tem/apdus/tag.rb'
|
35
|
+
|
24
36
|
require 'tem/ca.rb'
|
25
|
-
require 'tem/crypto_abi.rb'
|
26
37
|
require 'tem/ecert.rb'
|
27
38
|
require 'tem/hive.rb'
|
28
|
-
require 'tem/keys.rb'
|
29
|
-
require 'tem/lifecycle.rb'
|
30
39
|
require 'tem/sec_assembler.rb'
|
31
40
|
require 'tem/sec_opcodes.rb'
|
32
41
|
require 'tem/sec_exec_error.rb'
|
33
42
|
require 'tem/seclosures.rb'
|
34
43
|
require 'tem/secpack.rb'
|
35
|
-
require 'tem/tag.rb'
|
36
44
|
require 'tem/toolkit.rb'
|
37
45
|
require 'tem/tem.rb'
|
data/tem_ruby.gemspec
CHANGED
@@ -2,38 +2,34 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{tem_ruby}
|
5
|
-
s.version = "0.10.
|
5
|
+
s.version = "0.10.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"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-05-26}
|
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"]
|
13
|
-
s.extra_rdoc_files = ["bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "CHANGELOG", "lib/tem/_cert.rb", "lib/tem/
|
14
|
-
s.files = ["bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "CHANGELOG", "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/
|
15
|
-
s.has_rdoc = true
|
13
|
+
s.extra_rdoc_files = ["bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "CHANGELOG", "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/builders/abi.rb", "lib/tem/builders/crypto.rb", "lib/tem/ca.rb", "lib/tem/definitions/abi.rb", "lib/tem/ecert.rb", "lib/tem/hive.rb", "lib/tem/keys/asymmetric.rb", "lib/tem/keys/key.rb", "lib/tem/keys/symmetric.rb", "lib/tem/sec_assembler.rb", "lib/tem/sec_exec_error.rb", "lib/tem/sec_opcodes.rb", "lib/tem/seclosures.rb", "lib/tem/secpack.rb", "lib/tem/tem.rb", "lib/tem/toolkit.rb", "lib/tem/transport/auto_configurator.rb", "lib/tem/transport/java_card_mixin.rb", "lib/tem/transport/jcop_remote_protocol.rb", "lib/tem/transport/jcop_remote_server.rb", "lib/tem/transport/jcop_remote_transport.rb", "lib/tem/transport/pcsc_transport.rb", "lib/tem/transport/transport.rb", "lib/tem_ruby.rb", "LICENSE", "README"]
|
14
|
+
s.files = ["bin/tem_bench", "bin/tem_ca", "bin/tem_irb", "bin/tem_proxy", "bin/tem_stat", "CHANGELOG", "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/builders/abi.rb", "lib/tem/builders/crypto.rb", "lib/tem/ca.rb", "lib/tem/definitions/abi.rb", "lib/tem/ecert.rb", "lib/tem/hive.rb", "lib/tem/keys/asymmetric.rb", "lib/tem/keys/key.rb", "lib/tem/keys/symmetric.rb", "lib/tem/sec_assembler.rb", "lib/tem/sec_exec_error.rb", "lib/tem/sec_opcodes.rb", "lib/tem/seclosures.rb", "lib/tem/secpack.rb", "lib/tem/tem.rb", "lib/tem/toolkit.rb", "lib/tem/transport/auto_configurator.rb", "lib/tem/transport/java_card_mixin.rb", "lib/tem/transport/jcop_remote_protocol.rb", "lib/tem/transport/jcop_remote_server.rb", "lib/tem/transport/jcop_remote_transport.rb", "lib/tem/transport/pcsc_transport.rb", "lib/tem/transport/transport.rb", "lib/tem_ruby.rb", "LICENSE", "Manifest", "Rakefile", "README", "test/_test_cert.rb", "test/builders/test_abi_builder.rb", "test/tem_test_case.rb", "test/test_driver.rb", "test/test_exceptions.rb", "test/test_tem.rb", "test/transport/test_auto_configurator.rb", "test/transport/test_java_card_mixin.rb", "test/transport/test_jcop_remote.rb", "timings/blank_bound_secpack.rb", "timings/blank_sec.rb", "timings/devchip_decrypt.rb", "timings/post_buffer.rb", "timings/simple_apdu.rb", "timings/timings.rb", "timings/vm_perf.rb", "timings/vm_perf_bound.rb", "tem_ruby.gemspec"]
|
16
15
|
s.homepage = %q{http://tem.rubyforge.org}
|
17
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tem_ruby", "--main", "README"]
|
18
17
|
s.require_paths = ["lib"]
|
19
18
|
s.rubyforge_project = %q{tem}
|
20
|
-
s.rubygems_version = %q{1.3.
|
19
|
+
s.rubygems_version = %q{1.3.3}
|
21
20
|
s.summary = %q{TEM (Trusted Execution Module) driver, written in and for ruby.}
|
22
|
-
s.test_files = ["test/test_driver.rb", "test/test_exceptions.rb", "test/test_tem.rb", "test/transport/test_auto_configurator.rb", "test/transport/test_java_card_mixin.rb", "test/transport/test_jcop_remote.rb"]
|
21
|
+
s.test_files = ["test/builders/test_abi_builder.rb", "test/test_driver.rb", "test/test_exceptions.rb", "test/test_tem.rb", "test/transport/test_auto_configurator.rb", "test/transport/test_java_card_mixin.rb", "test/transport/test_jcop_remote.rb"]
|
23
22
|
|
24
23
|
if s.respond_to? :specification_version then
|
25
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
-
s.specification_version =
|
25
|
+
s.specification_version = 3
|
27
26
|
|
28
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
28
|
s.add_runtime_dependency(%q<smartcard>, [">= 0.3.0"])
|
30
|
-
s.add_development_dependency(%q<echoe>, [">= 0"])
|
31
29
|
else
|
32
30
|
s.add_dependency(%q<smartcard>, [">= 0.3.0"])
|
33
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
34
31
|
end
|
35
32
|
else
|
36
33
|
s.add_dependency(%q<smartcard>, [">= 0.3.0"])
|
37
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
38
34
|
end
|
39
35
|
end
|