Skip to content

Conversation

@mkannwischer
Copy link
Contributor

This adds the MLD_CONFIG_NO_RANDOMIZED_API configuration option to the config
file aligning with mlkem-native.

MLD_CONFIG_NO_RANDOMIZED_API allows to exclude all top-level APIs requiring
randombytes() from a mldsa-native build. This way consumers only requiring
the deterministic internal APIs do not have to provide a randomytes
implementation.
The excluded APIs are currently crypto_sign_keypair, crypto_sign,
crypto_sign_signature, and crypto_sign_signature_extmu.

Currently, this option is incompatible with the MLD_CONFIG_KEYGEN_PCT
configuration option at that relies on crypto_sign_signature.
A corresponding error is added in case both configuration options are set.

The basic_deterministic example is added to excercise the configuration option.

@mkannwischer mkannwischer force-pushed the no-rand branch 2 times, most recently from 65c79a0 to 0404d6f Compare November 6, 2025 03:01
@mkannwischer mkannwischer marked this pull request as ready for review November 6, 2025 07:11
@mkannwischer mkannwischer requested a review from a team as a code owner November 6, 2025 07:11
Copy link
Contributor

@hanno-becker hanno-becker left a comment

Choose a reason for hiding this comment

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

Two nits, but otherwise lgtm.

This adds the MLD_CONFIG_NO_RANDOMIZED_API configuration option to the config
file aligning with mlkem-native.

MLD_CONFIG_NO_RANDOMIZED_API allows to exclude all top-level APIs requiring
randombytes() from a mldsa-native build. This way consumers only requiring
the deterministic internal APIs do not have to provide a randomytes
implementation.
The excluded APIs  are currently crypto_sign_keypair, crypto_sign,
crypto_sign_signature, and crypto_sign_signature_extmu.

Currently, this option is incompatible with the MLD_CONFIG_KEYGEN_PCT
configuration option at that relies on crypto_sign_signature.
A corresponding error is added in case both configuration options are set.

Resolves #597

An example exercising this configuration option is added in the following
commit.

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
This commit adds an example exercising the MLD_CONFIG_NO_RANDOMIZED_API option,
i.e., how to build and use mldsa-native without providing a randombytes()
implementation but instead supplying all randomness externally.

We use a small trick to be able to produce the same testvectors as in the
basic example: We extract the randomness that is generated by our
deterministic RNG (notrandombytes.c) during the randomized tests and hardcode
the randomness in the example (main.c).

Resolves #598

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
…ith PCT

MLD_CONFIG_NO_RANDOMIZED_API and MLD_CONFIG_KEYGEN_PCT are incompatible and
hence the config variation test that enables PCT currently errors in the
basic_deterministic example (with the appopriate error message that the options
are incompatible).

This commit ports the --exclude-example option for the test script and uses
it in CI for the PCT test.

We also consolidate various small differences to the mlkem-native test script
(whitespace changes, etc.).

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
@mkannwischer mkannwischer merged commit d9a6334 into main Nov 7, 2025
248 checks passed
@mkannwischer mkannwischer deleted the no-rand branch November 7, 2025 05:56
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.

Example: basic_deterministic Config: Add MLD_CONFIG_NO_RANDOMIZED_API option

3 participants