use of com.github.zhenwei.core.crypto.params.ECKeyGenerationParameters in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method init.
private void init(GOST3410ParameterSpec gostParams, SecureRandom random) throws InvalidAlgorithmParameterException {
ASN1ObjectIdentifier oid = gostParams.getPublicKeyParamSet();
X9ECParameters ecP = ECGOST3410NamedCurves.getByOIDX9(oid);
if (ecP == null) {
throw new InvalidAlgorithmParameterException("unknown curve: " + oid);
}
this.ecParams = new ECNamedCurveSpec(ECGOST3410NamedCurves.getName(oid), ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
param = new ECKeyGenerationParameters(new ECGOST3410Parameters(new ECNamedDomainParameters(oid, ecP), oid, gostParams.getDigestParamSet(), gostParams.getEncryptionParamSet()), random);
engine.init(param);
initialised = true;
}
use of com.github.zhenwei.core.crypto.params.ECKeyGenerationParameters in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method init.
private void init(GOST3410ParameterSpec gostParams, SecureRandom random) throws InvalidAlgorithmParameterException {
X9ECParameters ecP = ECGOST3410NamedCurves.getByOIDX9(gostParams.getPublicKeyParamSet());
if (ecP == null) {
throw new InvalidAlgorithmParameterException("unknown curve: " + gostParams.getPublicKeyParamSet());
}
this.ecParams = new ECNamedCurveSpec(ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()), ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
param = new ECKeyGenerationParameters(new ECGOST3410Parameters(new ECNamedDomainParameters(gostParams.getPublicKeyParamSet(), ecP), gostParams.getPublicKeyParamSet(), gostParams.getDigestParamSet(), gostParams.getEncryptionParamSet()), random);
engine.init(param);
initialised = true;
}
use of com.github.zhenwei.core.crypto.params.ECKeyGenerationParameters in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method initialize.
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
if (params instanceof ECParameterSpec) {
ECParameterSpec p = (ECParameterSpec) params;
this.ecParams = params;
param = new ECKeyGenerationParameters(new ECDomainParameters(p.getCurve(), p.getG(), p.getN(), p.getH()), 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());
if (p instanceof DSTU4145ParameterSpec) {
DSTU4145ParameterSpec dstuSpec = (DSTU4145ParameterSpec) p;
param = new ECKeyGenerationParameters(new DSTU4145Parameters(new ECDomainParameters(curve, g, p.getOrder(), BigInteger.valueOf(p.getCofactor())), dstuSpec.getDKE()), random);
} else {
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();
}
// ECDomainParameters ecP = ECGOST3410NamedCurves.getByName(curveName);
ECDomainParameters ecP = DSTU4145NamedCurves.getByOID(new ASN1ObjectIdentifier(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());
java.security.spec.ECParameterSpec p = (java.security.spec.ECParameterSpec) ecParams;
ECCurve curve = EC5Util.convertCurve(p.getCurve());
ECPoint g = EC5Util.convertPoint(curve, p.getGenerator());
param = new ECKeyGenerationParameters(new ECDomainParameters(curve, g, p.getOrder(), BigInteger.valueOf(p.getCofactor())), random);
engine.init(param);
initialised = true;
} else if (params == null && WeGooProvider.CONFIGURATION.getEcImplicitlyCa() != null) {
ECParameterSpec p = WeGooProvider.CONFIGURATION.getEcImplicitlyCa();
this.ecParams = params;
param = new ECKeyGenerationParameters(new ECDomainParameters(p.getCurve(), p.getG(), p.getN(), p.getH()), random);
engine.init(param);
initialised = true;
} else if (params == null && WeGooProvider.CONFIGURATION.getEcImplicitlyCa() == null) {
throw new InvalidAlgorithmParameterException("null parameter passed but no implicitCA set");
} else {
throw new InvalidAlgorithmParameterException("parameter object not a ECParameterSpec: " + params.getClass().getName());
}
}
Aggregations