Skip to content

OpenSSL::Cipher#update doesn't accept a buffer argument #5242

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

Closed
janko opened this issue Jul 8, 2018 · 2 comments
Closed

OpenSSL::Cipher#update doesn't accept a buffer argument #5242

janko opened this issue Jul 8, 2018 · 2 comments

Comments

@janko
Copy link

janko commented Jul 8, 2018

Environment

$ jruby -v
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b27 +jit [darwin-x86_64]
$ uname -a
Darwin Jankos-MacBook-Pro-2.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64

Expected Behavior

On MRI, OpenSSL::Cipher#update accepts an optional second argument – a buffer to load the encrypted/decrypted data into. This argument functions much in the same way as in IO#read and friends, it's purpose is for reducing string allocations and decreasing memory usage.

require "openssl"

cipher = OpenSSL::Cipher.new("aes-256-cbc")
cipher.key = "a" * 32
cipher.encrypt
buffer = ""
cipher.update("bar" * 10, buffer)
buffer # => "8\xA7\xBE\xB1\xAE\x88jˣ\xE9j\u0000\xD2W_\x91"

Actual Behavior

In JRuby OpenSSL::Cipher#update doesn't accept the buffer argument.

require "openssl"

cipher = OpenSSL::Cipher.new("aes-256-cbc")
cipher.key = "a" * 32
cipher.encrypt
buffer = ""
cipher.update("bar" * 10, buffer) #~> ArgumentError: wrong number of arguments calling `update` (2 for 1)
buffer # => "8\xA7\xBE\xB1\xAE\x88jˣ\xE9j\u0000\xD2W_\x91"
@kares
Copy link
Member

kares commented Jul 13, 2018

this one should be a relatively simple fix, generally work to be done at a different (jruby-openssl) repo ...

@kares
Copy link
Member

kares commented Oct 17, 2018

resolved in jossl repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants