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

Issues testing OAEPadding on Jruby 1.7.11 #1819

Closed
derryos opened this issue Jul 16, 2014 · 3 comments
Closed

Issues testing OAEPadding on Jruby 1.7.11 #1819

derryos opened this issue Jul 16, 2014 · 3 comments

Comments

@derryos
Copy link

derryos commented Jul 16, 2014

I'm using OAEP padding as part of some decryption/encryption steps -
specifically using: /ECB/OAEPWithSHA1AndMGF1Padding

Testing encryption/decryption via standard ruby 1.9.3 and openssl 0.9.8e
works as expected. We don't explicitly name the above padding - we pass
OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING (padding parameter 4) to openssl's
RSA decryption methods and it works correctly.

When repeating the same test via JRuby 1.7.11 + 1.9.3, we saw padding
failures and after some debugging, linked it to the fact that the default
JRuby padding associated with padding parameter 4 (
https://github.com/jruby/jruby/blob/master/ext/openssl/src/main/java/org/jruby/ext/openssl/PKeyRSA.java#L443
)
is actually the same algorithm but with MD5 vs SHA1 as the digest algorithm.

Modifying that file and changing MD5->SHA1 fixed our issues. Is there a
reason why this is the case? I'm trying to understand why the behaviour is
different between standard ruby and JRuby.

@SteveAquino
Copy link

👍 Having this exact same problem, resulting in the following error:

OpenSSL::PKey::RSAError: data hash wrong
    from org/jruby/ext/openssl/PKeyRSA.java:467:in `private_decrypt'

Doesn't look like OAEPWithSHA1AndMGF1Padding is supported. Duplicating the exact same code but passing the correct algorithm works, but it would be nice to use the packaged library.

@kares
Copy link
Member

kares commented Jul 9, 2015

could we have a failing piece of .rb (RSA-key) related code, please - so we can make sure its tested

@kares
Copy link
Member

kares commented Jan 18, 2017

calling it a day since jruby/jruby-openssl#54

@kares kares closed this as completed Jan 18, 2017
@kares kares added this to the Invalid or Duplicate milestone Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants