The Wayback Machine - https://web.archive.org/web/20200906102606/https://github.com/jwt/ruby-jwt/issues/322/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HS512256 OpenSSL Exception: First num too large #322

Closed
RootTJNII opened this issue Jun 20, 2019 · 2 comments
Closed

HS512256 OpenSSL Exception: First num too large #322

RootTJNII opened this issue Jun 20, 2019 · 2 comments

Comments

@RootTJNII
Copy link

@RootTJNII RootTJNII commented Jun 20, 2019

When trying to use the HS512256 algorithm I'm seeing Unsupported digest algorithm (sha512256).: first num too large. I've narrowed this down to the OpenSSL::Digest.new("sha512256") call in https://github.com/jwt/ruby-jwt/blob/master/lib/jwt/algos/hmac.rb#L14

irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> "HS512256".sub('HS', 'sha')
=> "sha512256"
irb(main):003:0> OpenSSL::Digest.new("sha512256")
Traceback (most recent call last):
        6: from /usr/local/bin/irb:23:in `<main>'
        5: from /usr/local/bin/irb:23:in `load'
        4: from /usr/local/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        3: from (irb):3
        2: from (irb):3:in `new'
        1: from (irb):3:in `initialize'
RuntimeError (Unsupported digest algorithm (sha512256).: first num too large)

The ruby:2.6 container has the latest released OpenSSL gem per https://github.com/ruby/openssl/releases

$ docker run --rm -ti ruby:2.6 gem list openssl

*** LOCAL GEMS ***

openssl (default: 2.1.2)

I also don't see this algorithm in https://ruby-doc.org/stdlib-2.6/libdoc/openssl/rdoc/OpenSSL/Digest.html. Is SHA512256 correct?

@anakinj
Copy link
Member

@anakinj anakinj commented Jun 29, 2019

I think the issue is that to be able to use the SHA-512-256 algorithm you need to have the rbnacl gem and libsodium installed.

This is probably stated somewhere in the docs, but the code is not that good in showing what algorithms are supported natively and what require some extra things.

@RootTJNII
Copy link
Author

@RootTJNII RootTJNII commented Jul 8, 2019

Aah, yea, that's the problem. With rbnacl installed it works, and I see this is documented in the readme. Some sort of gate would be nice, like making that algo unavailable without rbnacl installed, but I'm sure the value of that feature will be outweighed by the weight of the implementation.

This can be closed as user error, thanks!

@RootTJNII RootTJNII closed this Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.