Skip to content

undefined method 'iv_len=' for #<OpenSSL::Cipher #207

Closed
@arpriego88

Description

@arpriego88

I have scenario where I need to change the iv length from 12 to 16. I am able to do this when in an IRB console using ruby-2.6.3:

require 'openssl'
 => true
cipher = OpenSSL::Cipher.new("aes-256-gcm")
 => #<OpenSSL::Cipher:0x00007fc4bd9e94c0>
cipher.decrypt
 => #<OpenSSL::Cipher:0x00007fc4bd9e94c0>
cipher.iv_len = 16
 => 16

cipher.methods
 => [:encrypt, :decrypt, :pkcs5_keyivgen, :final, :key=, :auth_data=, :auth_tag=, :auth_tag, :auth_tag_len=, :authenticated?, :key_len=, :key_len, :iv=, :iv_len=, :iv_len, :name,

However when using jruby-9.2.13.0 I get:

require 'openssl'
 => true
cipher = OpenSSL::Cipher.new("aes-256-gcm")
 => #<OpenSSL::Cipher:0x285c6918>
cipher.decrypt
 => #<OpenSSL::Cipher:0x285c6918>
cipher.iv_len
 => 12
cipher.iv_len = 16
Traceback (most recent call last):
        6: from /Users/arpriego88/.rvm/rubies/jruby-9.2.13.0/bin/irb:13:in `<main>'
        5: from org/jruby/RubyKernel.java:1189:in `catch'
        4: from org/jruby/RubyKernel.java:1189:in `catch'
        3: from org/jruby/RubyKernel.java:1442:in `loop'
        2: from org/jruby/RubyKernel.java:1048:in `eval'
        1: from (irb):5:in `evaluate'
NoMethodError (undefined method `iv_len=' for #<OpenSSL::Cipher:0x285c6918>)
Did you mean?  iv_len

# missing iv_len=
cipher.methods
 => [:auth_tag, :<<, :random_iv, :update, :auth_tag=, :auth_data=, :random_key, :key=, :iv=, :key_len=, :encrypt, :authenticated?, :name, :final, :pkcs5_keyivgen, :reset, :iv_len, :padding=, :decrypt, :block_size, :key_len, :java_kind_of?, :public_send, :pp, :frozen?, :protected_methods, :java_implements, :public_method, :freeze, :java, :singleton_methods, :untaint, :javafx, :enum_for, :private_methods, :method, :instance_variables, :object_id, :extend, :itself, :instance_variable_set, :respond_to?, :java_name, :singleton_method, :hash, :methods, :to_java, :java_package, :singleton_class, :public_methods, :to_enum, :display, :yield_self, :tainted?, :instance_variable_defined?, :untrusted?, :define_singleton_method, :nil?, :!~, :com, :instance_of?, :java_require, :javax, :java_signature, :to_s, :===, :tap, :java_annotation, :inspect, :send, :trust, :instance_variable_get, :is_a?, :eql?, :java_field, :remove_instance_variable, :untrust, :<=>, :class, :=~, :org, :taint, :kind_of?, :clone, :dup, :==, :!, :equal?, :instance_exec, :__id__, :instance_eval, :__send__, :!=]

Will this be a pain to add?

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