transit: add associated_data support to rewrap endpoint#31842
Open
mango766 wants to merge 1 commit intohashicorp:mainfrom
Open
transit: add associated_data support to rewrap endpoint#31842mango766 wants to merge 1 commit intohashicorp:mainfrom
mango766 wants to merge 1 commit intohashicorp:mainfrom
Conversation
The rewrap endpoint was missing associated_data (AD/AAD) support, making it impossible to rewrap ciphertext that was encrypted with associated data using AEAD cipher modes (e.g., AES-GCM). Both the encrypt and decrypt endpoints already support this parameter, but the rewrap endpoint was missing it in three places: 1. The endpoint's Fields map (API parameter definition) 2. Non-batch request item construction 3. The decrypt and encrypt factory slices in the processing loop Without this fix, users had to manually decrypt and re-encrypt as separate calls, which defeats the purpose of rewrap (not exposing plaintext to the client). Fixes hashicorp#31791
|
Someone is attempting to deploy a commit to the HashiCorp Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes easonysliu seems not to be a GitHub user. Have you signed the CLA already but the status is still pending? Recheck it. |
Contributor
|
Please remember to sign the CLA. Thanks! |
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.
Description
The transit
rewrapendpoint currently does not accept theassociated_dataparameter, even though both theencryptanddecryptendpoints support it. This means that ciphertext encrypted with associated data (AD/AAD) using AEAD cipher modes like AES-GCM cannot be rewrapped — the only workaround is to decrypt and re-encrypt as separate API calls, which defeats the purpose of rewrap (avoiding exposure of plaintext to the client).Fixes #31791
Root Cause
The
associated_datasupport was missing frompath_rewrap.goin three places:associated_dataparameter was not declared in the endpoint schema, so non-batch requests couldn't pass it at allAssociatedDatafield was never populated from the request dataAssocDataFactorywas created or passed toDecryptWithOptionsorEncryptWithOptions, so even batch requests that includedassociated_datavia mapstructure had it silently ignoredThe
RewrapBatchRequestItemstruct already had anAssociatedDatafield and theAssocDataFactorytype already existed — they just weren't wired up.Changes
All changes are in
builtin/logical/transit/path_rewrap.go:associated_datafield to the endpoint'sFieldsmap (matching the encrypt/decrypt endpoints)AssociatedDatafromd.Get("associated_data")for non-batch requestsAssocDataFactoryto the decrypt factory slice (so decryption can verify the AAD)AssocDataFactoryto the encrypt factory slice (so re-encryption preserves the AAD binding)How I verified
go build ./builtin/logical/transit/...— compiles cleanlygo test ./builtin/logical/transit/... -run "TestTransit_.*"— all existing tests passpath_encrypt.goandpath_decrypt.goto ensure consistency