use of com.google.cloud.kms.v1.MacVerifyResponse in project java-kms by googleapis.
the class VerifyMac method verifyMac.
// Sign data with a given mac key.
public void verifyMac(String projectId, String locationId, String keyRingId, String keyId, String keyVersionId, String data, byte[] signature) throws IOException {
// safely clean up any remaining background resources.
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
// Build the key version name from the project, location, key ring, key,
// and key version.
CryptoKeyVersionName keyVersionName = CryptoKeyVersionName.of(projectId, locationId, keyRingId, keyId, keyVersionId);
// Verify the signature
MacVerifyResponse response = client.macVerify(keyVersionName, ByteString.copyFromUtf8(data), ByteString.copyFrom(signature));
// The data comes back as raw bytes, which may include non-printable
// characters. This base64-encodes the result so it can be printed below.
System.out.printf("Success: %s%n", response.getSuccess());
}
}
Aggregations