@@ -248,8 +248,7 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
248248 IRubyObject arg = args [0 ];
249249
250250 if ( arg instanceof Group ) {
251- this .group = (Group ) arg ;
252- this .curveName = this .group .getCurveName ();
251+ setGroup ((Group ) arg );
253252 return this ;
254253 }
255254
@@ -380,6 +379,11 @@ private void unwrapPrivateKeyWithName() {
380379 }
381380 }
382381
382+ private void setGroup (final Group group ) {
383+ this .group = group ;
384+ this .curveName = this .group .getCurveName ();
385+ }
386+
383387 //private static ECNamedCurveParameterSpec readECParameters(final byte[] input) throws IOException {
384388 // ASN1ObjectIdentifier oid = ASN1ObjectIdentifier.getInstance(input);
385389 // return ECNamedCurveTable.getParameterSpec(oid.getId());
@@ -407,6 +411,19 @@ public PKeyEC generate_key(final ThreadContext context) {
407411 return this ;
408412 }
409413
414+ @ JRubyMethod (meta = true )
415+ public static IRubyObject generate (final ThreadContext context , final IRubyObject self , final IRubyObject group ) {
416+ PKeyEC randomKey = new PKeyEC (context .runtime , (RubyClass ) self );
417+
418+ if (group instanceof Group ) {
419+ randomKey .setGroup ((Group ) group );
420+ } else {
421+ randomKey .curveName = group .convertToString ().toString ();
422+ }
423+
424+ return randomKey .generate_key (context );
425+ }
426+
410427 @ JRubyMethod (name = "dsa_sign_asn1" )
411428 public IRubyObject dsa_sign_asn1 (final ThreadContext context , final IRubyObject data ) {
412429 try {
0 commit comments