Search in sources :

Example 6 with ECNamedDomainParameters

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;
}
Also used : ECDomainParameters(com.github.zhenwei.core.crypto.params.ECDomainParameters) X9ECParameters(com.github.zhenwei.core.asn1.x9.X9ECParameters) ECParameterSpec(com.github.zhenwei.provider.jce.spec.ECParameterSpec) ECNamedDomainParameters(com.github.zhenwei.core.crypto.params.ECNamedDomainParameters) Map(java.util.Map) ASN1ObjectIdentifier(com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)

Example 7 with ECNamedDomainParameters

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;
}
Also used : ECDomainParameters(com.github.zhenwei.core.crypto.params.ECDomainParameters) ECParameterSpec(com.github.zhenwei.provider.jce.spec.ECParameterSpec) ECNamedCurveParameterSpec(com.github.zhenwei.provider.jce.spec.ECNamedCurveParameterSpec) ECNamedDomainParameters(com.github.zhenwei.core.crypto.params.ECNamedDomainParameters) ASN1ObjectIdentifier(com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)

Example 8 with ECNamedDomainParameters

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;
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) X9ECParameters(com.github.zhenwei.core.asn1.x9.X9ECParameters) ECGOST3410Parameters(com.github.zhenwei.core.crypto.params.ECGOST3410Parameters) ECNamedDomainParameters(com.github.zhenwei.core.crypto.params.ECNamedDomainParameters) ASN1ObjectIdentifier(com.github.zhenwei.core.asn1.ASN1ObjectIdentifier) ECNamedCurveSpec(com.github.zhenwei.provider.jce.spec.ECNamedCurveSpec) ECKeyGenerationParameters(com.github.zhenwei.core.crypto.params.ECKeyGenerationParameters)

Example 9 with ECNamedDomainParameters

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;
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) X9ECParameters(com.github.zhenwei.core.asn1.x9.X9ECParameters) ECGOST3410Parameters(com.github.zhenwei.core.crypto.params.ECGOST3410Parameters) ECNamedDomainParameters(com.github.zhenwei.core.crypto.params.ECNamedDomainParameters) ECNamedCurveSpec(com.github.zhenwei.provider.jce.spec.ECNamedCurveSpec) ECKeyGenerationParameters(com.github.zhenwei.core.crypto.params.ECKeyGenerationParameters)

Example 10 with ECNamedDomainParameters

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");
    }
}
Also used : PublicVerificationKey(com.github.zhenwei.pkix.util.oer.its.PublicVerificationKey) ITSPublicVerificationKey(com.github.zhenwei.pkix.its.ITSPublicVerificationKey) ECNamedDomainParameters(com.github.zhenwei.core.crypto.params.ECNamedDomainParameters) ECPoint(com.github.zhenwei.core.math.ec.ECPoint) ASN1ObjectIdentifier(com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)

Aggregations

ECNamedDomainParameters (com.github.zhenwei.core.crypto.params.ECNamedDomainParameters)14 ASN1ObjectIdentifier (com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)12 X9ECParameters (com.github.zhenwei.core.asn1.x9.X9ECParameters)10 ECDomainParameters (com.github.zhenwei.core.crypto.params.ECDomainParameters)6 ASN1Encodable (com.github.zhenwei.core.asn1.ASN1Encodable)5 DSAParameters (com.github.zhenwei.core.crypto.params.DSAParameters)5 ECGOST3410Parameters (com.github.zhenwei.core.crypto.params.ECGOST3410Parameters)5 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)4 ECPrivateKeyParameters (com.github.zhenwei.core.crypto.params.ECPrivateKeyParameters)4 ECPublicKeyParameters (com.github.zhenwei.core.crypto.params.ECPublicKeyParameters)4 ECPoint (com.github.zhenwei.core.math.ec.ECPoint)4 GOST3410PublicKeyAlgParameters (com.github.zhenwei.core.asn1.cryptopro.GOST3410PublicKeyAlgParameters)3 RSAPrivateKey (com.github.zhenwei.core.asn1.pkcs.RSAPrivateKey)3 ECPrivateKey (com.github.zhenwei.core.asn1.sec.ECPrivateKey)3 AlgorithmIdentifier (com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier)3 DSAParameter (com.github.zhenwei.core.asn1.x509.DSAParameter)3 X962Parameters (com.github.zhenwei.core.asn1.x9.X962Parameters)3 DSAPrivateKeyParameters (com.github.zhenwei.core.crypto.params.DSAPrivateKeyParameters)3 Ed25519PrivateKeyParameters (com.github.zhenwei.core.crypto.params.Ed25519PrivateKeyParameters)3 RSAPrivateCrtKeyParameters (com.github.zhenwei.core.crypto.params.RSAPrivateCrtKeyParameters)3