diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 6f94f73ba..60c482347 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -233,6 +233,9 @@ jobs: - name: bring_your_own_fips202 run: | CFLAGS="-O0" make run -C examples/bring_your_own_fips202 + - name: bring_your_own_fips202_static + run: | + CFLAGS="-O0" make run -C examples/bring_your_own_fips202_static - name: custom_backend run: | CFLAGS="-O0" make run -C examples/custom_backend diff --git a/BIBLIOGRAPHY.md b/BIBLIOGRAPHY.md index ff02ecbbd..dbacd17e1 100644 --- a/BIBLIOGRAPHY.md +++ b/BIBLIOGRAPHY.md @@ -337,6 +337,8 @@ source code and documentation. - [README.md](README.md) - [examples/bring_your_own_fips202/README.md](examples/bring_your_own_fips202/README.md) - [examples/bring_your_own_fips202/custom_fips202/README.md](examples/bring_your_own_fips202/custom_fips202/README.md) + - [examples/bring_your_own_fips202_static/README.md](examples/bring_your_own_fips202_static/README.md) + - [examples/bring_your_own_fips202_static/custom_fips202/README.md](examples/bring_your_own_fips202_static/custom_fips202/README.md) - [examples/custom_backend/README.md](examples/custom_backend/README.md) ### `tweetfips` diff --git a/Makefile b/Makefile index bec1a9c9f..7df386e80 100644 --- a/Makefile +++ b/Makefile @@ -227,6 +227,7 @@ clean: -$(RM) -rf *.gcno *.gcda *.lcov *.o *.so -$(RM) -rf $(BUILD_DIR) -make clean -C examples/bring_your_own_fips202 >/dev/null + -make clean -C examples/bring_your_own_fips202_static >/dev/null -make clean -C examples/custom_backend >/dev/null -make clean -C examples/basic >/dev/null -make clean -C examples/basic_deterministic >/dev/null diff --git a/examples/README.md b/examples/README.md index 65957ebc3..4e571220f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -26,6 +26,12 @@ security level, in such a way that level-independent code is shared, and leverag See [bring_your_own_fips202](bring_your_own_fips202) for an example of how to use mlkem-native with your own FIPS-202 implementation. +## Custom FIPS202 implementation (static state variant) + +See [bring_your_own_fips202_static](bring_your_own_fips202_static) for an example of how to use mlkem-native with a +custom FIPS-202 implementation using a static state. This variant demonstrates the serial-only FIPS-202 configuration +(`MLK_CONFIG_SERIAL_FIPS202_ONLY`). + ## Custom config + custom FIPS-202 backend See [custom_backend](custom_backend) for an example of how to use mlkem-native with a custom configuration file and a diff --git a/examples/bring_your_own_fips202_static/Makefile b/examples/bring_your_own_fips202_static/Makefile new file mode 100644 index 000000000..5eed2f5fa --- /dev/null +++ b/examples/bring_your_own_fips202_static/Makefile @@ -0,0 +1,115 @@ +# (SPDX-License-Identifier: CC-BY-4.0) + +.PHONY: build run clean size +.DEFAULT_GOAL := all + +# Append cross-prefix for cross compilation +# Remove or ignore for native builds +CC ?= gcc +SIZE ?= size +# When called from the root Makefile, CROSS_PREFIX has already been added here +ifeq (,$(findstring $(CROSS_PREFIX),$(CC))) +CC := $(CROSS_PREFIX)$(CC) +endif + +ifeq (,$(findstring $(CROSS_PREFIX),$(SIZE))) +SIZE := $(CROSS_PREFIX)$(SIZE) +endif + +# Part A: +# +# mlkem-native source and header files +MLK_SOURCE=$(wildcard \ + mlkem_native/src/*.c \ + mlkem_native/src/**/*.c \ + mlkem_native/src/**/**/*.c \ + mlkem_native/src/**/**/**/*.c) + +INC=-Imlkem_native/src/ -Imlkem_native/ + +# Part B: +# +# Custom FIPS-202 implementation +# +# At present, this must be located in a directory named "fips202". +# This limitation will be lifted in the future. +FIPS202_SOURCE=custom_fips202/tiny_sha3/sha3.c + +# Part C: +# +# Random number generator +# +# !!! WARNING !!! +# +# The randombytes() implementation used here is for TESTING ONLY. +# You MUST NOT use this implementation outside of testing. +# +# !!! WARNING !!! +RNG_SOURCE=$(wildcard test_only_rng/*.c) + +# Part D: +# +# Your application source code +APP_SOURCE=$(wildcard *.c) + +ALL_SOURCE=$(MLK_SOURCE) $(FIPS202_SOURCE) $(RNG_SOURCE) $(APP_SOURCE) + +BUILD_DIR=build +BIN=test_binary + +CFLAGS := \ + -Wall \ + -Wextra \ + -Werror \ + -Wmissing-prototypes \ + -Wshadow \ + -Wpointer-arith \ + -Wredundant-decls \ + -Wconversion \ + -Wno-long-long \ + -Wno-unknown-pragmas \ + -Wno-unused-command-line-argument \ + -fomit-frame-pointer \ + -std=c99 \ + -pedantic \ + -MMD \ + -O3 \ + $(CFLAGS) +CFLAGS += -DMLK_CONFIG_FIPS202_CUSTOM_HEADER="\"../custom_fips202/fips202.h\"" +CFLAGS += -DMLK_CONFIG_FIPS202X4_CUSTOM_HEADER="\"../custom_fips202/fips202x4.h\"" +CFLAGS += -DMLK_CONFIG_NAMESPACE_PREFIX=mlkem +CFLAGS += -DMLK_CONFIG_SERIAL_FIPS202_ONLY + +BINARY_NAME_FULL_512=$(BUILD_DIR)/$(BIN)512 +BINARY_NAME_FULL_768=$(BUILD_DIR)/$(BIN)768 +BINARY_NAME_FULL_1024=$(BUILD_DIR)/$(BIN)1024 +BINARIES_FULL=$(BINARY_NAME_FULL_512) $(BINARY_NAME_FULL_768) $(BINARY_NAME_FULL_1024) + +$(BINARY_NAME_FULL_512): CFLAGS += -DMLK_CONFIG_PARAMETER_SET=512 +$(BINARY_NAME_FULL_768): CFLAGS += -DMLK_CONFIG_PARAMETER_SET=768 +$(BINARY_NAME_FULL_1024): CFLAGS += -DMLK_CONFIG_PARAMETER_SET=1024 + +$(BINARIES_FULL): $(ALL_SOURCE) + echo "$@" + mkdir -p $(BUILD_DIR) + $(CC) $(CFLAGS) $(INC) $^ -o $@ + +all: build size + +build: $(BINARIES_FULL) + +run: $(BINARIES_FULL) + $(EXEC_WRAPPER) ./$(BINARY_NAME_FULL_512) + $(EXEC_WRAPPER) ./$(BINARY_NAME_FULL_768) + $(EXEC_WRAPPER) ./$(BINARY_NAME_FULL_1024) + +size: build + @echo "=== Size info for binaries $(BINARY_NAME_FULL_512) ===" + @$(SIZE) $(BINARY_NAME_FULL_512) + @echo "=== Size info for binaries $(BINARY_NAME_FULL_768) ===" + @$(SIZE) $(BINARY_NAME_FULL_768) + @echo "=== Size info for binaries $(BINARY_NAME_FULL_1024) ===" + @$(SIZE) $(BINARY_NAME_FULL_1024) + +clean: + rm -rf $(BUILD_DIR) diff --git a/examples/bring_your_own_fips202_static/README.md b/examples/bring_your_own_fips202_static/README.md new file mode 100644 index 000000000..ae25924ec --- /dev/null +++ b/examples/bring_your_own_fips202_static/README.md @@ -0,0 +1,28 @@ +[//]: # (SPDX-License-Identifier: CC-BY-4.0) + +# Bring your own FIPS-202 (Static State Variant) + +This directory contains a minimal example for how to use mlkem-native with external FIPS202 +HW/SW-implementations that use a single global state (for example, some hardware accelerators). +Specifically, this example demonstrates the use of the serial-only FIPS-202 configuration +`MLK_CONFIG_SERIAL_FIPS202_ONLY`. + +## Components + +An application using mlkem-native with a custom FIPS-202 implementation needs the following: + +1. Arithmetic part of the mlkem-native source tree: [`mlkem/src/`](../../mlkem/src) +2. A secure pseudo random number generator, implementing [`randombytes.h`](../../mlkem/src/randombytes.h). +2. A custom FIPS202 with `fips202.h` header compatible with [`mlkem/src/fips202/fips202.h`](../../mlkem/src/fips202/fips202.h). + The FIPS202x4 header `fips202x4.h` can is unused with `MLK_CONFIG_SERIAL_FIPS202_ONLY` and can be filled with stubs. +3. The application source code + +**WARNING:** The `randombytes()` implementation used here is for TESTING ONLY. You MUST NOT use this implementation +outside of testing. + +## Usage + +Build this example with `make build`, run with `make run`. + + +[^tiny_sha3]: Markku-Juhani O. Saarinen: tiny_sha3, [https://github.com/mjosaarinen/tiny_sha3](https://github.com/mjosaarinen/tiny_sha3) diff --git a/examples/bring_your_own_fips202_static/custom_fips202/README.md b/examples/bring_your_own_fips202_static/custom_fips202/README.md new file mode 100644 index 000000000..d843d4ff8 --- /dev/null +++ b/examples/bring_your_own_fips202_static/custom_fips202/README.md @@ -0,0 +1,12 @@ +[//]: # (SPDX-License-Identifier: CC-BY-4.0) + +# Custom FIPS-202 with Static State + +This directory contains a copy of tiny_sha3 [^tiny_sha3], but wrapped so that is operates on a single global state only. + +This illustrates and tests the configuration option `MLK_CONFIG_SERIAL_FIPS202_ONLY` which should be used +when interfacing with an external FIPS202 implementation -- for example, a hardware accelerator -- that has only +a single global state. + + +[^tiny_sha3]: Markku-Juhani O. Saarinen: tiny_sha3, [https://github.com/mjosaarinen/tiny_sha3](https://github.com/mjosaarinen/tiny_sha3) diff --git a/examples/bring_your_own_fips202_static/custom_fips202/fips202.h b/examples/bring_your_own_fips202_static/custom_fips202/fips202.h new file mode 100644 index 000000000..e9e044560 --- /dev/null +++ b/examples/bring_your_own_fips202_static/custom_fips202/fips202.h @@ -0,0 +1,170 @@ +/* + * Copyright (c) The mlkem-native project authors + * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT + */ + +/* + * This is a shim establishing the FIPS-202 API required by mlkem-native + * from the API exposed by tiny_sha3, using a static state. + */ + +#ifndef FIPS202_H +#define FIPS202_H + +#include + +#include "common.h" +#include "tiny_sha3/sha3.h" +typedef enum +{ + FIPS202_STATE_ABSORBING = 1, + FIPS202_STATE_SQUEEZING = 2, + FIPS202_STATE_RESET = 3 +} fips202_state_t; + +#define SHAKE128_RATE 168 +#define SHAKE256_RATE 136 +#define SHA3_256_RATE 136 +#define SHA3_384_RATE 104 +#define SHA3_512_RATE 72 + +/* Static state for serial FIPS202 */ +static struct +{ + fips202_state_t state; + sha3_ctx_t ctx; +} static_shake128_state = {FIPS202_STATE_RESET, {{{0}}, 0, 0, 0}}; + +/* Dummy context type - the actual state is static */ +typedef struct +{ + int dummy; +} mlk_shake128ctx; + +static MLK_INLINE void mlk_shake128_init(mlk_shake128ctx *state) +{ + (void)state; + assert(static_shake128_state.state == FIPS202_STATE_RESET); + shake128_init(&static_shake128_state.ctx); + static_shake128_state.state = FIPS202_STATE_ABSORBING; +} + +#define mlk_shake128_absorb_once MLK_NAMESPACE(shake128_absorb_once) +/************************************************* + * Name: mlk_shake128_absorb_once + * + * Description: Absorb step of the SHAKE128 XOF. + * + * Arguments: - mlk_shake128ctx *state: pointer to zeroized output Keccak + * state + * - const uint8_t *input: pointer to input to be absorbed into + * state + * - size_t inlen: length of input in bytes + **************************************************/ +static MLK_INLINE void mlk_shake128_absorb_once(mlk_shake128ctx *state, + const uint8_t *input, + size_t inlen) +{ + (void)state; + assert(static_shake128_state.state == FIPS202_STATE_ABSORBING); + shake_update(&static_shake128_state.ctx, input, inlen); + shake_xof(&static_shake128_state.ctx); + static_shake128_state.state = FIPS202_STATE_SQUEEZING; +} + +/* Squeeze output out of the sponge. + * + * Supports being called multiple times + */ +#define mlk_shake128_squeezeblocks MLK_NAMESPACE(shake128_squeezeblocks) +/************************************************* + * Name: mlk_shake128_squeezeblocks + * + * Description: Squeeze step of SHAKE128 XOF. Squeezes full blocks of + * SHAKE128_RATE bytes each. Modifies the state. Can be called + * multiple times to keep squeezing, i.e., is incremental. + * + * Arguments: - uint8_t *output: pointer to output blocks + * - size_t nblocks: number of blocks to be squeezed (written + * to output) + * - mlk_shake128ctx *state: pointer to in/output Keccak state + **************************************************/ +static MLK_INLINE void mlk_shake128_squeezeblocks(uint8_t *output, + size_t nblocks, + mlk_shake128ctx *state) +{ + (void)state; + assert(static_shake128_state.state == FIPS202_STATE_SQUEEZING); + shake_out(&static_shake128_state.ctx, output, nblocks * SHAKE128_RATE); +} + +/* Free the state */ +#define mlk_shake128_release MLK_NAMESPACE(shake128_release) +static MLK_INLINE void mlk_shake128_release(mlk_shake128ctx *state) +{ + (void)state; + static_shake128_state.state = FIPS202_STATE_RESET; +} + +/* One-stop SHAKE256 call. Aliasing between input and + * output is not permitted */ +#define mlk_shake256 MLK_NAMESPACE(shake256) +/************************************************* + * Name: mlk_shake256 + * + * Description: SHAKE256 XOF with non-incremental API + * + * Arguments: - uint8_t *output: pointer to output + * - size_t outlen: requested output length in bytes + * - const uint8_t *input: pointer to input + * - size_t inlen: length of input in bytes + **************************************************/ +static MLK_INLINE void mlk_shake256(uint8_t *output, size_t outlen, + const uint8_t *input, size_t inlen) +{ + sha3_ctx_t c; + shake256_init(&c); + shake_update(&c, input, inlen); + shake_xof(&c); + shake_out(&c, output, outlen); +} + +/* One-stop SHA3_256 call. Aliasing between input and + * output is not permitted */ +#define SHA3_256_HASHBYTES 32 +#define mlk_sha3_256 MLK_NAMESPACE(sha3_256) +/************************************************* + * Name: mlk_sha3_256 + * + * Description: SHA3-256 with non-incremental API + * + * Arguments: - uint8_t *output: pointer to output + * - const uint8_t *input: pointer to input + * - size_t inlen: length of input in bytes + **************************************************/ +static MLK_INLINE void mlk_sha3_256(uint8_t *output, const uint8_t *input, + size_t inlen) +{ + (void)sha3(input, inlen, output, SHA3_256_HASHBYTES); +} + +/* One-stop SHA3_512 call. Aliasing between input and + * output is not permitted */ +#define SHA3_512_HASHBYTES 64 +#define mlk_sha3_512 MLK_NAMESPACE(sha3_512) +/************************************************* + * Name: mlk_sha3_512 + * + * Description: SHA3-512 with non-incremental API + * + * Arguments: - uint8_t *output: pointer to output + * - const uint8_t *input: pointer to input + * - size_t inlen: length of input in bytes + **************************************************/ +static MLK_INLINE void mlk_sha3_512(uint8_t *output, const uint8_t *input, + size_t inlen) +{ + (void)sha3(input, inlen, output, SHA3_512_HASHBYTES); +} + +#endif /* !FIPS202_H */ diff --git a/examples/bring_your_own_fips202_static/custom_fips202/fips202x4.h b/examples/bring_your_own_fips202_static/custom_fips202/fips202x4.h new file mode 100644 index 000000000..e0678d126 --- /dev/null +++ b/examples/bring_your_own_fips202_static/custom_fips202/fips202x4.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) The mlkem-native project authors + * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT + */ + +#ifndef FIPS_202X4_H +#define FIPS_202X4_H + +#include + +#include "fips202.h" + +/* + * The incremental batched APIs are not required for this example since + * we build with MLK_CONFIG_SERIAL_FIPS202_ONLY. We still need the one-shot + * batched API, but it just falls back to the unbatched API. + */ + +#define mlk_shake256x4 MLK_NAMESPACE(shake256x4) +static MLK_INLINE void mlk_shake256x4(uint8_t *out0, uint8_t *out1, + uint8_t *out2, uint8_t *out3, + size_t outlen, uint8_t *in0, uint8_t *in1, + uint8_t *in2, uint8_t *in3, size_t inlen) +{ + mlk_shake256(out0, outlen, in0, inlen); + mlk_shake256(out1, outlen, in1, inlen); + mlk_shake256(out2, outlen, in2, inlen); + mlk_shake256(out3, outlen, in3, inlen); +} + +#endif /* !FIPS_202X4_H */ diff --git a/examples/bring_your_own_fips202_static/custom_fips202/tiny_sha3 b/examples/bring_your_own_fips202_static/custom_fips202/tiny_sha3 new file mode 120000 index 000000000..f59919ab1 --- /dev/null +++ b/examples/bring_your_own_fips202_static/custom_fips202/tiny_sha3 @@ -0,0 +1 @@ +../../bring_your_own_fips202/custom_fips202/tiny_sha3 \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/main.c b/examples/bring_your_own_fips202_static/main.c new file mode 100644 index 000000000..9c3795256 --- /dev/null +++ b/examples/bring_your_own_fips202_static/main.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) The mlkem-native project authors + * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT + */ + +#include +#include + +/* Import public mlkem-native API + * + * This requires specifying the parameter set and namespace prefix + * used for the build. + */ +#define MLK_CONFIG_API_PARAMETER_SET MLK_CONFIG_PARAMETER_SET +#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem +#include + +#include "test_only_rng/notrandombytes.h" + +#define CHECK(x) \ + do \ + { \ + int rc; \ + rc = (x); \ + if (!rc) \ + { \ + fprintf(stderr, "ERROR (%s,%d)\n", __FILE__, __LINE__); \ + return 1; \ + } \ + } while (0) + +int main(void) +{ + uint8_t pk[CRYPTO_PUBLICKEYBYTES]; + uint8_t sk[CRYPTO_SECRETKEYBYTES]; + uint8_t ct[CRYPTO_CIPHERTEXTBYTES]; + uint8_t key_a[CRYPTO_BYTES]; + uint8_t key_b[CRYPTO_BYTES]; + + /* The PCT modifies the PRNG state, so the KAT tests don't work. + * We run KAT tests only for disabled PCT. */ +#if !defined(MLK_CONFIG_KEYGEN_PCT) +#if MLK_CONFIG_PARAMETER_SET == 512 + const uint8_t expected_key[] = { + 0x77, 0x6c, 0x74, 0xdf, 0x30, 0x1f, 0x8d, 0x82, 0x52, 0x5e, 0x8e, + 0xbb, 0xb4, 0x00, 0x95, 0xcd, 0x2e, 0x92, 0xdf, 0x6d, 0xc9, 0x33, + 0xe7, 0x86, 0x62, 0x59, 0xf5, 0x31, 0xc7, 0x35, 0x0a, 0xd5}; +#elif MLK_CONFIG_PARAMETER_SET == 768 + const uint8_t expected_key[] = { + 0xe9, 0x13, 0x77, 0x84, 0x0e, 0x6b, 0x66, 0x94, 0xea, 0xa9, 0xf0, + 0x1c, 0x97, 0xff, 0x68, 0x87, 0x4e, 0x8b, 0x0c, 0x52, 0x0b, 0x00, + 0xc2, 0xcd, 0xe3, 0x7c, 0x4f, 0xc2, 0x39, 0x62, 0x6e, 0x70}; +#elif MLK_CONFIG_PARAMETER_SET == 1024 + const uint8_t expected_key[] = { + 0x5d, 0x9e, 0x23, 0x5f, 0xcc, 0xb2, 0xb3, 0x49, 0x9a, 0x5f, 0x49, + 0x0a, 0x56, 0xe3, 0xf0, 0xd3, 0xfd, 0x9b, 0x58, 0xbd, 0xa2, 0x8b, + 0x69, 0x0f, 0x91, 0xb5, 0x7b, 0x88, 0xa5, 0xa8, 0x0b, 0x90}; +#endif /* MLK_CONFIG_PARAMETER_SET == 1024 */ +#endif /* !MLK_CONFIG_KEYGEN_PCT */ + + /* WARNING: Test-only + * Normally, you would want to seed a PRNG with trustworthy entropy here. */ + randombytes_reset(); + + printf("Generating keypair ... "); + + /* Alice generates a public key */ + CHECK(crypto_kem_keypair(pk, sk) == 0); + + printf("DONE\n"); + printf("Encaps... "); + + /* Bob derives a secret key and creates a response */ + CHECK(crypto_kem_enc(ct, key_b, pk) == 0); + + printf("DONE\n"); + printf("Decaps... "); + + /* Alice uses Bobs response to get her shared key */ + CHECK(crypto_kem_dec(key_a, ct, sk) == 0); + + printf("DONE\n"); + printf("Compare... "); + + if (memcmp(key_a, key_b, CRYPTO_BYTES)) + { + printf("ERROR: Mismatching keys\n"); + return 1; + } + + printf("Shared secret: "); + { + size_t i; + for (i = 0; i < sizeof(key_a); i++) + { + printf("%02x", key_a[i]); + } + } + printf("\n"); + +#if !defined(MLK_CONFIG_KEYGEN_PCT) + /* Check against hardcoded result to make sure that + * we integrated custom FIPS202 correctly */ + CHECK(memcmp(key_a, expected_key, sizeof(key_a)) == 0); +#else + printf( + "[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n"); +#endif + + printf("OK\n"); + + return 0; +} diff --git a/examples/bring_your_own_fips202_static/mlkem_native/mlkem_native.h b/examples/bring_your_own_fips202_static/mlkem_native/mlkem_native.h new file mode 120000 index 000000000..dd32c33bb --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/mlkem_native.h @@ -0,0 +1 @@ +../../../mlkem/mlkem_native.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/cbmc.h b/examples/bring_your_own_fips202_static/mlkem_native/src/cbmc.h new file mode 120000 index 000000000..ceb4b4328 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/cbmc.h @@ -0,0 +1 @@ +../../../../mlkem/src/cbmc.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/common.h b/examples/bring_your_own_fips202_static/mlkem_native/src/common.h new file mode 120000 index 000000000..b91b8da93 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/common.h @@ -0,0 +1 @@ +../../../../mlkem/src/common.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/compress.c b/examples/bring_your_own_fips202_static/mlkem_native/src/compress.c new file mode 120000 index 000000000..7a268bba4 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/compress.c @@ -0,0 +1 @@ +../../../../mlkem/src/compress.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/compress.h b/examples/bring_your_own_fips202_static/mlkem_native/src/compress.h new file mode 120000 index 000000000..bbdf7a8d0 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/compress.h @@ -0,0 +1 @@ +../../../../mlkem/src/compress.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/config.h b/examples/bring_your_own_fips202_static/mlkem_native/src/config.h new file mode 120000 index 000000000..565d9cd74 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/config.h @@ -0,0 +1 @@ +../../../../mlkem/src/config.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/debug.c b/examples/bring_your_own_fips202_static/mlkem_native/src/debug.c new file mode 120000 index 000000000..92b15d453 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/debug.c @@ -0,0 +1 @@ +../../../../mlkem/src/debug.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/debug.h b/examples/bring_your_own_fips202_static/mlkem_native/src/debug.h new file mode 120000 index 000000000..3e25c792f --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/debug.h @@ -0,0 +1 @@ +../../../../mlkem/src/debug.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/indcpa.c b/examples/bring_your_own_fips202_static/mlkem_native/src/indcpa.c new file mode 120000 index 000000000..2a2fd88ba --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/indcpa.c @@ -0,0 +1 @@ +../../../../mlkem/src/indcpa.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/indcpa.h b/examples/bring_your_own_fips202_static/mlkem_native/src/indcpa.h new file mode 120000 index 000000000..a32974db4 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/indcpa.h @@ -0,0 +1 @@ +../../../../mlkem/src/indcpa.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/kem.c b/examples/bring_your_own_fips202_static/mlkem_native/src/kem.c new file mode 120000 index 000000000..89d895756 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/kem.c @@ -0,0 +1 @@ +../../../../mlkem/src/kem.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/kem.h b/examples/bring_your_own_fips202_static/mlkem_native/src/kem.h new file mode 120000 index 000000000..76983fdde --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/kem.h @@ -0,0 +1 @@ +../../../../mlkem/src/kem.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/native b/examples/bring_your_own_fips202_static/mlkem_native/src/native new file mode 120000 index 000000000..5083e395c --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/native @@ -0,0 +1 @@ +../../../../mlkem/src/native \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/params.h b/examples/bring_your_own_fips202_static/mlkem_native/src/params.h new file mode 120000 index 000000000..28e1dccb3 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/params.h @@ -0,0 +1 @@ +../../../../mlkem/src/params.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/poly.c b/examples/bring_your_own_fips202_static/mlkem_native/src/poly.c new file mode 120000 index 000000000..acdfae407 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/poly.c @@ -0,0 +1 @@ +../../../../mlkem/src/poly.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/poly.h b/examples/bring_your_own_fips202_static/mlkem_native/src/poly.h new file mode 120000 index 000000000..befaf0b27 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/poly.h @@ -0,0 +1 @@ +../../../../mlkem/src/poly.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/poly_k.c b/examples/bring_your_own_fips202_static/mlkem_native/src/poly_k.c new file mode 120000 index 000000000..0ed1ffb5c --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/poly_k.c @@ -0,0 +1 @@ +../../../../mlkem/src/poly_k.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/poly_k.h b/examples/bring_your_own_fips202_static/mlkem_native/src/poly_k.h new file mode 120000 index 000000000..9af042866 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/poly_k.h @@ -0,0 +1 @@ +../../../../mlkem/src/poly_k.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/randombytes.h b/examples/bring_your_own_fips202_static/mlkem_native/src/randombytes.h new file mode 120000 index 000000000..bf94296ea --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/randombytes.h @@ -0,0 +1 @@ +../../../../mlkem/src/randombytes.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/sampling.c b/examples/bring_your_own_fips202_static/mlkem_native/src/sampling.c new file mode 120000 index 000000000..d913314bb --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/sampling.c @@ -0,0 +1 @@ +../../../../mlkem/src/sampling.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/sampling.h b/examples/bring_your_own_fips202_static/mlkem_native/src/sampling.h new file mode 120000 index 000000000..fe3dc77fb --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/sampling.h @@ -0,0 +1 @@ +../../../../mlkem/src/sampling.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/symmetric.h b/examples/bring_your_own_fips202_static/mlkem_native/src/symmetric.h new file mode 120000 index 000000000..a4f831f0a --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/symmetric.h @@ -0,0 +1 @@ +../../../../mlkem/src/symmetric.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/sys.h b/examples/bring_your_own_fips202_static/mlkem_native/src/sys.h new file mode 120000 index 000000000..91ac039c0 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/sys.h @@ -0,0 +1 @@ +../../../../mlkem/src/sys.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/verify.c b/examples/bring_your_own_fips202_static/mlkem_native/src/verify.c new file mode 120000 index 000000000..fc6244bbc --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/verify.c @@ -0,0 +1 @@ +../../../../mlkem/src/verify.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/verify.h b/examples/bring_your_own_fips202_static/mlkem_native/src/verify.h new file mode 120000 index 000000000..a389b96c3 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/verify.h @@ -0,0 +1 @@ +../../../../mlkem/src/verify.h \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/mlkem_native/src/zetas.inc b/examples/bring_your_own_fips202_static/mlkem_native/src/zetas.inc new file mode 120000 index 000000000..264046488 --- /dev/null +++ b/examples/bring_your_own_fips202_static/mlkem_native/src/zetas.inc @@ -0,0 +1 @@ +../../../../mlkem/src/zetas.inc \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/test_only_rng/notrandombytes.c b/examples/bring_your_own_fips202_static/test_only_rng/notrandombytes.c new file mode 120000 index 000000000..65b7801b8 --- /dev/null +++ b/examples/bring_your_own_fips202_static/test_only_rng/notrandombytes.c @@ -0,0 +1 @@ +../../../test/notrandombytes/notrandombytes.c \ No newline at end of file diff --git a/examples/bring_your_own_fips202_static/test_only_rng/notrandombytes.h b/examples/bring_your_own_fips202_static/test_only_rng/notrandombytes.h new file mode 120000 index 000000000..e72c12b9c --- /dev/null +++ b/examples/bring_your_own_fips202_static/test_only_rng/notrandombytes.h @@ -0,0 +1 @@ +../../../test/notrandombytes/notrandombytes.h \ No newline at end of file diff --git a/scripts/tests b/scripts/tests index e6362a65c..710aaade6 100755 --- a/scripts/tests +++ b/scripts/tests @@ -198,6 +198,7 @@ class TEST_TYPES(Enum): BENCH_COMPONENTS = 4 ACVP = 5 BRING_YOUR_OWN_FIPS202 = 6 + BRING_YOUR_OWN_FIPS202_STATIC = 19 CUSTOM_BACKEND = 7 BASIC = 8 MONOLITHIC_BUILD = 9 @@ -221,6 +222,7 @@ class TEST_TYPES(Enum): def examples(): return [ TEST_TYPES.BRING_YOUR_OWN_FIPS202, + TEST_TYPES.BRING_YOUR_OWN_FIPS202_STATIC, TEST_TYPES.CUSTOM_BACKEND, TEST_TYPES.BASIC, TEST_TYPES.MONOLITHIC_BUILD, @@ -259,6 +261,8 @@ class TEST_TYPES(Enum): return "Stack Usage Test" if self == TEST_TYPES.BRING_YOUR_OWN_FIPS202: return "Example (Bring-Your-Own-FIPS202)" + if self == TEST_TYPES.BRING_YOUR_OWN_FIPS202_STATIC: + return "Example (Bring-Your-Own-FIPS202, static)" if self == TEST_TYPES.CUSTOM_BACKEND: return "Example (Custom Backend)" if self == TEST_TYPES.BASIC: @@ -285,6 +289,8 @@ class TEST_TYPES(Enum): def make_dir(self): if self == TEST_TYPES.BRING_YOUR_OWN_FIPS202: return "examples/bring_your_own_fips202" + if self == TEST_TYPES.BRING_YOUR_OWN_FIPS202_STATIC: + return "examples/bring_your_own_fips202_static" if self == TEST_TYPES.CUSTOM_BACKEND: return "examples/custom_backend" if self == TEST_TYPES.BASIC: @@ -320,6 +326,8 @@ class TEST_TYPES(Enum): return "stack" if self == TEST_TYPES.BRING_YOUR_OWN_FIPS202: return "" + if self == TEST_TYPES.BRING_YOUR_OWN_FIPS202_STATIC: + return "" if self == TEST_TYPES.CUSTOM_BACKEND: return "" if self == TEST_TYPES.BASIC: @@ -1117,6 +1125,7 @@ def cli(): help="Exclude specific examples from running (can be used multiple times)", choices=[ "bring_your_own_fips202", + "bring_your_own_fips202_static", "custom_backend", "basic", "basic_deterministic", @@ -1166,6 +1175,7 @@ def cli(): help="Explicitly list the examples to run; can be called multiple times", choices=[ "bring_your_own_fips202", + "bring_your_own_fips202_static", "custom_backend", "basic", "basic_deterministic",