diff --git a/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java b/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java index 6f2d918093b..78929c3bc71 100644 --- a/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java +++ b/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java @@ -74,8 +74,9 @@ private static void check(String keyAlg, int keySize, String sigAlgParam = requestedSigAlg == null ? "" : (" -sigalg " + requestedSigAlg); + System.out.println("starting..."); genkeypair(alias, - "-keyalg " + keyAlg + " -keysize " + keySize + sigAlgParam) + "-keyalg " + keyAlg + " -keysize " + keySize + sigAlgParam + " -debug -J-Djdk.nativeCryptoTrace=true") .shouldHaveExitValue(0); KeyStore ks = KeyStore.getInstance( diff --git a/test/jdk/sun/security/tools/keytool/fakegen/jdk.crypto.ec/sun/security/ec/ECKeyPairGenerator.java b/test/jdk/sun/security/tools/keytool/fakegen/jdk.crypto.ec/sun/security/ec/ECKeyPairGenerator.java index 68da125087f..40263f26c85 100644 --- a/test/jdk/sun/security/tools/keytool/fakegen/jdk.crypto.ec/sun/security/ec/ECKeyPairGenerator.java +++ b/test/jdk/sun/security/tools/keytool/fakegen/jdk.crypto.ec/sun/security/ec/ECKeyPairGenerator.java @@ -27,6 +27,7 @@ import java.security.*; import java.security.spec.AlgorithmParameterSpec; import java.security.spec.ECParameterSpec; +import java.security.spec.ECGenParameterSpec; import java.security.spec.ECPoint; import sun.security.util.ECUtil; @@ -51,7 +52,28 @@ public void initialize(int keySize, SecureRandom random) { @Override public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { - throw new UnsupportedOperationException(); + ECParameterSpec ecSpec = null; + + if (params instanceof ECParameterSpec) { + ECParameterSpec ecParams = (ECParameterSpec) params; + ecSpec = ECUtil.getECParameterSpec(null, ecParams); + if (ecSpec == null) { + throw new InvalidAlgorithmParameterException( + "Unsupported curve: " + params); + } + } else if (params instanceof ECGenParameterSpec) { + String name = ((ECGenParameterSpec) params).getName(); + ecSpec = ECUtil.getECParameterSpec(null, name); + if (ecSpec == null) { + throw new InvalidAlgorithmParameterException( + "Unknown curve name: " + name); + } + } else { + throw new InvalidAlgorithmParameterException( + "ECParameterSpec or ECGenParameterSpec required for EC"); + } + + this.keySize = ecSpec.getCurve().getField().getFieldSize(); } @Override