if (params instanceof ECParameterSpec)
{
ECParameterSpec p = (ECParameterSpec)params;
this.ecParams = params;
param = new ECKeyGenerationParameters(new ECDomainParameters(p.getCurve(), p.getG(), p.getN()), random);
engine.init(param);
initialised = true;
}
else if (params instanceof java.security.spec.ECParameterSpec)
{
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)
{
final String curveName = ((ECGenParameterSpec)params).getName();
if (this.algorithm.equals("ECGOST3410"))
{
ECDomainParameters ecP = ECGOST3410NamedCurves.getByName(curveName);
if (ecP == null)
{
throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
}
this.ecParams = new ECNamedCurveSpec(
curveName,
ecP.getCurve(),
ecP.getG(),
ecP.getN(),
ecP.getH(),
ecP.getSeed());
}
else
{
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
{
DERObjectIdentifier oid = new DERObjectIdentifier(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;
}
else if (params == null && ProviderUtil.getEcImplicitlyCa() != null)
{
ECParameterSpec p = ProviderUtil.getEcImplicitlyCa();
this.ecParams = params;
param = new ECKeyGenerationParameters(new ECDomainParameters(p.getCurve(), p.getG(), p.getN()), random);
engine.init(param);
initialised = true;
}
else if (params == null && ProviderUtil.getEcImplicitlyCa() == null)