use of com.google.api.services.cloudkms.v1.model.DecryptResponse in project data-transfer-project by google.
the class GoogleAppSecretDecrypter method decryptAppSecret.
public byte[] decryptAppSecret(byte[] ciphertext) throws IOException {
DecryptRequest request = new DecryptRequest().encodeCiphertext(ciphertext);
DecryptResponse response = cloudKMS.projects().locations().keyRings().cryptoKeys().decrypt(secretsCryptoKey, request).execute();
return response.decodePlaintext();
}
use of com.google.api.services.cloudkms.v1.model.DecryptResponse in project tink by google.
the class GcpKmsAead method decrypt.
@Override
public byte[] decrypt(final byte[] ciphertext, final byte[] aad) throws GeneralSecurityException {
try {
DecryptRequest request = new DecryptRequest().encodeCiphertext(ciphertext).encodeAdditionalAuthenticatedData(aad);
DecryptResponse response = this.kmsClient.projects().locations().keyRings().cryptoKeys().decrypt(this.kmsKeyUri, request).execute();
return response.decodePlaintext();
} catch (IOException e) {
throw new GeneralSecurityException("decryption failed", e);
}
}
use of com.google.api.services.cloudkms.v1.model.DecryptResponse in project java-docs-samples by GoogleCloudPlatform.
the class CryptFile method decrypt.
// [END kms_encrypt]
// [START kms_decrypt]
/**
* Decrypts the provided ciphertext with the specified crypto key.
*/
public static byte[] decrypt(String projectId, String locationId, String keyRingId, String cryptoKeyId, byte[] ciphertext) throws IOException {
// Create the Cloud KMS client.
CloudKMS kms = createAuthorizedClient();
// The resource name of the cryptoKey
String cryptoKeyName = String.format("projects/%s/locations/%s/keyRings/%s/cryptoKeys/%s", projectId, locationId, keyRingId, cryptoKeyId);
DecryptRequest request = new DecryptRequest().encodeCiphertext(ciphertext);
DecryptResponse response = kms.projects().locations().keyRings().cryptoKeys().decrypt(cryptoKeyName, request).execute();
return response.decodePlaintext();
}
use of com.google.api.services.cloudkms.v1.model.DecryptResponse in project data-transfer-project by google.
the class GoogleCryptoKeyManagementSystem method decryptAppSecret.
public byte[] decryptAppSecret(byte[] ciphertext) throws IOException {
DecryptRequest request = new DecryptRequest().encodeCiphertext(ciphertext);
DecryptResponse response = cloudKMS.projects().locations().keyRings().cryptoKeys().decrypt(secretsCryptoKey, request).execute();
return response.decodePlaintext();
}
Aggregations