OpenSSL Cipher throws a RangeError on the update function when given a very large string. I've verified that it happens with a file of 2 or 3GB in size. 1 GB works fine. This has been tested with 2.1.2, 2.1.3, and 2.2rc-1.
require'openssl'cipher=OpenSSL::Cipher::Cipher.new('aes-256-cbc')cipher.decryptcipher.iv="fooooooooooooooooooooooooooooooooo"cipher.key="barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"f=File.open("<path to a 2 GB file generated with dd>","r")contents=f.read;cipher.update(contents)
Running this will return:
RangeError: integer 2147483648 too big to convert to `int'
ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge
data gradually not to exceed INT_MAX. workaround of OpenSSL API
limitation. [ruby-core:67043] [Bug #10633]
I don't have much experience with building Ruby by hand, so part of my issue may be there, or perhaps the example provided by Kenneth should never work, but should blow up in a different way than what he ran into, but I pulled down and built ruby-trunk and I still fail out of the example that Kenneth provided. It doesn't fail in the same way, which makes me think my build is good, but the error is pretty nondescript:
That's it. Line 8 is consistent with Kenneth's line 8:
cipher.update(contents)
Should the provided script work now or is this indicative of something else going on? I tried connecting to the script process w/ strace and there wasn't much informative there. I also played around with gdb, but I don't have enough experience with gdb to actually dig into which of the "ossl_raise(eCipherError, NULL)" calls the script was hitting.