Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrap does not work if data is encrypted using associated data #29532

Closed
d3bt3ch opened this issue Feb 10, 2025 · 2 comments
Closed

Rewrap does not work if data is encrypted using associated data #29532

d3bt3ch opened this issue Feb 10, 2025 · 2 comments
Assignees

Comments

@d3bt3ch
Copy link

d3bt3ch commented Feb 10, 2025

If we encrypt data with an associated_data then rewrap fails with response

{
    "errors": [
        "cipher: message authentication failed"
    ]
}

We tried to provide associated_data while rewrapping as well (though the parameter is not documented, thus probably not supported in rewrap operation) but without any luck.

@aslamovamir
Copy link
Contributor

Hi @d3bt3ch thanks for opening the issue with us!
Hmm, looks like what you assume is right: rewrap operation in Vault's transit secret engine does not support associated_data as a parameter. The reason why this error might be happening is that given the rewrap operation is supposed to re-encrypt data using a newer version of the encryption key without modifying any authenticated data, if associated_data was used during encryption but is not supported during rewrap, the new encryption process fails because Vault cannot properly validate the auth tag.
The associated_data is used in AEAD (Authenticated Encryption with Associated Data) encryption operations, like encrypt and decrypt, but it is not required or used in rewrap. If your use case involves AEAD and you need to rewrap while maintaining authentication with associated_data, you would have to decrypt the data first and then re-encrypt it with the new key version, manually providing the associated_data. So, the suggestion would be to 1) Read and decrypt the data using the original associated_data 2) Encrypt the data again with associated_data using the latest key version 3) Store the newly encrypted data.
If you would like more information about the rewrap operation, this link might help more!

@d3bt3ch
Copy link
Author

d3bt3ch commented Feb 10, 2025

So, the suggestion would be to 1) Read and decrypt the data using the original associated_data 2) Encrypt the data again with associated_data using the latest key version 3) Store the newly encrypted data.

That is exactly what we ended up coding. Thank you for the clarification.

@d3bt3ch d3bt3ch closed this as completed Feb 10, 2025
@aslamovamir aslamovamir self-assigned this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants