edb 0.6 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/edb/cryptography/aes_256_cbc.rb +8 -8
- data/lib/edb/version.rb +1 -1
- data/specs/cryptography/aes_256_cbc_spec.rb +0 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e17dd73f932110daaefd68f24eba4d82996d1bfe
|
4
|
+
data.tar.gz: ed2f112288ebc8c6f2af8d419e68acfdf149ad3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6117055df2f1cc9b1df10eee1c12feb4f5255efba51ac22a8be0645a188071a2c6aa1bc5648a6841f058f0268d122da22da76c019078bd730ff0b63779eec176
|
7
|
+
data.tar.gz: 024d5044d2df77d90363b419468fe31c1a4a91cfe4352660168f83eff45073765eba607a5c5f800cdaedcb5440414e7a3c1ea2e8d2938d354e73f23fc50381f3
|
data/Gemfile.lock
CHANGED
@@ -35,8 +35,10 @@ module EDB
|
|
35
35
|
cipher = OpenSSL::Cipher.new('AES-256-CBC')
|
36
36
|
cipher.encrypt
|
37
37
|
|
38
|
-
|
39
|
-
cipher.
|
38
|
+
hkdf = HKDF.new(::EDB.opts[:CRYPTOGRAPHY][:AES_256_CBC][:secret])
|
39
|
+
cipher.key = hkdf.next_bytes(32)
|
40
|
+
authentication_key = hkdf.next_bytes(64)
|
41
|
+
cipher.iv = iv = cipher.random_iv
|
40
42
|
|
41
43
|
ciphered_data = cipher.update(data) + cipher.final
|
42
44
|
ciphered_data << iv
|
@@ -52,7 +54,10 @@ module EDB
|
|
52
54
|
decipher.decrypt
|
53
55
|
|
54
56
|
authentication = slice_str!(ciphered_data, 32)
|
55
|
-
|
57
|
+
|
58
|
+
hkdf = HKDF.new(::EDB.opts[:CRYPTOGRAPHY][:AES_256_CBC][:secret])
|
59
|
+
decipher.key = hkdf.next_bytes(32)
|
60
|
+
authentication_key = hkdf.next_bytes(64)
|
56
61
|
|
57
62
|
new_authentication = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), authentication_key, ciphered_data)
|
58
63
|
raise 'Authentication failed.' unless FastSecureCompare.compare(authentication, new_authentication)
|
@@ -67,11 +72,6 @@ module EDB
|
|
67
72
|
len = str.length
|
68
73
|
str.slice!(len - n, len)
|
69
74
|
end
|
70
|
-
|
71
|
-
def hash_keychain(s)
|
72
|
-
hkdf = HKDF.new(s)
|
73
|
-
[ hkdf.next_bytes(64), hkdf.next_bytes(64) ]
|
74
|
-
end
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/lib/edb/version.rb
CHANGED
@@ -45,13 +45,4 @@ describe EDB::Cryptography::AES_256_CBC do
|
|
45
45
|
expect(str).to eq 'senjou'
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
49
|
-
describe '#hash_keychain' do
|
50
|
-
let(:keychain) { EDB::Cryptography::AES_256_CBC.instance_eval { hash_keychain('hitagi') } }
|
51
|
-
|
52
|
-
it 'returns an array with two 64 bytes long keys' do
|
53
|
-
expect(keychain[0].length).to be 64
|
54
|
-
expect(keychain[1].length).to be 64
|
55
|
-
end
|
56
|
-
end
|
57
48
|
end
|