Search in sources :

Example 6 with EcdsaPublicKey

use of com.google.crypto.tink.proto.EcdsaPublicKey in project tink by google.

the class EcdsaVerifyKeyManager method getPrimitive.

/**
 * @param key {@code EcdsaPublicKey} proto
 */
@Override
public PublicKeyVerify getPrimitive(MessageLite key) throws GeneralSecurityException {
    if (!(key instanceof EcdsaPublicKey)) {
        throw new GeneralSecurityException("expected EcdsaPublicKey proto");
    }
    EcdsaPublicKey keyProto = (EcdsaPublicKey) key;
    validate(keyProto);
    ECPublicKey publicKey = EllipticCurves.getEcPublicKey(SigUtil.toCurveType(keyProto.getParams().getCurve()), keyProto.getX().toByteArray(), keyProto.getY().toByteArray());
    return new EcdsaVerifyJce(publicKey, SigUtil.toEcdsaAlgo(keyProto.getParams().getHashType()));
}
Also used : ECPublicKey(java.security.interfaces.ECPublicKey) EcdsaPublicKey(com.google.crypto.tink.proto.EcdsaPublicKey) GeneralSecurityException(java.security.GeneralSecurityException) EcdsaVerifyJce(com.google.crypto.tink.subtle.EcdsaVerifyJce)

Aggregations

EcdsaPublicKey (com.google.crypto.tink.proto.EcdsaPublicKey)6 ECPublicKey (java.security.interfaces.ECPublicKey)4 GeneralSecurityException (java.security.GeneralSecurityException)3 KeyPair (java.security.KeyPair)3 ECPrivateKey (java.security.interfaces.ECPrivateKey)3 ECPoint (java.security.spec.ECPoint)3 PublicKeySign (com.google.crypto.tink.PublicKeySign)1 EcdsaKeyFormat (com.google.crypto.tink.proto.EcdsaKeyFormat)1 EcdsaParams (com.google.crypto.tink.proto.EcdsaParams)1 EcdsaPrivateKey (com.google.crypto.tink.proto.EcdsaPrivateKey)1 EllipticCurveType (com.google.crypto.tink.proto.EllipticCurveType)1 HashType (com.google.crypto.tink.proto.HashType)1 EcdsaVerifyJce (com.google.crypto.tink.subtle.EcdsaVerifyJce)1 KeyPairGenerator (java.security.KeyPairGenerator)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ECParameterSpec (java.security.spec.ECParameterSpec)1 Test (org.junit.Test)1