Add option to select curve for EC KeyPair
import org.bouncycastle.asn1.x509.Time;
import org.bouncycastle.asn1.x509.V3TBSCertificateGenerator;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
+import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec;
import org.bouncycastle.jsse.BCSSLConnection;
import org.bouncycastle.jsse.BCSSLSocket;
@@ -225,10 +226,16 @@ public static KeyPair generatePSSKeyPair()
public static KeyPair generateECKeyPair()
throws Exception
+ {
+ return generateECKeyPair("secp256r1");
+ }
+
+ public static KeyPair generateECKeyPair(String curveName)
+ throws Exception
{
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("EC", ProviderUtils.PROVIDER_NAME_BC);
- kpGen.initialize(256, RANDOM);
+ kpGen.initialize(new ECNamedCurveGenParameterSpec(curveName), RANDOM);
return kpGen.generateKeyPair();
}
