-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
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"Reactions are currently unavailable