-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce global config and reorganize backends
This commit introduces a global configuration file `mlkem/config.h` which should contain all user-configurable parameters. With this commit, it contains: - MLKEM_K - MLKEM_NAMESPACE - FIPS202_NAMESPACE - MLKEM_USE_NATIVE - MLKEM_NATIVE_ARITH_BACKEND - MLKEM_NATIVE_FIPS202_BACKEND The backends have been reorganized to follow a simpler file structure: Every backend profile is identified by metadata file in the toplevel directory of the backend. For example, `aarch64` has `opt.h` and `clean.h`. Those metadata files so far only set the name of the backend, and point to the actual implementation. The reason why the metadata file and the implementation are kept separate is so that assembly files can include the metadata file and know if they should be assembled: For example, `aarch64/opt.h` sets `MLKEM_NATIVE_ARITH_BACKEND_AARCH64_OPT` which all relevant files are guarded by; similar for clean. Previously, they were all guarded more coarsely by `MLKEM_USE_NATIVE_AARCH64` or `MLKEM_USE_NATIVE_X86_64` -- those have been removed. The source code of the backends has been moved into `src` directories. Ultimately, we may want to split `aarch64` into `aarch64_opt` and `aarch64_clean`, so the distinction between profile and backend goes away, but this is not yet attempted. Signed-off-by: Hanno Becker <[email protected]>
- Loading branch information
1 parent
668dbab
commit 67de1dc
Showing
104 changed files
with
689 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
examples/bring_your_own_fips202/custom_fips202/namespace.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2024 The mlkem-native project authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifdef MLKEM_NATIVE_FIPS202_IMPL_H | ||
#error Only one FIPS202 assembly profile can be defined -- did you include multiple profiles? | ||
#else | ||
#define MLKEM_NATIVE_FIPS202_IMPL_H | ||
|
||
/* Include to enforce consistency of API and implementation */ | ||
#include "native/api.h" | ||
|
||
#if defined(MLKEM_NATIVE_FIPS202_BACKEND_IMPL) | ||
#include MLKEM_NATIVE_FIPS202_BACKEND_IMPL | ||
#endif | ||
|
||
#endif /* MLKEM_NATIVE_FIPS202_IMPL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024 The mlkem-native project authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* FIPS202 assembly profile targeting Cortex-A55 */ | ||
|
||
#ifdef FIPS202_NATIVE_PROFILE_H | ||
#error Only one FIPS202 assembly profile can be defined -- did you include multiple profiles? | ||
#else | ||
#define FIPS202_NATIVE_PROFILE_H | ||
|
||
/* Identifier for this backend so that source and assembly files | ||
* in the build can be appropriately guarded. */ | ||
#define MLKEM_NATIVE_FIPS202_BACKEND_AARCH64_A55 | ||
|
||
#define MLKEM_NATIVE_FIPS202_BACKEND_NAME AARCH64_A55 | ||
|
||
/* Filename of the C backend implementation. | ||
* This is not inlined here because this header is included in assembly | ||
* files as well. */ | ||
#define MLKEM_NATIVE_FIPS202_BACKEND_IMPL "aarch64/src/cortex_a55_impl.h" | ||
|
||
#endif /* FIPS202_NATIVE_PROFILE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024 The mlkem-native project authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* Default FIPS202 assembly profile for AArch64 systems */ | ||
|
||
#ifdef FIPS202_NATIVE_PROFILE_H | ||
#error Only one FIPS202 assembly profile can be defined -- did you include multiple profiles? | ||
#else | ||
#define FIPS202_NATIVE_PROFILE_H | ||
|
||
/* Identifier for this backend so that source and assembly files | ||
* in the build can be appropriately guarded. */ | ||
#define MLKEM_NATIVE_FIPS202_BACKEND_AARCH64_DEFAULT | ||
|
||
#define MLKEM_NATIVE_FIPS202_BACKEND_NAME AARCH64_DEFAULT | ||
|
||
/* Filename of the C backend implementation. | ||
* This is not inlined here because this header is included in assembly | ||
* files as well. */ | ||
#define MLKEM_NATIVE_FIPS202_BACKEND_IMPL "aarch64/src/default_impl.h" | ||
|
||
#endif /* FIPS202_NATIVE_PROFILE_H */ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,12 @@ | |
// Author: Hanno Becker <[email protected]> | ||
// Author: Matthias Kannwischer <[email protected]> | ||
|
||
#include "config.h" | ||
#if defined(MLKEM_USE_NATIVE_AARCH64) | ||
#include "common.h" | ||
#if defined(MLKEM_NATIVE_FIPS202_BACKEND_AARCH64_DEFAULT) || \ | ||
defined(MLKEM_NATIVE_FIPS202_BACKEND_AARCH64_A55) | ||
|
||
// Needed to provide ASM_LOAD directive | ||
#include "common.i" | ||
#include "namespace.h" | ||
|
||
/********************** CONSTANTS *************************/ | ||
.data | ||
|
@@ -457,4 +457,5 @@ initial: | |
free_stack | ||
ret | ||
|
||
#endif /* MLKEM_USE_NATIVE_AARCH64 */ | ||
#endif /* defined(MLKEM_NATIVE_FIPS202_BACKEND_AARCH64_DEFAULT) || | ||
defined(MLKEM_NATIVE_FIPS202_BACKEND_AARCH64_A55) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.