Skip to content

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

Open
@kreynolds

Description

@kreynolds

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions