Improve supported-curve detection
@@ -137,6 +137,17 @@ static ECParameterSpec getECParameterSpec(JcaTlsCrypto crypto, String curveName)
static ECParameterSpec getECParameterSpec(JcaTlsCrypto crypto, AlgorithmParameterSpec initSpec)
{
+ KeyPairGenerator kpGen;
+ try
+ {
+ kpGen = crypto.getHelper().createKeyPairGenerator("EC");
+ kpGen.initialize(initSpec, crypto.getSecureRandom());
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+
// Try the "modern" way
try
{
@@ -161,8 +172,6 @@ static ECParameterSpec getECParameterSpec(JcaTlsCrypto crypto, AlgorithmParamete
*/
try
{
- KeyPairGenerator kpGen = crypto.getHelper().createKeyPairGenerator("EC");
- kpGen.initialize(initSpec, crypto.getSecureRandom());
KeyPair kp = kpGen.generateKeyPair();
return ((ECKey)kp.getPrivate()).getParams();
}
