You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix uint16_t truncation of req_len in MlDsa, Ed25519, and Hkdf client functions by using uint32_t for intermediate length computation before bounds check
Hello Claude this file is to go over how to fix proposed bugs for this branch.
2
+
3
+
to start off read the STEPS section then go to the BUG-REPORT section to see the report is
4
+
5
+
STEPS:
6
+
1. review proposued bug and confirm the existance
7
+
2. If bug does exisit
8
+
a. come up with option for the fix and compare it to proposed fix if there is one
9
+
b. Check all docs and commit history for effeted code to see if it's intentinal or the so called bug is applicatible in certaion scenarioes
10
+
3. Once the bug fix is found
11
+
a. Analyze to see if there are any other implications in other spots in the code base and if any other changes need to be made to compinsate for the fix.
12
+
b. analayze if there should be a test in place to prevent this from happneing in the future
13
+
14
+
15
+
BUG-REPORT:
16
+
# 776: uint16_t Truncation of Request Length in wh_Client_MlDsaSign and wh_Client_MlDsaVerify
Both `wh_Client_MlDsaSign` and `wh_Client_MlDsaVerify` compute `req_len` as `uint16_t` from a sum involving `word32` (uint32_t) operands (`in_len`, `sig_len`, `msg_len`). If the sum exceeds 65535, the value silently wraps. The truncated `req_len` is then compared against `WOLFHSM_CFG_COMM_DATA_LEN` for bounds checking; a wrapped value could pass this check despite the actual data being much larger. Other functions in the same file (e.g., `wh_Client_CmacKdf` at line 3886) correctly use `uint32_t` for the intermediate computation and only cast to `uint16_t` after validating the bounds.
Use `uint32_t` for the intermediate length computation, validate it against `WOLFHSM_CFG_COMM_DATA_LEN`, then assign to `uint16_t` only after the bounds check passes. Follow the pattern at line 3886-3892 in `wh_Client_CmacKdf`.
0 commit comments