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

cipher.final should not be required for streaming ciphers #182

Open
kreynolds opened this issue Jul 10, 2019 · 0 comments
Open

cipher.final should not be required for streaming ciphers #182

kreynolds opened this issue Jul 10, 2019 · 0 comments

Comments

@kreynolds
Copy link

I misfiled this in jruby so I'm refiling it here as a more appropriate place.

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

  • OpenSSL::Cipher.new('aes-256-ctr') should not require cipher.final for streaming ciphers

Actual Behavior

  • It requires cipher.final to get the trailing bytes

Sample script

require 'openssl'
require 'securerandom'

# String which will have 4 trailing bytes
string = 'a'.b*20

cipher = OpenSSL::Cipher.new('aes-256-ctr')
cipher.iv = SecureRandom.random_bytes(16)
cipher.key = SecureRandom.random_bytes(32)

# str should be 20 bytes long
puts cipher.update(string).size

# In MRI
# => 20
# In JRuby
# => 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants