use of com.google.crypto.tink.KmsClient in project tink by google.
the class KmsAeadKeyManagerTest method setUp.
@Before
public void setUp() throws Exception {
KmsClient kmsClient = new GcpKmsClient().withCredentials(TestUtil.SERVICE_ACCOUNT_FILE);
KmsClients.add(kmsClient);
Config.register(AeadConfig.TINK_1_0_0);
}
use of com.google.crypto.tink.KmsClient 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);
}
use of com.google.crypto.tink.KmsClient 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);
}
Aggregations