Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions ext/openssl/ossl_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,9 @@ ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
return ossl_pkey_wrap(pkey);
}

static VALUE
pkey_ctx_apply_options_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ctx_v))
static int
pkey_ctx_apply_options_i(VALUE key, VALUE value, VALUE ctx_v)
{
VALUE key = rb_ary_entry(i, 0), value = rb_ary_entry(i, 1);
EVP_PKEY_CTX *ctx = (EVP_PKEY_CTX *)ctx_v;

if (SYMBOL_P(key))
Expand All @@ -255,7 +254,7 @@ pkey_ctx_apply_options_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ctx_v))
if (EVP_PKEY_CTX_ctrl_str(ctx, StringValueCStr(key), StringValueCStr(value)) <= 0)
ossl_raise(ePKeyError, "EVP_PKEY_CTX_ctrl_str(ctx, %+"PRIsVALUE", %+"PRIsVALUE")",
key, value);
return Qnil;
return ST_CONTINUE;
}

static VALUE
Expand All @@ -264,8 +263,7 @@ pkey_ctx_apply_options0(VALUE args_v)
VALUE *args = (VALUE *)args_v;
Check_Type(args[1], T_HASH);

rb_block_call(args[1], rb_intern("each"), 0, NULL,
pkey_ctx_apply_options_i, args[0]);
rb_hash_foreach(args[1], pkey_ctx_apply_options_i, args[0]);
return Qnil;
}

Expand Down
11 changes: 11 additions & 0 deletions test/openssl/test_pkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
}
end

def test_s_generate_parameters_options_without_each
options_class = Class.new(Hash) {
def each
raise "must not be called"
end
}
options = options_class["ec_paramgen_curve" => "secp384r1"]
pkey = OpenSSL::PKey.generate_parameters("EC", options)

Check failure on line 35 in test/openssl/test_pkey.rb

View workflow job for this annotation

GitHub Actions / ubuntu-latest truffleruby

Error

RuntimeError: must not be called /home/runner/work/openssl/openssl/test/openssl/test_pkey.rb:31:in 'each' /home/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1208:in 'Truffle::CExt#rb_hash_foreach' /home/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1299:in 'block in Truffle::CExt#rb_protect' /home/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1320:in 'Truffle::CExt.raise_exception' /home/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1320:in 'Truffle::CExt#rb_jump_tag' /home/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext_ruby.rb:83:in 'OpenSSL::PKey#generate_parameters' /home/runner/work/openssl/openssl/test/openssl/test_pkey.rb:35:in 'OpenSSL::TestPKey#test_s_generate_parameters_options_without_each' <internal:core> core/throw_catch.rb:36:in 'Kernel#catch' <internal:core> core/throw_catch.rb:36:in 'Kernel#catch'

Check failure on line 35 in test/openssl/test_pkey.rb

View workflow job for this annotation

GitHub Actions / macos-latest truffleruby

Error

RuntimeError: must not be called /Users/runner/work/openssl/openssl/test/openssl/test_pkey.rb:31:in 'each' /Users/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1208:in 'Truffle::CExt#rb_hash_foreach' /Users/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1299:in 'block in Truffle::CExt#rb_protect' /Users/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1320:in 'Truffle::CExt.raise_exception' /Users/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext.rb:1320:in 'Truffle::CExt#rb_jump_tag' /Users/runner/.rubies/truffleruby-40.0.0/lib/truffle/truffle/cext_ruby.rb:83:in 'OpenSSL::PKey#generate_parameters' /Users/runner/work/openssl/openssl/test/openssl/test_pkey.rb:35:in 'OpenSSL::TestPKey#test_s_generate_parameters_options_without_each' <internal:core> core/throw_catch.rb:36:in 'Kernel#catch' <internal:core> core/throw_catch.rb:36:in 'Kernel#catch'
assert_equal "secp384r1", pkey.group.curve_name
end

def test_s_generate_parameters_with_block
# DSA kengen is not FIPS-approved.
# https://github.com/openssl/openssl/commit/49a35f0#diff-605396c063194975af8ce31399d42690ab18186b422fb5012101cc9132660fe1R611-R614
Expand Down
Loading