Search in sources :

Example 1 with KmsAeadKey

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

the class KmsAeadKeyManager method getPrimitive.

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

Aggregations

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