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

SecureRandom does not implement #bytes like MRI #5773

Closed
kreynolds opened this issue Jun 26, 2019 · 5 comments
Closed

SecureRandom does not implement #bytes like MRI #5773

kreynolds opened this issue Jun 26, 2019 · 5 comments

Comments

@kreynolds
Copy link

@kreynolds kreynolds commented Jun 26, 2019

Environment

Provide at least:

  • jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b OpenJDK 64-Bit Server VM 11.0.2+9 on 11.0.2+9 +jit [darwin-x86_64]
  • Darwin Kelleys-MBP.neo.rr.com 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

Expected Behavior

  • SecureRandom should implement #bytes to match MRI. For example, MRI implements #bytes and #gen_random, and the remaining methods are extended with a formatter.

Actual Behavior

  • It does not implement #bytes at all.
@headius
Copy link
Member

@headius headius commented Jul 9, 2019

We implement random_bytes...perhaps this is just a new alias?

Loading

@headius
Copy link
Member

@headius headius commented Jul 9, 2019

Looks like it was an alias that became a wrapper method, and we just never added it (or mistakenly removed it).

Loading

@headius
Copy link
Member

@headius headius commented Jul 9, 2019

Trivial fix coming.

It looks like there's specs for Random#bytes here but nothing for SecureRandom.bytes here. Could you have a look and see if we can share or duplicate these specs? cc @eregon for help moving this to something shared, if that's necessary.

Loading

@headius headius closed this in 62d8abb Jul 9, 2019
@headius headius added this to the JRuby 9.2.8.0 milestone Jul 9, 2019
@headius
Copy link
Member

@headius headius commented Jul 9, 2019

FWIW this following workaround basically does what I did:

class << SecureRandom
  def bytes(n); random_bytes(n); end
  alias gen_random bytes
end

Loading

@kreynolds
Copy link
Author

@kreynolds kreynolds commented Jul 10, 2019

Yeah, I know its a trivial alias, I just filed in the interest of maintaining general compatibility. Thanks for knocking this one out :)

Loading

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