Skip to content

ArgumentError when "auth_tag" method is used with tag length parameter #290

Closed
@mrhardikjoshi

Description

@mrhardikjoshi

Issue:

Considering jruby 9.4.5.0 should support Ruby 3.1.x, the auth_tag method on Cipher should support an optional parameter of tag length, documentation in 3.1.2

But when auth_tag is used with tag-length parameter in jruby 9.4.5.0 it throws ArgumentError. This issue in turn causes error while generating new rails application when some customisation params are given. rails/rails#49737

Code snippet to reproduce:

Following code works on ruby 3.1.2 but fails on jruby 9.4.5.0

require "openssl"
cipher=OpenSSL::Cipher.new('aes-128-gcm').tap do |c|
  c.encrypt
  c.key="\xCB\u0013\xB1\xBD\x9A\x91\xA8\xBA \xA7\xE3\x8B\u000E\xCCR\u001D"
  c.random_iv
  c.final
end
cipher.auth_tag(16)

Error / Stacktrace in Jruby:

irb(main):008> cipher.auth_tag(16)
(irb):8:in `evaluate': `auth_tag': wrong number of arguments (given 1, expected 0) (ArgumentError)
	from org/jruby/RubyKernel.java:1161:in `eval'
	from org/jruby/RubyKernel.java:1603:in `loop'
	from org/jruby/RubyKernel.java:1310:in `catch'
	from /Users/hardik_joshi/.rbenv/versions/jruby-9.4.5.0/lib/ruby/gems/shared/gems/irb-1.11.1/exe/irb:9:in `<main>'
	from org/jruby/RubyKernel.java:1107:in `load'
	from /Users/hardik_joshi/.rbenv/versions/jruby-9.4.5.0/bin/irb:25:in `<main>'

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