Skip to content

Commit c12e6fb

Browse files
committed
Simplify configurations in multilevel example
The configurations in the multilevel-build example are the same except for MLKEM_K, which can be modified by #define before inclusion of the respective monobuild CU. This commit simplifies the multilevel-monobuild example accordingly. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent 10ee5b5 commit c12e6fb

5 files changed

Lines changed: 15 additions & 262 deletions

File tree

examples/monolithic_build_multilevel/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ files. Moreover, it clears all `#define`s clauses set by mlkem-native at the end
1010
inclusion in another compilation unit.
1111

1212
The manually written source file [mlkem_native_all.c](mlkem_native_all.c) includes
13-
[mlkem_native_monobuild.c](mlkem_native_monobuild.c) three times, once for each of the three configuration files
14-
[config_512.h](config_512.h), [config_768.h](config_768.h),
15-
[config_1024.h](config_1024.h) for the different levels. For each inclusion, it sets `MLKEM_NATIVE_CONFIG_FILE`
13+
[mlkem_native_monobuild.c](mlkem_native_monobuild.c) three times, each time using the fixed config
14+
[multilevel_config.h](multilevel_config.h), but changing the security level (specified
15+
by `MLKEM_K`) every time. For each inclusion, it sets `MLKEM_NATIVE_CONFIG_FILE`
1616
appropriately first, and then includes the monobuild:
1717
```C
1818
/* Three instances of mlkem-native for all security levels */
@@ -21,19 +21,22 @@ appropriately first, and then includes the monobuild:
2121
#define MLKEM_NATIVE_MULTILEVEL_BUILD_WITH_SHARED
2222
#define MLKEM_NATIVE_MONOBUILD_KEEP_SHARED_HEADERS
2323

24-
#define MLKEM_NATIVE_CONFIG_FILE "config_512.h"
24+
#define MLKEM_K 2
25+
#define MLKEM_NATIVE_CONFIG_FILE "multilevel_config.h"
2526
#include "mlkem_native_monobuild.c"
2627
#undef MLKEM_NATIVE_CONFIG_FILE
2728

2829
/* Exclude level-independent code */
2930
#undef MLKEM_NATIVE_MULTILEVEL_BUILD_WITH_SHARED
3031
#define MLKEM_NATIVE_MULTILEVEL_BUILD_NO_SHARED
3132

32-
#define MLKEM_NATIVE_CONFIG_FILE "config_1024.h"
33+
#define MLKEM_K 3
34+
#define MLKEM_NATIVE_CONFIG_FILE "multilevel_config.h"
3335
#include "mlkem_native_monobuild.c"
3436
#undef MLKEM_NATIVE_CONFIG_FILE
3537

36-
#define MLKEM_NATIVE_CONFIG_FILE "config_768.h"
38+
#define MLKEM_K 4
39+
#define MLKEM_NATIVE_CONFIG_FILE "multilevel_config.h"
3740
#undef MLKEM_NATIVE_MONOBUILD_KEEP_SHARED_HEADERS
3841
#include "mlkem_native_monobuild.c"
3942
#undef MLKEM_NATIVE_CONFIG_FILE

examples/monolithic_build_multilevel/config_1024.h

Lines changed: 0 additions & 118 deletions
This file was deleted.

examples/monolithic_build_multilevel/config_512.h

Lines changed: 0 additions & 135 deletions
This file was deleted.

examples/monolithic_build_multilevel/mlkem_native_all.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111
#define MLKEM_NATIVE_MULTILEVEL_BUILD_WITH_SHARED
1212
#define MLKEM_NATIVE_MONOBUILD_KEEP_SHARED_HEADERS
1313

14-
#define MLKEM_NATIVE_CONFIG_FILE "config_512.h"
14+
#define MLKEM_K 2
15+
#define MLKEM_NATIVE_CONFIG_FILE "multilevel_config.h"
1516
#include "mlkem_native_monobuild.c"
1617
#undef MLKEM_NATIVE_CONFIG_FILE
1718

1819
/* Exclude level-independent code */
1920
#undef MLKEM_NATIVE_MULTILEVEL_BUILD_WITH_SHARED
2021
#define MLKEM_NATIVE_MULTILEVEL_BUILD_NO_SHARED
2122

22-
#define MLKEM_NATIVE_CONFIG_FILE "config_1024.h"
23+
#define MLKEM_K 3
24+
#define MLKEM_NATIVE_CONFIG_FILE "multilevel_config.h"
2325
#include "mlkem_native_monobuild.c"
2426
#undef MLKEM_NATIVE_CONFIG_FILE
2527

26-
#define MLKEM_NATIVE_CONFIG_FILE "config_768.h"
28+
#define MLKEM_K 4
29+
#define MLKEM_NATIVE_CONFIG_FILE "multilevel_config.h"
2730
#undef MLKEM_NATIVE_MONOBUILD_KEEP_SHARED_HEADERS
2831
#include "mlkem_native_monobuild.c"
2932
#undef MLKEM_NATIVE_CONFIG_FILE
File renamed without changes.

0 commit comments

Comments
 (0)