Commit 3b2d711
committed
XMSS: clean -Wconversion warnings and add XMSS to Wconversion CI matrix
Add --enable-xmss to all 11 existing wolfCrypt-Wconversion matrix rows so
the XMSS sources (wc_xmss.c, wc_xmss_impl.c) are exercised under the same
strict conversion-warning flags already enforced for ML-KEM. Add 2 new
matrix rows that cover the XMSS sub-options (small, verify-only on 32-bit)
which use distinct code paths.
Add a test_xmss_runtime job that builds --enable-xmss and
--enable-xmss=yes,small (without --disable-crypttests) and runs
testwolfcrypt for each. The build-only matrix can't catch a bad cast that
silently changes the wire output; the runtime job is the safety net (same
pattern as test_lms_runtime in PR #14).
To make the XMSS sources compile cleanly under -Wconversion
-Warith-conversion -Wsign-conversion -Wcast-qual:
- wc_xmss.h: U-suffix on length constants, (word32) casts inside size
macros (XMSS_HASH_PRF_DATA_LEN, XMSS_CHAIN_HASH_DATA_LEN,
XMSS_RAND_HASH_DATA_LEN, XMSS_RETAIN_LEN) so arithmetic stays unsigned.
- wc_xmss_impl.c:
- U-suffix on the local fixed-parameter constants (XMSS_WOTS_W,
XMSS_HASH_PADDING_*, XMSS_PRF_M_LEN, XMSS_IDX_LEN, etc.).
- In wc_xmss_msg_convert: kept word16 csum (per RFC 8391 the WOTS+
checksum field is fixed 16-bit, the algorithm relies on 2^16
wraparound), with explicit (word16) casts at every assignment to
silence the warning without changing semantics. Same pattern as the
LMS PR's wc_lmots_q_expand fix.
- Replaced hand-rolled length expressions with the (now fixed) macros
where possible (XMSS_HASH_PRF_DATA_LEN, XMSS_RAND_HASH_DATA_LEN).
- Cast (byte)i at addr_buf[XMSS_ADDR_*]/addr[XMSS_ADDR_*] = i sites
where i is word32 (WOTS+ chain/hash addressing).
- Changed wc_idx_zero/wc_idx_update parameter from word8/int len to
word32 so length flows cleanly into XMEMSET; rewrote the increment
loop to use unsigned i with i > 0 termination.
- Restored (word32)1U on shifts whose exponent can reach the tree
height (up to 60 for XMSSMT-SHA2_60/12_256) — bare 1U is unsigned
int which is undefined behaviour for shifts >= 32 on most targets.
- Changed wc_xmss_bds_state_treehash_init / wc_xmss_bds_next_idx 'int
i' parameter to word32, removing call-site (int) casts.
- Cast at the narrowest assignment boundary throughout (e.g.,
`const word8 hsk = (word8)(params->sub_h - params->bds_k)`,
`addr[XMSS_ADDR_LAYER] = (word32)(params->d - 1)`).
- Switch (word8)min(...) cast at the narrow assignment site to
silence the word32→word8 narrowing from the shared min() helper.
- wc_xmss.c:
- 3 → 3U in wc_RNG_GenerateBlock(rng, seed, 3 * key->params->n).
- Cast public API's int msgLen/mLen to (word32) when forwarding to
wc_xmss_sign / wc_xmssmt_sign / wc_xmssmt_verify; added the missing
msgLen <= 0 check in wc_XmssKey_Verify (Sign already had it).
Verified: 13 matrix rows build clean under the conversion flags;
testwolfcrypt's "XMSS Vfy" / "XMSS" tests pass for --enable-xmss,
--enable-xmss=yes,small, and --enable-xmss=yes,verify-only;
bench_xmss_xmssmt parameter sets within noise vs. master.
https://claude.ai/code/session_01EJmy1bKDgHseTwZ5Qqpu1g1 parent 7b53303 commit 3b2d711
4 files changed
Lines changed: 179 additions & 139 deletions
File tree
- .github/workflows
- wolfcrypt/src
- wolfssl/wolfcrypt
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
752 | | - | |
| 752 | + | |
| 753 | + | |
753 | 754 | | |
754 | 755 | | |
755 | | - | |
| 756 | + | |
| 757 | + | |
756 | 758 | | |
757 | 759 | | |
758 | | - | |
| 760 | + | |
759 | 761 | | |
760 | 762 | | |
761 | 763 | | |
| |||
1083 | 1085 | | |
1084 | 1086 | | |
1085 | 1087 | | |
1086 | | - | |
| 1088 | + | |
1087 | 1089 | | |
1088 | 1090 | | |
1089 | 1091 | | |
| |||
1093 | 1095 | | |
1094 | 1096 | | |
1095 | 1097 | | |
1096 | | - | |
| 1098 | + | |
1097 | 1099 | | |
1098 | 1100 | | |
1099 | 1101 | | |
| |||
1473 | 1475 | | |
1474 | 1476 | | |
1475 | 1477 | | |
1476 | | - | |
| 1478 | + | |
1477 | 1479 | | |
1478 | 1480 | | |
1479 | | - | |
| 1481 | + | |
| 1482 | + | |
1480 | 1483 | | |
1481 | 1484 | | |
1482 | 1485 | | |
| |||
1603 | 1606 | | |
1604 | 1607 | | |
1605 | 1608 | | |
1606 | | - | |
| 1609 | + | |
1607 | 1610 | | |
1608 | 1611 | | |
1609 | 1612 | | |
| |||
1631 | 1634 | | |
1632 | 1635 | | |
1633 | 1636 | | |
1634 | | - | |
| 1637 | + | |
1635 | 1638 | | |
1636 | 1639 | | |
1637 | 1640 | | |
| |||
0 commit comments