Skip to content

Conversation

@robin-nitrokey
Copy link
Member

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.

Copy link
Contributor

@sosthene-nitrokey sosthene-nitrokey left a comment

Choose a reason for hiding this comment

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

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).

@robin-nitrokey
Copy link
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.

@robin-nitrokey
Copy link
Member Author

robin-nitrokey commented May 15, 2025

Nevermind, fido-authenticator already strips the padding (though this was probably not necessary with the current implementation):

https://github.com/Nitrokey/fido-authenticator/blob/5ebb4a48302e4c80a2abe1c2d86201a3df2a1d2d/src/ctap2.rs#L1247

Also, the full test suite succeeds even with this PR.

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
@robin-nitrokey robin-nitrokey merged commit e107ed3 into main May 15, 2025
2 checks passed
@robin-nitrokey robin-nitrokey deleted the aes-padding branch May 15, 2025 10:01
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.

Review padding used for Aes256Cbc mechanism

3 participants