openssl-ccm 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/README.md +1 -1
- data/lib/openssl/ccm/version.rb +1 -1
- data/lib/openssl/ccm.rb +11 -2
- data/test/test_ccm.rb +40 -0
- metadata +32 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcfb9a56cb2e5cc402ae3ffe01b433e389d8c578
|
4
|
+
data.tar.gz: 7ce23883a6eed6ef9ee941b4b2367522a69ebe67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863821e84c474fbd9218a3d967b9a519165f7ff7b684536d6048ea1e2682f743936b7c925e6b4c7e2a73ebbf85d226ed7c7cd082692423240e304edd6f296443
|
7
|
+
data.tar.gz: 14a6aef3b2b91fb5faf309735d44731058fcfdd7bebed7872bd4da347fc30332e5d6a72b3ea772907412540a5bf3ba1d5b43ff676ac6b0be86b8346ad6d3cf17
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/SmallLars/openssl-ccm.png?branch=master)](https://travis-ci.org/SmallLars/openssl-ccm)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/SmallLars/openssl-ccm/badge.png?branch=master)](https://coveralls.io/r/SmallLars/openssl-ccm)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/SmallLars/openssl-ccm.png)](https://codeclimate.com/github/SmallLars/openssl-ccm)
|
6
|
-
[![Inline docs](http://inch-
|
6
|
+
[![Inline docs](http://inch-ci.org/github/smalllars/openssl-ccm.png)](http://inch-ci.org/github/smalllars/openssl-ccm)
|
7
7
|
|
8
8
|
# openssl-ccm
|
9
9
|
|
data/lib/openssl/ccm/version.rb
CHANGED
data/lib/openssl/ccm.rb
CHANGED
@@ -21,7 +21,8 @@ module OpenSSL
|
|
21
21
|
#
|
22
22
|
# @return [[String]] supported algorithms
|
23
23
|
def self.ciphers
|
24
|
-
l = OpenSSL::Cipher.ciphers.keep_if { |c| c.end_with?('-128-CBC')
|
24
|
+
l = OpenSSL::Cipher.ciphers.keep_if { |c| c.end_with?('-128-CBC') or
|
25
|
+
c.end_with?('-192-CBC') or c.end_with?('-256-CBC') }
|
25
26
|
l.length.times { |i| l[i] = l[i][0..-9] }
|
26
27
|
l
|
27
28
|
end
|
@@ -45,7 +46,15 @@ module OpenSSL
|
|
45
46
|
fail CCMError, 'invalid mac length'
|
46
47
|
end
|
47
48
|
|
48
|
-
|
49
|
+
if key.length < 24
|
50
|
+
cipher_key_size = "128"
|
51
|
+
elsif key.length < 32
|
52
|
+
cipher_key_size = "192"
|
53
|
+
else
|
54
|
+
cipher_key_size = "256"
|
55
|
+
end
|
56
|
+
|
57
|
+
@cipher = OpenSSL::Cipher.new("#{cipher}-" + cipher_key_size + "-CBC")
|
49
58
|
@key = key
|
50
59
|
@mac_len = mac_len
|
51
60
|
end
|
data/test/test_ccm.rb
CHANGED
@@ -296,4 +296,44 @@ class CCMTest < Test::Unit::TestCase
|
|
296
296
|
end
|
297
297
|
end
|
298
298
|
end
|
299
|
+
|
300
|
+
#Test case from https://github.com/weidai11/cryptopp/blob/master/TestVectors/ccm.txt
|
301
|
+
def test_aes_data_256
|
302
|
+
key = %W(
|
303
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
304
|
+
fb7615b23d80891dd470980bc79584c8b2fb64ce60978f4d17fce45a49e830b7
|
305
|
+
)
|
306
|
+
|
307
|
+
nonce = %W(
|
308
|
+
000000000000000000000000
|
309
|
+
dbd1a3636024b7b402da7d6f
|
310
|
+
)
|
311
|
+
|
312
|
+
plaintext = %W(
|
313
|
+
00000000000000000000000000000000
|
314
|
+
a845348ec8c5b5f126f50e76fefd1b1e
|
315
|
+
)
|
316
|
+
|
317
|
+
ciphertext = %W(
|
318
|
+
c1944044c8e7aa95d2de9513c7f3dd8c
|
319
|
+
cc881261c6a7fa72b96a1739176b277f
|
320
|
+
)
|
321
|
+
|
322
|
+
mac = %W(
|
323
|
+
4b0a3e5e51f151eb0ffae7c43d010fdb
|
324
|
+
3472e1145f2c0cbe146349062cf0e423
|
325
|
+
)
|
326
|
+
|
327
|
+
assert(OpenSSL::CCM.ciphers.include?('AES'), 'Missing AES-Cipher')
|
328
|
+
key.length.times do |i|
|
329
|
+
mac_len = mac[i].length / 2
|
330
|
+
ccm = OpenSSL::CCM.new('AES', [key[i]].pack('H*'), mac_len)
|
331
|
+
c = ccm.encrypt([plaintext[i]].pack('H*'), [nonce[i]].pack('H*'))
|
332
|
+
c_unpack = c.unpack('H*')
|
333
|
+
assert_equal([mac[i]], c[-mac_len..-1].unpack('H*'),
|
334
|
+
"Wrong MAC ENCRYPT in Test #{i} ")
|
335
|
+
assert_equal([ciphertext[i]], c[0..-mac_len - 1].unpack('H*'),
|
336
|
+
"Wrong ciphertext ENCRYPT in Test #{i}")
|
337
|
+
end
|
338
|
+
end
|
299
339
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openssl-ccm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Schmertmann
|
@@ -90,6 +90,26 @@ dependencies:
|
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 0.18.1
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: test-unit
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '3.1'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.1.4
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.1'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.1.4
|
93
113
|
- !ruby/object:Gem::Dependency
|
94
114
|
name: coveralls
|
95
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,25 +185,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
185
|
version: '0'
|
166
186
|
requirements: []
|
167
187
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.5.0
|
169
189
|
signing_key:
|
170
190
|
specification_version: 4
|
171
191
|
summary: RFC 3610 - CCM
|
172
192
|
test_files:
|
173
193
|
- test/test_ccm.rb
|
174
|
-
- test/data_1-3_e
|
175
|
-
- test/data_1-1_e
|
176
|
-
- test/data_3
|
177
|
-
- test/data_3-4_e
|
178
|
-
- test/data_3-2_e
|
179
|
-
- test/data_2-2_e
|
180
|
-
- test/data_1-2_e
|
181
194
|
- test/data_1-4_e
|
182
195
|
- test/data_3-1_e
|
183
|
-
- test/data_3-
|
184
|
-
- test/data_1
|
196
|
+
- test/data_3-2_e
|
197
|
+
- test/data_1-2_e
|
198
|
+
- test/data_1-1_e
|
199
|
+
- test/data_2-2_e
|
200
|
+
- test/data_3-4_e
|
185
201
|
- test/data_2
|
202
|
+
- test/data_1
|
203
|
+
- test/data_3
|
186
204
|
- test/data_2-4_e
|
187
|
-
- test/
|
205
|
+
- test/data_3-3_e
|
206
|
+
- test/data_1-3_e
|
188
207
|
- test/data_2-3_e
|
208
|
+
- test/data_2-1_e
|
189
209
|
has_rdoc:
|