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);
}
Aggregations