jwe 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +51 -0
- data/.rubocop.yml +11 -1
- data/.rubocop_todo.yml +53 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +7 -0
- data/README.md +2 -3
- data/Rakefile +9 -7
- data/jwe.gemspec +11 -6
- data/lib/jwe/alg/a128_kw.rb +2 -0
- data/lib/jwe/alg/a192_kw.rb +2 -0
- data/lib/jwe/alg/a256_kw.rb +2 -0
- data/lib/jwe/alg/aes_kw.rb +6 -4
- data/lib/jwe/alg/dir.rb +2 -0
- data/lib/jwe/alg/rsa15.rb +2 -0
- data/lib/jwe/alg/rsa_oaep.rb +2 -0
- data/lib/jwe/alg.rb +2 -0
- data/lib/jwe/base64.rb +2 -0
- data/lib/jwe/enc/a128cbc_hs256.rb +2 -0
- data/lib/jwe/enc/a128gcm.rb +2 -0
- data/lib/jwe/enc/a192cbc_hs384.rb +2 -0
- data/lib/jwe/enc/a192gcm.rb +2 -0
- data/lib/jwe/enc/a256cbc_hs512.rb +2 -0
- data/lib/jwe/enc/a256gcm.rb +2 -0
- data/lib/jwe/enc/aes_cbc_hs.rb +2 -0
- data/lib/jwe/enc/aes_gcm.rb +2 -0
- data/lib/jwe/enc/cipher.rb +2 -0
- data/lib/jwe/enc.rb +2 -0
- data/lib/jwe/serialization/compact.rb +2 -0
- data/lib/jwe/version.rb +3 -1
- data/lib/jwe/zip/def.rb +2 -0
- data/lib/jwe/zip.rb +2 -0
- data/lib/jwe.rb +3 -1
- data/spec/jwe/alg_spec.rb +4 -2
- data/spec/jwe/base64_spec.rb +2 -0
- data/spec/jwe/enc_spec.rb +15 -13
- data/spec/jwe/serialization_spec.rb +2 -0
- data/spec/jwe/zip_spec.rb +2 -0
- data/spec/jwe_spec.rb +9 -7
- data/spec/spec_helper.rb +2 -0
- metadata +17 -56
- data/.codeclimate.yml +0 -15
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9b0c6b1a25f2248646f35e0879debdaa3cf80983b23f5eb485bfc60c7c8c28f
|
4
|
+
data.tar.gz: 62b5d86d4d85130de7c4d38976678f6df8bfd31d9cdbfe00de8cfd4626052e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a4bf04a9400f563735c91582b5d61a361a32971489431e098a35a21a2952a2517ac126cfb1ff806eaffe5444ee935d6f3c273eeebc8690720814fa1ee0f521
|
7
|
+
data.tar.gz: 288e86713b00064cdf1b388f8bea1007bda0c6fc45a34be50514724d706b29618bb1e37ebf892cfafa93e144265bba914839f4ecdad8e804a1971afe077adc74
|
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
name: test
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- "*"
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- "*"
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
lint:
|
13
|
+
name: RuboCop
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: "ruby"
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Run RuboCop
|
23
|
+
run: bundle exec rubocop
|
24
|
+
|
25
|
+
test:
|
26
|
+
name: Ruby ${{ matrix.ruby }}
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
strategy:
|
29
|
+
fail-fast: false
|
30
|
+
matrix:
|
31
|
+
ruby:
|
32
|
+
- "2.5"
|
33
|
+
- "2.6"
|
34
|
+
- "2.7"
|
35
|
+
- "3.0"
|
36
|
+
- "3.1"
|
37
|
+
- "3.2"
|
38
|
+
- "3.3"
|
39
|
+
- "3.4"
|
40
|
+
|
41
|
+
steps:
|
42
|
+
- uses: actions/checkout@v4
|
43
|
+
|
44
|
+
- name: Set up Ruby
|
45
|
+
uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
ruby-version: ${{ matrix.ruby }}
|
48
|
+
bundler-cache: true
|
49
|
+
|
50
|
+
- name: Run tests
|
51
|
+
run: bundle exec rspec
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
7
|
+
|
8
|
+
Layout/LineLength:
|
2
9
|
Enabled: false
|
10
|
+
|
3
11
|
Style/RaiseArgs:
|
4
12
|
Enabled: false
|
13
|
+
|
5
14
|
Metrics/BlockLength:
|
6
15
|
Enabled: false
|
16
|
+
|
7
17
|
Style/PercentLiteralDelimiters:
|
8
18
|
PreferredDelimiters:
|
9
19
|
"%w": "[]"
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,53 @@
|
|
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'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v1.0.0](https://github.com/jwt/ruby-jwe/tree/v1.0.0) (NEXT)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/jwt/ruby-jwe/compare/v0.4.0...v1.0.0)
|
6
|
+
|
7
|
+
**Features:**
|
8
|
+
|
9
|
+
- Support Ruby 3.4 (#26)(https://github.com/jwt/ruby-jwe/pull/26)
|
10
|
+
- Drop support for Ruby versions prior to 2.5 (#27)(https://github.com/jwt/ruby-jwe/pull/27)
|
11
|
+
|
12
|
+
**Fixes and enhancements:**
|
13
|
+
|
14
|
+
- Refreshed codebase (CI and linter fixes) (#27)(https://github.com/jwt/ruby-jwe/pull/27), (#28)(https://github.com/jwt/ruby-jwe/pull/28)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# JWE
|
2
2
|
|
3
|
-
[![Build Status](https://
|
4
|
-
[![
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/jwt/ruby-jwe/badges/coverage.svg)](https://codeclimate.com/github/aomega08/jwe/coverage)
|
3
|
+
[![Build Status](https://github.com/jwt/ruby-jwe/workflows/test/badge.svg?branch=master)](https://github.com/jwt/ruby-jwe/actions)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/jwe.svg)](https://badge.fury.io/rb/jwe)
|
6
5
|
|
7
6
|
A ruby implementation of the [RFC 7516 JSON Web Encryption (JWE)](https://tools.ietf.org/html/rfc7516) standard.
|
8
7
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
require 'bundler/gem_tasks'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
task default: :spec
|
data/jwe.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('../lib/', __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'jwe/version'
|
@@ -9,16 +11,19 @@ Gem::Specification.new do |s|
|
|
9
11
|
s.description = 'A Ruby implementation of the RFC 7516 JSON Web Encryption (JWE) standard'
|
10
12
|
s.authors = ['Francesco Boffa']
|
11
13
|
s.email = 'fra.boffa@gmail.com'
|
12
|
-
s.homepage = '
|
14
|
+
s.homepage = 'https://github.com/jwt/ruby-jwe'
|
13
15
|
s.license = 'MIT'
|
14
16
|
|
15
17
|
s.files = `git ls-files`.split("\n")
|
16
18
|
s.require_paths = %w[lib]
|
17
19
|
|
18
|
-
s.required_ruby_version = '>= 2.
|
20
|
+
s.required_ruby_version = '>= 2.5.0'
|
21
|
+
|
22
|
+
s.metadata = {
|
23
|
+
'bug_tracker_uri' => 'https://github.com/jwt/ruby-jwe/issues',
|
24
|
+
'changelog_uri' => "https://github.com/jwt/ruby-jwe/blob/v#{JWE::VERSION}/CHANGELOG.md",
|
25
|
+
'rubygems_mfa_required' => 'true'
|
26
|
+
}
|
19
27
|
|
20
|
-
s.
|
21
|
-
s.add_development_dependency 'rake'
|
22
|
-
s.add_development_dependency 'simplecov'
|
23
|
-
s.add_development_dependency 'codeclimate-test-reporter'
|
28
|
+
s.add_dependency 'base64'
|
24
29
|
end
|
data/lib/jwe/alg/a128_kw.rb
CHANGED
data/lib/jwe/alg/a192_kw.rb
CHANGED
data/lib/jwe/alg/a256_kw.rb
CHANGED
data/lib/jwe/alg/aes_kw.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'jwe/enc/cipher'
|
2
4
|
|
3
5
|
module JWE
|
@@ -8,13 +10,13 @@ module JWE
|
|
8
10
|
attr_accessor :iv
|
9
11
|
|
10
12
|
def initialize(key = nil, iv = "\xA6\xA6\xA6\xA6\xA6\xA6\xA6\xA6")
|
11
|
-
self.iv = iv.
|
12
|
-
self.key = key.
|
13
|
+
self.iv = iv.b
|
14
|
+
self.key = key.b
|
13
15
|
end
|
14
16
|
|
15
17
|
def encrypt(cek)
|
16
18
|
a = iv
|
17
|
-
r = cek.
|
19
|
+
r = cek.b.scan(/.{8}/m)
|
18
20
|
|
19
21
|
6.times do |j|
|
20
22
|
a, r = kw_encrypt_round(j, a, r)
|
@@ -36,7 +38,7 @@ module JWE
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def decrypt(encrypted_cek)
|
39
|
-
c = encrypted_cek.
|
41
|
+
c = encrypted_cek.b.scan(/.{8}/m)
|
40
42
|
a, *r = c
|
41
43
|
|
42
44
|
5.downto(0) do |j|
|
data/lib/jwe/alg/dir.rb
CHANGED
data/lib/jwe/alg/rsa15.rb
CHANGED
data/lib/jwe/alg/rsa_oaep.rb
CHANGED
data/lib/jwe/alg.rb
CHANGED
data/lib/jwe/base64.rb
CHANGED
data/lib/jwe/enc/a128gcm.rb
CHANGED
data/lib/jwe/enc/a192gcm.rb
CHANGED
data/lib/jwe/enc/a256gcm.rb
CHANGED
data/lib/jwe/enc/aes_cbc_hs.rb
CHANGED
data/lib/jwe/enc/aes_gcm.rb
CHANGED
data/lib/jwe/enc/cipher.rb
CHANGED
data/lib/jwe/enc.rb
CHANGED
data/lib/jwe/version.rb
CHANGED
data/lib/jwe/zip/def.rb
CHANGED
data/lib/jwe/zip.rb
CHANGED
data/lib/jwe.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
4
|
require 'json'
|
3
5
|
require 'openssl'
|
@@ -17,7 +19,7 @@ module JWE
|
|
17
19
|
class InvalidData < RuntimeError; end
|
18
20
|
|
19
21
|
VALID_ALG = ['RSA1_5', 'RSA-OAEP', 'RSA-OAEP-256', 'A128KW', 'A192KW', 'A256KW', 'dir', 'ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW', 'A128GCMKW', 'A192GCMKW', 'A256GCMKW', 'PBES2-HS256+A128KW', 'PBES2-HS384+A192KW', 'PBES2-HS512+A256KW'].freeze
|
20
|
-
VALID_ENC = [
|
22
|
+
VALID_ENC = %w[A128CBC-HS256 A192CBC-HS384 A256CBC-HS512 A128GCM A192GCM A256GCM].freeze
|
21
23
|
VALID_ZIP = ['DEF'].freeze
|
22
24
|
|
23
25
|
class << self
|
data/spec/jwe/alg_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'jwe/alg/dir'
|
2
4
|
require 'jwe/alg/rsa_oaep'
|
3
5
|
require 'jwe/alg/rsa15'
|
@@ -35,7 +37,7 @@ describe JWE::Alg::Dir do
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
key_path = File.dirname(__FILE__)
|
40
|
+
key_path = "#{File.dirname(__FILE__)}/../keys/rsa.pem"
|
39
41
|
key = OpenSSL::PKey::RSA.new File.read(key_path)
|
40
42
|
|
41
43
|
describe JWE::Alg::RsaOaep do
|
@@ -74,7 +76,7 @@ end
|
|
74
76
|
JWE::Alg::A256kw
|
75
77
|
].each_with_index do |klass, i|
|
76
78
|
describe klass do
|
77
|
-
let(:kek) { SecureRandom.random_bytes(16 + i * 8) }
|
79
|
+
let(:kek) { SecureRandom.random_bytes(16 + (i * 8)) }
|
78
80
|
let(:cek) { SecureRandom.random_bytes(32) }
|
79
81
|
let(:alg) { klass.new(kek) }
|
80
82
|
|
data/spec/jwe/base64_spec.rb
CHANGED
data/spec/jwe/enc_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'jwe/enc/a128cbc_hs256'
|
2
4
|
require 'jwe/enc/a192cbc_hs384'
|
3
5
|
require 'jwe/enc/a256cbc_hs512'
|
@@ -21,48 +23,48 @@ gcm = [
|
|
21
23
|
{
|
22
24
|
class: JWE::Enc::A128gcm,
|
23
25
|
keylen: 16,
|
24
|
-
helloworld: "\"\xC6\xE4h\x8AI\x83\x90v\xAF\xE2\x11".
|
25
|
-
tag: "\x85|\xF7\xE1\x94\tVG\x84\xE1\xA8\x81\a\xF4\xC60".
|
26
|
+
helloworld: "\"\xC6\xE4h\x8AI\x83\x90v\xAF\xE2\x11".b,
|
27
|
+
tag: "\x85|\xF7\xE1\x94\tVG\x84\xE1\xA8\x81\a\xF4\xC60".b,
|
26
28
|
ivlen: 12,
|
27
29
|
iv: "\x0" * 12
|
28
30
|
},
|
29
31
|
{
|
30
32
|
class: JWE::Enc::A192gcm,
|
31
33
|
keylen: 24,
|
32
|
-
helloworld: "\x9F\xA4\xEC\xCCa\x86\tRO\xD7\xE3\x8D".
|
33
|
-
tag: "\xF6\xC0\xB8\x91A\xB1\xF0}\xD4u\xD0_\xCD\xA7\x17'".
|
34
|
+
helloworld: "\x9F\xA4\xEC\xCCa\x86\tRO\xD7\xE3\x8D".b,
|
35
|
+
tag: "\xF6\xC0\xB8\x91A\xB1\xF0}\xD4u\xD0_\xCD\xA7\x17'".b,
|
34
36
|
ivlen: 12,
|
35
37
|
iv: "\x0" * 12
|
36
38
|
},
|
37
39
|
{
|
38
40
|
class: JWE::Enc::A256gcm,
|
39
41
|
keylen: 32,
|
40
|
-
helloworld: "\xFDq\xDC\xDD\x87\x9DK\x97\x03G\x99\f".
|
41
|
-
tag: "\xC6\xF1\r\xDD\x14\x7Fqf,6\x0EK\x7F\x9D\x1D\t".
|
42
|
+
helloworld: "\xFDq\xDC\xDD\x87\x9DK\x97\x03G\x99\f".b,
|
43
|
+
tag: "\xC6\xF1\r\xDD\x14\x7Fqf,6\x0EK\x7F\x9D\x1D\t".b,
|
42
44
|
ivlen: 12,
|
43
45
|
iv: "\x0" * 12
|
44
46
|
},
|
45
47
|
{
|
46
48
|
class: JWE::Enc::A128cbcHs256,
|
47
49
|
keylen: 32,
|
48
|
-
helloworld: "\a\x02F\xA4m%\xDFH\xB4\xA4.\xBF:\xBF$\xE2".
|
49
|
-
tag: "\xDE$t\xBA\x8B\xEE\u001Df\x81\a\xC1\xBB\x98\xDFl\xF2".
|
50
|
+
helloworld: "\a\x02F\xA4m%\xDFH\xB4\xA4.\xBF:\xBF$\xE2".b,
|
51
|
+
tag: "\xDE$t\xBA\x8B\xEE\u001Df\x81\a\xC1\xBB\x98\xDFl\xF2".b,
|
50
52
|
ivlen: 16,
|
51
53
|
iv: "\x0" * 16
|
52
54
|
},
|
53
55
|
{
|
54
56
|
class: JWE::Enc::A192cbcHs384,
|
55
57
|
keylen: 48,
|
56
|
-
helloworld: "p\xFES\xF0\xB4\xCC]8\x1D\xDE\x8Dt\xE7tMh".
|
57
|
-
tag: "\xA8a\x04kRJ\x06`tp6\x8E\x9Ba\xE1e\xF6\xDA\"\x15\xEBk\xFDm".
|
58
|
+
helloworld: "p\xFES\xF0\xB4\xCC]8\x1D\xDE\x8Dt\xE7tMh".b,
|
59
|
+
tag: "\xA8a\x04kRJ\x06`tp6\x8E\x9Ba\xE1e\xF6\xDA\"\x15\xEBk\xFDm".b,
|
58
60
|
ivlen: 16,
|
59
61
|
iv: "\x0" * 16
|
60
62
|
},
|
61
63
|
{
|
62
64
|
class: JWE::Enc::A256cbcHs512,
|
63
65
|
keylen: 64,
|
64
|
-
helloworld: "c\xFD\\\xB9Z\xB6\xE3\xB7\xEE\xA1\xD8\xDF\xB5\xB2\xF8\xEB".
|
65
|
-
tag: "wC\xE3:\x91\x89W\x97\xBE\xB0\xBD\xEAo\xC66\x9F\xB82\xFDn\xA7.\u0014l\xFC2\xD7\xDFq\xB5[\xC6".
|
66
|
+
helloworld: "c\xFD\\\xB9Z\xB6\xE3\xB7\xEE\xA1\xD8\xDF\xB5\xB2\xF8\xEB".b,
|
67
|
+
tag: "wC\xE3:\x91\x89W\x97\xBE\xB0\xBD\xEAo\xC66\x9F\xB82\xFDn\xA7.\u0014l\xFC2\xD7\xDFq\xB5[\xC6".b,
|
66
68
|
ivlen: 16,
|
67
69
|
iv: "\x0" * 16
|
68
70
|
}
|
@@ -85,7 +87,7 @@ gcm.each do |group|
|
|
85
87
|
context 'with a valid key' do
|
86
88
|
it 'returns the encrypted payload' do
|
87
89
|
enc = klass.new(key, group[:iv])
|
88
|
-
expect(enc.encrypt(plaintext, '').
|
90
|
+
expect(enc.encrypt(plaintext, '').b).to eq group[:helloworld]
|
89
91
|
end
|
90
92
|
|
91
93
|
it 'sets an authentication tag' do
|
data/spec/jwe/zip_spec.rb
CHANGED
data/spec/jwe_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
describe JWE do
|
2
4
|
let(:plaintext) { 'The true sign of intelligence is not knowledge but imagination.' }
|
3
|
-
let(:rsa_key) { OpenSSL::PKey::RSA.new File.read(File.dirname(__FILE__)
|
5
|
+
let(:rsa_key) { OpenSSL::PKey::RSA.new File.read("#{File.dirname(__FILE__)}/keys/rsa.pem") }
|
4
6
|
let(:password) { SecureRandom.random_bytes(64) }
|
5
7
|
|
6
8
|
it 'roundtrips' do
|
@@ -55,19 +57,19 @@ describe JWE do
|
|
55
57
|
|
56
58
|
it 'raises when decoding a bad alg' do
|
57
59
|
hdr = { alg: 'TEST', enc: 'A128GCM' }
|
58
|
-
payload = JWE::Base64.jwe_encode(hdr.to_json)
|
60
|
+
payload = "#{JWE::Base64.jwe_encode(hdr.to_json)}.QY.QY.QY.QY"
|
59
61
|
expect { JWE.decrypt(payload, rsa_key) }.to raise_error(ArgumentError)
|
60
62
|
end
|
61
63
|
|
62
64
|
it 'raises when decoding a bad enc' do
|
63
65
|
hdr = { alg: 'A192CBC-HS384', enc: 'TEST' }
|
64
|
-
payload = JWE::Base64.jwe_encode(hdr.to_json)
|
66
|
+
payload = "#{JWE::Base64.jwe_encode(hdr.to_json)}.QY.QY.QY.QY"
|
65
67
|
expect { JWE.decrypt(payload, rsa_key) }.to raise_error(ArgumentError)
|
66
68
|
end
|
67
69
|
|
68
70
|
it 'raises when decoding a bad zip' do
|
69
71
|
hdr = { alg: 'A192CBC-HS384', enc: 'A128GCM', zip: 'TEST' }
|
70
|
-
payload = JWE::Base64.jwe_encode(hdr.to_json)
|
72
|
+
payload = "#{JWE::Base64.jwe_encode(hdr.to_json)}.QY.QY.QY.QY"
|
71
73
|
expect { JWE.decrypt(payload, rsa_key) }.to raise_error(ArgumentError)
|
72
74
|
end
|
73
75
|
|
@@ -77,7 +79,7 @@ describe JWE do
|
|
77
79
|
|
78
80
|
it 'raises when decrypting with a nil key' do
|
79
81
|
hdr = { alg: 'A192CBC-HS384', enc: 'A128GCM', zip: 'TEST' }
|
80
|
-
payload = JWE::Base64.jwe_encode(hdr.to_json)
|
82
|
+
payload = "#{JWE::Base64.jwe_encode(hdr.to_json)}.QY.QY.QY.QY"
|
81
83
|
expect { JWE.decrypt(payload, nil) }.to raise_error(ArgumentError)
|
82
84
|
end
|
83
85
|
|
@@ -87,7 +89,7 @@ describe JWE do
|
|
87
89
|
|
88
90
|
it 'raises when decrypting with a blank key' do
|
89
91
|
hdr = { alg: 'A192CBC-HS384', enc: 'A128GCM', zip: 'TEST' }
|
90
|
-
payload = JWE::Base64.jwe_encode(hdr.to_json)
|
92
|
+
payload = "#{JWE::Base64.jwe_encode(hdr.to_json)}.QY.QY.QY.QY"
|
91
93
|
expect { JWE.decrypt(payload, " \t \n ") }.to raise_error(ArgumentError)
|
92
94
|
end
|
93
95
|
|
@@ -97,7 +99,7 @@ describe JWE do
|
|
97
99
|
|
98
100
|
it 'raises when decrypting with a nil key with `dir` algorithm' do
|
99
101
|
hdr = { alg: 'A192CBC-HS384', enc: 'A128GCM', zip: 'TEST' }
|
100
|
-
payload = JWE::Base64.jwe_encode(hdr.to_json)
|
102
|
+
payload = "#{JWE::Base64.jwe_encode(hdr.to_json)}.QY.QY.QY.QY"
|
101
103
|
expect { JWE.decrypt(payload, nil, alg: 'dir') }.to raise_error(ArgumentError)
|
102
104
|
end
|
103
105
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,65 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Boffa
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: base64
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: simplecov
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: codeclimate-test-reporter
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
20
|
+
type: :runtime
|
63
21
|
prerelease: false
|
64
22
|
version_requirements: !ruby/object:Gem::Requirement
|
65
23
|
requirements:
|
@@ -72,11 +30,12 @@ executables: []
|
|
72
30
|
extensions: []
|
73
31
|
extra_rdoc_files: []
|
74
32
|
files:
|
75
|
-
- ".
|
33
|
+
- ".github/workflows/test.yml"
|
76
34
|
- ".gitignore"
|
77
35
|
- ".rspec"
|
78
36
|
- ".rubocop.yml"
|
79
|
-
- ".
|
37
|
+
- ".rubocop_todo.yml"
|
38
|
+
- CHANGELOG.md
|
80
39
|
- Gemfile
|
81
40
|
- LICENSE.md
|
82
41
|
- README.md
|
@@ -114,11 +73,14 @@ files:
|
|
114
73
|
- spec/jwe_spec.rb
|
115
74
|
- spec/keys/rsa.pem
|
116
75
|
- spec/spec_helper.rb
|
117
|
-
homepage:
|
76
|
+
homepage: https://github.com/jwt/ruby-jwe
|
118
77
|
licenses:
|
119
78
|
- MIT
|
120
|
-
metadata:
|
121
|
-
|
79
|
+
metadata:
|
80
|
+
bug_tracker_uri: https://github.com/jwt/ruby-jwe/issues
|
81
|
+
changelog_uri: https://github.com/jwt/ruby-jwe/blob/v1.0.0/CHANGELOG.md
|
82
|
+
rubygems_mfa_required: 'true'
|
83
|
+
post_install_message:
|
122
84
|
rdoc_options: []
|
123
85
|
require_paths:
|
124
86
|
- lib
|
@@ -126,16 +88,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
88
|
requirements:
|
127
89
|
- - ">="
|
128
90
|
- !ruby/object:Gem::Version
|
129
|
-
version: 2.
|
91
|
+
version: 2.5.0
|
130
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
93
|
requirements:
|
132
94
|
- - ">="
|
133
95
|
- !ruby/object:Gem::Version
|
134
96
|
version: '0'
|
135
97
|
requirements: []
|
136
|
-
|
137
|
-
|
138
|
-
signing_key:
|
98
|
+
rubygems_version: 3.5.11
|
99
|
+
signing_key:
|
139
100
|
specification_version: 4
|
140
101
|
summary: JSON Web Encryption implementation in Ruby
|
141
102
|
test_files: []
|
data/.codeclimate.yml
DELETED
data/.travis.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: trusty
|
3
|
-
rvm:
|
4
|
-
- 2.0.0-p648
|
5
|
-
- 2.1.10
|
6
|
-
- 2.2.7
|
7
|
-
- 2.3.4
|
8
|
-
- 2.4.1
|
9
|
-
|
10
|
-
after_script:
|
11
|
-
- bundle exec codeclimate-test-reporter
|
12
|
-
|
13
|
-
env:
|
14
|
-
CODECLIMATE_REPO_TOKEN: d9854e6b60cf9cbd78bb8036da0a5c63d6178a14a19a8043752dc5fecec99831
|