Search in sources :

Example 1 with PublicVerificationKey

use of com.github.zhenwei.pkix.util.oer.its.PublicVerificationKey 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

ASN1ObjectIdentifier (com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)1 ECNamedDomainParameters (com.github.zhenwei.core.crypto.params.ECNamedDomainParameters)1 ECPoint (com.github.zhenwei.core.math.ec.ECPoint)1 ITSPublicVerificationKey (com.github.zhenwei.pkix.its.ITSPublicVerificationKey)1 PublicVerificationKey (com.github.zhenwei.pkix.util.oer.its.PublicVerificationKey)1