diff --git a/src/main/java/org/jruby/ext/openssl/PKeyEC.java b/src/main/java/org/jruby/ext/openssl/PKeyEC.java index 063f4037..21d9733d 100644 --- a/src/main/java/org/jruby/ext/openssl/PKeyEC.java +++ b/src/main/java/org/jruby/ext/openssl/PKeyEC.java @@ -946,7 +946,10 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a if ( arg instanceof Group ) { this.group = (Group) arg; + } else { + throw runtime.newTypeError(arg, _EC(runtime).getClass("Group")); } + if ( argc == 2 ) { // (group, bn) final byte[] encoded; if (args[1] instanceof BN) { diff --git a/src/test/ruby/ec/test_ec.rb b/src/test/ruby/ec/test_ec.rb index 7618a330..e39c8021 100644 --- a/src/test/ruby/ec/test_ec.rb +++ b/src/test/ruby/ec/test_ec.rb @@ -94,6 +94,13 @@ def test_point # assert_equal hybrid, point.to_octet_string(:hybrid) end + def test_point_error + assert_raise(ArgumentError) { OpenSSL::PKey::EC::Point.new } + assert_raise(TypeError) { OpenSSL::PKey::EC::Point.new(nil) } + assert_raise(TypeError) { OpenSSL::PKey::EC::Point.new(nil, '') } + assert_raise(TypeError) { OpenSSL::PKey::EC::Point.new(100, '') } + end + def test_random_point group = OpenSSL::PKey::EC::Group.new("prime256v1") key = OpenSSL::PKey::EC.generate(group)