Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ jobs:
- name: multilevel_build_native
run: |
CFLAGS="-O0" make run -C examples/multilevel_build_native
- name: multilevel_build_no_stdlib
run: |
CFLAGS="-O0" make run -C examples/multilevel_build_no_stdlib
simpasm:
strategy:
fail-fast: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cbmc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
id-token: 'write'
uses: ./.github/workflows/ci_ec2_reusable.yml
with:
name: CBMC (MLKEM-512)
name: CBMC (ML-KEM-512)
ec2_instance_type: c7g.4xlarge
ec2_ami: ubuntu-latest (custom AMI)
ec2_ami_id: ami-08ddb0acd99dc3d33 # aarch64, ubuntu-latest, 64g
Expand All @@ -38,7 +38,7 @@ jobs:
id-token: 'write'
uses: ./.github/workflows/ci_ec2_reusable.yml
with:
name: CBMC (MLKEM-768)
name: CBMC (ML-KEM-768)
ec2_instance_type: c7g.4xlarge
ec2_ami: ubuntu-latest (custom AMI)
ec2_ami_id: ami-08ddb0acd99dc3d33 # aarch64, ubuntu-latest, 64g
Expand All @@ -60,7 +60,7 @@ jobs:
id-token: 'write'
uses: ./.github/workflows/ci_ec2_reusable.yml
with:
name: CBMC (MLKEM-1024)
name: CBMC (ML-KEM-1024)
ec2_instance_type: c7g.4xlarge
ec2_ami: ubuntu-latest (custom AMI)
ec2_ami_id: ami-08ddb0acd99dc3d33 # aarch64, ubuntu-latest, 64g
Expand Down
1 change: 1 addition & 0 deletions BIBLIOGRAPHY.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ source code and documentation.
* URL: https://csrc.nist.gov/projects/cryptographic-module-validation-program/fips-140-3-ig-announcements
* Referenced from:
- [examples/basic_deterministic/mlkem_native/custom_no_randomized_config.h](examples/basic_deterministic/mlkem_native/custom_no_randomized_config.h)
- [examples/multilevel_build_no_stdlib/mlkem_native/example_no_stdlib_config.h](examples/multilevel_build_no_stdlib/mlkem_native/example_no_stdlib_config.h)
- [integration/liboqs/config_aarch64.h](integration/liboqs/config_aarch64.h)
- [integration/liboqs/config_c.h](integration/liboqs/config_c.h)
- [integration/liboqs/config_x86_64.h](integration/liboqs/config_x86_64.h)
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,4 @@ clean:
-make clean -C examples/monolithic_build_multilevel_native >/dev/null
-make clean -C examples/multilevel_build >/dev/null
-make clean -C examples/multilevel_build_native >/dev/null
-make clean -C examples/multilevel_build_no_stdlib > /dev/null
5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ See [basic_deterministic](basic_deterministic) for a basic example of how to bui
See [multilevel_build](multilevel_build) for an example of how to build one instance of mlkem-native per security level,
in such a way that level-independent code is shared.

## Multi-level build without the standard library (C only)

See multilevel_build_no_stdlib for an example of how to build one instance of mlkem-native per security level without the standard library.
In this example, `mlk_memcpy` and `mlk_memset` are replaced with custom implementations through [custom_no_stdlib_config.h](../test/custom_stdlib_config.h).

## Multi-level build (with native code)

See [multilevel_build_native](multilevel_build_native) for an example of how to build one instance of mlkem-native per
Expand Down
8 changes: 4 additions & 4 deletions examples/monolithic_build_multilevel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ by `MLK_CONFIG_PARAMETER_SET`) every time.
```

Note the setting `MLK_CONFIG_MULTILEVEL_WITH_SHARED` which forces the inclusion of all level-independent
code in the MLKEM-512 build, and the setting `MLK_CONFIG_MULTILEVEL_NO_SHARED`, which drops all
code in the ML-KEM-512 build, and the setting `MLK_CONFIG_MULTILEVEL_NO_SHARED`, which drops all
level-independent code in the subsequent builds. Finally, `MLK_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS` entails that
`mlkem_native.c` does not `#undefine` the `#define` clauses from level-independent files.

Expand All @@ -54,23 +54,23 @@ would lead to name-clashes upon multiple use.
```C
#define MLK_CONFIG_API_NO_SUPERCOP

/* API for MLKEM-512 */
/* API for ML-KEM-512 */
#define MLK_CONFIG_API_PARAMETER_SET 512
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem512
#include <mlkem_native.h>
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-768 */
/* API for ML-KEM-768 */
#define MLK_CONFIG_API_PARAMETER_SET 768
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem768
#include <mlkem_native.h>
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-1024 */
/* API for ML-KEM-1024 */
#define MLK_CONFIG_API_PARAMETER_SET 1024
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem1024
#include <mlkem_native.h>
Expand Down
6 changes: 3 additions & 3 deletions examples/monolithic_build_multilevel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int test_keys_mlkem512(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-512] OK\n");
printf("[ML-KEM-512] OK\n");
return 0;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ static int test_keys_mlkem768(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-768] OK\n");
printf("[ML-KEM-768] OK\n");
return 0;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ static int test_keys_mlkem1024(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-1024] OK\n");
printf("[ML-KEM-1024] OK\n");
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/monolithic_build_multilevel/mlkem_native_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@

#define MLK_CONFIG_API_NO_SUPERCOP

/* API for MLKEM-512 */
/* API for ML-KEM-512 */
#define MLK_CONFIG_API_PARAMETER_SET 512
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem512
#include <mlkem_native.h>
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-768 */
/* API for ML-KEM-768 */
#define MLK_CONFIG_API_PARAMETER_SET 768
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem768
#include <mlkem_native.h>
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-1024 */
/* API for ML-KEM-1024 */
#define MLK_CONFIG_API_PARAMETER_SET 1024
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem1024
#include <mlkem_native.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/monolithic_build_multilevel_native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ appropriately first, and then includes the monobuild:
```

Note the setting `MLK_CONFIG_MULTILEVEL_WITH_SHARED` which forces the inclusion of all level-independent
code in the MLKEM-512 build, and the setting `MLK_CONFIG_MULTILEVEL_NO_SHARED`, which drops all
code in the ML-KEM-512 build, and the setting `MLK_CONFIG_MULTILEVEL_NO_SHARED`, which drops all
level-independent code in the subsequent builds. Finally, `MLK_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS` entails that
[mlkem_native.c](mlkem/mlkem_native.c) does not `#undefine` the `#define` clauses from level-independent files.

Expand Down
6 changes: 3 additions & 3 deletions examples/monolithic_build_multilevel_native/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int test_keys_mlkem512(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-512] OK\n");
printf("[ML-KEM-512] OK\n");
return 0;
}

Expand Down Expand Up @@ -132,7 +132,7 @@ static int test_keys_mlkem768(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-768] OK\n");
printf("[ML-KEM-768] OK\n");
return 0;
}

Expand Down Expand Up @@ -188,7 +188,7 @@ static int test_keys_mlkem1024(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-1024] OK\n");
printf("[ML-KEM-1024] OK\n");
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/multilevel_build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ CFLAGS := \
-Wno-unknown-pragmas \
-Wno-unused-command-line-argument \
-fomit-frame-pointer \
-DMLK_CONFIG_NAMESPACE_PREFIX=mlkem \
-DMLK_CONFIG_NAMESPACE_PREFIX=mlkem \
-std=c99 \
-pedantic \
-MMD \
Expand Down
6 changes: 3 additions & 3 deletions examples/multilevel_build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# Multi-level build

This directory contains a minimal example for how to build mlkem-native with support for all 3 security levels
MLKEM-512, MLKEM-768, and MLKEM-1024, and so that level-independent code is shared. In this example, only the C-backend
ML-KEM-512, ML-KEM-768, and ML-KEM-1024, and so that level-independent code is shared. In this example, only the C-backend
of mlkem-native is used.

The library is built 3 times in different build directories `build/mlkem{512,768,1024}`. For the MLKEM-512 build, we set
The library is built 3 times in different build directories `build/mlkem{512,768,1024}`. For the ML-KEM-512 build, we set
`MLK_CONFIG_MULTILEVEL_WITH_SHARED` to force the inclusion of all level-independent code in the
MLKEM512-build. For MLKEM-768 and MLKEM-1024, we set `MLK_CONFIG_MULTILEVEL_NO_SHARED` to not include any
MLKEM512-build. For ML-KEM-768 and ML-KEM-1024, we set `MLK_CONFIG_MULTILEVEL_NO_SHARED` to not include any
level-independent code. Finally, we use the common namespace prefix `mlkem` as `MLK_CONFIG_NAMESPACE_PREFIX` for all three
builds; the suffix 512/768/1024 will be added to level-dependent functions automatically.

Expand Down
6 changes: 3 additions & 3 deletions examples/multilevel_build/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int test_keys_mlkem512(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-512] OK\n");
printf("[ML-KEM-512] OK\n");
return 0;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ static int test_keys_mlkem768(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-768] OK\n");
printf("[ML-KEM-768] OK\n");
return 0;
}

Expand Down Expand Up @@ -183,7 +183,7 @@ static int test_keys_mlkem1024(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-1024] OK\n");
printf("[ML-KEM-1024] OK\n");
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/multilevel_build/mlkem_native_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
#if !defined(MLK_ALL_H)
#define MLK_ALL_H

/* API for MLKEM-512 */
/* API for ML-KEM-512 */
#define MLK_CONFIG_API_PARAMETER_SET 512
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem512
#include "mlkem_native/mlkem/mlkem_native.h"
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-768 */
/* API for ML-KEM-768 */
#define MLK_CONFIG_API_PARAMETER_SET 768
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem768
#include "mlkem_native/mlkem/mlkem_native.h"
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-1024 */
/* API for ML-KEM-1024 */
#define MLK_CONFIG_API_PARAMETER_SET 1024
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem1024
#include "mlkem_native/mlkem/mlkem_native.h"
Expand Down
6 changes: 3 additions & 3 deletions examples/multilevel_build_native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Multi-level build

This directory contains a minimal example for how to build mlkem-native with support for all 3 security levels
MLKEM-512, MLKEM-768, and MLKEM-1024. All level-independent code is shared, and native backends are in use.
ML-KEM-512, ML-KEM-768, and ML-KEM-1024. All level-independent code is shared, and native backends are in use.

The library is built 3 times in different build directories `build/mlkem{512,768,1024}`. For the MLKEM-512 build, we set
The library is built 3 times in different build directories `build/mlkem{512,768,1024}`. For the ML-KEM-512 build, we set
`MLK_CONFIG_MULTILEVEL_WITH_SHARED` to force the inclusion of all level-independent code in the
MLKEM512-build. For MLKEM-768 and MLKEM-1024, we set `MLK_CONFIG_MULTILEVEL_NO_SHARED` to not include any
MLKEM512-build. For ML-KEM-768 and ML-KEM-1024, we set `MLK_CONFIG_MULTILEVEL_NO_SHARED` to not include any
level-independent code. Finally, we use the common namespace prefix `mlkem` as `MLK_CONFIG_NAMESPACE_PREFIX` for all three
builds; the suffix 512/768/1024 will be added to level-dependent functions automatically.

Expand Down
6 changes: 3 additions & 3 deletions examples/multilevel_build_native/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int test_keys_mlkem512(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-512] OK\n");
printf("[ML-KEM-512] OK\n");
return 0;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ static int test_keys_mlkem768(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-768] OK\n");
printf("[ML-KEM-768] OK\n");
return 0;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ static int test_keys_mlkem1024(void)
"[WARNING] Skipping KAT test since PCT is enabled and modifies PRNG\n");
#endif

printf("[MLKEM-1024] OK\n");
printf("[ML-KEM-1024] OK\n");
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/multilevel_build_native/mlkem_native_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
#if !defined(MLK_ALL_H)
#define MLK_ALL_H

/* API for MLKEM-512 */
/* API for ML-KEM-512 */
#define MLK_CONFIG_API_PARAMETER_SET 512
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem512
#include "mlkem_native/mlkem/mlkem_native.h"
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-768 */
/* API for ML-KEM-768 */
#define MLK_CONFIG_API_PARAMETER_SET 768
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem768
#include "mlkem_native/mlkem/mlkem_native.h"
#undef MLK_CONFIG_API_PARAMETER_SET
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
#undef MLK_H

/* API for MLKEM-1024 */
/* API for ML-KEM-1024 */
#define MLK_CONFIG_API_PARAMETER_SET 1024
#define MLK_CONFIG_API_NAMESPACE_PREFIX mlkem1024
#include "mlkem_native/mlkem/mlkem_native.h"
Expand Down
3 changes: 3 additions & 0 deletions examples/multilevel_build_no_stdlib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT

build
Loading
Loading