Search in sources :

Example 6 with JwtEcdsaPublicKey

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

the class JwtEcdsaVerifyKeyManagerTest method validateKey_ok.

// Note: we use Theory as a parametrized test -- different from what the Theory framework intends.
@Theory
public void validateKey_ok(@FromDataPoints("parametersAlgos") JwtEcdsaAlgorithm algorithm) throws Exception {
    if (TestUtil.isTsan()) {
        // factory.createKey is too slow in Tsan.
        return;
    }
    JwtEcdsaKeyFormat keyFormat = JwtEcdsaKeyFormat.newBuilder().setAlgorithm(algorithm).build();
    JwtEcdsaPrivateKey privateKey = factory.createKey(keyFormat);
    JwtEcdsaPublicKey publicKey = signManager.getPublicKey(privateKey);
    verifyManager.validateKey(publicKey);
}
Also used : JwtEcdsaPublicKey(com.google.crypto.tink.proto.JwtEcdsaPublicKey) JwtEcdsaPrivateKey(com.google.crypto.tink.proto.JwtEcdsaPrivateKey) JwtEcdsaKeyFormat(com.google.crypto.tink.proto.JwtEcdsaKeyFormat) Theory(org.junit.experimental.theories.Theory)

Example 7 with JwtEcdsaPublicKey

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

the class JwtEcdsaVerifyKeyManagerTest method createPrimitive_ok.

// Note: we use Theory as a parametrized test -- different from what the Theory framework intends.
@Theory
public void createPrimitive_ok(@FromDataPoints("parametersAlgos") JwtEcdsaAlgorithm algorithm) throws Exception {
    if (TestUtil.isTsan()) {
        // factory.createKey is too slow in Tsan.
        return;
    }
    JwtEcdsaKeyFormat keyFormat = JwtEcdsaKeyFormat.newBuilder().setAlgorithm(algorithm).build();
    JwtEcdsaPrivateKey privateKey = factory.createKey(keyFormat);
    JwtEcdsaPublicKey publicKey = signManager.getPublicKey(privateKey);
    JwtPublicKeySignInternal signer = signManager.getPrimitive(privateKey, JwtPublicKeySignInternal.class);
    JwtPublicKeyVerifyInternal verifier = verifyManager.getPrimitive(publicKey, JwtPublicKeyVerifyInternal.class);
    RawJwt token = RawJwt.newBuilder().withoutExpiration().build();
    JwtValidator validator = JwtValidator.newBuilder().allowMissingExpiration().build();
    verifier.verifyAndDecodeWithKid(signer.signAndEncodeWithKid(token, Optional.empty()), validator, Optional.empty());
}
Also used : JwtEcdsaPublicKey(com.google.crypto.tink.proto.JwtEcdsaPublicKey) JwtEcdsaPrivateKey(com.google.crypto.tink.proto.JwtEcdsaPrivateKey) JwtEcdsaKeyFormat(com.google.crypto.tink.proto.JwtEcdsaKeyFormat) Theory(org.junit.experimental.theories.Theory)

Aggregations

JwtEcdsaPublicKey (com.google.crypto.tink.proto.JwtEcdsaPublicKey)7 JwtEcdsaPrivateKey (com.google.crypto.tink.proto.JwtEcdsaPrivateKey)6 JwtEcdsaKeyFormat (com.google.crypto.tink.proto.JwtEcdsaKeyFormat)5 Theory (org.junit.experimental.theories.Theory)5 ByteString (com.google.protobuf.ByteString)2 JwtEcdsaAlgorithm (com.google.crypto.tink.proto.JwtEcdsaAlgorithm)1 KeyData (com.google.crypto.tink.proto.KeyData)1 Keyset (com.google.crypto.tink.proto.Keyset)1 InputStream (java.io.InputStream)1 KeyPair (java.security.KeyPair)1 ECPrivateKey (java.security.interfaces.ECPrivateKey)1 ECPublicKey (java.security.interfaces.ECPublicKey)1 ECPoint (java.security.spec.ECPoint)1 HashMap (java.util.HashMap)1