SigUtil: Catch EdDSA IAE

SU3File: Hide EdDSA and unavailable sig types from help text
This commit is contained in:
zzz
2014-05-05 19:49:24 +00:00
parent 97c1ba2d02
commit 91408cbdce
2 changed files with 14 additions and 2 deletions

View File

@@ -515,6 +515,10 @@ public class SU3File {
StringBuilder buf = new StringBuilder(256);
buf.append("Available signature types:\n");
for (SigType t : EnumSet.allOf(SigType.class)) {
if (!t.isAvailable())
continue;
if (t == SigType.EdDSA_SHA512_25519)
continue; // not supported by keytool, and does double hashing right now
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
if (t.getCode() == DEFAULT_SIG_CODE)
buf.append(" DEFAULT");

View File

@@ -248,14 +248,22 @@ public class SigUtil {
private static EdDSAPublicKey cvtToJavaEdDSAKey(SigningPublicKey pk)
throws GeneralSecurityException {
return new EdDSAPublicKey(new EdDSAPublicKeySpec(
try {
return new EdDSAPublicKey(new EdDSAPublicKeySpec(
pk.getData(), (EdDSAParameterSpec) pk.getType().getParams()));
} catch (IllegalArgumentException iae) {
throw new InvalidKeyException(iae);
}
}
private static EdDSAPrivateKey cvtToJavaEdDSAKey(SigningPrivateKey pk)
throws GeneralSecurityException {
return new EdDSAPrivateKey(new EdDSAPrivateKeySpec(
try {
return new EdDSAPrivateKey(new EdDSAPrivateKeySpec(
pk.getData(), (EdDSAParameterSpec) pk.getType().getParams()));
} catch (IllegalArgumentException iae) {
throw new InvalidKeyException(iae);
}
}
public static SigningPublicKey fromJavaKey(EdDSAPublicKey pk, SigType type)