aes256cbc: Use no padding instead of zero padding#210
Merged
robin-nitrokey merged 1 commit intomainfrom May 15, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Reviewed applications:
- Opcard OK (we check length and reject non multiple of 16 bytes)
- PIV: AES only ever encrypts/decrypts 16 bytes (and check the length)
- FIDO
- Secrets (no AES)
- Webcrypt (AES is used without checking length, here it's an issue, we can ignore for now because not even included in the test firmware).
Member
Author
|
There is actually one case in fido-authenticator where zero-padding is performed: the encrypted PIN when setting a new PIN. I’ll prepare a PR with this change. |
Member
Author
|
Nevermind, fido-authenticator already strips the padding (though this was probably not necessary with the current implementation): Also, the full test suite succeeds even with this PR. |
sosthene-nitrokey
approved these changes
May 15, 2025
Defaulting to zero padding can be problematic. Using no padding leaves it up to the application to handle the padding correctly according to the use case. Fixes: #209
de72c5f to
e107ed3
Compare
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.
Defaulting to zero padding can be problematic. Using no padding leaves it up to the application to handle the padding correctly according to the use case.
Fixes: #209
To do: Review all applications and backends to ensure that only full blocks are used with AES-256.