feat(data_encryption): support AES-256 keys in the encryption keyring - #13756
Open
AlinsRan wants to merge 1 commit into
Open
feat(data_encryption): support AES-256 keys in the encryption keyring#13756AlinsRan wants to merge 1 commit into
AlinsRan wants to merge 1 commit into
Conversation
init_iv_tbl only ever built AES-128 ciphers, so a 32-byte data_encryption keyring key could not be used for AES-256. A 16-byte key now selects AES-128 and a 32-byte key selects AES-256; keys of any other length are skipped instead of being forced through aes.cipher(128, ...), which previously errored via the assert. Adds t/core/data_encryption.t covering the 16-byte, 32-byte, mixed-keyring and unsupported-length cases. Signed-off-by: AlinsRan <alinsran@apache.org>
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
core.data_encryption.init_iv_tblonly ever built AES-128 ciphers:So a 32-byte
apisix.data_encryption.keyringkey could not be used for AES-256, and any key whose length is not exactly 16 bytes was forced throughaes.cipher(128, ...)and errored via theassert.This selects the cipher by key length: a 16-byte key → AES-128, a 32-byte key → AES-256. Keys of any other length are skipped rather than crashing.
No schema change is needed — the keyring is read from config without a length constraint.
Which issue(s) this PR fixes
Lets operators use a stronger AES-256 keyring for
encrypt_fields/ SSL key encryption.Checklist
t/core/data_encryption.t: 16-byte, 32-byte, mixed keyring, unsupported length)