jwe 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d669663ec6b48136c82b078fa3d01c0d6c03a92a
4
- data.tar.gz: 62ede4a2f3ea9044e727a27a28642ce183864b99
3
+ metadata.gz: fa8fe82eeb7d259a610ce7e6a89374a8d5cd7ff2
4
+ data.tar.gz: 0a1a8862400049ee407852f0e21cbb0cb6a8210b
5
5
  SHA512:
6
- metadata.gz: 37054c453193a2e56d31d8269eeb29a3159646dbe073fd856abc4a3a567b843689e4cef436bb77e4c6e7b1059070399b1912725ebaa60bf4ccc6593179447d3f
7
- data.tar.gz: e46636207448627d548d7804754b17d4d66962aef10b0d40193da75b0af2222c1d006971ab432e7e356c744b415cee2a12c3f29fea630f732d75c309e56a602f
6
+ metadata.gz: 40e851c53020b8c790080090ba7ca53e9e4264a5bcb990dd78598d2b0109ca5fe83e77fe2a3ae40c2ee5fcf75265e6074985f1038ef5ebd4003df8fa23fc5b59
7
+ data.tar.gz: f01772b4e6dc52ccded47081617c2890d21faf017b00ee285e525138e7d65765d9b2e38889b391159cf876e20328e81423afdf0123bcdd9497cc6581d4ad5478
data/.gitignore CHANGED
@@ -8,4 +8,5 @@ bundle
8
8
  /.ruby-gemset
9
9
  /.ruby-version
10
10
  Gemfile.lock
11
+ /coverage
11
12
 
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.1.0
5
5
  - 2.2.0
6
6
  - 2.3.0
7
+ - 2.4.0
7
8
  addons:
8
9
  code_climate:
9
10
  repo_token: b5653aee7f7a47c0d70a89feb535648aa06575497b1eab9e16068c49bf4462c3
@@ -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 'codeclimate-test-reporter'
22
+ s.add_development_dependency 'simplecov'
21
23
  end
@@ -18,7 +18,7 @@ module JWE
18
18
  cipher.iv = iv
19
19
 
20
20
  ciphertext = cipher.update(cleartext) + cipher.final
21
- length = [ciphertext.length * 8].pack('Q>') # 64bit big endian
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 = [ciphertext.length * 8].pack('Q>') # 64bit big endian
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
@@ -1,3 +1,3 @@
1
1
  module JWE
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -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: "\xD2\xC2\xA5M\xF1e\x00\xDB}\xDB\x15\x9F\xFF\x8A\x7F\x94".force_encoding('BINARY'),
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: "\xEA\xF4\xD73M\xC6\x1D\x13\x0E\x9E\xAE%L\xD3\x04#\x80:\xA8}\xD7\x16E{".force_encoding('BINARY'),
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: "\xD2W\xCAE\xBC\xE9\xC5\xCF\xD5\xE0\x88@j\xE4\xA1-\x16\xDA\x8F5(\x1D\x0E\x15.\xDC\x11\x12\x00`\xCER".force_encoding('BINARY'),
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
  }
@@ -21,8 +21,9 @@ describe JWE do
21
21
 
22
22
  describe 'when using dir alg method' do
23
23
  it 'roundtrips' do
24
- encrypted = JWE.encrypt(plaintext, password, alg: 'dir')
25
- result = JWE.decrypt(encrypted, password)
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
@@ -1,5 +1,5 @@
1
- require 'codeclimate-test-reporter'
2
- CodeClimate::TestReporter.start
1
+ require 'simplecov'
2
+ SimpleCov.start
3
3
 
4
4
  require 'rspec'
5
5
  require 'jwe'
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.1.1
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: 2016-09-12 00:00:00.000000000 Z
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: codeclimate-test-reporter
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: '0'
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.4.8
118
+ rubygems_version: 2.6.11
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: JSON Web Encryption implementation in Ruby