Skip to content
Merged
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
2 changes: 1 addition & 1 deletion ext/openssl/ossl_pkey_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)

break;
default:
ossl_raise(rb_eArgError, "wrong number of arguments");
ossl_raise(rb_eArgError, "wrong number of arguments (given %d, expected 1 or 4)", argc);
}

ASSUME(group);
Expand Down
9 changes: 9 additions & 0 deletions test/openssl/test_pkey_ec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ def test_ec_group
assert_equal group1.degree, group4.degree
end

def test_ec_group_initialize_error_message
# Test that passing 2 arguments raises the helpful error
e = assert_raise(ArgumentError) do
OpenSSL::PKey::EC::Group.new(:GFp, 123)
end

assert_equal("wrong number of arguments (given 2, expected 1 or 4)", e.message)
end

def test_ec_point
group = OpenSSL::PKey::EC::Group.new("prime256v1")
key = OpenSSL::PKey::EC.generate(group)
Expand Down