Skip to content

Conversation

@mkannwischer
Copy link
Contributor

Split KEYPAIR allocation constants into _NO_PCT and PCT variants to
accurately reflect memory usage with and without pairwise consistency
testing (PCT). MLD_TOTAL_ALLOC
*_KEYPAIR now automatically selects
the appropriate value based on MLD_CONFIG_KEYGEN_PCT.

For legacy configs, assume PCT is enabled (conservative).

Also correct REDUCE_RAM KEYPAIR values which were previously using
PCT values unconditionally.

The default alloc test config no longer enables PCT; PCT is tested
via config-variations.

@mkannwischer mkannwischer force-pushed the mld-alloc-pct branch 3 times, most recently from 2eaa5b6 to f880e8d Compare January 11, 2026 02:38
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 11, 2026
Multilevel builds require MLK_CONFIG_NO_SUPERCOP since the SUPERCOP
naming convention (crypto_kem_xxx) does not disambiguate between
parameter sets.

Add MLK_CONFIG_NO_SUPERCOP to all multilevel build configs and
propagate it to the API layer in the legacy config path.

This also fixes problem with mlkem_native.h: On multiple inclusions of
mlkem_native.h without NO_SUPERCOP set, mlkem_native.h would not undef the
API_CONFIG macros in the end of the file causing the second inclusion of
mlkem_native.h to set the LEGACY_CONFIG option.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 11, 2026
Split KEYPAIR allocation constants into _NO_PCT and _PCT variants to
accurately reflect memory usage with and without pairwise consistency
testing (PCT). MLK_TOTAL_ALLOC_*_KEYPAIR now automatically selects
the appropriate value based on MLK_CONFIG_KEYGEN_PCT.

For legacy configs, assume PCT is enabled (conservative).

The default alloc test config no longer enables PCT; PCT is tested
via config-variations.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
@mkannwischer mkannwischer marked this pull request as ready for review January 11, 2026 03:47
@mkannwischer mkannwischer requested a review from a team as a code owner January 11, 2026 03:47
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 12, 2026
Multilevel builds require MLK_CONFIG_NO_SUPERCOP since the SUPERCOP
naming convention (crypto_kem_xxx) does not disambiguate between
parameter sets.

Add MLK_CONFIG_NO_SUPERCOP to all multilevel build configs and
propagate it to the API layer in the legacy config path.

This also fixes problem with mlkem_native.h: On multiple inclusions of
mlkem_native.h without NO_SUPERCOP set, mlkem_native.h would not undef the
API_CONFIG macros in the end of the file causing the second inclusion of
mlkem_native.h to set the LEGACY_CONFIG option.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 12, 2026
Split KEYPAIR allocation constants into _NO_PCT and _PCT variants to
accurately reflect memory usage with and without pairwise consistency
testing (PCT). MLK_TOTAL_ALLOC_*_KEYPAIR now automatically selects
the appropriate value based on MLK_CONFIG_KEYGEN_PCT.

For legacy configs, assume PCT is enabled (conservative).

The default alloc test config no longer enables PCT; PCT is tested
via config-variations.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
@mkannwischer mkannwischer force-pushed the mld-alloc-pct branch 3 times, most recently from e346f89 to 85c42a0 Compare January 12, 2026 07:01
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 12, 2026
Multilevel builds require MLK_CONFIG_NO_SUPERCOP since the SUPERCOP
naming convention (crypto_kem_xxx) does not disambiguate between
parameter sets.

Add MLK_CONFIG_NO_SUPERCOP to all multilevel build configs and
propagate it to the API layer in the legacy config path.

This also fixes problem with mlkem_native.h: On multiple inclusions of
mlkem_native.h without NO_SUPERCOP set, mlkem_native.h would not undef the
API_CONFIG macros in the end of the file causing the second inclusion of
mlkem_native.h to set the LEGACY_CONFIG option.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 12, 2026
Split KEYPAIR allocation constants into _NO_PCT and _PCT variants to
accurately reflect memory usage with and without pairwise consistency
testing (PCT). MLK_TOTAL_ALLOC_*_KEYPAIR now automatically selects
the appropriate value based on MLK_CONFIG_KEYGEN_PCT.

For legacy configs, assume PCT is enabled (conservative).

The default alloc test config no longer enables PCT; PCT is tested
via config-variations.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 12, 2026
Multilevel builds require MLK_CONFIG_NO_SUPERCOP since the SUPERCOP
naming convention (crypto_kem_xxx) does not disambiguate between
parameter sets.

Add MLK_CONFIG_NO_SUPERCOP to all multilevel build configs and
propagate it to the API layer in the legacy config path.

This also fixes problem with mlkem_native.h: On multiple inclusions of
mlkem_native.h without NO_SUPERCOP set, mlkem_native.h would not undef the
API_CONFIG macros in the end of the file causing the second inclusion of
mlkem_native.h to set the LEGACY_CONFIG option.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Jan 12, 2026
Split KEYPAIR allocation constants into _NO_PCT and _PCT variants to
accurately reflect memory usage with and without pairwise consistency
testing (PCT). MLK_TOTAL_ALLOC_*_KEYPAIR now automatically selects
the appropriate value based on MLK_CONFIG_KEYGEN_PCT.

For legacy configs, assume PCT is enabled (conservative).

The default alloc test config no longer enables PCT; PCT is tested
via config-variations.

 - Ported from pq-code-package/mldsa-native#869

Signed-off-by: Matthias J. Kannwischer <[email protected]>
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.

LGTM

Multilevel builds require MLD_CONFIG_NO_SUPERCOP since the SUPERCOP
naming convention (crypto_sign_xxx) does not disambiguate between
parameter sets.

Add MLD_CONFIG_NO_SUPERCOP to all multilevel build configs and
propagate it to the API layer in the legacy config path.

This also fixes problem with mldsa_native.h: On multiple inclusions of
mldsa_native.h without NO_SUPERCOP set, mldsa_native.h would not undef the
API_CONFIG macros in the end of the file causing the second inclusion of
mldsa_native.h to set the LEGACY_CONFIG option.

Signed-off-by: Matthias J. Kannwischer <[email protected]>
Split KEYPAIR allocation constants into _NO_PCT and _PCT variants to
accurately reflect memory usage with and without pairwise consistency
testing (PCT). MLD_TOTAL_ALLOC_*_KEYPAIR now automatically selects
the appropriate value based on MLD_CONFIG_KEYGEN_PCT.

For legacy configs, assume PCT is enabled (conservative).

Also correct REDUCE_RAM KEYPAIR values which were previously using
PCT values unconditionally.

The default alloc test config no longer enables PCT; PCT is tested
via config-variations.

Signed-off-by: Matthias J. Kannwischer <[email protected]>
Add config-variations tests for REDUCE_RAM and REDUCE_RAM + PCT
configurations to ensure allocation constants are validated for
all four configuration variants.

Signed-off-by: Matthias J. Kannwischer <[email protected]>
Remove MLD_MAX_TOTAL_ALLOC and MLD_MAX_TOTAL_ALLOC_{KEYPAIR,SIGN,VERIFY}
constants. These exposed the maximum allocation across all security
levels even in single-level builds, which was confusing. Users should
instead use the explicitly security-level-labeled constants such as
MLD_TOTAL_ALLOC_87_KEYPAIR.

The per-level MLD_TOTAL_ALLOC_{44,65,87}_{KEYPAIR,SIGN,VERIFY} and
aggregate MLD_TOTAL_ALLOC_{44,65,87} constants remain available.

Signed-off-by: Matthias J. Kannwischer <[email protected]>
@mkannwischer mkannwischer merged commit 421e662 into main Jan 12, 2026
337 checks passed
@mkannwischer mkannwischer deleted the mld-alloc-pct branch January 12, 2026 13:23
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.

3 participants