openssl-ccm 1.2.0 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +6 -6
- data/lib/openssl/ccm/version.rb +1 -1
- data/lib/openssl/ccm.rb +5 -6
- data/test/test_ccm.rb +24 -19
- metadata +40 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35a41e57bff48e3beb7088edbd3393da7b3406495d2ba454e8677c4841973f3f
|
4
|
+
data.tar.gz: 10f313e08c40b07386fd32435656bb143fefb361c0bf512f693573caf76dabfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d0a59af7d0492c0a6f70f1c10780233d6f631a35b8a839e5645dd39b00424098564483e9538b2da2aa6d72e34d872edd4c8c6298b74bad809def79f0be8bc8f
|
7
|
+
data.tar.gz: 8a6f4c08e263878b68eb5ac905d9fa34e997960376bf518b8fe792f0779db2b7a1edb2802dab22ef46545519ee00d25ac598a7419021fd4544bbe581d498d44a
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rake', '>=
|
4
|
-
gem 'rdoc', '>=4.
|
5
|
-
gem 'yard', '>=0.
|
6
|
-
gem 'rubocop', '>=0.
|
7
|
-
gem 'test-unit', '>=3.
|
8
|
-
gem 'coveralls', '>=0.
|
3
|
+
gem 'rake', '>=12.3.2'
|
4
|
+
gem 'rdoc', '>=4.3.0'
|
5
|
+
gem 'yard', '>=0.9.16'
|
6
|
+
gem 'rubocop', '>=0.50.0'
|
7
|
+
gem 'test-unit', '>=3.2.9'
|
8
|
+
gem 'coveralls', '>=0.8.22'
|
data/lib/openssl/ccm/version.rb
CHANGED
data/lib/openssl/ccm.rb
CHANGED
@@ -21,10 +21,7 @@ module OpenSSL
|
|
21
21
|
#
|
22
22
|
# @return [[String]] supported algorithms
|
23
23
|
def self.ciphers
|
24
|
-
|
25
|
-
c.end_with?('-192-CBC') or c.end_with?('-256-CBC') }
|
26
|
-
l.length.times { |i| l[i] = l[i][0..-9] }
|
27
|
-
l
|
24
|
+
@ciphers ||= OpenSSL::Cipher.ciphers.select { |c| c.match(/-(128|192|256)-CBC$/i) }.map { |e| e[0..-9].upcase }.uniq
|
28
25
|
end
|
29
26
|
|
30
27
|
public
|
@@ -38,7 +35,7 @@ module OpenSSL
|
|
38
35
|
#
|
39
36
|
# @return [Object] the new CCM object
|
40
37
|
def initialize(cipher, key, mac_len)
|
41
|
-
unless CCM.ciphers.include?(cipher)
|
38
|
+
unless CCM.ciphers.include?(cipher.upcase)
|
42
39
|
fail CCMError, "unsupported cipher algorithm (#{cipher})"
|
43
40
|
end
|
44
41
|
fail CCMError, 'invalid key length' unless key.b.length >= 16
|
@@ -54,7 +51,7 @@ module OpenSSL
|
|
54
51
|
cipher_key_size = "256"
|
55
52
|
end
|
56
53
|
|
57
|
-
@cipher = OpenSSL::Cipher.new("#{cipher}-" + cipher_key_size + "-CBC")
|
54
|
+
@cipher = OpenSSL::Cipher.new("#{cipher.upcase}-" + cipher_key_size + "-CBC")
|
58
55
|
@key = key
|
59
56
|
@mac_len = mac_len
|
60
57
|
end
|
@@ -122,6 +119,7 @@ module OpenSSL
|
|
122
119
|
@cipher.reset
|
123
120
|
@cipher.encrypt
|
124
121
|
@cipher.key = @key
|
122
|
+
@cipher.iv = "\x00" * 16
|
125
123
|
|
126
124
|
b_0 = Array.new(8, 0)
|
127
125
|
b_0[0] = (additional_data.empty? ? 0 : 64) \
|
@@ -167,6 +165,7 @@ module OpenSSL
|
|
167
165
|
@cipher.reset
|
168
166
|
@cipher.encrypt
|
169
167
|
@cipher.key = @key
|
168
|
+
@cipher.iv = "\x00" * 16
|
170
169
|
@cipher.update(a.pack('C*'))
|
171
170
|
end
|
172
171
|
end
|
data/test/test_ccm.rb
CHANGED
@@ -281,16 +281,19 @@ class CCMTest < Test::Unit::TestCase
|
|
281
281
|
mac_len = [16, 8, 14, 8]
|
282
282
|
|
283
283
|
assert(OpenSSL::CCM.ciphers.include?('AES'), 'Missing AES-Cipher')
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
284
|
+
|
285
|
+
for cipher in ['aes', 'AES']
|
286
|
+
1.upto(3) do |i|
|
287
|
+
open("test/data_#{i}", mode = 'r') do |i_file|
|
288
|
+
input = i_file.read
|
289
|
+
key.length.times do |j|
|
290
|
+
open("test/data_#{i}-#{j + 1}_e", mode = 'r') do |o_file|
|
291
|
+
output = o_file.read
|
292
|
+
ccm = OpenSSL::CCM.new(cipher, [key[j]].pack('H*'), mac_len[j])
|
293
|
+
c = ccm.encrypt(input, [nonce[j]].pack('H*'))
|
294
|
+
assert_equal(output.unpack('H*'), c.unpack('H*'),
|
295
|
+
"Wrong ENCRYPT in Vector #{i + 1}")
|
296
|
+
end
|
294
297
|
end
|
295
298
|
end
|
296
299
|
end
|
@@ -325,15 +328,17 @@ class CCMTest < Test::Unit::TestCase
|
|
325
328
|
)
|
326
329
|
|
327
330
|
assert(OpenSSL::CCM.ciphers.include?('AES'), 'Missing AES-Cipher')
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
331
|
+
|
332
|
+
for cipher in ['aes', 'AES']
|
333
|
+
key.length.times do |i|
|
334
|
+
mac_len = mac[i].length / 2
|
335
|
+
ccm = OpenSSL::CCM.new(cipher, [key[i]].pack('H*'), mac_len)
|
336
|
+
c = ccm.encrypt([plaintext[i]].pack('H*'), [nonce[i]].pack('H*'))
|
337
|
+
assert_equal([mac[i]], c[-mac_len..-1].unpack('H*'),
|
338
|
+
"Wrong MAC ENCRYPT in Test #{i} ")
|
339
|
+
assert_equal([ciphertext[i]], c[0..-mac_len - 1].unpack('H*'),
|
340
|
+
"Wrong ciphertext ENCRYPT in Test #{i}")
|
341
|
+
end
|
337
342
|
end
|
338
343
|
end
|
339
344
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openssl-ccm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Schmertmann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,120 +16,120 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '12.3'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 12.3.2
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '12.3'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 12.3.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rdoc
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '4.
|
39
|
+
version: '4.3'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 4.
|
42
|
+
version: 4.3.0
|
43
43
|
type: :development
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '4.
|
49
|
+
version: '4.3'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 4.
|
52
|
+
version: 4.3.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: yard
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '0.
|
59
|
+
version: '0.9'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.
|
62
|
+
version: 0.9.16
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0.
|
69
|
+
version: '0.9'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 0.
|
72
|
+
version: 0.9.16
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: rubocop
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '0.
|
79
|
+
version: '0.50'
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.50.0
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.50'
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 0.
|
92
|
+
version: 0.50.0
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: test-unit
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - "~>"
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: '3.
|
99
|
+
version: '3.2'
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 3.
|
102
|
+
version: 3.2.9
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
109
|
+
version: '3.2'
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 3.
|
112
|
+
version: 3.2.9
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: coveralls
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '0.
|
119
|
+
version: '0.8'
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0.
|
122
|
+
version: 0.8.22
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - "~>"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: '0.
|
129
|
+
version: '0.8'
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.
|
132
|
+
version: 0.8.22
|
133
133
|
description: Ruby Gem for RFC 3610 - Counter with CBC-MAC (CCM)
|
134
134
|
email:
|
135
135
|
- SmallLars@t-online.de
|
@@ -184,26 +184,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
|
-
|
188
|
-
|
189
|
-
signing_key:
|
187
|
+
rubygems_version: 3.3.15
|
188
|
+
signing_key:
|
190
189
|
specification_version: 4
|
191
190
|
summary: RFC 3610 - CCM
|
192
191
|
test_files:
|
193
192
|
- test/test_ccm.rb
|
194
|
-
- test/data_1
|
195
|
-
- test/data_3-1_e
|
196
|
-
- test/data_3-2_e
|
197
|
-
- test/data_1-2_e
|
193
|
+
- test/data_1
|
198
194
|
- test/data_1-1_e
|
199
|
-
- test/
|
200
|
-
- test/
|
195
|
+
- test/data_1-2_e
|
196
|
+
- test/data_1-3_e
|
197
|
+
- test/data_1-4_e
|
201
198
|
- test/data_2
|
202
|
-
- test/
|
203
|
-
- test/
|
199
|
+
- test/data_2-1_e
|
200
|
+
- test/data_2-2_e
|
201
|
+
- test/data_2-3_e
|
204
202
|
- test/data_2-4_e
|
203
|
+
- test/data_3
|
204
|
+
- test/data_3-1_e
|
205
|
+
- test/data_3-2_e
|
205
206
|
- test/data_3-3_e
|
206
|
-
- test/
|
207
|
-
- test/data_2-3_e
|
208
|
-
- test/data_2-1_e
|
209
|
-
has_rdoc:
|
207
|
+
- test/data_3-4_e
|