fix(gcpkms): verify ciphertext_crc32c and AAD_crc32c on Decrypt response#5
Open
ibondarenko1 wants to merge 1 commit into
Open
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
The two GcpKmsAead variants in
GcpKmsAead.java(RESTGcpKmsAeadat lines 106-135 and gRPCGcpKmsAeadGrpcat lines 234-262) both set request-side CRC32C checksums ondecrypt, but neither checks the response'sverified_ciphertext_crc32corverified_additional_authenticated_data_crc32cflags. TheEncryptpaths 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
Decryptnow fails closed on:!response.getVerifiedCiphertextCrc32c()!response.getVerifiedAdditionalAuthenticatedDataCrc32c()in both the REST variant (using boxed
Booleangetters with null-check) and the gRPC variant (using primitivebooleangetters), 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.