Skip to content

Rust wrapper: rename dilithium to mldsa#10780

Open
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:rust-rename-dilithium-mldsa
Open

Rust wrapper: rename dilithium to mldsa#10780
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:rust-rename-dilithium-mldsa

Conversation

@holtrop-wolfssl

Copy link
Copy Markdown
Contributor

Description

Rust wrapper: rename dilithium to mldsa

This follows the rename of the C API dilithium.h to wc_mldsa.h. Even though backward-compatible macros were created in the C API, the Rust wrapper FFI does not see those, so it wasn't picking up that ML-DSA support was enabled.

Testing

How did you test?

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@holtrop-wolfssl holtrop-wolfssl self-assigned this Jun 25, 2026
Copilot AI review requested due to automatic review settings June 25, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Rust wolfcrypt wrapper to track the upstream C API rename from Dilithium (dilithium.h / wc_dilithium_*) to ML-DSA (wc_mldsa.h / wc_MlDsaKey_*), so Rust cfg() detection and FFI symbol matching work correctly when ML-DSA is enabled.

Changes:

  • Rename the Rust API surface from dilithium::Dilithium to mldsa::MlDsa and switch FFI calls to wc_MlDsaKey_*.
  • Update bindgen input headers and build.rs cfg scanning to use wc_mldsa.h and wc_MlDsaKey_* symbols.
  • Update Rust tests and autotools distribution lists to match the new ML-DSA naming.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wrapper/rust/wolfssl-wolfcrypt/tests/test_mldsa.rs Updates test imports and cfg gates from dilithium to mldsa / MlDsa.
wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs Renames wrapper type/API and switches FFI calls/constants to the canonical ML-DSA C API.
wrapper/rust/wolfssl-wolfcrypt/src/lib.rs Removes dilithium module export and adds mldsa module export.
wrapper/rust/wolfssl-wolfcrypt/headers.h Switches bindgen header include from dilithium.h to wc_mldsa.h.
wrapper/rust/wolfssl-wolfcrypt/build.rs Updates cfg scanning keys from wc_dilithium_* to wc_MlDsaKey_*.
wrapper/rust/include.am Updates autotools EXTRA_DIST entries from dilithium to mldsa files/tests.
Comments suppressed due to low confidence (6)

wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs:443

  • size() unconditionally calls sys::wc_MlDsaKey_Size, but in wolfSSL this API is only declared when WOLFSSL_MLDSA_PRIVATE_KEY is enabled (see wolfssl/wolfcrypt/wc_mldsa.h:784-787). In public-key/verify-only builds the binding will not contain wc_MlDsaKey_Size, so this method will fail to compile even though the mldsa module is enabled. Gate this method on a cfg that implies private-key support (e.g. mldsa_sign, which is absent under WOLFSSL_MLDSA_VERIFY_ONLY).
    wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs:473
  • priv_size() unconditionally calls sys::wc_MlDsaKey_PrivSize, but this API is only declared when both WOLFSSL_MLDSA_PRIVATE_KEY and WOLFSSL_MLDSA_PUBLIC_KEY are enabled (see wolfssl/wolfcrypt/wc_mldsa.h:788-792). In verify-only/public-key-only builds the binding will not contain wc_MlDsaKey_PrivSize, causing a compile error. Gate this method on a cfg that implies private-key support (e.g. mldsa_sign).
    wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs:639
  • import_private() is currently gated only by mldsa_import (set from wc_MlDsaKey_ImportPubRaw), but wc_MlDsaKey_ImportPrivRaw is only available when WOLFSSL_MLDSA_PRIVATE_KEY is enabled (see wolfssl/wolfcrypt/wc_mldsa.h:811-817). In public-key/verify-only builds mldsa_import may be enabled while ImportPrivRaw is not present, leading to a compile error. Tighten the cfg gate to require a private-key-capable cfg (e.g. mldsa_sign).
    wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs:681
  • import_key() is currently gated only by mldsa_import (derived from public-key import), but wc_MlDsaKey_ImportKey is only declared under WOLFSSL_MLDSA_PRIVATE_KEY (see wolfssl/wolfcrypt/wc_mldsa.h:811-817). This can break builds that only enable public-key operations. Gate it on a private-key-capable cfg as well (e.g. mldsa_sign).
    wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs:764
  • export_private() is currently gated only by mldsa_export (set from wc_MlDsaKey_ExportPubRaw), but wc_MlDsaKey_ExportPrivRaw is only declared when WOLFSSL_MLDSA_PRIVATE_KEY is enabled (see wolfssl/wolfcrypt/wc_mldsa.h:823-826). In verify-only/public-key-only builds this can cause a compile error. Tighten the cfg gate to require a private-key-capable cfg (e.g. mldsa_sign).
    wrapper/rust/wolfssl-wolfcrypt/src/mldsa.rs:808
  • export_key() is currently gated only by mldsa_export (public-key export), but wc_MlDsaKey_ExportKey is only declared under WOLFSSL_MLDSA_PRIVATE_KEY (see wolfssl/wolfcrypt/wc_mldsa.h:823-831). This can break builds that only have public-key/verify support. Gate it on a private-key-capable cfg as well (e.g. mldsa_sign).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@holtrop-wolfssl

Copy link
Copy Markdown
Contributor Author

retest this please (build timed out)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants