jwe 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/jwe.gemspec +3 -1
- data/lib/jwe/enc/aes_cbc_hs.rb +2 -2
- data/lib/jwe/version.rb +1 -1
- data/spec/jwe/enc_spec.rb +3 -3
- data/spec/jwe_spec.rb +3 -2
- data/spec/spec_helper.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa8fe82eeb7d259a610ce7e6a89374a8d5cd7ff2
|
4
|
+
data.tar.gz: 0a1a8862400049ee407852f0e21cbb0cb6a8210b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e851c53020b8c790080090ba7ca53e9e4264a5bcb990dd78598d2b0109ca5fe83e77fe2a3ae40c2ee5fcf75265e6074985f1038ef5ebd4003df8fa23fc5b59
|
7
|
+
data.tar.gz: f01772b4e6dc52ccded47081617c2890d21faf017b00ee285e525138e7d65765d9b2e38889b391159cf876e20328e81423afdf0123bcdd9497cc6581d4ad5478
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/jwe.gemspec
CHANGED
@@ -15,7 +15,9 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.require_paths = %w(lib)
|
17
17
|
|
18
|
+
s.required_ruby_version = '>= 2.0.0'
|
19
|
+
|
18
20
|
s.add_development_dependency 'rspec'
|
19
21
|
s.add_development_dependency 'rake'
|
20
|
-
s.add_development_dependency '
|
22
|
+
s.add_development_dependency 'simplecov'
|
21
23
|
end
|
data/lib/jwe/enc/aes_cbc_hs.rb
CHANGED
@@ -18,7 +18,7 @@ module JWE
|
|
18
18
|
cipher.iv = iv
|
19
19
|
|
20
20
|
ciphertext = cipher.update(cleartext) + cipher.final
|
21
|
-
length = [
|
21
|
+
length = [authenticated_data.length * 8].pack('Q>') # 64bit big endian
|
22
22
|
|
23
23
|
to_sign = authenticated_data + iv + ciphertext + length
|
24
24
|
signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new(hash_name), mac_key, to_sign)
|
@@ -30,7 +30,7 @@ module JWE
|
|
30
30
|
def decrypt(ciphertext, authenticated_data)
|
31
31
|
raise JWE::BadCEK.new("The supplied key is invalid. Required length: #{key_length}") if cek.length != key_length
|
32
32
|
|
33
|
-
length = [
|
33
|
+
length = [authenticated_data.length * 8].pack('Q>') # 64bit big endian
|
34
34
|
to_sign = authenticated_data + iv + ciphertext + length
|
35
35
|
signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new(hash_name), mac_key, to_sign)
|
36
36
|
if signature[0...mac_key.length] != tag
|
data/lib/jwe/version.rb
CHANGED
data/spec/jwe/enc_spec.rb
CHANGED
@@ -46,7 +46,7 @@ gcm = [
|
|
46
46
|
class: JWE::Enc::A128cbcHs256,
|
47
47
|
keylen: 32,
|
48
48
|
helloworld: "\a\x02F\xA4m%\xDFH\xB4\xA4.\xBF:\xBF$\xE2".force_encoding('BINARY'),
|
49
|
-
tag: "\
|
49
|
+
tag: "\xDE$t\xBA\x8B\xEE\u001Df\x81\a\xC1\xBB\x98\xDFl\xF2".force_encoding('BINARY'),
|
50
50
|
ivlen: 16,
|
51
51
|
iv: "\x0" * 16
|
52
52
|
},
|
@@ -54,7 +54,7 @@ gcm = [
|
|
54
54
|
class: JWE::Enc::A192cbcHs384,
|
55
55
|
keylen: 48,
|
56
56
|
helloworld: "p\xFES\xF0\xB4\xCC]8\x1D\xDE\x8Dt\xE7tMh".force_encoding('BINARY'),
|
57
|
-
tag: "\
|
57
|
+
tag: "\xA8a\x04kRJ\x06`tp6\x8E\x9Ba\xE1e\xF6\xDA\"\x15\xEBk\xFDm".force_encoding('BINARY'),
|
58
58
|
ivlen: 16,
|
59
59
|
iv: "\x0" * 16
|
60
60
|
},
|
@@ -62,7 +62,7 @@ gcm = [
|
|
62
62
|
class: JWE::Enc::A256cbcHs512,
|
63
63
|
keylen: 64,
|
64
64
|
helloworld: "c\xFD\\\xB9Z\xB6\xE3\xB7\xEE\xA1\xD8\xDF\xB5\xB2\xF8\xEB".force_encoding('BINARY'),
|
65
|
-
tag: "\
|
65
|
+
tag: "wC\xE3:\x91\x89W\x97\xBE\xB0\xBD\xEAo\xC66\x9F\xB82\xFDn\xA7.\u0014l\xFC2\xD7\xDFq\xB5[\xC6".force_encoding('BINARY'),
|
66
66
|
ivlen: 16,
|
67
67
|
iv: "\x0" * 16
|
68
68
|
}
|
data/spec/jwe_spec.rb
CHANGED
@@ -21,8 +21,9 @@ describe JWE do
|
|
21
21
|
|
22
22
|
describe 'when using dir alg method' do
|
23
23
|
it 'roundtrips' do
|
24
|
-
|
25
|
-
|
24
|
+
aes_password = SecureRandom.random_bytes(16)
|
25
|
+
encrypted = JWE.encrypt(plaintext, aes_password, alg: 'dir')
|
26
|
+
result = JWE.decrypt(encrypted, aes_password)
|
26
27
|
|
27
28
|
expect(result).to eq plaintext
|
28
29
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Boffa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: simplecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.0.0
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.6.11
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: JSON Web Encryption implementation in Ruby
|