Repository navigation
Ensure ECCSI SSK is in [1, q-1]. Fix multiple issues in TI/Xilinx AES. Update base16/64/blake2b documentation. - #11902
kareem-wolfssl wants to merge 5 commits into
Conversation
|
@claude review |
|
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟣
wolfcrypt/src/port/ti/ti-aes.c— Pre-existing: on TI, a hardware failure in the main AES-GCM/CCM encrypt path is still reported as AES_GCM_AUTH_E, even in CCM mode. This change makes the other paths return WC_HW_E or a mode-correct code, so encrypt is now the inconsistent one. Fix: return WC_HW_E when ROM_AESDataProcessAuth returns false in AesAuthEncrypt. That matches the new early-path handling at ti-aes.c:617-625 and keeps the existing ForceZero of out and authTag.Why this was flagged
AesAuthEncrypt (ti-aes.c:577) is reached via wc_AesGcmEncrypt, wc_AesCcmEncrypt and GMAC. When ROM_AESDataProcessAuth returns false (ti-aes.c:667-674), the code sets
ret = AES_GCM_AUTH_Eat ti-aes.c:679 regardless of mode. Encryption has no authentication to fail, so this is an engine failure. In the same function this PR now returns WC_HW_E for an engine failure in the empty-input path (ti-aes.c:617-625). In AesAuthDecrypt it now picks AES_CCM_AUTH_E for CCM at ti-aes.c:808. So a CCM caller on TI hardware gets an AES-GCM authentication error for a hardware fault, and the error depends on which branch ran. The base behaved the same way (pre-existing). This PR's partial fix leaves this sibling path inconsistent.Verification: Pre-existing. In AesAuthEncrypt (wolfcrypt/src/port/ti/ti-aes.c:668-680), when ROM_AESDataProcessAuth returns false, the code still returns AES_GCM_AUTH_E whatever the mode. That includes CCM. This PR changes the empty-input path (lines 617-625) to return WC_HW_E, and AesAuthDecrypt now picks the code by mode at line 808. The harm is limited because out and authTag are zeroed (lines 676-678), and the base branch already returns this code.
-
🟣
wolfcrypt/src/port/ti/ti-aes.c— pre-existing: TI AES-GCM callers with a non-12-byte nonce can still get an IV derived from an uninitialized subkey if the hardware call fails. The PR checks ROM_AESDataProcess elsewhere but not at ti-aes.c:476 in AesAuthSetIv. If that call fails,subkeyis never written and is still loaded via ROM_AESKey2Set to GHASH the nonce. Fix: check the result at ti-aes.c:476 and return WC_HW_E. This means AesAuthSetIv must return int, and AesAuthEncrypt/AesAuthDecrypt must pass that error up, the same way AesAlign16 now does.Why this was flagged
The trigger is wc_AesGcmEncrypt/Decrypt on TI hardware with a nonce length other than GCM_NONCE_MID_SZ, which reaches the else branch of AesAuthSetIv (ti-aes.c:462). The trigger also needs ROM_AESDataProcess to return false at ti-aes.c:476. The stack array
subkey(ti-aes.c:464) is then still uninitialized. It is passed to ROM_AESKey2Set at ti-aes.c:481, so the J0 counter written to aes->reg comes from whatever was on the stack. Encryption then goes ahead and reports success with a wrong tag and keystream, with no error to the caller. Different nonces could even map to the same counter. This PR adds checks with the same purpose at AesAlign16 (ti-aes.c:165) and at both empty-input tag paths (ti-aes.c:617, 745), so this sibling is the one ROM_AESDataProcess call left unchecked. The base has the same behaviour here.Verification: pre-existing. Trigger: TI GCM with a nonce length other than GCM_NONCE_MID_SZ, and ROM_AESDataProcess returning false.
ROM_AESDataProcess(AES_BASE, zeros, subkey, sizeof zeros);(wolfcrypt/src/port/ti/ti-aes.c:476) ignores its bool result, andROM_AESKey2Set(AES_BASE, subkey, ...)(line 481) then loads whatever subkey holds. The base already behaves the same way by the same route.
6542711 to
2777b74
Compare
Tighten auth code size checks in Xilinx AES support.
2777b74 to
bc4c4f4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Active issues remain: the API documentation omits required BAD_FUNC_ARG conditions, and the Xilinx AES-GCM encryptor now permits short tags that the decryptor neither supports nor safely handles.
3 open issues
Review effort: Lite
|
|
||
| if (aes == NULL || (in == NULL && sz > 0) || (out == NULL) || iv == NULL || | ||
| authTag == NULL || authTagSz > AES_GCM_AUTH_SZ) { | ||
| authTag == NULL || wc_local_AesGcmCheckTagSz(authTagSz) != 0) { |
There was a problem hiding this comment.
Master currently accepts any size from 0-16 bytes, so this is tightening the accepted range. The software implementation currently allows 12–16 bytes. IMO it doesn't make sense for this to be stricter, even if the HW decrypt doesn't accept 12-15 bytes currently.


Description
Testing
Built-in + added tests
Checklist