grizzly_ber 0.0.4 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grizzly_ber.rb +132 -125
- data/lib/grizzly_tag.rb +121 -121
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53d7ab07529b15d9aa734970098be59d26c0f5f
|
4
|
+
data.tar.gz: 6c9400a6562e683cf4fecddd5ffc5e914efa85c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70872c91a78a71d23f812ddc3c8c6620d306373a4359216a00b88e2db59fd7efeff117b355c30a1530ef26cadad3d16cf54278b4f9cf3482b07e2d3a013db707
|
7
|
+
data.tar.gz: d0fb5e0ac7d558892ab2481958a6f4333aca695f2bde1d07138ef7f96773745e4a7c243586ad48f3e3c5bcc7718c64c02408489189a84ffef45f62f5fb30b419
|
data/lib/grizzly_ber.rb
CHANGED
@@ -1,138 +1,59 @@
|
|
1
1
|
require 'grizzly_tag'
|
2
2
|
|
3
|
-
class
|
4
|
-
attr_reader :
|
5
|
-
|
6
|
-
def initialize(hex_string = "")
|
7
|
-
@tag = nil
|
8
|
-
@length = nil
|
9
|
-
@value = nil
|
10
|
-
decode_hex(hex_string)
|
11
|
-
end
|
12
|
-
|
13
|
-
def value=(new_value)
|
14
|
-
if new_value.is_a? String
|
15
|
-
@value = new_value
|
16
|
-
@tag = nil if isConstruct?
|
17
|
-
elsif new_value.is_a? Array and new_value.all? {|tlv| tlv.is_a? GrizzlyBer}
|
18
|
-
@value = new_value
|
19
|
-
@tag = nil if not isConstruct?
|
20
|
-
else
|
21
|
-
@value = nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def tag=(new_tag)
|
26
|
-
@tag = new_tag
|
27
|
-
@value = nil if isConstruct? and @value.is_a? String
|
28
|
-
@value = nil if not isConstruct? and @value.is_a? Array
|
29
|
-
@value = [] if isConstruct? and @value.nil?
|
30
|
-
end
|
31
|
-
|
32
|
-
def find(tag_or_name)
|
33
|
-
if tag_or_name.is_a? String
|
34
|
-
tag = GrizzlyTag.tag_from_name(tag_or_name)
|
35
|
-
else
|
36
|
-
tag = tag_or_name
|
37
|
-
end
|
38
|
-
return self if @tag == tag
|
39
|
-
return nil unless isConstruct?
|
40
|
-
@value.find{|tlv| tlv.find(tag) != nil}
|
41
|
-
end
|
42
|
-
|
43
|
-
def remove!(tag_or_name)
|
44
|
-
tag_to_remove = find(tag_or_name)
|
45
|
-
@value.delete tag_to_remove unless tag_to_remove.nil?
|
46
|
-
end
|
47
|
-
|
48
|
-
def decode_hex(hex_string)
|
49
|
-
decode_binary([hex_string].pack("H*"))
|
50
|
-
end
|
3
|
+
class GrizzlyBerElement
|
4
|
+
attr_reader :tag, :value
|
51
5
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
decode_all_binary([hex_string].pack("H*"))
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.decode_all_binary(binary_string)
|
61
|
-
decode_all_byte_array(binary_string.unpack("C*"))
|
62
|
-
end
|
63
|
-
|
64
|
-
def encode_hex
|
65
|
-
encoded = ""
|
66
|
-
encoded << @tag.to_s(16).upcase
|
67
|
-
if length_of_length == 1
|
68
|
-
encoded << length.to_s(16).rjust(2,'0').upcase
|
69
|
-
else
|
70
|
-
encoded << ((length_of_length-1) | 0x80).to_s(16).rjust(2,'0').upcase
|
71
|
-
encoded << length.to_s(16).rjust((length_of_length-1)*2,'0').upcase
|
72
|
-
end
|
73
|
-
encoded << encode_only_values
|
6
|
+
def initialize(byte_array = [])
|
7
|
+
raise ArgumentError, "byte_array must be of type Array" unless byte_array.is_a?(Array)
|
8
|
+
@tag = "" # is an uppercase hex string
|
9
|
+
@value = nil # is a byte array if this is a data element or a GrizzlyBer if it's a sequence element
|
10
|
+
decode_value decode_length decode_tag byte_array
|
74
11
|
end
|
75
12
|
|
76
|
-
def
|
77
|
-
[
|
13
|
+
def tag=(tag)
|
14
|
+
raise ArgumentError, "tag must be a valid hex string" unless tag.is_a? String and tag.size.even? and tag =~ /^[0-9A-F]*$/
|
15
|
+
@tag = tag
|
78
16
|
end
|
79
17
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
else
|
84
|
-
@value.inject("") {|encoded_children,child| encoded_children << child.encode_hex}
|
85
|
-
end
|
18
|
+
def value=(value)
|
19
|
+
raise ArgumentError, "value must be of type Array or GrizzlyBer" unless value.is_a?(Array) || value.is_a?(GrizzlyBer)
|
20
|
+
@value = value
|
86
21
|
end
|
87
22
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
23
|
+
def to_ber
|
24
|
+
ber_array = ""
|
25
|
+
ber_array += @tag.upcase
|
26
|
+
value_hex_string = @value.pack("C*").unpack("H*").first.upcase if @value.is_a? Array
|
27
|
+
value_hex_string = @value.to_ber if @value.is_a? GrizzlyBer
|
28
|
+
value_byte_count = value_hex_string.size/2
|
29
|
+
if value_byte_count < 0x7F # if the length of the value array is only one byte long and does not have its upper bit set
|
30
|
+
ber_array << byte_to_hex(value_byte_count)
|
95
31
|
else
|
96
|
-
|
97
|
-
|
98
|
-
|
32
|
+
#pack("w") was meant to do this length calc but doesn't work right...
|
33
|
+
number_of_bytes_in_byte_count = ((value_byte_count).to_s(16).size/2.0).ceil
|
34
|
+
ber_array << byte_to_hex(number_of_bytes_in_byte_count | 0x80)
|
35
|
+
ber_array += (value_byte_count).to_s(16).rjust(number_of_bytes_in_byte_count*2,'0').upcase
|
99
36
|
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
protected
|
104
|
-
|
105
|
-
def length
|
106
|
-
return value.length/2 if value.is_a? String #because hex strings are 2 chars per byte
|
107
|
-
value.inject(0) {|length, tlv| length += tlv.length_of_tag + tlv.length_of_length + tlv.length}
|
37
|
+
ber_array += value_hex_string
|
108
38
|
end
|
109
39
|
|
110
|
-
|
111
|
-
[@tag.to_s(16)].pack("H*").unpack("C*").count
|
112
|
-
end
|
113
|
-
|
114
|
-
def length_of_length
|
115
|
-
1 + ((length < 0x7F) ? 0 : [length.to_s(16)].pack("H*").unpack("C*").count)
|
116
|
-
end
|
40
|
+
private
|
117
41
|
|
118
|
-
def
|
119
|
-
|
120
|
-
self
|
42
|
+
def byte_to_hex(byte)
|
43
|
+
byte.to_s(16).rjust(2,'0').upcase
|
121
44
|
end
|
122
45
|
|
123
|
-
private
|
124
|
-
|
125
46
|
def decode_tag(byte_array)
|
126
47
|
byte_array.shift while byte_array.size > 0 and (byte_array[0] == 0x00 or byte_array[0] == 0xFF)
|
127
48
|
return [] if byte_array.size < 1
|
128
49
|
|
129
50
|
first_byte = byte_array.shift
|
130
|
-
@tag
|
51
|
+
@tag << byte_to_hex(first_byte)
|
131
52
|
return byte_array if (first_byte & 0x1F) != 0x1F
|
132
53
|
|
133
54
|
while byte_array.size > 0
|
134
55
|
next_byte = byte_array.shift
|
135
|
-
@tag
|
56
|
+
@tag << byte_to_hex(next_byte)
|
136
57
|
return byte_array if (next_byte & 0x80) != 0x80
|
137
58
|
end
|
138
59
|
|
@@ -157,25 +78,111 @@ class GrizzlyBer
|
|
157
78
|
byte_array
|
158
79
|
end
|
159
80
|
|
160
|
-
def isConstruct?
|
161
|
-
([@tag.to_s(16)].pack("H*").unpack("C*").first & 0x20) == 0x20
|
162
|
-
end
|
163
|
-
|
164
81
|
def decode_value(byte_array)
|
165
82
|
return [] if byte_array.size < 1 or byte_array.size < @length
|
166
|
-
if
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
83
|
+
return @value = byte_array.shift(@length) if [@tag].pack("H*").unpack("C*").first & 0x20 == 0
|
84
|
+
@value = GrizzlyBer.new.from_ber byte_array.shift(@length)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class GrizzlyBer
|
89
|
+
include Enumerable
|
90
|
+
|
91
|
+
def initialize(hex_string = "")
|
92
|
+
raise ArgumentError, "hex_string must be a valid hex string" unless hex_string.is_a? String and hex_string.size.even? and hex_string =~ /^[0-9A-F]*$/
|
93
|
+
@elements = [] # is an array of GrizzlyBerElement
|
94
|
+
from_ber_hex_string(hex_string)
|
95
|
+
end
|
96
|
+
|
97
|
+
def from_ber_hex_string(hex_string)
|
98
|
+
raise ArgumentError, "hex_string must be a valid hex string" unless hex_string.is_a? String and hex_string.size.even? and hex_string =~ /^[0-9A-F]*$/
|
99
|
+
self.from_ber [hex_string].pack("H*").unpack("C*")
|
100
|
+
end
|
101
|
+
|
102
|
+
def from_ber(byte_array)
|
103
|
+
raise ArgumentError, "byte_array must be an array of bytes" unless byte_array.is_a? Array and byte_array.all? {|byte| byte.is_a? Integer and byte <= 0xFF}
|
104
|
+
while byte_array.size > 0
|
105
|
+
element = GrizzlyBerElement.new(byte_array)
|
106
|
+
return nil if element.tag.nil?
|
107
|
+
return nil if element.value.nil?
|
108
|
+
@elements << element
|
172
109
|
end
|
110
|
+
self
|
173
111
|
end
|
174
112
|
|
175
|
-
def
|
176
|
-
|
177
|
-
|
178
|
-
|
113
|
+
def to_ber
|
114
|
+
@elements.reduce("") {|ber_array, element| ber_array += element.to_ber}
|
115
|
+
end
|
116
|
+
|
117
|
+
def [](index_or_tag)
|
118
|
+
return value_of_first_element_with_tag(index_or_tag) if index_or_tag.is_a? String
|
119
|
+
@elements[index_or_tag]
|
120
|
+
end
|
121
|
+
|
122
|
+
def []=(index_or_tag,value)
|
123
|
+
return set_value_for_tag(index_or_tag, value) if index_or_tag.is_a? String
|
124
|
+
@elements[index].value = value
|
125
|
+
@elements[index]
|
126
|
+
end
|
127
|
+
|
128
|
+
def size
|
129
|
+
@elements.size
|
130
|
+
end
|
131
|
+
|
132
|
+
def each &block
|
133
|
+
@elements.each &block
|
179
134
|
end
|
180
|
-
end
|
181
135
|
|
136
|
+
def value_of_first_element_with_tag(tag)
|
137
|
+
first_tagged_element = @elements.find {|element| tag.upcase == element.tag}
|
138
|
+
first_tagged_element ||= @elements.find {|element| element.tag == GrizzlyTag.named(tag)[:tag]} if GrizzlyTag.named(tag)
|
139
|
+
first_tagged_element &&= first_tagged_element.value
|
140
|
+
end
|
141
|
+
|
142
|
+
def hex_value_of_first_element_with_tag(tag)
|
143
|
+
first_tagged_element = value_of_first_element_with_tag(tag)
|
144
|
+
first_tagged_element &&= first_tagged_element.pack("C*").unpack("H*").first.upcase
|
145
|
+
end
|
146
|
+
|
147
|
+
def set_value_for_tag(tag, value)
|
148
|
+
tag.upcase!
|
149
|
+
first_tagged_element = @elements.find {|element| tag == element.tag}
|
150
|
+
first_tagged_element ||= @elements.find {|element| element.tag == GrizzlyTag.named(tag)[:tag]} if GrizzlyTag.named(tag)
|
151
|
+
if first_tagged_element.nil?
|
152
|
+
first_tagged_element = GrizzlyBerElement.new
|
153
|
+
first_tagged_element.tag = tag
|
154
|
+
@elements << first_tagged_element
|
155
|
+
end
|
156
|
+
first_tagged_element.value = value
|
157
|
+
first_tagged_element
|
158
|
+
end
|
159
|
+
|
160
|
+
def set_hex_value_for_tag(tag, value)
|
161
|
+
set_value_for_tag(tag, [value].pack("H*").unpack("C*"))
|
162
|
+
end
|
163
|
+
|
164
|
+
def remove!(tag)
|
165
|
+
@elements = @elements.select {|element| element.tag != tag.upcase}
|
166
|
+
self
|
167
|
+
end
|
168
|
+
|
169
|
+
def to_s(indent_size: 0)
|
170
|
+
indent = " " * 3 * indent_size
|
171
|
+
@elements.reduce("") do |output, element|
|
172
|
+
info = GrizzlyTag.tagged(element.tag) || {:name => "Unknown Tag", :description => "Unknown"}
|
173
|
+
output += "#{indent}#{element.tag}: #{info[:name]}\n"
|
174
|
+
output += "#{indent} Description: #{info[:description]}\n"
|
175
|
+
if element.value.is_a? GrizzlyBer
|
176
|
+
output += element.value.to_s(indent_size: indent_size+1)
|
177
|
+
else
|
178
|
+
output += "#{indent} Value: #{element.value.pack("C*").unpack("H*").first}"
|
179
|
+
output += ", \"#{element.value.pack("C*")}\"" if info[:format] == :string
|
180
|
+
output += "\n"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
private
|
186
|
+
|
187
|
+
|
188
|
+
end
|
data/lib/grizzly_tag.rb
CHANGED
@@ -23,126 +23,126 @@ module GrizzlyTag
|
|
23
23
|
|
24
24
|
@@tags = [
|
25
25
|
#Tags taken from EMV 4.3 Book 3 Annex A
|
26
|
-
new_tag(:tag =>
|
27
|
-
new_tag(:tag =>
|
28
|
-
new_tag(:tag =>
|
29
|
-
new_tag(:tag =>
|
30
|
-
new_tag(:tag =>
|
31
|
-
new_tag(:tag =>
|
32
|
-
new_tag(:tag =>
|
33
|
-
new_tag(:tag =>
|
34
|
-
new_tag(:tag =>
|
35
|
-
new_tag(:tag =>
|
36
|
-
new_tag(:tag =>
|
37
|
-
new_tag(:tag =>
|
38
|
-
new_tag(:tag =>
|
39
|
-
new_tag(:tag =>
|
40
|
-
new_tag(:tag =>
|
41
|
-
new_tag(:tag =>
|
42
|
-
new_tag(:tag =>
|
43
|
-
new_tag(:tag =>
|
44
|
-
new_tag(:tag =>
|
45
|
-
new_tag(:tag =>
|
46
|
-
new_tag(:tag =>
|
47
|
-
new_tag(:tag =>
|
48
|
-
new_tag(:tag =>
|
49
|
-
new_tag(:tag =>
|
50
|
-
new_tag(:tag =>
|
51
|
-
new_tag(:tag =>
|
52
|
-
new_tag(:tag =>
|
53
|
-
new_tag(:tag =>
|
54
|
-
new_tag(:tag =>
|
55
|
-
new_tag(:tag =>
|
56
|
-
new_tag(:tag =>
|
57
|
-
new_tag(:tag =>
|
58
|
-
new_tag(:tag =>
|
59
|
-
new_tag(:tag =>
|
60
|
-
new_tag(:tag =>
|
61
|
-
new_tag(:tag =>
|
62
|
-
new_tag(:tag =>
|
63
|
-
new_tag(:tag =>
|
64
|
-
new_tag(:tag =>
|
65
|
-
new_tag(:tag =>
|
66
|
-
new_tag(:tag =>
|
67
|
-
new_tag(:tag =>
|
68
|
-
new_tag(:tag =>
|
69
|
-
new_tag(:tag =>
|
70
|
-
new_tag(:tag =>
|
71
|
-
new_tag(:tag =>
|
72
|
-
new_tag(:tag =>
|
73
|
-
new_tag(:tag =>
|
74
|
-
new_tag(:tag =>
|
75
|
-
new_tag(:tag =>
|
76
|
-
new_tag(:tag =>
|
77
|
-
new_tag(:tag =>
|
78
|
-
new_tag(:tag =>
|
79
|
-
new_tag(:tag =>
|
80
|
-
new_tag(:tag =>
|
81
|
-
new_tag(:tag =>
|
82
|
-
new_tag(:tag =>
|
83
|
-
new_tag(:tag =>
|
84
|
-
new_tag(:tag =>
|
85
|
-
new_tag(:tag =>
|
86
|
-
new_tag(:tag =>
|
87
|
-
new_tag(:tag =>
|
88
|
-
new_tag(:tag =>
|
89
|
-
new_tag(:tag =>
|
90
|
-
new_tag(:tag =>
|
91
|
-
new_tag(:tag =>
|
92
|
-
new_tag(:tag =>
|
93
|
-
new_tag(:tag =>
|
94
|
-
new_tag(:tag =>
|
95
|
-
new_tag(:tag =>
|
96
|
-
new_tag(:tag =>
|
97
|
-
new_tag(:tag =>
|
98
|
-
new_tag(:tag =>
|
99
|
-
new_tag(:tag =>
|
100
|
-
new_tag(:tag =>
|
101
|
-
new_tag(:tag =>
|
102
|
-
new_tag(:tag =>
|
103
|
-
new_tag(:tag =>
|
104
|
-
new_tag(:tag =>
|
105
|
-
new_tag(:tag =>
|
106
|
-
new_tag(:tag =>
|
107
|
-
new_tag(:tag =>
|
108
|
-
new_tag(:tag =>
|
109
|
-
new_tag(:tag =>
|
110
|
-
new_tag(:tag =>
|
111
|
-
new_tag(:tag =>
|
112
|
-
new_tag(:tag =>
|
113
|
-
new_tag(:tag =>
|
114
|
-
new_tag(:tag =>
|
115
|
-
new_tag(:tag =>
|
116
|
-
new_tag(:tag =>
|
117
|
-
new_tag(:tag =>
|
118
|
-
new_tag(:tag =>
|
119
|
-
new_tag(:tag =>
|
120
|
-
new_tag(:tag =>
|
121
|
-
new_tag(:tag =>
|
122
|
-
new_tag(:tag =>
|
123
|
-
new_tag(:tag =>
|
124
|
-
new_tag(:tag =>
|
125
|
-
new_tag(:tag =>
|
126
|
-
new_tag(:tag =>
|
127
|
-
new_tag(:tag =>
|
128
|
-
new_tag(:tag =>
|
129
|
-
new_tag(:tag =>
|
130
|
-
new_tag(:tag =>
|
131
|
-
new_tag(:tag =>
|
132
|
-
new_tag(:tag =>
|
133
|
-
new_tag(:tag =>
|
134
|
-
new_tag(:tag =>
|
135
|
-
new_tag(:tag =>
|
136
|
-
new_tag(:tag =>
|
137
|
-
new_tag(:tag =>
|
138
|
-
new_tag(:tag =>
|
139
|
-
new_tag(:tag =>
|
140
|
-
new_tag(:tag =>
|
141
|
-
new_tag(:tag =>
|
142
|
-
new_tag(:tag =>
|
143
|
-
new_tag(:tag =>
|
144
|
-
new_tag(:tag =>
|
145
|
-
new_tag(:tag =>
|
146
|
-
new_tag(:tag =>
|
26
|
+
new_tag(:tag => "5F57", :name => "Account Type", :description => "Indicates the type of account selected on the terminal, coded as specified in Annex G"),
|
27
|
+
new_tag(:tag => "9F01", :name => "Acquirer Identifier", :description => "Uniquely identifies the acquirer within each payment system"),
|
28
|
+
new_tag(:tag => "9F40", :name => "Additional Terminal Capabilities", :description => "Indicates the data input and output capabilities of the terminal"),
|
29
|
+
new_tag(:tag => "81", :name => "Amount, Authorised (Binary)", :description => "Authorised amount of the transaction (excluding adjustments)"),
|
30
|
+
new_tag(:tag => "9F02", :name => "Amount, Authorised (Numeric)", :description => "Authorised amount of the transaction (excluding adjustments)"),
|
31
|
+
new_tag(:tag => "9F04", :name => "Amount, Other (Binary)", :description => "Secondary amount associated with the transaction representing a cashback amount"),
|
32
|
+
new_tag(:tag => "9F03", :name => "Amount, Other (Numeric)", :description => "Secondary amount associated with the transaction representing a cashback amount"),
|
33
|
+
new_tag(:tag => "9F3A", :name => "Amount, Reference Currency", :description => "Authorised amount expressed in the reference currency"),
|
34
|
+
new_tag(:tag => "9F26", :name => "Application Cryptogram", :description => "Cryptogram returned by the ICC in response of the GENERATE AC command"),
|
35
|
+
new_tag(:tag => "9F42", :name => "Application Currency Code", :description => "Indicates the currency in which the account is managed according to ISO 4217"),
|
36
|
+
new_tag(:tag => "9F44", :name => "Application Currency Exponent", :description => "Indicates the implied position of the decimal point from the right of the amount represented according to ISO 4217"),
|
37
|
+
new_tag(:tag => "9F05", :name => "Application Discretionary Data", :description => "Issuer or payment system specified data relating to the application"),
|
38
|
+
new_tag(:tag => "5F25", :name => "Application Effective Date", :description => "Date from which the application may be used"),
|
39
|
+
new_tag(:tag => "5F24", :name => "Application Expiration Date", :description => "Date after which application expires"),
|
40
|
+
new_tag(:tag => "94", :name => "Application File Locator (AFL)", :description => "Indicates the location (SFI, range of records) of the AEFs related to a given application"),
|
41
|
+
new_tag(:tag => "4F", :name => "Application Dedicated File (ADF) Name", :description => "Identifies the application as described in ISO/IEC 7816-5"),
|
42
|
+
new_tag(:tag => "9F06", :name => "Application Identifier (AID) – terminal", :description => "Identifies the application as described in ISO/IEC 7816-5"),
|
43
|
+
new_tag(:tag => "82", :name => "Application Interchange Profile", :description => "Indicates the capabilities of the card to support specific functions in the application"),
|
44
|
+
new_tag(:tag => "50", :name => "Application Label", :format => :string, :description => "Mnemonic associated with the AID according to ISO/IEC 7816-5"),
|
45
|
+
new_tag(:tag => "9F12", :name => "Application Preferred Name", :format => :string, :description => "Preferred mnemonic associated with the AID"),
|
46
|
+
new_tag(:tag => "5A", :name => "Application Primary Account Number (PAN)", :description => "Valid cardholder account number"),
|
47
|
+
new_tag(:tag => "5F34", :name => "Application Primary Account Number (PAN) Sequence Number", :description => "Identifies and differentiates cards with the same PAN"),
|
48
|
+
new_tag(:tag => "87", :name => "Application Priority Indicator", :description => "Indicates the priority of a given application or group of applications in a directory"),
|
49
|
+
new_tag(:tag => "9F3B", :name => "Application Reference Currency", :description => "1-4 currency codes used between the terminal and the ICC when the Transaction Currency Code is different from the Application Currency Code; each code is 3 digits according to ISO 4217"),
|
50
|
+
new_tag(:tag => "9F43", :name => "Application Reference Currency Exponent", :description => "Indicates the implied position of the decimal point from the right of the amount, for each of the 1-4 reference currencies represented according to ISO 4217"),
|
51
|
+
new_tag(:tag => "70", :name => "Application Template", :description => "Contains one or more data objects relevant to an application directory entry according to ISO/IEC 7816-5"),
|
52
|
+
new_tag(:tag => "9F36", :name => "Application Transaction Counter (ATC)", :description => "Counter maintained by the application in the ICC (incrementing the ATC is managed by the ICC)"),
|
53
|
+
new_tag(:tag => "9F07", :name => "Application Usage Control", :description => "Indicates issuer’s specified restrictions on the geographic usage and services allowed for the application"),
|
54
|
+
new_tag(:tag => "9F08", :name => "Application Version Number", :description => "Version number assigned by the payment system for the application"),
|
55
|
+
new_tag(:tag => "9F09", :name => "Application Version Number", :description => "Version number assigned by the payment system for the application"),
|
56
|
+
new_tag(:tag => "89", :name => "Authorisation Code", :description => "Value generated by the authorisation authority for an approved transaction"),
|
57
|
+
new_tag(:tag => "8A", :name => "Authorisation Response Code", :format => :string, :description => "Code that defines the disposition of a message"),
|
58
|
+
new_tag(:tag => "5F54", :name => "Bank Identifier Code (BIC)", :description => "Uniquely identifies a bank as defined in ISO 9362."),
|
59
|
+
new_tag(:tag => "8C", :name => "Risk Management Data Object List 1 (CDOL1)", :description => "List of data objects (tag and length) to be passed to the ICC in the first GENERATE AC command"),
|
60
|
+
new_tag(:tag => "8D", :name => "Card Risk Management Data Object List 2 (CDOL2)", :description => "List of data objects (tag and length) to be passed to the ICC in the second GENERATE AC command"),
|
61
|
+
new_tag(:tag => "5F20", :name => "Cardholder Name", :format => :string, :description => "Indicates cardholder name according to ISO 7813"),
|
62
|
+
new_tag(:tag => "9F0B", :name => "Cardholder Name Extended", :format => :string, :description => "Indicates the whole cardholder name when greater than 26 characters using the same coding convention as in ISO 7813"),
|
63
|
+
new_tag(:tag => "8E", :name => "Cardholder Verification Method (CVM) List", :description => "Identifies a method of verification of the cardholder supported by the application"),
|
64
|
+
new_tag(:tag => "9F34", :name => "Cardholder Verification Method (CVM) Results", :description => "Indicates the results of the last CVM performed"),
|
65
|
+
new_tag(:tag => "8F", :name => "Certification Authority Public Key Index", :description => "Identifies the certification authority’s public key in conjunction with the RID"),
|
66
|
+
new_tag(:tag => "9F22", :name => "Certification Authority Public Key Index", :description => "Identifies the certification authority’s public key in conjunction with the RID"),
|
67
|
+
new_tag(:tag => "83", :name => "Command Template", :description => "Identifies the data field of a command message"),
|
68
|
+
new_tag(:tag => "9F27", :name => "Cryptogram Information Data", :description => "Indicates the type of cryptogram and the actions to be performed by the terminal"),
|
69
|
+
new_tag(:tag => "9F45", :name => "Data Authentication Code", :description => "An issuer assigned value that is retained by the terminal during the verification process of the Signed Static Application Data"),
|
70
|
+
new_tag(:tag => "84", :name => "Dedicated File (DF) Name", :description => "Identifies the name of the DF as described in ISO/IEC 7816-4"),
|
71
|
+
new_tag(:tag => "9D", :name => "Directory Definition File (DDF) Name", :description => "Identifies the name of a DF associated with a directory"),
|
72
|
+
new_tag(:tag => "73", :name => "Directory Discretionary Template", :description => "Issuer discretionary part of the directory according to ISO/IEC 7816-5"),
|
73
|
+
new_tag(:tag => "9F49", :name => "Dynamic Data Authentication Data Object List (DDOL)", :description => "List of data objects (tag and length) to be passed to the ICC in the INTERNAL AUTHENTICATE command"),
|
74
|
+
new_tag(:tag => "BF0C", :name => "File Control Information (FCI) Issuer Discretionary Data", :description => "Issuer discretionary part of the FCI"),
|
75
|
+
new_tag(:tag => "A5", :name => "File Control Information (FCI) Proprietary Template", :description => "Identifies the data object proprietary to this specification in the FCI template according to ISO/IEC 7816-4"),
|
76
|
+
new_tag(:tag => "6F", :name => "File Control Information (FCI) Template", :description => "Identifies the FCI template according to ISO/IEC 7816-4"),
|
77
|
+
new_tag(:tag => "9F4C", :name => "ICC Dynamic Number", :description => "Time-variant number generated by the ICC, to be captured by the terminal"),
|
78
|
+
new_tag(:tag => "9F2D", :name => "Integrated Circuit Card (ICC) PIN Encipherment Public Key Certificate", :description => "ICC PIN Encipherment Public Key certified by the issuer"),
|
79
|
+
new_tag(:tag => "9F2E", :name => "Integrated Circuit Card (ICC) PIN Encipherment Public Key Exponent", :description => "ICC PIN Encipherment Public Key Exponent used for PIN encipherment"),
|
80
|
+
new_tag(:tag => "9F2F", :name => "Integrated Circuit Card (ICC) PIN Encipherment Public Key Remainder", :description => "Remaining digits of the ICC PIN Encipherment Public Key Modulus"),
|
81
|
+
new_tag(:tag => "9F46", :name => "Integrated Circuit Card (ICC) Public Key Certificate", :description => "ICC Public Key certified by the issuer"),
|
82
|
+
new_tag(:tag => "9F47", :name => "Integrated Circuit Card (ICC) Public Key Exponent", :description => "ICC Public Key Exponent used for the verification of the Signed Dynamic Application Data"),
|
83
|
+
new_tag(:tag => "9F48", :name => "Integrated Circuit Card (ICC) Public Key Remainder", :description => "Remaining digits of the ICC Public Key Modulus"),
|
84
|
+
new_tag(:tag => "9F1E", :name => "Interface Device (IFD) Serial Number", :format => :string, :description => "Unique and permanent serial number assigned to the IFD by the manufacturer"),
|
85
|
+
new_tag(:tag => "5F53", :name => "International Bank Account Number (IBAN)", :description => "Uniquely identifies the account of a customer at a financial institution as defined in ISO 13616."),
|
86
|
+
new_tag(:tag => "9F0D", :name => "Issuer Action Code - Default", :description => "Specifies the issuer’s conditions that cause a transaction to be rejected if it might have been approved online, but the terminal is unable to process the transaction online"),
|
87
|
+
new_tag(:tag => "9F0E", :name => "Issuer Action Code - Denial", :description => "Specifies the issuer’s conditions that cause the denial of a transaction without attempt to go online"),
|
88
|
+
new_tag(:tag => "9F0F", :name => "Issuer Action Code - Online", :description => "Specifies the issuer’s conditions that cause a transaction to be transmitted online"),
|
89
|
+
new_tag(:tag => "9F10", :name => "Issuer Application Data", :description => "Contains proprietary application data for transmission to the issuer in an online transaction."),
|
90
|
+
new_tag(:tag => "91", :name => "Issuer Authentication Data", :description => "Data sent to the ICC for online issuer authentication"),
|
91
|
+
new_tag(:tag => "9F11", :name => "Issuer Code Table Index", :description => "Indicates the code table according to ISO/IEC 8859 for displaying the Application Preferred Name"),
|
92
|
+
new_tag(:tag => "5F28", :name => "Issuer Country Code", :description => "Indicates the country of the issuer according to ISO 3166"),
|
93
|
+
new_tag(:tag => "5F55", :name => "Issuer Country Code (alpha2 format)", :description => "Indicates the country of the issuer as defined in ISO 3166 (using a 2 character alphabetic code)"),
|
94
|
+
new_tag(:tag => "5F56", :name => "Issuer Country Code (alpha3 format)", :description => "Indicates the country of the issuer as defined in ISO 3166 (using a 3 character alphabetic code)"),
|
95
|
+
new_tag(:tag => "42", :name => "Issuer Identification Number (IIN)", :description => "The number that identifies the major industry and the card issuer and that forms the first part of the Primary Account Number (PAN)"),
|
96
|
+
new_tag(:tag => "90", :name => "Issuer Public Key Certificate", :description => "Issuer public key certified by a certification authority"),
|
97
|
+
new_tag(:tag => "9F32", :name => "Issuer Public Key Exponent", :description => "Issuer public key exponent used for the verification of the Signed Static Application Data and the ICC Public Key Certificate"),
|
98
|
+
new_tag(:tag => "92", :name => "Issuer Public Key Remainder", :description => "Remaining digits of the Issuer Public Key Modulus"),
|
99
|
+
new_tag(:tag => "86", :name => "Issuer Script Command", :description => "Contains a command for transmission to the ICC"),
|
100
|
+
new_tag(:tag => "9F18", :name => "Issuer Script Identifier", :description => "Identification of the Issuer Script"),
|
101
|
+
new_tag(:tag => "71", :name => "Issuer Script Template 1", :description => "Contains proprietary issuer data for transmission to the ICC before the second GENERATE AC command"),
|
102
|
+
new_tag(:tag => "72", :name => "Issuer Script Template 2", :description => "Contains proprietary issuer data for transmission to the ICC after the second GENERATE AC command"),
|
103
|
+
new_tag(:tag => "5F50", :name => "Issuer URL", :format => :string, :description => "The URL provides the location of the Issuer’s Library Server on the Internet."),
|
104
|
+
new_tag(:tag => "5F2D", :name => "Language Preference", :format => :string, :description => "1-4 languages stored in order of preference, each represented by 2 alphabetical characters according to ISO 639"),
|
105
|
+
new_tag(:tag => "9F13", :name => "Last Online Application Transaction Counter (ATC) Register", :description => "ATC value of the last transaction that went online"),
|
106
|
+
new_tag(:tag => "9F4D", :name => "Log Entry", :description => "Provides the SFI of the Transaction Log file and its number of records"),
|
107
|
+
new_tag(:tag => "9F4F", :name => "Log Format", :description => "List (in tag and length format) of data objects representing the logged data elements that are passed to the terminal when a transaction log record is read"),
|
108
|
+
new_tag(:tag => "9F14", :name => "Lower Consecutive Offline Limit", :description => "Issuer-specified preference for the maximum number of consecutive offline transactions for this ICC application allowed in a terminal with online capability"),
|
109
|
+
new_tag(:tag => "9F15", :name => "Merchant Category Code", :description => "Classifies the type of business being done by the merchant, represented according to ISO 8583:1993 for Card Acceptor Business Code"),
|
110
|
+
new_tag(:tag => "9F16", :name => "Merchant Identifier", :format => :string, :description => "When concatenated with the Acquirer Identifier, uniquely identifies a given merchant"),
|
111
|
+
new_tag(:tag => "9F4E", :name => "Merchant Name and Location", :format => :string, :description => "Indicates the name and location of the merchant"),
|
112
|
+
new_tag(:tag => "9F17", :name => "Personal Identification Number (PIN) Try Counter", :description => "Number of PIN tries remaining"),
|
113
|
+
new_tag(:tag => "9F39", :name => "Point-of-Service (POS) Entry Mode", :description => "Indicates the method by which the PAN was entered, according to the first two digits of the ISO 8583:1987 POS Entry Mode"),
|
114
|
+
new_tag(:tag => "9F38", :name => "Processing Options Data Object List (PDOL)", :description => "Contains a list of terminal resident data objects (tags and lengths) needed by the ICC in processing the GET PROCESSING OPTIONS command"),
|
115
|
+
new_tag(:tag => "70", :name => "READ RECORD Response Message Template", :description => "Contains the contents of the record read. (Mandatory for SFIs 1-10. Response messages for SFIs 11-30 are outside the scope of EMV, but may use template '70')"),
|
116
|
+
new_tag(:tag => "80", :name => "Response Message Template Format 1", :description => "Contains the data objects (without tags and lengths) returned by the ICC in response to a command"),
|
117
|
+
new_tag(:tag => "77", :name => "Response Message Template Format 2", :description => "Contains the data objects (with tags and lengths) returned by the ICC in response to a command"),
|
118
|
+
new_tag(:tag => "5F30", :name => "Service Code", :description => "Service code as defined in ISO/IEC 7813 for track 1 and track 2"),
|
119
|
+
new_tag(:tag => "88", :name => "Short File Identifier (SFI)", :description => "Identifies the AEF referenced in commands related to a given ADF or DDF. It is a binary data object having a value in the range 1 to 30 and with the three high order bits set to zero."),
|
120
|
+
new_tag(:tag => "9F4B", :name => "Signed Dynamic Application Data", :description => "Digital signature on critical application parameters for DDA or CDA"),
|
121
|
+
new_tag(:tag => "93", :name => "Signed Static Application Data", :description => "Digital signature on critical application parameters for SDA"),
|
122
|
+
new_tag(:tag => "9F4A", :name => "Static Data Authentication Tag List", :description => "List of tags of primitive data objects defined in this specification whose value fields are to be included in the Signed Static or Dynamic Application Data"),
|
123
|
+
new_tag(:tag => "9F33", :name => "Terminal Capabilities", :description => "Indicates the card data input, CVM, and security capabilities of the terminal"),
|
124
|
+
new_tag(:tag => "9F1A", :name => "Terminal Country Code", :description => "Indicates the country of the terminal, represented according to ISO 3166"),
|
125
|
+
new_tag(:tag => "9F1B", :name => "Terminal Floor Limit", :description => "Indicates the floor limit in the terminal in conjunction with the AID"),
|
126
|
+
new_tag(:tag => "9F1C", :name => "Terminal Identification", :format => :string, :description => "Designates the unique location of a terminal at a merchant"),
|
127
|
+
new_tag(:tag => "9F1D", :name => "Terminal Risk Management Data", :description => "Application-specific value used by the card for risk management purposes"),
|
128
|
+
new_tag(:tag => "9F35", :name => "Terminal Type", :description => "Indicates the environment of the terminal, its communications capability, and its operational control"),
|
129
|
+
new_tag(:tag => "95", :name => "Terminal Verification Results", :description => "Status of the different functions as seen from the terminal"),
|
130
|
+
new_tag(:tag => "9F1F", :name => "Track 1 Discretionary Data", :description => "Discretionary part of track 1 according to ISO/IEC 7813"),
|
131
|
+
new_tag(:tag => "9F20", :name => "Track 2 Discretionary Data", :description => "Discretionary part of track 2 according to ISO/IEC 7813"),
|
132
|
+
new_tag(:tag => "57", :name => "Track 2 Equivalent Data", :description => "Contains the data elements of track 2 according to ISO/IEC 7813, excluding start sentinel, end sentinel, and Longitudinal Redundancy Check (LRC)"),
|
133
|
+
new_tag(:tag => "97", :name => "Transaction Certificate Data Object List (TDOL)", :description => "List of data objects (tag and length) to be used by the terminal in generating the TC Hash Value"),
|
134
|
+
new_tag(:tag => "98", :name => "Transaction Certificate (TC) Hash Value", :description => "Result of a hash function specified in Book 2, Annex B3.1"),
|
135
|
+
new_tag(:tag => "5F2A", :name => "Transaction Currency Code", :description => "Indicates the currency code of the transaction according to ISO 4217"),
|
136
|
+
new_tag(:tag => "5F36", :name => "Transaction Currency Exponent", :description => "Indicates the implied position of the decimal point from the right of the transaction amount represented according to ISO 4217"),
|
137
|
+
new_tag(:tag => "9A", :name => "Transaction Date", :description => "Local date that the transaction was authorised"),
|
138
|
+
new_tag(:tag => "99", :name => "Transaction Personal Identification Number (PIN) Data", :description => "Data entered by the cardholder for the purpose of the PIN verification"),
|
139
|
+
new_tag(:tag => "9F3C", :name => "Transaction Reference Currency Code", :description => "Code defining the common currency used by the terminal in case the Transaction Currency Code is different from the Application Currency Code"),
|
140
|
+
new_tag(:tag => "9F3D", :name => "Transaction Reference Currency Exponent", :description => "Indicates the implied position of the decimal point from the right of the transaction amount, with the Transaction Reference Currency Code represented according to ISO 4217"),
|
141
|
+
new_tag(:tag => "9F41", :name => "Transaction Sequence Counter", :description => "Counter maintained by the terminal that is incremented by one for each transaction"),
|
142
|
+
new_tag(:tag => "9B", :name => "Transaction Status Information", :description => "Indicates the functions performed in a transaction"),
|
143
|
+
new_tag(:tag => "9F21", :name => "Transaction Time", :description => "Local time that the transaction was authorised"),
|
144
|
+
new_tag(:tag => "9C", :name => "Transaction Type", :description => "Indicates the type of financial transaction, represented by the first two digits of the ISO 8583:1987 Processing Code. The actual values to be used for the Transaction Type data element are defined by the relevant payment system"),
|
145
|
+
new_tag(:tag => "9F37", :name => "Unpredictable Number", :description => "Value to provide variability and uniqueness to the generation of a cryptogram"),
|
146
|
+
new_tag(:tag => "9F23", :name => "Upper Consecutive Offline Limit", :description => "Issuer-specified preference for the maximum number of consecutive offline transactions for this ICC application allowed in a terminal without online capability"),
|
147
147
|
]
|
148
148
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grizzly_ber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Balsdon
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: CODEC for TLV-BER encoded strings.
|
13
|
+
description: CODEC for EMV TLV-BER encoded strings.
|
14
14
|
email: ryan.balsdon@shopify.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
@@ -30,7 +30,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
36
|
- - '>='
|