potatosalad / ruby-jose

JSON Object Signing and Encryption (JOSE) for Ruby
http://www.rubydoc.info/gems/jose
MIT License
63 stars 32 forks source link

OpenSSL issue when decrypting token #22

Open saemideluxe opened 11 months ago

saemideluxe commented 11 months ago

Hi there

When I call

JOSE::JWK.from_oct(my_key)
JOSE::JWE.block_decrypt(jwk, token)

I get the following error from OpenSSL:

/home/sam/test_ruby/vendor/bundle/ruby/3.1.0/gems/jose-1.1.3/lib/jose/jwe/enc_aes_gcm.rb:46:in `final': OpenSSL::Cipher::CipherError
        from /home/sam/test_ruby/vendor/bundle/ruby/3.1.0/gems/jose-1.1.3/lib/jose/jwe/enc_aes_gcm.rb:46:in `block_decrypt'
        from /home/sam/test_ruby/vendor/bundle/ruby/3.1.0/gems/jose-1.1.3/lib/jose/jwe.rb:602:in `block_decrypt'
        from /home/sam/test_ruby/vendor/bundle/ruby/3.1.0/gems/jose-1.1.3/lib/jose/jwe.rb:584:in `block_decrypt'
        from /home/sam/test_ruby/test.rb:11:in `<top (required)>'
        from /usr/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
        from /usr/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /usr/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
        from /usr/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
        from /usr/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /usr/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /usr/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
        from /usr/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /usr/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
        from /usr/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
        from /usr/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
        from /usr/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
        from /usr/bin/bundle3.1:25:in `load'
        from /usr/bin/bundle3.1:25:in `<main>'

Decrypting the token and the key work when using jose for nodejs. Any idea what could be the problem?

nebula28 commented 2 months ago

I'm receiving this same error