openssl-ccm 1.2.1 → 1.2.2
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.rb +3 -6
- data/lib/openssl/ccm/version.rb +1 -1
- data/test/test_ccm.rb +24 -19
- metadata +33 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 94f0f2ac744cac26cf3f3fe5ec47b676d656d0a3d57eaef6ac5af2e5aceade69
|
4
|
+
data.tar.gz: 0c5e4bee394768df4c0d7f88edd4c297513e420c8bfb2dd10f4ddbe885fa552f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec73e24140d4702b6a5debd39d5ef77dd1815d9c5a9bccc586350474ddbe971f02727261deb1fe320596662847cd2598b08ac652ce8b42c279bbeceb67df5fb
|
7
|
+
data.tar.gz: f6e5f8c3a7380b21cab77f9ca1af26635c9564fc4f0b05df7b4b537bad6b96e9d4bb622efd796d9708d2dd1119891c7e6fb84bd6d423795fe41fa3b54ee9d24a
|
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.8.
|
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.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
|
data/lib/openssl/ccm/version.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Schmertmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,100 +16,100 @@ 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
|
@@ -119,7 +119,7 @@ dependencies:
|
|
119
119
|
version: '0.8'
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0.8.
|
122
|
+
version: 0.8.22
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -129,7 +129,7 @@ dependencies:
|
|
129
129
|
version: '0.8'
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.8.
|
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
|
@@ -185,25 +185,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.7.7
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: RFC 3610 - CCM
|
192
192
|
test_files:
|
193
193
|
- test/test_ccm.rb
|
194
|
-
- test/data_1-4_e
|
195
|
-
- test/data_3-1_e
|
196
194
|
- test/data_3-2_e
|
197
|
-
- test/data_1-2_e
|
198
|
-
- test/data_1-1_e
|
199
|
-
- test/data_2-2_e
|
200
195
|
- test/data_3-4_e
|
201
|
-
- test/
|
202
|
-
- test/data_1
|
196
|
+
- test/data_3-1_e
|
203
197
|
- test/data_3
|
198
|
+
- test/data_1-2_e
|
204
199
|
- test/data_2-4_e
|
205
|
-
- test/
|
200
|
+
- test/data_1-4_e
|
206
201
|
- test/data_1-3_e
|
202
|
+
- test/data_2-2_e
|
207
203
|
- test/data_2-3_e
|
204
|
+
- test/data_1
|
205
|
+
- test/data_2
|
206
|
+
- test/data_1-1_e
|
208
207
|
- test/data_2-1_e
|
209
|
-
|
208
|
+
- test/data_3-3_e
|