Search in sources :

Example 1 with ECCurve

use of org.openecard.bouncycastle.math.ec.ECCurve in project open-ecard by ecsec.

the class ExplicitDomainParameters method loadECDHParameter.

private void loadECDHParameter(ASN1Sequence seq) {
    // ASN1Integer version = (ASN1Integer) seq.getObjectAt(0);
    // ASN1Sequence modulus = (ASN1Sequence) seq.getObjectAt(1);
    // ASN1Sequence coefficient = (ASN1Sequence) seq.getObjectAt(2);
    // ASN1OctetString basepoint = (ASN1OctetString) seq.getObjectAt(3);
    ASN1Integer order = (ASN1Integer) seq.getObjectAt(4);
    ASN1Integer cofactor = (ASN1Integer) seq.getObjectAt(5);
    try {
        // BigInteger p = new BigInteger(modulus.getObjectAt(1).toASN1Primitive().getEncoded());
        // BigInteger a = new BigInteger(coefficient.getObjectAt(0).toASN1Primitive().getEncoded());
        // BigInteger b = new BigInteger(coefficient.getObjectAt(1).toASN1Primitive().getEncoded());
        BigInteger r = order.getValue();
        BigInteger f = cofactor.getValue();
        X9ECParameters ECParameters = X9ECParameters.getInstance(seq);
        ECCurve curve = ECParameters.getCurve();
        domainParameter = new ECParameterSpec(curve, ECParameters.getG(), r, f);
    } catch (Exception e) {
        _logger.error("Failed to load proprietary domain parameters", e);
    }
}
Also used : X9ECParameters(org.openecard.bouncycastle.asn1.x9.X9ECParameters) ECParameterSpec(org.openecard.bouncycastle.jce.spec.ECParameterSpec) ECCurve(org.openecard.bouncycastle.math.ec.ECCurve) BigInteger(java.math.BigInteger) ASN1Integer(org.openecard.bouncycastle.asn1.ASN1Integer)

Aggregations

BigInteger (java.math.BigInteger)1 ASN1Integer (org.openecard.bouncycastle.asn1.ASN1Integer)1 X9ECParameters (org.openecard.bouncycastle.asn1.x9.X9ECParameters)1 ECParameterSpec (org.openecard.bouncycastle.jce.spec.ECParameterSpec)1 ECCurve (org.openecard.bouncycastle.math.ec.ECCurve)1