Skip to content

Commit cb51844

Browse files
committed
common: Split context-parameter machinery into context.h
Move the MLD_CONTEXT_PARAMETERS_n macros and the associated configuration check out of common.h into a new, level-generic header context.h, included by common.h at the point the material previously sat. No behavioral change. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent 2fbc340 commit cb51844

12 files changed

Lines changed: 178 additions & 137 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../mldsa/src/context.h
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../mldsa/src/context.h
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../mldsa/src/context.h

integration/liboqs/ML-DSA-44_META.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ implementations:
3232
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA44_C_verify_extmu
3333
api-with-context-string: true
3434
sources: integration/liboqs/config_c.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
35-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
36-
mldsa/src/debug.h mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c
37-
mldsa/src/poly.h mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
38-
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
39-
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
40-
mldsa/src/zetas.inc
35+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
36+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h
37+
mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c
38+
mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h
39+
mldsa/src/reduce.h mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h
40+
mldsa/src/sys.h mldsa/src/zetas.inc
4141
- name: x86_64
4242
version: FIPS204
4343
folder_name: .
@@ -49,13 +49,13 @@ implementations:
4949
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA44_X86_64_verify_extmu
5050
api-with-context-string: true
5151
sources: integration/liboqs/config_x86_64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
52-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
53-
mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h mldsa/src/packing.c
54-
mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c
55-
mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c
56-
mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h mldsa/src/rounding.h
57-
mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h mldsa/src/zetas.inc
58-
mldsa/src/native/x86_64
52+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
53+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h
54+
mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h
55+
mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
56+
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
57+
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
58+
mldsa/src/zetas.inc mldsa/src/native/x86_64
5959
supported_platforms:
6060
- architecture: x86_64
6161
operating_systems:
@@ -76,13 +76,13 @@ implementations:
7676
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA44_AARCH64_verify_extmu
7777
api-with-context-string: true
7878
sources: integration/liboqs/config_aarch64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
79-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
80-
mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h mldsa/src/packing.c
81-
mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c
82-
mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c
83-
mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h mldsa/src/rounding.h
84-
mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h mldsa/src/zetas.inc
85-
mldsa/src/native/aarch64
79+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
80+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h
81+
mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h
82+
mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
83+
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
84+
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
85+
mldsa/src/zetas.inc mldsa/src/native/aarch64
8686
supported_platforms:
8787
- architecture: arm_8
8888
operating_systems:

integration/liboqs/ML-DSA-65_META.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ implementations:
3232
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA65_C_verify_extmu
3333
api-with-context-string: true
3434
sources: integration/liboqs/config_c.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
35-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
36-
mldsa/src/debug.h mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c
37-
mldsa/src/poly.h mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
38-
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
39-
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
40-
mldsa/src/zetas.inc
35+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
36+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h
37+
mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c
38+
mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h
39+
mldsa/src/reduce.h mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h
40+
mldsa/src/sys.h mldsa/src/zetas.inc
4141
- name: x86_64
4242
version: FIPS204
4343
folder_name: .
@@ -49,13 +49,13 @@ implementations:
4949
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA65_X86_64_verify_extmu
5050
api-with-context-string: true
5151
sources: integration/liboqs/config_x86_64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
52-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
53-
mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h mldsa/src/packing.c
54-
mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c
55-
mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c
56-
mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h mldsa/src/rounding.h
57-
mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h mldsa/src/zetas.inc
58-
mldsa/src/native/x86_64
52+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
53+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h
54+
mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h
55+
mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
56+
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
57+
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
58+
mldsa/src/zetas.inc mldsa/src/native/x86_64
5959
supported_platforms:
6060
- architecture: x86_64
6161
operating_systems:
@@ -76,13 +76,13 @@ implementations:
7676
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA65_AARCH64_verify_extmu
7777
api-with-context-string: true
7878
sources: integration/liboqs/config_aarch64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
79-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
80-
mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h mldsa/src/packing.c
81-
mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c
82-
mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c
83-
mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h mldsa/src/rounding.h
84-
mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h mldsa/src/zetas.inc
85-
mldsa/src/native/aarch64
79+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
80+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h
81+
mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h
82+
mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
83+
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
84+
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
85+
mldsa/src/zetas.inc mldsa/src/native/aarch64
8686
supported_platforms:
8787
- architecture: arm_8
8888
operating_systems:

integration/liboqs/ML-DSA-87_META.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ implementations:
3232
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA87_C_verify_extmu
3333
api-with-context-string: true
3434
sources: integration/liboqs/config_c.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
35-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
36-
mldsa/src/debug.h mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c
37-
mldsa/src/poly.h mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
38-
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
39-
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
40-
mldsa/src/zetas.inc
35+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
36+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h
37+
mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c
38+
mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h
39+
mldsa/src/reduce.h mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h
40+
mldsa/src/sys.h mldsa/src/zetas.inc
4141
- name: x86_64
4242
version: FIPS204
4343
folder_name: .
@@ -49,13 +49,13 @@ implementations:
4949
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA87_X86_64_verify_extmu
5050
api-with-context-string: true
5151
sources: integration/liboqs/config_x86_64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
52-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
53-
mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h mldsa/src/packing.c
54-
mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c
55-
mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c
56-
mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h mldsa/src/rounding.h
57-
mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h mldsa/src/zetas.inc
58-
mldsa/src/native/x86_64
52+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
53+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h
54+
mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h
55+
mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
56+
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
57+
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
58+
mldsa/src/zetas.inc mldsa/src/native/x86_64
5959
supported_platforms:
6060
- architecture: x86_64
6161
operating_systems:
@@ -76,13 +76,13 @@ implementations:
7676
signature_verify_extmu: PQCP_MLDSA_NATIVE_MLDSA87_AARCH64_verify_extmu
7777
api-with-context-string: true
7878
sources: integration/liboqs/config_aarch64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h
79-
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/ct.c mldsa/src/ct.h mldsa/src/debug.c
80-
mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h mldsa/src/packing.c
81-
mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h mldsa/src/poly_kl.c
82-
mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h mldsa/src/polyvec_lazy.c
83-
mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h mldsa/src/rounding.h
84-
mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h mldsa/src/zetas.inc
85-
mldsa/src/native/aarch64
79+
mldsa/src/cbmc.h mldsa/src/common.h mldsa/src/context.h mldsa/src/ct.c mldsa/src/ct.h
80+
mldsa/src/debug.c mldsa/src/debug.h mldsa/src/native/api.h mldsa/src/native/meta.h
81+
mldsa/src/packing.c mldsa/src/packing.h mldsa/src/params.h mldsa/src/poly.c mldsa/src/poly.h
82+
mldsa/src/poly_kl.c mldsa/src/poly_kl.h mldsa/src/polyvec.c mldsa/src/polyvec.h
83+
mldsa/src/polyvec_lazy.c mldsa/src/polyvec_lazy.h mldsa/src/randombytes.h mldsa/src/reduce.h
84+
mldsa/src/rounding.h mldsa/src/sign.c mldsa/src/sign.h mldsa/src/symmetric.h mldsa/src/sys.h
85+
mldsa/src/zetas.inc mldsa/src/native/aarch64
8686
supported_platforms:
8787
- architecture: arm_8
8888
operating_systems:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) The mldsa-native project authors
2+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3+
diff --git a/third_party/mldsa_native/BUILD.mldsa_native.bazel b/third_party/mldsa_native/BUILD.mldsa_native.bazel
4+
--- a/third_party/mldsa_native/BUILD.mldsa_native.bazel
5+
+++ b/third_party/mldsa_native/BUILD.mldsa_native.bazel
6+
@@ -12,6 +12,7 @@ cc_library(
7+
"mldsa/mldsa_native.h",
8+
"mldsa/src/cbmc.h",
9+
"mldsa/src/common.h",
10+
+ "mldsa/src/context.h",
11+
"mldsa/src/randombytes.h",
12+
"mldsa/src/debug.h",
13+
"mldsa/src/debug.c",

mldsa/mldsa_native.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,6 @@
227227
#undef MLD_COMMON_H
228228
#undef MLD_CONCAT
229229
#undef MLD_CONCAT_
230-
#undef MLD_CONTEXT_PARAMETERS_0
231-
#undef MLD_CONTEXT_PARAMETERS_1
232-
#undef MLD_CONTEXT_PARAMETERS_2
233-
#undef MLD_CONTEXT_PARAMETERS_3
234-
#undef MLD_CONTEXT_PARAMETERS_4
235-
#undef MLD_CONTEXT_PARAMETERS_5
236-
#undef MLD_CONTEXT_PARAMETERS_6
237-
#undef MLD_CONTEXT_PARAMETERS_7
238-
#undef MLD_CONTEXT_PARAMETERS_8
239-
#undef MLD_CONTEXT_PARAMETERS_9
240230
#undef MLD_EMPTY_CU
241231
#undef MLD_ERR_FAIL
242232
#undef MLD_ERR_OUT_OF_MEMORY
@@ -454,6 +444,18 @@
454444
/*
455445
* Undefine macros from MLD_CONFIG_PARAMETER_SET-generic files
456446
*/
447+
/* mldsa/src/context.h */
448+
#undef MLD_CONTEXT_H
449+
#undef MLD_CONTEXT_PARAMETERS_0
450+
#undef MLD_CONTEXT_PARAMETERS_1
451+
#undef MLD_CONTEXT_PARAMETERS_2
452+
#undef MLD_CONTEXT_PARAMETERS_3
453+
#undef MLD_CONTEXT_PARAMETERS_4
454+
#undef MLD_CONTEXT_PARAMETERS_5
455+
#undef MLD_CONTEXT_PARAMETERS_6
456+
#undef MLD_CONTEXT_PARAMETERS_7
457+
#undef MLD_CONTEXT_PARAMETERS_8
458+
#undef MLD_CONTEXT_PARAMETERS_9
457459
/* mldsa/src/ct.h */
458460
#undef MLD_CT_H
459461
#undef MLD_USE_ASM_VALUE_BARRIER

mldsa/mldsa_native_asm.S

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,6 @@
240240
#undef MLD_COMMON_H
241241
#undef MLD_CONCAT
242242
#undef MLD_CONCAT_
243-
#undef MLD_CONTEXT_PARAMETERS_0
244-
#undef MLD_CONTEXT_PARAMETERS_1
245-
#undef MLD_CONTEXT_PARAMETERS_2
246-
#undef MLD_CONTEXT_PARAMETERS_3
247-
#undef MLD_CONTEXT_PARAMETERS_4
248-
#undef MLD_CONTEXT_PARAMETERS_5
249-
#undef MLD_CONTEXT_PARAMETERS_6
250-
#undef MLD_CONTEXT_PARAMETERS_7
251-
#undef MLD_CONTEXT_PARAMETERS_8
252-
#undef MLD_CONTEXT_PARAMETERS_9
253243
#undef MLD_EMPTY_CU
254244
#undef MLD_ERR_FAIL
255245
#undef MLD_ERR_OUT_OF_MEMORY
@@ -467,6 +457,18 @@
467457
/*
468458
* Undefine macros from MLD_CONFIG_PARAMETER_SET-generic files
469459
*/
460+
/* mldsa/src/context.h */
461+
#undef MLD_CONTEXT_H
462+
#undef MLD_CONTEXT_PARAMETERS_0
463+
#undef MLD_CONTEXT_PARAMETERS_1
464+
#undef MLD_CONTEXT_PARAMETERS_2
465+
#undef MLD_CONTEXT_PARAMETERS_3
466+
#undef MLD_CONTEXT_PARAMETERS_4
467+
#undef MLD_CONTEXT_PARAMETERS_5
468+
#undef MLD_CONTEXT_PARAMETERS_6
469+
#undef MLD_CONTEXT_PARAMETERS_7
470+
#undef MLD_CONTEXT_PARAMETERS_8
471+
#undef MLD_CONTEXT_PARAMETERS_9
470472
/* mldsa/src/ct.h */
471473
#undef MLD_CT_H
472474
#undef MLD_USE_ASM_VALUE_BARRIER

mldsa/src/common.h

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -202,62 +202,11 @@
202202
#error Bad configuration: MLD_CONFIG_CUSTOM_ALLOC_FREE must be set together with MLD_CUSTOM_ALLOC and MLD_CUSTOM_FREE
203203
#endif
204204

205-
/*
206-
* If the integration wants to provide a context parameter for use in
207-
* platform-specific hooks, then it should define this parameter.
208-
*
209-
* The MLD_CONTEXT_PARAMETERS_n macros are intended to be used with macros
210-
* defining the function names and expand to either pass or discard the context
211-
* argument as required by the current build. If there is no context parameter
212-
* requested then these are removed from the prototypes and from all calls.
213-
*/
214-
#ifdef MLD_CONFIG_CONTEXT_PARAMETER
215-
#define MLD_CONTEXT_PARAMETERS_0(context) (context)
216-
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
217-
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
218-
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
219-
(arg0, arg1, arg2, context)
220-
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
221-
(arg0, arg1, arg2, arg3, context)
222-
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
223-
(arg0, arg1, arg2, arg3, arg4, context)
224-
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
225-
(arg0, arg1, arg2, arg3, arg4, arg5, context)
226-
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
227-
context) \
228-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, context)
229-
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
230-
arg7, context) \
231-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, context)
232-
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
233-
arg7, arg8, context) \
234-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, context)
235-
#else /* MLD_CONFIG_CONTEXT_PARAMETER */
236-
#define MLD_CONTEXT_PARAMETERS_0(context) ()
237-
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
238-
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
239-
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
240-
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
241-
(arg0, arg1, arg2, arg3)
242-
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
243-
(arg0, arg1, arg2, arg3, arg4)
244-
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
245-
(arg0, arg1, arg2, arg3, arg4, arg5)
246-
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
247-
context) \
248-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
249-
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
250-
arg7, context) \
251-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
252-
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
253-
arg7, arg8, context) \
254-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
255-
#endif /* !MLD_CONFIG_CONTEXT_PARAMETER */
256-
257-
#if defined(MLD_CONFIG_CONTEXT_PARAMETER_TYPE) != \
258-
defined(MLD_CONFIG_CONTEXT_PARAMETER)
259-
#error MLD_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLD_CONFIG_CONTEXT_PARAMETER is defined
260-
#endif
205+
/* Context-parameter machinery (MLD_CONTEXT_PARAMETERS_n and related config
206+
* checks). Kept in a separate, level-generic header for readability; included
207+
* here so it is available to the allocation macros below and to all consumers
208+
* of common.h. */
209+
#include "context.h"
261210

262211
#if !defined(MLD_CONFIG_CUSTOM_ALLOC_FREE)
263212
/* Default: stack allocation */

0 commit comments

Comments
 (0)