Skip to content

Commit

Permalink
[fix] do not check empty string as curve name
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Apr 10, 2024
1 parent 5315832 commit f7f1009
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/main/java/org/jruby/ext/openssl/PKeyEC.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
final RubyString str = readInitArg(context, arg);
final String strJava = str.toString();

if ( isCurveName(strJava) ) {
if (!strJava.isEmpty() && isCurveName(strJava)) {
this.curveName = strJava;
return this;
}
Expand Down Expand Up @@ -311,22 +311,6 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
else debugStackTrace(runtime, e);
}
}
// if ( key == null && ! noClassDef ) {
// try { // readECParameters
// ASN1ObjectIdentifier oid = ASN1ObjectIdentifier.getInstance(str.getBytes());
// ECNamedCurveParameterSpec paramSpec = ECNamedCurveTable.getParameterSpec(oid.getId());
//
// // ecdsaFactory.generatePublic(keySpec)
//
// }
// catch (NoClassDefFoundError e) { noClassDef = true; debugStackTrace(runtime, e); }
// catch (InvalidKeySpecException e) { debug(runtime, "PKeyEC could not read public key", e); }
// catch (IOException e) { debug(runtime, "PKeyEC could not read public key", e); }
// catch (RuntimeException e) {
// if ( isKeyGenerationFailure(e) ) debug(runtime, "PKeyEC could not read public key", e);
// else debugStackTrace(runtime, e);
// }
// }

if ( key == null ) key = tryPKCS8EncodedKey(runtime, ecdsaFactory, str.getBytes());
if ( key == null ) key = tryX509EncodedKey(runtime, ecdsaFactory, str.getBytes());
Expand Down

0 comments on commit f7f1009

Please sign in to comment.