-
Notifications
You must be signed in to change notification settings - Fork 656
Add ML-KEM composite KEM #5686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
falko-strenzke
wants to merge
21
commits into
randombit:master
Choose a base branch
from
falko-strenzke:falko/mlkem-composite
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,215
−11
Open
Add ML-KEM composite KEM #5686
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
857679b
add parsing of ECC group from ECC parameters
falko-strenzke 8a7a5f7
MLKEM composite
falko-strenzke 0ca8217
revert the addition of RNG into ctor of KEM encryptor
falko-strenzke 3a8ed09
add cert-based KAT tests
falko-strenzke 87a4d4d
add missing const
falko-strenzke bf5563f
apply most suggestions from reneme
falko-strenzke de8dfe5
Update src/lib/pubkey/mlkem-composite/mlkem_comp_parameters.cpp
falko-strenzke 4af337f
fix the new check-supported
falko-strenzke 72df8ae
fix some CI errors
falko-strenzke 601eff7
fix algo api name in doc
falko-strenzke c70ab2c
fix some CI failures
falko-strenzke 47f957f
fix some CI failures
falko-strenzke 0497b56
fix MSVC array compile problem
falko-strenzke f7354a0
fix CI compilation error and add mlkem-comp to bsi policy
falko-strenzke ba9621f
fix bugs found by claude
falko-strenzke 0e3f203
fix conditional compilation issue
falko-strenzke d7b8f38
fix conditional compilation error
falko-strenzke a9bda13
fix conditional compilation
falko-strenzke 068b98c
fixed for case of empty parameters for MSVC
falko-strenzke 41f94cf
fix code formatting
falko-strenzke e9ae2d2
add python tests
falko-strenzke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ rsa | |
| ecies | ||
| dh | ||
| ecdh | ||
| mlkem-composite | ||
|
|
||
| # Allowed KDF for ECIES (see 2.3.4) | ||
| kdf1_iso18033 | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -79,6 +79,10 @@ | |||||||||
| #include <botan/ml_kem.h> | ||||||||||
| #endif | ||||||||||
|
|
||||||||||
| #if defined(BOTAN_HAS_MLKEM_COMPOSITE) | ||||||||||
| #include <botan/mlkem_comp.h> | ||||||||||
| #endif | ||||||||||
|
|
||||||||||
| #if defined(BOTAN_HAS_FRODOKEM) | ||||||||||
| #include <botan/frodokem.h> | ||||||||||
| #endif | ||||||||||
|
|
@@ -1348,6 +1352,63 @@ int botan_pubkey_load_ml_kem(botan_pubkey_t* key, const uint8_t pubkey[], size_t | |||||||||
| #endif | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /* | ||||||||||
| * Algorithm specific key operations: MLKEM-Composite | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| int botan_privkey_load_mlkem_composite(botan_privkey_t* key, | ||||||||||
| const uint8_t privkey[], | ||||||||||
| size_t key_len, | ||||||||||
| const char* mlkem_composite_algo) { | ||||||||||
| #if defined(BOTAN_HAS_MLKEM_COMPOSITE) | ||||||||||
| if(key == nullptr || privkey == nullptr || mlkem_composite_algo == nullptr) { | ||||||||||
| return BOTAN_FFI_ERROR_NULL_POINTER; | ||||||||||
| } | ||||||||||
| *key = nullptr; | ||||||||||
|
|
||||||||||
| return ffi_guard_thunk(__func__, [=]() -> int { | ||||||||||
| auto param = Botan::MLKEM_Composite_Param::from_id_str(mlkem_composite_algo); | ||||||||||
| if(!param.has_value()) { | ||||||||||
| return BOTAN_FFI_ERROR_BAD_PARAMETER; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| auto mlkem_composite_key = | ||||||||||
| std::make_unique<Botan::MLKEM_Composite_PrivateKey>(param.value().id(), std::span{privkey, key_len}); | ||||||||||
| return ffi_new_object(key, std::move(mlkem_composite_key)); | ||||||||||
| }); | ||||||||||
| #else | ||||||||||
| BOTAN_UNUSED(key, key_len, privkey, mlkem_composite_algo); | ||||||||||
| return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; | ||||||||||
| #endif | ||||||||||
| } | ||||||||||
|
|
||||||||||
| int botan_pubkey_load_mlkem_composite(botan_pubkey_t* key, | ||||||||||
| const uint8_t pubkey[], | ||||||||||
| size_t key_len, | ||||||||||
| const char* mlkem_composite_algo) { | ||||||||||
| #if defined(BOTAN_HAS_MLKEM_COMPOSITE) | ||||||||||
| if(key == nullptr || pubkey == nullptr || mlkem_composite_algo == nullptr) { | ||||||||||
| return BOTAN_FFI_ERROR_NULL_POINTER; | ||||||||||
|
Comment on lines
+1390
to
+1391
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above:
Suggested change
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| *key = nullptr; | ||||||||||
|
|
||||||||||
| return ffi_guard_thunk(__func__, [=]() -> int { | ||||||||||
| auto param = Botan::MLKEM_Composite_Param::from_id_str(mlkem_composite_algo); | ||||||||||
| if(!param.has_value()) { | ||||||||||
| return BOTAN_FFI_ERROR_BAD_PARAMETER; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| auto mlkem_composite_key = | ||||||||||
| std::make_unique<Botan::MLKEM_Composite_PublicKey>(param.value().id(), std::span{pubkey, key_len}); | ||||||||||
| return ffi_new_object(key, std::move(mlkem_composite_key)); | ||||||||||
| }); | ||||||||||
| #else | ||||||||||
| BOTAN_UNUSED(key, key_len, pubkey, mlkem_composite_algo); | ||||||||||
| return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; | ||||||||||
| #endif | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /* | ||||||||||
| * Algorithm specific key operations: ML-DSA | ||||||||||
| */ | ||||||||||
|
|
||||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: There's a helper that could be used here: