{
java.security.spec.ECParameterSpec p = (java.security.spec.ECParameterSpec)params;
this.ecParams = params;
ECCurve curve = EC5Util.convertCurve(p.getCurve());
ECPoint g = EC5Util.convertPoint(curve, p.getGenerator(), false);
param = new ECKeyGenerationParameters(new ECDomainParameters(curve, g, p.getOrder(), BigInteger.valueOf(p.getCofactor())), random);
engine.init(param);
initialised = true;
}
else if (params instanceof ECGenParameterSpec || params instanceof ECNamedCurveGenParameterSpec)
{
String curveName;
if (params instanceof ECGenParameterSpec)
{
curveName = ((ECGenParameterSpec)params).getName();
}
else
{
curveName = ((ECNamedCurveGenParameterSpec)params).getName();
}
X9ECParameters ecP = X962NamedCurves.getByName(curveName);
if (ecP == null)
{
ecP = SECNamedCurves.getByName(curveName);
if (ecP == null)
{
ecP = NISTNamedCurves.getByName(curveName);
}
if (ecP == null)
{
ecP = TeleTrusTNamedCurves.getByName(curveName);
}
if (ecP == null)
{
// See if it's actually an OID string (SunJSSE ServerHandshaker setupEphemeralECDHKeys bug)
try
{
ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(curveName);
ecP = X962NamedCurves.getByOID(oid);
if (ecP == null)
{
ecP = SECNamedCurves.getByOID(oid);
}
if (ecP == null)
{
ecP = NISTNamedCurves.getByOID(oid);
}
if (ecP == null)
{
ecP = TeleTrusTNamedCurves.getByOID(oid);
}
if (ecP == null)
{
throw new InvalidAlgorithmParameterException("unknown curve OID: " + curveName);
}
}
catch (IllegalArgumentException ex)
{
throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
}
}
}
this.ecParams = new ECNamedCurveSpec(
curveName,
ecP.getCurve(),
ecP.getG(),
ecP.getN(),
ecP.getH(),
null); // ecP.getSeed()); Work-around JDK bug -- it won't look up named curves properly if seed is present
java.security.spec.ECParameterSpec p = (java.security.spec.ECParameterSpec)ecParams;
ECCurve curve = EC5Util.convertCurve(p.getCurve());
ECPoint g = EC5Util.convertPoint(curve, p.getGenerator(), false);
param = new ECKeyGenerationParameters(new ECDomainParameters(curve, g, p.getOrder(), BigInteger.valueOf(p.getCofactor())), random);
engine.init(param);
initialised = true;