Check SHE field widths in the software path only - #11279
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts SHE message generation so packed-field width checks (counter/flags/key IDs) are enforced only on the software packing path, allowing crypto-callback implementations (e.g., secure elements/HSMs) to accept wider logical key numbering without being rejected up-front.
Changes:
- Moved packed-field width validation in
wc_SHE_GenerateM1M2M3()to occur only after the crypto-callback attempt (i.e., only for software path). - Moved packed-field width validation in
wc_SHE_GenerateM4M5()to occur only after the crypto-callback attempt (i.e., only for software path).
Suppressed comments (2)
wolfcrypt/src/wc_she.c:705
- As with M1/M2/M3 generation, the callback path can now accept key IDs beyond WC_SHE_KEY_ID_MAX, but the public header docs describe authKeyId/targetKeyId as 4-bit slot IDs. Consider updating the API documentation to clarify that the software path enforces packed-field widths, while callbacks may use their own key numbering/mapping.
/* Only the software path packs these into M4, so the widths are
* checked here. A callback may use its own key numbering. */
if (counter > WC_SHE_COUNTER_MAX ||
wolfcrypt/src/wc_she.c:708
- There are existing tests that assert BAD_FUNC_ARG for out-of-range packed field widths on the software path, but no test appears to validate that the callback path bypasses these width checks (e.g., allowing authKeyId/targetKeyId > WC_SHE_KEY_ID_MAX when the callback succeeds). Adding a callback-path regression test would help ensure this behavioral contract remains intact.
if (counter > WC_SHE_COUNTER_MAX ||
authKeyId > WC_SHE_KEY_ID_MAX || targetKeyId > WC_SHE_KEY_ID_MAX) {
return BAD_FUNC_ARG;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Can one of the admins verify this patch? |
A crypto callback builds the SHE messages itself and may use its own wider key numbering, so the software packing limits must not reject its values.
035202f to
f6963c7
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11279
Scan targets checked: wolfcrypt-bugs, wolfcrypt-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review comment dealt with
A crypto callback builds the SHE messages itself and may use its own wider key numbering, so the software packing limits must not reject its values.