-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML-KEM] Add experimental support for ML-KEM-512-IPD (#1516)
Add support and testing for ML-KEM-512-IPD, as specified in FIPS 203 Initial Public Draft. This is an intermediate step to support the final standardized ML-KEM once FIPS 203 is finalized. We do not plan to support the IPD version long-term, it will be surpassed by the final FIPS 203 (ML-KEM) definition.
- Loading branch information
Showing
26 changed files
with
1,638 additions
and
1,674 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
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
Large diffs are not rendered by default.
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,28 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
#include "ml_kem.h" | ||
#include "ml_kem_ipd_ref_common/api.h" | ||
|
||
// Note: These methods currently default to using the reference code for ML_KEM. | ||
// In a future where AWS-LC has optimized options available, those can be | ||
// conditionally (or based on compile-time flags) called here, depending on | ||
// platform support. | ||
|
||
int ml_kem_512_ipd_keypair(uint8_t *public_key /* OUT */, | ||
uint8_t *secret_key /* OUT */) { | ||
return ml_kem_512_ref_keypair(public_key, secret_key); | ||
} | ||
|
||
int ml_kem_512_ipd_encapsulate(uint8_t *ciphertext /* OUT */, | ||
uint8_t *shared_secret /* OUT */, | ||
const uint8_t *public_key /* IN */) { | ||
return ml_kem_512_ref_enc(ciphertext, shared_secret, public_key); | ||
} | ||
|
||
int ml_kem_512_ipd_decapsulate(uint8_t *shared_secret /* OUT */, | ||
const uint8_t *ciphertext /* IN */, | ||
const uint8_t *secret_key /* IN */) { | ||
return ml_kem_512_ref_dec(shared_secret, ciphertext, secret_key); | ||
} | ||
|
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,25 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
#ifndef ML_KEM_H | ||
#define ML_KEM_H | ||
|
||
#include <stdint.h> | ||
#include <openssl/base.h> | ||
|
||
#define MLKEM512IPD_SHARED_SECRET_LEN (32) | ||
#define MLKEM512IPD_PUBLIC_KEY_BYTES (800) | ||
#define MLKEM512IPD_SECRET_KEY_BYTES (1632) | ||
#define MLKEM512IPD_CIPHERTEXT_BYTES (768) | ||
|
||
int ml_kem_512_ipd_keypair(uint8_t *public_key /* OUT */, | ||
uint8_t *secret_key /* OUT */); | ||
|
||
int ml_kem_512_ipd_encapsulate(uint8_t *ciphertext /* OUT */, | ||
uint8_t *shared_secret /* OUT */, | ||
const uint8_t *public_key /* IN */); | ||
|
||
int ml_kem_512_ipd_decapsulate(uint8_t *shared_secret /* OUT */, | ||
const uint8_t *ciphertext /* IN */, | ||
const uint8_t *secret_key /* IN */); | ||
#endif // ML_KEM_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,19 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
// The following two lines have to be in that order, first the definition of | ||
// KYBER_K, and then the inclusion of params.h so that the correct version | ||
// of Kyber would be selected. KYBER_K equal to 2 corresponds to ML-KEM-512. | ||
// Both lines also have to come before all the source files. | ||
#define KYBER_K 2 | ||
#include "./ml_kem_ipd_ref_common/params.h" | ||
|
||
#include "./ml_kem_ipd_ref_common/cbd.c" | ||
#include "./ml_kem_ipd_ref_common/indcpa.c" | ||
#include "./ml_kem_ipd_ref_common/kem.c" | ||
#include "./ml_kem_ipd_ref_common/ntt.c" | ||
#include "./ml_kem_ipd_ref_common/poly.c" | ||
#include "./ml_kem_ipd_ref_common/polyvec.c" | ||
#include "./ml_kem_ipd_ref_common/reduce.c" | ||
#include "./ml_kem_ipd_ref_common/symmetric-shake.c" | ||
#include "./ml_kem_ipd_ref_common/verify.c" |
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.