Skip to content

fix(gcpkms): verify ciphertext_crc32c and AAD_crc32c on Decrypt response#5

Open
ibondarenko1 wants to merge 1 commit into
tink-crypto:mainfrom
ibondarenko1:fix/decrypt-crc32c-integrity-gates
Open

fix(gcpkms): verify ciphertext_crc32c and AAD_crc32c on Decrypt response#5
ibondarenko1 wants to merge 1 commit into
tink-crypto:mainfrom
ibondarenko1:fix/decrypt-crc32c-integrity-gates

Conversation

@ibondarenko1
Copy link
Copy Markdown

Background

The two GcpKmsAead variants in GcpKmsAead.java (REST GcpKmsAead at lines 106-135 and gRPC GcpKmsAeadGrpc at lines 234-262) both set request-side CRC32C checksums on decrypt, but neither checks the response's verified_ciphertext_crc32c or verified_additional_authenticated_data_crc32c flags. The Encrypt paths in both variants already perform these checks.

Per the Cloud KMS Data Integrity Guidelines, the response must be rejected if the server did not confirm receipt of the request CRCs.

Change

Decrypt now fails closed on:

  • !response.getVerifiedCiphertextCrc32c()
  • !response.getVerifiedAdditionalAuthenticatedDataCrc32c()

in both the REST variant (using boxed Boolean getters with null-check) and the gRPC variant (using primitive boolean getters), matching the existing Encrypt-side patterns in the same file.

Sibling fixes

All five PRs converge on the same Cloud KMS Data Integrity Guidelines compliance.

The two GcpKmsAead variants in this file (REST GcpKmsAead lines
106-135 and gRPC GcpKmsAeadGrpc lines 234-262) both set request-side
CRC32C checksums on Decrypt but neither checks the response's
verified_ciphertext_crc32c or verified_additional_authenticated_data_crc32c
flags. The Encrypt paths in both variants already do these checks.

Per Cloud KMS Data Integrity Guidelines
(https://cloud.google.com/kms/docs/data-integrity-guidelines), the
response must be rejected if the server did not confirm receipt of
the request CRCs.

This change adds the symmetric verified_*_crc32c response checks to
both Decrypt variants, matching the existing Encrypt-side pattern in
the same file.

Sibling fixes: tink-go-gcpkms#21, tink-cc-gcpkms#2, tink-cc-gcpkms#3,
tink-py PR #77 (Python had no CRC32C at all on either direction).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants