diff --git a/.github/workflows/integration-pavona.yml b/.github/workflows/integration-pavona.yml index f6e06f5714..c0e5cc8383 100644 --- a/.github/workflows/integration-pavona.yml +++ b/.github/workflows/integration-pavona.yml @@ -79,11 +79,15 @@ jobs: echo "=== Patched extensions.bzl ===" cat third_party/mlkem_native/extensions.bzl - - name: Patch functest to only test deterministic API + - name: Apply integration patches run: | cd "$PAVONA_DIR" - # speed-up tests in CI by only running deterministic tests - git apply "$GITHUB_WORKSPACE/integration/pavona/derand-only.patch" + for patch in "$GITHUB_WORKSPACE"/integration/pavona/*.patch; do + if [ -f "$patch" ]; then + echo "Applying $patch" + git apply "$patch" + fi + done - name: Run mlkem functest run: | diff --git a/examples/bring_your_own_fips202/mlkem_native/src/context.h b/examples/bring_your_own_fips202/mlkem_native/src/context.h new file mode 120000 index 0000000000..6dd9732ebe --- /dev/null +++ b/examples/bring_your_own_fips202/mlkem_native/src/context.h @@ -0,0 +1 @@ +../../../../mlkem/src/context.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/context.h b/examples/bring_your_own_fips202_static/mlkem_native/src/context.h new file mode 120000 index 0000000000..6dd9732ebe --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/context.h @@ -0,0 +1 @@ +../../../../mlkem/src/context.h \ No newline at end of file diff --git a/examples/custom_backend/mlkem_native/src/context.h b/examples/custom_backend/mlkem_native/src/context.h new file mode 120000 index 0000000000..6dd9732ebe --- /dev/null +++ b/examples/custom_backend/mlkem_native/src/context.h @@ -0,0 +1 @@ +../../../../mlkem/src/context.h \ No newline at end of file diff --git a/examples/monolithic_build/mlkem_native/src/context.h b/examples/monolithic_build/mlkem_native/src/context.h new file mode 120000 index 0000000000..6dd9732ebe --- /dev/null +++ b/examples/monolithic_build/mlkem_native/src/context.h @@ -0,0 +1 @@ +../../../../mlkem/src/context.h \ No newline at end of file diff --git a/integration/liboqs/ML-KEM-1024_META.yml b/integration/liboqs/ML-KEM-1024_META.yml index c6031253cc..a246a5fdbf 100644 --- a/integration/liboqs/ML-KEM-1024_META.yml +++ b/integration/liboqs/ML-KEM-1024_META.yml @@ -36,11 +36,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM1024_C_dec sources: integration/liboqs/config_c.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc - name: x86_64 version: FIPS203 folder_name: . @@ -52,11 +52,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_dec sources: integration/liboqs/config_x86_64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/x86_64 + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/x86_64 supported_platforms: - architecture: x86_64 operating_systems: @@ -77,11 +77,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_dec sources: integration/liboqs/config_aarch64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/aarch64 + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/aarch64 supported_platforms: - architecture: arm_8 operating_systems: @@ -100,11 +100,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM1024_PPC64LE_dec sources: integration/liboqs/config_ppc64le.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/ppc64le + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/ppc64le supported_platforms: - architecture: ppc64le operating_systems: diff --git a/integration/liboqs/ML-KEM-512_META.yml b/integration/liboqs/ML-KEM-512_META.yml index feb7cc6ff8..580b00320b 100644 --- a/integration/liboqs/ML-KEM-512_META.yml +++ b/integration/liboqs/ML-KEM-512_META.yml @@ -36,11 +36,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM512_C_dec sources: integration/liboqs/config_c.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc - name: x86_64 version: FIPS203 folder_name: . @@ -52,11 +52,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM512_X86_64_dec sources: integration/liboqs/config_x86_64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/x86_64 + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/x86_64 supported_platforms: - architecture: x86_64 operating_systems: @@ -77,11 +77,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_dec sources: integration/liboqs/config_aarch64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/aarch64 + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/aarch64 supported_platforms: - architecture: arm_8 operating_systems: @@ -100,11 +100,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM512_PPC64LE_dec sources: integration/liboqs/config_ppc64le.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/ppc64le + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/ppc64le supported_platforms: - architecture: ppc64le operating_systems: diff --git a/integration/liboqs/ML-KEM-768_META.yml b/integration/liboqs/ML-KEM-768_META.yml index 05f07b42d4..f6fac94537 100644 --- a/integration/liboqs/ML-KEM-768_META.yml +++ b/integration/liboqs/ML-KEM-768_META.yml @@ -36,11 +36,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM768_C_dec sources: integration/liboqs/config_c.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc - name: x86_64 version: FIPS203 folder_name: . @@ -52,11 +52,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM768_X86_64_dec sources: integration/liboqs/config_x86_64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/x86_64 + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/x86_64 supported_platforms: - architecture: x86_64 operating_systems: @@ -77,11 +77,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_dec sources: integration/liboqs/config_aarch64.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/aarch64 + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/aarch64 supported_platforms: - architecture: arm_8 operating_systems: @@ -100,11 +100,11 @@ implementations: signature_dec: PQCP_MLKEM_NATIVE_MLKEM768_PPC64LE_dec sources: integration/liboqs/config_ppc64le.h integration/liboqs/fips202_glue.h integration/liboqs/fips202x4_glue.h mlkem/src/cbmc.h mlkem/src/common.h mlkem/src/compress.c mlkem/src/compress.h - mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h mlkem/src/kem.c - mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h mlkem/src/params.h - mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h mlkem/src/randombytes.h - mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h mlkem/src/sys.h - mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/ppc64le + mlkem/src/context.h mlkem/src/debug.c mlkem/src/debug.h mlkem/src/indcpa.c mlkem/src/indcpa.h + mlkem/src/kem.c mlkem/src/kem.h mlkem/src/native/api.h mlkem/src/native/meta.h + mlkem/src/params.h mlkem/src/poly.c mlkem/src/poly.h mlkem/src/poly_k.c mlkem/src/poly_k.h + mlkem/src/randombytes.h mlkem/src/sampling.c mlkem/src/sampling.h mlkem/src/symmetric.h + mlkem/src/sys.h mlkem/src/verify.c mlkem/src/verify.h mlkem/src/zetas.inc mlkem/src/native/ppc64le supported_platforms: - architecture: ppc64le operating_systems: diff --git a/integration/pavona/add_context.patch b/integration/pavona/add_context.patch new file mode 100644 index 0000000000..97d88d5ea5 --- /dev/null +++ b/integration/pavona/add_context.patch @@ -0,0 +1,13 @@ +# Copyright (c) The mlkem-native project authors +# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT +diff --git a/third_party/mlkem_native/BUILD.mlkem_native.bazel b/third_party/mlkem_native/BUILD.mlkem_native.bazel +--- a/third_party/mlkem_native/BUILD.mlkem_native.bazel ++++ b/third_party/mlkem_native/BUILD.mlkem_native.bazel +@@ -12,6 +12,7 @@ cc_library( + "mlkem/mlkem_native.h", + "mlkem/src/cbmc.h", + "mlkem/src/common.h", ++ "mlkem/src/context.h", + "mlkem/src/randombytes.h", + "mlkem/src/debug.h", + "mlkem/src/debug.c", diff --git a/mlkem/mlkem_native.c b/mlkem/mlkem_native.c index d8b0fd5398..52f8a4bcb8 100644 --- a/mlkem/mlkem_native.c +++ b/mlkem/mlkem_native.c @@ -202,11 +202,6 @@ #undef MLK_COMMON_H #undef MLK_CONCAT #undef MLK_CONCAT_ -#undef MLK_CONTEXT_PARAMETERS_0 -#undef MLK_CONTEXT_PARAMETERS_1 -#undef MLK_CONTEXT_PARAMETERS_2 -#undef MLK_CONTEXT_PARAMETERS_3 -#undef MLK_CONTEXT_PARAMETERS_4 #undef MLK_EMPTY_CU #undef MLK_ERR_FAIL #undef MLK_ERR_OUT_OF_MEMORY @@ -311,6 +306,13 @@ #undef mlk_poly_frommsg #undef mlk_poly_tobytes #undef mlk_poly_tomsg +/* mlkem/src/context.h */ +#undef MLK_CONTEXT_H +#undef MLK_CONTEXT_PARAMETERS_0 +#undef MLK_CONTEXT_PARAMETERS_1 +#undef MLK_CONTEXT_PARAMETERS_2 +#undef MLK_CONTEXT_PARAMETERS_3 +#undef MLK_CONTEXT_PARAMETERS_4 /* mlkem/src/debug.h */ #undef MLK_DEBUG_H #undef mlk_assert diff --git a/mlkem/mlkem_native_asm.S b/mlkem/mlkem_native_asm.S index c2edd2b161..28c56b348b 100644 --- a/mlkem/mlkem_native_asm.S +++ b/mlkem/mlkem_native_asm.S @@ -226,11 +226,6 @@ #undef MLK_COMMON_H #undef MLK_CONCAT #undef MLK_CONCAT_ -#undef MLK_CONTEXT_PARAMETERS_0 -#undef MLK_CONTEXT_PARAMETERS_1 -#undef MLK_CONTEXT_PARAMETERS_2 -#undef MLK_CONTEXT_PARAMETERS_3 -#undef MLK_CONTEXT_PARAMETERS_4 #undef MLK_EMPTY_CU #undef MLK_ERR_FAIL #undef MLK_ERR_OUT_OF_MEMORY @@ -335,6 +330,13 @@ #undef mlk_poly_frommsg #undef mlk_poly_tobytes #undef mlk_poly_tomsg +/* mlkem/src/context.h */ +#undef MLK_CONTEXT_H +#undef MLK_CONTEXT_PARAMETERS_0 +#undef MLK_CONTEXT_PARAMETERS_1 +#undef MLK_CONTEXT_PARAMETERS_2 +#undef MLK_CONTEXT_PARAMETERS_3 +#undef MLK_CONTEXT_PARAMETERS_4 /* mlkem/src/debug.h */ #undef MLK_DEBUG_H #undef mlk_assert diff --git a/mlkem/src/common.h b/mlkem/src/common.h index 463029bde9..05d67bc84f 100644 --- a/mlkem/src/common.h +++ b/mlkem/src/common.h @@ -188,36 +188,11 @@ #error Bad configuration: MLK_CONFIG_CUSTOM_ALLOC_FREE must be set together with MLK_CUSTOM_ALLOC and MLK_CUSTOM_FREE #endif -/* - * If the integration wants to provide a context parameter for use in - * platform-specific hooks, then it should define this parameter. - * - * The MLK_CONTEXT_PARAMETERS_n macros are intended to be used with macros - * defining the function names and expand to either pass or discard the context - * argument as required by the current build. If there is no context parameter - * requested then these are removed from the prototypes and from all calls. - */ -#ifdef MLK_CONFIG_CONTEXT_PARAMETER -#define MLK_CONTEXT_PARAMETERS_0(context) (context) -#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context) -#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context) -#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \ - (arg0, arg1, arg2, context) -#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \ - (arg0, arg1, arg2, arg3, context) -#else /* MLK_CONFIG_CONTEXT_PARAMETER */ -#define MLK_CONTEXT_PARAMETERS_0(context) () -#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0) -#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1) -#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2) -#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \ - (arg0, arg1, arg2, arg3) -#endif /* !MLK_CONFIG_CONTEXT_PARAMETER */ - -#if defined(MLK_CONFIG_CONTEXT_PARAMETER_TYPE) != \ - defined(MLK_CONFIG_CONTEXT_PARAMETER) -#error MLK_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLK_CONFIG_CONTEXT_PARAMETER is defined -#endif +/* Context-parameter machinery (MLK_CONTEXT_PARAMETERS_n and related config + * checks). Kept in a separate, level-generic header for readability; included + * here so it is available to the allocation macros below and to all consumers + * of common.h. */ +#include "context.h" #if !defined(MLK_CONFIG_CUSTOM_ALLOC_FREE) /* Default: stack allocation */ diff --git a/mlkem/src/context.h b/mlkem/src/context.h new file mode 100644 index 0000000000..c51954078a --- /dev/null +++ b/mlkem/src/context.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) The mlkem-native project authors + * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT + */ +#ifndef MLK_CONTEXT_H +#define MLK_CONTEXT_H + +/* This header is included by common.h once the configuration has been pulled + * in; it is not meant to be included directly. */ + +/* + * If the integration wants to provide a context parameter for use in + * platform-specific hooks, then it should define this parameter. + * + * The MLK_CONTEXT_PARAMETERS_n macros are intended to be used with macros + * defining the function names and expand to either pass or discard the context + * argument as required by the current build. If there is no context parameter + * requested then these are removed from the prototypes and from all calls. + */ +#ifdef MLK_CONFIG_CONTEXT_PARAMETER +#define MLK_CONTEXT_PARAMETERS_0(context) (context) +#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context) +#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context) +#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \ + (arg0, arg1, arg2, context) +#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \ + (arg0, arg1, arg2, arg3, context) +#else /* MLK_CONFIG_CONTEXT_PARAMETER */ +#define MLK_CONTEXT_PARAMETERS_0(context) () +#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0) +#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1) +#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2) +#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \ + (arg0, arg1, arg2, arg3) +#endif /* !MLK_CONFIG_CONTEXT_PARAMETER */ + +#if defined(MLK_CONFIG_CONTEXT_PARAMETER_TYPE) != \ + defined(MLK_CONFIG_CONTEXT_PARAMETER) +#error MLK_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLK_CONFIG_CONTEXT_PARAMETER is defined +#endif + +#endif /* !MLK_CONTEXT_H */ diff --git a/scripts/autogen b/scripts/autogen index d2ebfadc6f..ab7ed79002 100755 --- a/scripts/autogen +++ b/scripts/autogen @@ -2967,7 +2967,11 @@ def check_macro_typos(): if is_autogen or filename == "integration/awslc/awslc.patch": return True - if is_autogen or filename == "mlkem/src/common.h": + if ( + is_autogen + or filename == "mlkem/src/common.h" + or filename == "mlkem/src/context.h" + ): if m == "MLK_CONTEXT_PARAMETERS_n": return True