use of com.github.zhenwei.core.crypto.params.ECNamedDomainParameters in project LinLong-Java by zhenwei1108.
the class ECUtil method getDomainParameters.
public static ECDomainParameters getDomainParameters(ProviderConfiguration configuration, X962Parameters params) {
ECDomainParameters domainParameters;
if (params.isNamedCurve()) {
ASN1ObjectIdentifier oid = ASN1ObjectIdentifier.getInstance(params.getParameters());
X9ECParameters ecP = ECUtil.getNamedCurveByOid(oid);
if (ecP == null) {
Map extraCurves = configuration.getAdditionalECParameters();
ecP = (X9ECParameters) extraCurves.get(oid);
}
domainParameters = new ECNamedDomainParameters(oid, ecP);
} else if (params.isImplicitlyCA()) {
com.github.zhenwei.provider.jce.spec.ECParameterSpec iSpec = configuration.getEcImplicitlyCa();
domainParameters = new ECDomainParameters(iSpec.getCurve(), iSpec.getG(), iSpec.getN(), iSpec.getH(), iSpec.getSeed());
} else {
X9ECParameters ecP = X9ECParameters.getInstance(params.getParameters());
domainParameters = new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
return domainParameters;
}
use of com.github.zhenwei.core.crypto.params.ECNamedDomainParameters in project LinLong-Java by zhenwei1108.
the class ECUtil method getDomainParameters.
public static ECDomainParameters getDomainParameters(ProviderConfiguration configuration, com.github.zhenwei.provider.jce.spec.ECParameterSpec params) {
ECDomainParameters domainParameters;
if (params instanceof ECNamedCurveParameterSpec) {
ECNamedCurveParameterSpec nParams = (ECNamedCurveParameterSpec) params;
ASN1ObjectIdentifier nameOid = ECUtil.getNamedCurveOid(nParams.getName());
domainParameters = new ECNamedDomainParameters(nameOid, nParams.getCurve(), nParams.getG(), nParams.getN(), nParams.getH(), nParams.getSeed());
} else if (params == null) {
com.github.zhenwei.provider.jce.spec.ECParameterSpec iSpec = configuration.getEcImplicitlyCa();
domainParameters = new ECDomainParameters(iSpec.getCurve(), iSpec.getG(), iSpec.getN(), iSpec.getH(), iSpec.getSeed());
} else {
domainParameters = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed());
}
return domainParameters;
}
use of com.github.zhenwei.core.crypto.params.ECNamedDomainParameters 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.ECNamedDomainParameters 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.ECNamedDomainParameters in project LinLong-Java by zhenwei1108.
the class BcITSPublicVerificationKey method fromKeyParameters.
static PublicVerificationKey fromKeyParameters(ECPublicKeyParameters pubKey) {
ASN1ObjectIdentifier curveID = ((ECNamedDomainParameters) pubKey.getParameters()).getName();
ECPoint q = pubKey.getQ();
if (curveID.equals(SECObjectIdentifiers.secp256r1)) {
return new PublicVerificationKey(PublicVerificationKey.ecdsaNistP256, EccP256CurvePoint.builder().createUncompressedP256(q.getAffineXCoord().toBigInteger(), q.getAffineYCoord().toBigInteger()));
} else if (curveID.equals(TeleTrusTObjectIdentifiers.brainpoolP256r1)) {
return new PublicVerificationKey(PublicVerificationKey.ecdsaBrainpoolP256r1, EccP256CurvePoint.builder().createUncompressedP256(q.getAffineXCoord().toBigInteger(), q.getAffineYCoord().toBigInteger()));
} else if (curveID.equals(TeleTrusTObjectIdentifiers.brainpoolP384r1)) {
return new PublicVerificationKey(PublicVerificationKey.ecdsaBrainpoolP384r1, EccP384CurvePoint.builder().createUncompressedP384(q.getAffineXCoord().toBigInteger(), q.getAffineYCoord().toBigInteger()));
} else {
throw new IllegalArgumentException("unknown curve in public encryption key");
}
}
Aggregations