Skip to content

Commit 5925eff

Browse files
committed
More ML-DSA renaming
1 parent be67bf8 commit 5925eff

4 files changed

Lines changed: 1997 additions & 1704 deletions

File tree

doc/dilithium-to-mldsa-migration.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ the legacy API.
3737
| `wc_dilithium_*` (lifecycle / sizing) | `wc_MlDsaKey_*` |
3838
| `wc_Dilithium_*` (DER encode / decode) | `wc_MlDsaKey_*` |
3939
| internal lower-case `dilithium_*` helpers | `mldsa_*` |
40+
| `DILITHIUM_*` algorithm-parameter macros | `MLDSA_*` (matches `MLKEM_*` in `wc_mlkem.h`) |
41+
| `PARAMS_ML_DSA_{44,65,87}_*` per-parameter-set internal constants | `PARAMS_MLDSA_{44,65,87}_*` |
42+
| `DILITHIUM_LEVEL{2,3,5}_*_SIZE`, `ML_DSA_LEVEL{2,3,5}_*_SIZE`, `MLDSA_LEVEL{2,3,5}_*_SIZE`, `DILITHIUM_ML_DSA_{44,65,87}_*_SIZE` | `WC_MLDSA_{44,65,87}_*_SIZE` |
43+
| `WC_ML_DSA_{44,65,87}` level identifiers, `WC_ML_DSA_{44,65,87}_DRAFT`, `WC_ML_DSA_DRAFT` | `WC_MLDSA_{44,65,87}`, `WC_MLDSA_{44,65,87}_DRAFT`, `WC_MLDSA_DRAFT` |
44+
| `DEBUG_DILITHIUM` | `DEBUG_MLDSA` |
45+
46+
The `WOLFSSL_NO_ML_DSA_{44,65,87}` parameter-set disable gates are
47+
intentionally kept in their underscored form (matching the
48+
`WOLFSSL_NO_ML_KEM_{512,768,1024}` spelling in `wc_mlkem.h`); they are
49+
not renamed.
4050

4151
The 16 sign / verify / import / DER-decode entry points were also
4252
re-ordered to put the `MlDsaKey*` first (matching the FIPS 204 / ML-KEM
@@ -165,6 +175,74 @@ wolfSSL-internal infrastructure (an auto-generated cert-buffer data
165175
file and the static allocator's default sizing), not consumer-facing
166176
API; these changes do not require downstream code changes.
167177

178+
## Macro / comment cleanup inside `wc_mldsa.{c,h}`
179+
180+
A follow-on cleanup of the ML-DSA implementation file finished the
181+
internal naming migration that the file/symbol rename above started:
182+
183+
- All algorithm-parameter macros defined in `wolfssl/wolfcrypt/wc_mldsa.h`
184+
(`DILITHIUM_Q`, `DILITHIUM_N`, `DILITHIUM_D`, `DILITHIUM_ETA_*`,
185+
`DILITHIUM_GAMMA1_*`, `DILITHIUM_K_SZ`, `DILITHIUM_MU_SZ`,
186+
`DILITHIUM_MAX_*`, …) were renamed to canonical `MLDSA_*` spellings
187+
matching the `MLKEM_*` internal constants in
188+
`<wolfssl/wolfcrypt/wc_mlkem.h>`. The per-parameter-set internal
189+
algorithm constants `PARAMS_ML_DSA_{44,65,87}_*` were also collapsed
190+
to `PARAMS_MLDSA_{44,65,87}_*` for internal-naming consistency.
191+
- The per-parameter-set size constants previously existed in **three**
192+
redundant spellings — `DILITHIUM_LEVEL{2,3,5}_*_SIZE`,
193+
`ML_DSA_LEVEL{2,3,5}_*_SIZE`, and
194+
`DILITHIUM_ML_DSA_{44,65,87}_*_SIZE`. They were consolidated to a
195+
single canonical family, `WC_MLDSA_{44,65,87}_*_SIZE`. All three
196+
legacy spellings remain reachable as aliases through the
197+
`<wolfssl/wolfcrypt/dilithium.h>` shim (gated by
198+
`WOLFSSL_NO_DILITHIUM_LEGACY_NAMES`); a duplicate `MLDSA_N`
199+
definition in `wc_mldsa.h` was also removed.
200+
- All ~20 file-local macros inside `wolfcrypt/src/wc_mldsa.c`
201+
(`DILITHIUM_SIGN_BYTES`, `DILITHIUM_GEN_S_*`, `DILITHIUM_HASH_OID_LEN`,
202+
`DILITHIUM_PARAMS_CNT`, `DILITHIUM_COEFF_S*`, `DILITHIUM_QINV`,
203+
`DILITHIUM_NTT_ZETA_1`, `DILITHIUM_POS_OFFSET`, …) were renamed
204+
to `MLDSA_*`. The file-local macros are not user-visible and have no
205+
alias in the shim.
206+
- The user-tunable knobs documented in the `wc_mldsa.c` file-top
207+
comment block — `DEBUG_DILITHIUM` and the five performance-tuning
208+
defines `DILITHIUM_MUL_SLOW`, `DILITHIUM_MUL_44_SLOW`,
209+
`DILITHIUM_MUL_11_SLOW`, `DILITHIUM_MUL_QINV_SLOW`,
210+
`DILITHIUM_MUL_Q_SLOW` — were renamed to `DEBUG_MLDSA` /
211+
`MLDSA_MUL_*_SLOW`. These are set from `user_settings.h` or `-D`,
212+
so a forward-translation block was added to the legacy-gates arm
213+
in `<wolfssl/wolfcrypt/dilithium.h>` (gated by
214+
`WOLFSSL_NO_DILITHIUM_LEGACY_GATES`) so consumers using the legacy
215+
spelling continue to get the intended code path.
216+
- A long-standing typo, `dilitihium_get_der_length()` (5 call sites,
217+
`static`-scope), was corrected to `mldsa_get_der_length()`.
218+
- All `DILITHIUM_*` legacy macro spellings remain reachable from
219+
unmigrated in-tree consumers (`wolfcrypt/src/asn.c`, `src/ssl_load.c`,
220+
`src/internal.c`, `src/tls13.c`, `src/ssl.c`, `src/x509.c`,
221+
`src/ssl_api_pk.c`, `src/ssl_certman.c`, `wolfssl/internal.h`,
222+
`wolfssl/wolfcrypt/asn.h`, `asn_public.h`, `oid_sum.h`,
223+
`examples/configs/user_settings_pq.h`,
224+
`wolfcrypt/benchmark/benchmark.c`, `wolfcrypt/test/test.c`,
225+
`tests/api/test_mldsa.c`) and downstream code through a new
226+
reverse-arm macro alias block in `<wolfssl/wolfcrypt/dilithium.h>`,
227+
gated by the existing `WOLFSSL_NO_DILITHIUM_LEGACY_NAMES` opt-out.
228+
- All function and section comments inside `wc_mldsa.c` had their
229+
"Dilithium" / "dilithium" prose replaced with "ML-DSA" (the file-top
230+
credit retains a parenthetical mention of the historical name).
231+
- Every algorithm-step citation was re-numbered against FIPS 204 Final
232+
(August 2024). The implementation was previously annotated with the
233+
draft (IPD) numbering — e.g. `Algorithm 18 skEncode`, `Algorithm 26
234+
ExpandA`, `Algorithm 29 Power2Round`. These were updated to the
235+
Final numbering (`Algorithm 24 skEncode`, `Algorithm 32 ExpandA`,
236+
`Algorithm 35 Power2Round`, …) and the section references were
237+
retargeted from the draft `§8.x` building-blocks group to the Final
238+
`§7.x` arrangement. SHAKE128/256 notation references were redirected
239+
from the IPD `§8.3` to the Final `§3.7`. Citation punctuation was
240+
normalized from `FIPS 204. N.M:` to `FIPS 204 §N.M,`.
241+
242+
These changes are contained to `wolfcrypt/src/wc_mldsa.c`,
243+
`wolfssl/wolfcrypt/wc_mldsa.h`, and the macro-alias block in
244+
`wolfssl/wolfcrypt/dilithium.h`. No external consumer is touched.
245+
168246
### Retained internal symbols
169247

170248
A few internal-only spellings are intentionally **not** renamed in this

0 commit comments

Comments
 (0)