Skip to content
Closed
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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ DO NOT MODIFY - GENERATED CODE
<include>org/jruby/ext/openssl/Random.java</include>
<include>org/jruby/ext/openssl/SSL.java</include>
<include>org/jruby/ext/openssl/SSLContext.java</include>
<include>org/jruby/ext/openssl/SSLKeyStore.java</include>
<include>org/jruby/ext/openssl/SSLSession.java</include>
<include>org/jruby/ext/openssl/SSLSocket.java</include>
<include>org/jruby/ext/openssl/SecurityHelper.java</include>
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/jruby/ext/openssl/PKeyEdDSA.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ private PKeyEdDSA(Ruby runtime, RubyClass type, PublicKey publicKey, PrivateKey
}

PKeyEdDSA(Ruby runtime, PublicKey publicKey) {
this(runtime, publicKey, null);
this(runtime, convertNonBCPublicKey(runtime, publicKey), null);
}

static PublicKey convertNonBCPublicKey(Ruby runtime, PublicKey publicKey) {
if (publicKey instanceof EdDSAPublicKey) return publicKey;
try {
return SecurityHelper.getKeyFactory("EdDSA")
.generatePublic(new X509EncodedKeySpec(publicKey.getEncoded()));
} catch (GeneralSecurityException e) {
throw newPKeyError(runtime, e);
}
}

static PKeyEdDSA newInstance(final Ruby runtime, final KeyPair keyPair) {
Expand Down Expand Up @@ -332,6 +342,6 @@ static boolean isEdDSAAlgorithm(final String alg) {
}

static boolean isEdDSAKey(final PublicKey key) {
return key instanceof EdDSAPublicKey;
return key instanceof EdDSAPublicKey || (key != null && isEdDSAAlgorithm(key.getAlgorithm()));
}
}
Loading
Loading