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

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

Closed
mrhardikjoshi opened this issue Jan 16, 2024 · 0 comments · Fixed by #291
Closed

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

mrhardikjoshi opened this issue Jan 16, 2024 · 0 comments · Fixed by #291

Comments

@mrhardikjoshi
Copy link

mrhardikjoshi commented Jan 16, 2024

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>'
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

Successfully merging a pull request may close this issue.

1 participant