jwe 1.1.0 → 1.1.2
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/.github/dependabot.yml +7 -0
- data/.github/workflows/test.yml +3 -2
- data/.gitignore +3 -1
- data/.rubocop.yml +4 -2
- data/CHANGELOG.md +17 -0
- data/README.md +3 -3
- data/Rakefile +4 -1
- data/jwe.gemspec +1 -1
- data/lib/jwe/alg/aes_kw.rb +2 -5
- data/lib/jwe/alg/rsa15.rb +21 -0
- data/lib/jwe/alg.rb +4 -2
- data/lib/jwe/enc/aes_cbc_hs.rb +2 -6
- data/lib/jwe/enc/aes_gcm.rb +6 -4
- data/lib/jwe/enc/cipher.rb +1 -1
- data/lib/jwe/version.rb +1 -1
- data/lib/jwe/zip/def.rb +26 -3
- data/lib/jwe.rb +3 -3
- data/spec/jwe/alg_spec.rb +24 -0
- data/spec/jwe/enc_spec.rb +8 -0
- data/spec/jwe/zip_spec.rb +21 -1
- data/spec/jwe_spec.rb +43 -0
- metadata +4 -4
- data/.rubocop_todo.yml +0 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf579e6953c21455a4231c65f035af414d5c8bd2a4e37d1a554190df19a3a432
|
|
4
|
+
data.tar.gz: 353473ad89206001ff019dba57f0c661ca442a09867592df80071bd3455b770b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 373b6a2fc7b4b80b85c932c8a264a50d6898f1609dcb1ae898359230ba50aa6fb509e89fa933aff44afc14685a2c98e9eccf5cd17f642a4a52dd1985a544008a
|
|
7
|
+
data.tar.gz: 7044387c0a4f6064738e79314ebec8311b9d847b1372674ef0d399a7965da90b6cce0742177bd3ffdf69a9e551f02b59b9d5c1a14011818b137c39541c1174f9
|
data/.github/workflows/test.yml
CHANGED
|
@@ -13,7 +13,7 @@ jobs:
|
|
|
13
13
|
name: RuboCop
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v7
|
|
17
17
|
- name: Set up Ruby
|
|
18
18
|
uses: ruby/setup-ruby@v1
|
|
19
19
|
with:
|
|
@@ -37,9 +37,10 @@ jobs:
|
|
|
37
37
|
- "3.2"
|
|
38
38
|
- "3.3"
|
|
39
39
|
- "3.4"
|
|
40
|
+
- "4.0"
|
|
40
41
|
|
|
41
42
|
steps:
|
|
42
|
-
- uses: actions/checkout@
|
|
43
|
+
- uses: actions/checkout@v7
|
|
43
44
|
|
|
44
45
|
- name: Set up Ruby
|
|
45
46
|
uses: ruby/setup-ruby@v1
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
|
2
|
-
|
|
3
1
|
AllCops:
|
|
4
2
|
TargetRubyVersion: 2.5
|
|
5
3
|
NewCops: enable
|
|
@@ -17,3 +15,7 @@ Metrics/BlockLength:
|
|
|
17
15
|
Style/PercentLiteralDelimiters:
|
|
18
16
|
PreferredDelimiters:
|
|
19
17
|
"%w": "[]"
|
|
18
|
+
|
|
19
|
+
Naming/MethodParameterName:
|
|
20
|
+
AllowedNames: ["iv", "b", "j", "a", "r", "t"]
|
|
21
|
+
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v1.1.2](https://github.com/jwt/ruby-jwe/tree/v1.1.2) (2026-11-26)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/jwt/ruby-jwe/compare/v1.1.1...v1.1.2)
|
|
6
|
+
|
|
7
|
+
**Fixes and enhancements:**
|
|
8
|
+
|
|
9
|
+
- Use implicit rejection for RSA1_5 CEK decryption to prevent a PKCS#1 v1.5 padding oracle (GHSA-9hgp-rr8g-x7cq)
|
|
10
|
+
- Limit DEF decompressed content to 1 MiB to prevent decompression bombs (GHSA-qwvx-w3vv-2r28)
|
|
11
|
+
|
|
12
|
+
## [v1.1.1](https://github.com/jwt/ruby-jwe/tree/v1.1.1) (2025-08-07)
|
|
13
|
+
|
|
14
|
+
[Full Changelog](https://github.com/jwt/ruby-jwe/compare/v1.1.0...v1.1.1)
|
|
15
|
+
|
|
16
|
+
**Fixes and enhancements:**
|
|
17
|
+
|
|
18
|
+
- Fix tag length checking for AES-GCM (CVE-2025-54887)
|
|
19
|
+
|
|
3
20
|
## [v1.1.0](https://github.com/jwt/ruby-jwe/tree/v1.1.0) (2025-07-22)
|
|
4
21
|
|
|
5
22
|
[Full Changelog](https://github.com/jwt/ruby-jwe/compare/v1.0.0...v1.1.0)
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ gem install jwe
|
|
|
12
12
|
```
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
This example uses the default alg and enc methods (RSA-OAEP and
|
|
15
|
+
This example uses the default alg and enc methods (RSA-OAEP and A128GCM). It requires an RSA key.
|
|
16
16
|
|
|
17
17
|
```ruby
|
|
18
18
|
require 'jwe'
|
|
@@ -113,10 +113,10 @@ Key management:
|
|
|
113
113
|
* ~~PBES2-HS512+A256KW~~
|
|
114
114
|
|
|
115
115
|
Encryption:
|
|
116
|
-
* A128CBC-HS256
|
|
116
|
+
* A128CBC-HS256
|
|
117
117
|
* A192CBC-HS384
|
|
118
118
|
* A256CBC-HS512
|
|
119
|
-
* A128GCM
|
|
119
|
+
* A128GCM (default)
|
|
120
120
|
* A192GCM
|
|
121
121
|
* A256GCM
|
|
122
122
|
|
data/Rakefile
CHANGED
data/jwe.gemspec
CHANGED
data/lib/jwe/alg/aes_kw.rb
CHANGED
|
@@ -6,8 +6,7 @@ module JWE
|
|
|
6
6
|
module Alg
|
|
7
7
|
# Generic AES Key Wrapping algorithm for any key size.
|
|
8
8
|
module AesKw
|
|
9
|
-
attr_accessor :key
|
|
10
|
-
attr_accessor :iv
|
|
9
|
+
attr_accessor :key, :iv
|
|
11
10
|
|
|
12
11
|
def initialize(key = nil, iv = "\xA6\xA6\xA6\xA6\xA6\xA6\xA6\xA6")
|
|
13
12
|
self.iv = iv.b
|
|
@@ -45,9 +44,7 @@ module JWE
|
|
|
45
44
|
a, r = kw_decrypt_round(j, a, r)
|
|
46
45
|
end
|
|
47
46
|
|
|
48
|
-
if a != iv
|
|
49
|
-
raise StandardError.new('The encrypted key has been tampered. Do not use this key.')
|
|
50
|
-
end
|
|
47
|
+
raise StandardError.new('The encrypted key has been tampered. Do not use this key.') if a != iv
|
|
51
48
|
|
|
52
49
|
r.join
|
|
53
50
|
end
|
data/lib/jwe/alg/rsa15.rb
CHANGED
|
@@ -6,6 +6,12 @@ module JWE
|
|
|
6
6
|
class Rsa15
|
|
7
7
|
attr_accessor :key
|
|
8
8
|
|
|
9
|
+
# Expected length of the content encryption key. When set, decryption
|
|
10
|
+
# failures are masked with a random CEK of this length (implicit
|
|
11
|
+
# rejection, RFC 7516 section 11.5), so a malformed encrypted key is
|
|
12
|
+
# indistinguishable from a failed content authentication.
|
|
13
|
+
attr_accessor :cek_length
|
|
14
|
+
|
|
9
15
|
def initialize(key)
|
|
10
16
|
self.key = key
|
|
11
17
|
end
|
|
@@ -15,7 +21,22 @@ module JWE
|
|
|
15
21
|
end
|
|
16
22
|
|
|
17
23
|
def decrypt(encrypted_cek)
|
|
24
|
+
return key.private_decrypt(encrypted_cek) if cek_length.nil?
|
|
25
|
+
|
|
26
|
+
fallback_cek = SecureRandom.random_bytes(cek_length)
|
|
27
|
+
cek = unwrap(encrypted_cek)
|
|
28
|
+
|
|
29
|
+
return fallback_cek unless cek && cek.bytesize == cek_length
|
|
30
|
+
|
|
31
|
+
cek
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def unwrap(encrypted_cek)
|
|
18
37
|
key.private_decrypt(encrypted_cek)
|
|
38
|
+
rescue OpenSSL::PKey::PKeyError
|
|
39
|
+
nil
|
|
19
40
|
end
|
|
20
41
|
end
|
|
21
42
|
end
|
data/lib/jwe/alg.rb
CHANGED
|
@@ -21,8 +21,10 @@ module JWE
|
|
|
21
21
|
self.for(alg).new(key).encrypt(cek)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def self.decrypt_cek(alg, key, encrypted_cek)
|
|
25
|
-
self.for(alg).new(key)
|
|
24
|
+
def self.decrypt_cek(alg, key, encrypted_cek, cek_length: nil)
|
|
25
|
+
algorithm = self.for(alg).new(key)
|
|
26
|
+
algorithm.cek_length = cek_length if cek_length && algorithm.respond_to?(:cek_length=)
|
|
27
|
+
algorithm.decrypt(encrypted_cek)
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
end
|
data/lib/jwe/enc/aes_cbc_hs.rb
CHANGED
|
@@ -6,9 +6,7 @@ module JWE
|
|
|
6
6
|
module Enc
|
|
7
7
|
# Abstract AES in Block cipher mode, with message signature for different key sizes.
|
|
8
8
|
module AesCbcHs
|
|
9
|
-
|
|
10
|
-
attr_accessor :iv
|
|
11
|
-
attr_accessor :tag
|
|
9
|
+
attr_writer :cek, :iv, :tag
|
|
12
10
|
|
|
13
11
|
def initialize(cek = nil, iv = nil)
|
|
14
12
|
self.iv = iv
|
|
@@ -30,9 +28,7 @@ module JWE
|
|
|
30
28
|
raise JWE::BadCEK, "The supplied key is invalid. Required length: #{key_length}" if cek.length != key_length
|
|
31
29
|
|
|
32
30
|
signature = generate_tag(authenticated_data, iv, ciphertext)
|
|
33
|
-
if signature != tag
|
|
34
|
-
raise JWE::InvalidData, 'Authentication tag verification failed'
|
|
35
|
-
end
|
|
31
|
+
raise JWE::InvalidData, 'Authentication tag verification failed' if signature != tag
|
|
36
32
|
|
|
37
33
|
cipher_round(:decrypt, iv, ciphertext)
|
|
38
34
|
rescue OpenSSL::Cipher::CipherError
|
data/lib/jwe/enc/aes_gcm.rb
CHANGED
|
@@ -6,9 +6,7 @@ module JWE
|
|
|
6
6
|
module Enc
|
|
7
7
|
# Abstract AES in Galois Counter mode for different key sizes.
|
|
8
8
|
module AesGcm
|
|
9
|
-
|
|
10
|
-
attr_accessor :iv
|
|
11
|
-
attr_accessor :tag
|
|
9
|
+
attr_writer :iv, :cek, :tag
|
|
12
10
|
|
|
13
11
|
def initialize(cek = nil, iv = nil)
|
|
14
12
|
self.iv = iv
|
|
@@ -38,7 +36,11 @@ module JWE
|
|
|
38
36
|
cipher.send(direction)
|
|
39
37
|
cipher.key = cek
|
|
40
38
|
cipher.iv = iv
|
|
41
|
-
|
|
39
|
+
if direction == :decrypt
|
|
40
|
+
raise JWE::InvalidData, 'Invalid ciphertext or authentication tag' unless tag.bytesize == 16
|
|
41
|
+
|
|
42
|
+
cipher.auth_tag = tag
|
|
43
|
+
end
|
|
42
44
|
cipher.auth_data = auth_data
|
|
43
45
|
end
|
|
44
46
|
|
data/lib/jwe/enc/cipher.rb
CHANGED
|
@@ -7,7 +7,7 @@ module JWE
|
|
|
7
7
|
class << self
|
|
8
8
|
def for(cipher_name)
|
|
9
9
|
OpenSSL::Cipher.new(cipher_name)
|
|
10
|
-
rescue RuntimeError
|
|
10
|
+
rescue RuntimeError, OpenSSL::Cipher::CipherError
|
|
11
11
|
raise JWE::NotImplementedError.new("The version of OpenSSL linked to your Ruby does not support the cipher #{cipher_name}.")
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/jwe/version.rb
CHANGED
data/lib/jwe/zip/def.rb
CHANGED
|
@@ -6,6 +6,10 @@ module JWE
|
|
|
6
6
|
module Zip
|
|
7
7
|
# Deflate algorithm.
|
|
8
8
|
class Def
|
|
9
|
+
# Upper bound for the size of decompressed content, guarding against
|
|
10
|
+
# decompression bombs.
|
|
11
|
+
MAX_DECOMPRESSED_SIZE = 1024 * 1024
|
|
12
|
+
|
|
9
13
|
def compress(payload)
|
|
10
14
|
zlib = Zlib::Deflate.new(Zlib::DEFAULT_COMPRESSION, -Zlib::MAX_WBITS)
|
|
11
15
|
zlib.deflate(payload, Zlib::FINISH)
|
|
@@ -13,12 +17,31 @@ module JWE
|
|
|
13
17
|
|
|
14
18
|
# Was using RFC 1950 instead of 1951.
|
|
15
19
|
def decompress(payload)
|
|
16
|
-
Zlib::
|
|
20
|
+
decompress_bounded(payload, Zlib::MAX_WBITS)
|
|
17
21
|
|
|
18
22
|
# Keeping compatibility for old encoded tokens
|
|
19
23
|
rescue Zlib::DataError
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
decompress_bounded(payload, -Zlib::MAX_WBITS)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def decompress_bounded(payload, window_bits)
|
|
30
|
+
inflater = Zlib::Inflate.new(window_bits)
|
|
31
|
+
output = String.new(encoding: Encoding::BINARY)
|
|
32
|
+
|
|
33
|
+
inflater.inflate(payload) { |chunk| append_bounded(output, chunk) }
|
|
34
|
+
append_bounded(output, inflater.finish)
|
|
35
|
+
|
|
36
|
+
output
|
|
37
|
+
ensure
|
|
38
|
+
inflater.close if inflater && !inflater.closed?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def append_bounded(output, chunk)
|
|
42
|
+
raise JWE::InvalidData, 'Decompressed content exceeds the maximum size' if chunk.bytesize > MAX_DECOMPRESSED_SIZE - output.bytesize
|
|
43
|
+
|
|
44
|
+
output << chunk
|
|
22
45
|
end
|
|
23
46
|
end
|
|
24
47
|
end
|
data/lib/jwe.rb
CHANGED
|
@@ -43,8 +43,8 @@ module JWE
|
|
|
43
43
|
header = JSON.parse(header)
|
|
44
44
|
check_params(header, key)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
cipher =
|
|
46
|
+
cipher = Enc.for(header['enc'], nil, iv, tag)
|
|
47
|
+
cipher.cek = Alg.decrypt_cek(header['alg'], key, enc_key, cek_length: cipher.key_length)
|
|
48
48
|
|
|
49
49
|
plaintext = cipher.decrypt(ciphertext, payload.split('.').first)
|
|
50
50
|
|
|
@@ -75,7 +75,7 @@ module JWE
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def param_to_class_name(param)
|
|
78
|
-
klass = param.gsub(/[
|
|
78
|
+
klass = param.gsub(/[-+]/, '_').downcase.sub(/^[a-z\d]*/) { ::Regexp.last_match(0).capitalize }
|
|
79
79
|
klass.gsub(/_([a-z\d]*)/i) { Regexp.last_match(1).capitalize }
|
|
80
80
|
end
|
|
81
81
|
|
data/spec/jwe/alg_spec.rb
CHANGED
|
@@ -91,6 +91,30 @@ describe JWE::Alg::Rsa15 do
|
|
|
91
91
|
ciphertext = alg.encrypt('random key')
|
|
92
92
|
expect(alg.decrypt(ciphertext)).to eq 'random key'
|
|
93
93
|
end
|
|
94
|
+
|
|
95
|
+
context 'when the expected CEK length is known' do
|
|
96
|
+
let(:cek) { SecureRandom.random_bytes(16) }
|
|
97
|
+
|
|
98
|
+
before { alg.cek_length = 16 }
|
|
99
|
+
|
|
100
|
+
it 'decrypts the encrypted key to the original key' do
|
|
101
|
+
expect(alg.decrypt(alg.encrypt(cek))).to eq cek
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'returns a random CEK of the expected length when unwrapping fails' do
|
|
105
|
+
malformed = "\x00".b * (key.n.num_bits / 8)
|
|
106
|
+
result = alg.decrypt(malformed)
|
|
107
|
+
|
|
108
|
+
expect(result.bytesize).to eq 16
|
|
109
|
+
expect(alg.decrypt(malformed)).to_not eq result
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'returns a random CEK of the expected length when the unwrapped key has the wrong length' do
|
|
113
|
+
result = alg.decrypt(alg.encrypt(SecureRandom.random_bytes(32)))
|
|
114
|
+
|
|
115
|
+
expect(result.bytesize).to eq 16
|
|
116
|
+
end
|
|
117
|
+
end
|
|
94
118
|
end
|
|
95
119
|
|
|
96
120
|
[
|
data/spec/jwe/enc_spec.rb
CHANGED
|
@@ -130,6 +130,14 @@ gcm.each do |group|
|
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
+
context 'when the tag is not 16 bytes' do
|
|
134
|
+
it 'raises an error' do
|
|
135
|
+
enc = klass.new(key, group[:iv])
|
|
136
|
+
enc.tag = group[:tag][0...-1]
|
|
137
|
+
expect { enc.decrypt(group[:helloworld], '') }.to raise_error(JWE::InvalidData)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
133
141
|
context 'when the ciphertext is not valid' do
|
|
134
142
|
it 'raises an error' do
|
|
135
143
|
enc = klass.new(key, group[:iv])
|
data/spec/jwe/zip_spec.rb
CHANGED
|
@@ -15,7 +15,7 @@ describe JWE::Zip do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
describe JWE::Zip::Def do
|
|
18
|
-
context 'with the
|
|
18
|
+
context 'with the original payload' do
|
|
19
19
|
it 'deflates and inflates to original payload' do
|
|
20
20
|
deflate = JWE::Zip::Def.new
|
|
21
21
|
deflated = deflate.compress('hello world')
|
|
@@ -36,4 +36,24 @@ describe JWE::Zip::Def do
|
|
|
36
36
|
deflate = JWE::Zip::Def.new
|
|
37
37
|
expect(deflate.decompress(deflated)).to eq 'hello world'
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
context 'when limiting the decompressed size' do
|
|
41
|
+
let(:deflate) { JWE::Zip::Def.new }
|
|
42
|
+
let(:max) { JWE::Zip::Def::MAX_DECOMPRESSED_SIZE }
|
|
43
|
+
|
|
44
|
+
it 'inflates content of exactly the maximum size' do
|
|
45
|
+
payload = 'a' * max
|
|
46
|
+
expect(deflate.decompress(deflate.compress(payload))).to eq payload
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'rejects content exceeding the maximum size' do
|
|
50
|
+
deflated = deflate.compress('a' * (max + 1))
|
|
51
|
+
expect { deflate.decompress(deflated) }.to raise_error(JWE::InvalidData)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'rejects RFC 1950 content exceeding the maximum size' do
|
|
55
|
+
deflated = Zlib::Deflate.deflate('a' * (max + 1))
|
|
56
|
+
expect { deflate.decompress(deflated) }.to raise_error(JWE::InvalidData)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
39
59
|
end
|
data/spec/jwe_spec.rb
CHANGED
|
@@ -21,6 +21,49 @@ describe JWE do
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
describe 'when DEF compressed content exceeds the maximum size' do
|
|
25
|
+
it 'raises JWE::InvalidData' do
|
|
26
|
+
payload = 'a' * (JWE::Zip::Def::MAX_DECOMPRESSED_SIZE + 1)
|
|
27
|
+
encrypted = JWE.encrypt(payload, rsa_key, zip: 'DEF')
|
|
28
|
+
|
|
29
|
+
expect { JWE.decrypt(encrypted, rsa_key) }.to raise_error(JWE::InvalidData)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe 'when using RSA1_5 alg method' do
|
|
34
|
+
let(:parts) { JWE.encrypt(plaintext, rsa_key, alg: 'RSA1_5', enc: enc).split('.') }
|
|
35
|
+
|
|
36
|
+
%w[A128GCM A256CBC-HS512].each do |enc_name|
|
|
37
|
+
context "with #{enc_name}" do
|
|
38
|
+
let(:enc) { enc_name }
|
|
39
|
+
|
|
40
|
+
it 'roundtrips' do
|
|
41
|
+
expect(JWE.decrypt(parts.join('.'), rsa_key)).to eq plaintext
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'raises JWE::InvalidData for a malformed encrypted key' do
|
|
45
|
+
parts[1] = JWE::Base64.jwe_encode("\x00".b * (rsa_key.n.num_bits / 8))
|
|
46
|
+
|
|
47
|
+
expect { JWE.decrypt(parts.join('.'), rsa_key) }.to raise_error(JWE::InvalidData)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'raises JWE::InvalidData for an encrypted key of the wrong length' do
|
|
51
|
+
parts[1] = JWE::Base64.jwe_encode(rsa_key.public_encrypt('short'))
|
|
52
|
+
|
|
53
|
+
expect { JWE.decrypt(parts.join('.'), rsa_key) }.to raise_error(JWE::InvalidData)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'raises JWE::InvalidData for a modified tag' do
|
|
57
|
+
tag = JWE::Base64.jwe_decode(parts[4]).bytes
|
|
58
|
+
tag[-1] ^= 1
|
|
59
|
+
parts[4] = JWE::Base64.jwe_encode(tag.pack('C*'))
|
|
60
|
+
|
|
61
|
+
expect { JWE.decrypt(parts.join('.'), rsa_key) }.to raise_error(JWE::InvalidData)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
24
67
|
describe 'when using dir alg method' do
|
|
25
68
|
it 'roundtrips' do
|
|
26
69
|
aes_password = SecureRandom.random_bytes(16)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jwe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Francesco Boffa
|
|
@@ -29,11 +29,11 @@ executables: []
|
|
|
29
29
|
extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
|
31
31
|
files:
|
|
32
|
+
- ".github/dependabot.yml"
|
|
32
33
|
- ".github/workflows/test.yml"
|
|
33
34
|
- ".gitignore"
|
|
34
35
|
- ".rspec"
|
|
35
36
|
- ".rubocop.yml"
|
|
36
|
-
- ".rubocop_todo.yml"
|
|
37
37
|
- CHANGELOG.md
|
|
38
38
|
- Gemfile
|
|
39
39
|
- LICENSE.md
|
|
@@ -78,7 +78,7 @@ licenses:
|
|
|
78
78
|
- MIT
|
|
79
79
|
metadata:
|
|
80
80
|
bug_tracker_uri: https://github.com/jwt/ruby-jwe/issues
|
|
81
|
-
changelog_uri: https://github.com/jwt/ruby-jwe/blob/v1.1.
|
|
81
|
+
changelog_uri: https://github.com/jwt/ruby-jwe/blob/v1.1.2/CHANGELOG.md
|
|
82
82
|
rubygems_mfa_required: 'true'
|
|
83
83
|
rdoc_options: []
|
|
84
84
|
require_paths:
|
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
rubygems_version: 3.
|
|
97
|
+
rubygems_version: 3.7.2
|
|
98
98
|
specification_version: 4
|
|
99
99
|
summary: JSON Web Encryption implementation in Ruby
|
|
100
100
|
test_files: []
|
data/.rubocop_todo.yml
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# This configuration was generated by
|
|
2
|
-
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2025-02-16 07:54:09 UTC using RuboCop version 1.72.1.
|
|
4
|
-
# The point is for the user to remove these configuration records
|
|
5
|
-
# one by one as the offenses are removed from the code base.
|
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
-
|
|
9
|
-
# Offense count: 6
|
|
10
|
-
Lint/DuplicateMethods:
|
|
11
|
-
Exclude:
|
|
12
|
-
- 'lib/jwe/enc/aes_cbc_hs.rb'
|
|
13
|
-
- 'lib/jwe/enc/aes_gcm.rb'
|
|
14
|
-
|
|
15
|
-
# Offense count: 15
|
|
16
|
-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
17
|
-
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
|
18
|
-
Naming/MethodParameterName:
|
|
19
|
-
Exclude:
|
|
20
|
-
- 'lib/jwe/alg/aes_kw.rb'
|
|
21
|
-
- 'lib/jwe/enc.rb'
|
|
22
|
-
- 'lib/jwe/enc/aes_cbc_hs.rb'
|
|
23
|
-
- 'lib/jwe/enc/aes_gcm.rb'
|
|
24
|
-
- 'lib/jwe/serialization/compact.rb'
|
|
25
|
-
|
|
26
|
-
# Offense count: 8
|
|
27
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
28
|
-
# Configuration parameters: EnforcedStyle.
|
|
29
|
-
# SupportedStyles: separated, grouped
|
|
30
|
-
Style/AccessorGrouping:
|
|
31
|
-
Exclude:
|
|
32
|
-
- 'lib/jwe/alg/aes_kw.rb'
|
|
33
|
-
- 'lib/jwe/enc/aes_cbc_hs.rb'
|
|
34
|
-
- 'lib/jwe/enc/aes_gcm.rb'
|
|
35
|
-
|
|
36
|
-
# Offense count: 1
|
|
37
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
38
|
-
Style/ExpandPathArguments:
|
|
39
|
-
Exclude:
|
|
40
|
-
- 'jwe.gemspec'
|
|
41
|
-
|
|
42
|
-
# Offense count: 2
|
|
43
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
44
|
-
Style/IfUnlessModifier:
|
|
45
|
-
Exclude:
|
|
46
|
-
- 'lib/jwe/alg/aes_kw.rb'
|
|
47
|
-
- 'lib/jwe/enc/aes_cbc_hs.rb'
|
|
48
|
-
|
|
49
|
-
# Offense count: 1
|
|
50
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
51
|
-
Style/PerlBackrefs:
|
|
52
|
-
Exclude:
|
|
53
|
-
- 'lib/jwe.rb'
|