ThePassionate commented on PR #4114: URL: https://github.com/apache/nuttx-apps/pull/4114#issuecomment-7120177501
Both points addressed: 1. `keybits` is validated against `mbedtls_cipher_info_get_key_bitlen(ctx->cipher_info)` before the switch, so the 256-bit cipher fed a 128-bit key and `keybits` over 256 (the `memcpy` overflow) are both rejected on entry now. 2. Testing: `mbedtls_cipher_cmac()` with `MBEDTLS_CIPHER_AES_256_ECB` now runs through the alt on sim (`CONFIG_MBEDTLS_CMAC_ALT`; the run needs `MBEDTLS_ALLOW_PRIVATE_ACCESS` added locally, see the Impact note) against the SP 800-38B AES-256 vectors, cross-checked with python cryptography: ``` cmactest aes-256 mlen=0 success cmactest aes-256 mlen=16 success cmactest aes-256 mlen=40 success cmactest aes-256 mlen=64 success cmactest aes-128 mlen=0 success cmactest aes-128 mlen=64 success cmactest aes-256 keybits 128 rejected success cmactest aes-256 keybits 512 rejected success --- reference values (host python cryptography, SP 800-38B) --- mlen=0 028962f61b7bf89efc6b551f4667d983 (the tag you gave) mlen=16 28a7023f452e8f82bd4bf28d8c37c35c mlen=40 aaf3d8f1de5640c232f5b169b9c911e6 mlen=64 e1992190549f6ed5696a2c056c315410 ``` The commit message now names apache/nuttx#21957 for the kernel side of `CRYPTO_AES_256_CMAC`. On the mislabelled key in `testing/drivers/crypto/aescmac.c`: good catch. I'll send a tiny follow-up that fixes the comment - the vectors in the test match the key that is actually in the file, only the "SP 800-38B key" claim is wrong. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
