Skip to content

fix(encryption): return DataInvalid for invalid AES key sizes - #3226

Merged
blackmwk merged 1 commit into
apache:mainfrom
xanderbailey:xb/key_length_data_invalid
Sep 15, 2026
Merged

blackmwk merged 1 commit into
apache:mainfrom
xanderbailey:xb/key_length_data_invalid

Conversation

@xanderbailey

Copy link
Copy Markdown
Contributor

AesKeySize::from_key_length and AesKeySize::from_str returned FeatureUnsupported for anything outside 128/192/256-bit. AES defines no other key sizes, so these are invalid input rather than something a later version could support, and FeatureUnsupported here is indistinguishable from the genuinely unsupported cases such as an unknown key metadata version.

from_key_length is reachable from SecureKey::new, StandardKeyMetadata::try_new and the encryption.data-key-length table property, all of which now surface DataInvalid. Messages change from "Unsupported ..." to "Invalid ..." to match.

Which issue does this PR close?

  • Closes #.

What changes are included in this PR?

Are these changes tested?

AI Disclosure

`AesKeySize::from_key_length` and `AesKeySize::from_str` returned
`FeatureUnsupported` for anything outside 128/192/256-bit. AES defines no other
key sizes, so these are invalid input rather than something a later version
could support, and `FeatureUnsupported` here is indistinguishable from the
genuinely unsupported cases such as an unknown key metadata version.

`from_key_length` is reachable from `SecureKey::new`,
`StandardKeyMetadata::try_new` and the `encryption.data-key-length` table
property, all of which now surface `DataInvalid`. Messages change from
"Unsupported ..." to "Invalid ..." to match.
@xanderbailey

Copy link
Copy Markdown
Contributor Author

@blackmwk @kevinjqliu hopefully not controversial

@blackmwk blackmwk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xanderbailey for this fix!

@blackmwk
blackmwk added this pull request to the merge queue Sep 15, 2026
Merged via the queue into apache:main with commit aa5ff7e Sep 15, 2026
23 checks passed
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