Search in sources :

Example 1 with KmsEnvelopeAeadKey

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

the class KmsEnvelopeAeadKeyManager method getPrimitive.

/**
 * @param key {@code KmsEnvelopeAeadKey} proto
 */
@Override
public Aead getPrimitive(MessageLite key) throws GeneralSecurityException {
    if (!(key instanceof KmsEnvelopeAeadKey)) {
        throw new GeneralSecurityException("expected KmsEnvelopeAeadKey proto");
    }
    KmsEnvelopeAeadKey keyProto = (KmsEnvelopeAeadKey) key;
    validate(keyProto);
    String keyUri = keyProto.getParams().getKekUri();
    KmsClient kmsClient = KmsClients.get(keyUri);
    Aead remote = kmsClient.getAead(keyUri);
    return new KmsEnvelopeAead(keyProto.getParams().getDekTemplate(), remote);
}
Also used : KmsEnvelopeAeadKey(com.google.crypto.tink.proto.KmsEnvelopeAeadKey) GeneralSecurityException(java.security.GeneralSecurityException) Aead(com.google.crypto.tink.Aead) ByteString(com.google.protobuf.ByteString) KmsClient(com.google.crypto.tink.KmsClient)

Aggregations

Aead (com.google.crypto.tink.Aead)1 KmsClient (com.google.crypto.tink.KmsClient)1 KmsEnvelopeAeadKey (com.google.crypto.tink.proto.KmsEnvelopeAeadKey)1 ByteString (com.google.protobuf.ByteString)1 GeneralSecurityException (java.security.GeneralSecurityException)1