Skip to content

Commit

Permalink
ML-KEM move to the FIPS module (aws#1802)
Browse files Browse the repository at this point in the history
Move the ML-KEM implementation to the FIPS module.
  • Loading branch information
dkostic authored Aug 26, 2024
1 parent f3f9fe7 commit 4ec9993
Show file tree
Hide file tree
Showing 33 changed files with 615 additions and 615 deletions.
1 change: 0 additions & 1 deletion crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ add_library(
kyber/kem_kyber.c
lhash/lhash.c
mem.c
ml_kem/ml_kem.c
obj/obj.c
obj/obj_xref.c
ocsp/ocsp_asn.c
Expand Down
6 changes: 3 additions & 3 deletions crypto/evp_extra/evp_extra_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2072,9 +2072,9 @@ static const struct KnownKEM kKEMs[] = {
{"Kyber512r3", NID_KYBER512_R3, 800, 1632, 768, 32, 64, 32, "kyber/kat/kyber512r3.txt"},
{"Kyber768r3", NID_KYBER768_R3, 1184, 2400, 1088, 32, 64, 32, "kyber/kat/kyber768r3.txt"},
{"Kyber1024r3", NID_KYBER1024_R3, 1568, 3168, 1568, 32, 64, 32, "kyber/kat/kyber1024r3.txt"},
{"MLKEM512", NID_MLKEM512, 800, 1632, 768, 32, 64, 32, "ml_kem/kat/mlkem512.txt"},
{"MLKEM768", NID_MLKEM768, 1184, 2400, 1088, 32, 64, 32, "ml_kem/kat/mlkem768.txt"},
{"MLKEM1024", NID_MLKEM1024, 1568, 3168, 1568, 32, 64, 32, "ml_kem/kat/mlkem1024.txt"},
{"MLKEM512", NID_MLKEM512, 800, 1632, 768, 32, 64, 32, "fipsmodule/ml_kem/kat/mlkem512.txt"},
{"MLKEM768", NID_MLKEM768, 1184, 2400, 1088, 32, 64, 32, "fipsmodule/ml_kem/kat/mlkem768.txt"},
{"MLKEM1024", NID_MLKEM1024, 1568, 3168, 1568, 32, 64, 32, "fipsmodule/ml_kem/kat/mlkem1024.txt"},
};

class PerKEMTest : public testing::TestWithParam<KnownKEM> {};
Expand Down
1 change: 1 addition & 0 deletions crypto/fipsmodule/bcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
#include "kdf/sskdf.c"
#include "md4/md4.c"
#include "md5/md5.c"
#include "ml_kem/ml_kem.c"
#include "modes/cbc.c"
#include "modes/cfb.c"
#include "modes/ctr.c"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdint.h>
#include <string.h>

#include "../../internal.h"
#include "../../../internal.h"

#include "params.h"
#include "indcpa.h"
Expand Down Expand Up @@ -162,7 +162,7 @@ static unsigned int rej_uniform(int16_t *r,
**************************************************/
#define GEN_MATRIX_NBLOCKS ((12*KYBER_N/8*(1 << 12)/KYBER_Q + XOF_BLOCKBYTES)/XOF_BLOCKBYTES)
// Not static for benchmarking
void gen_matrix(ml_kem_params *params, polyvec *a, const uint8_t *seed, int transposed)
void gen_matrix(ml_kem_params *params, polyvec *a, const uint8_t seed[KYBER_SYMBYTES], int transposed)
{
unsigned int ctr, i, j, k;
unsigned int buflen, off;
Expand Down Expand Up @@ -267,7 +267,7 @@ void indcpa_enc(ml_kem_params *params,
uint8_t *c,
const uint8_t *m,
const uint8_t *pk,
const uint8_t *coins)
const uint8_t coins[KYBER_SYMBYTES])
{
unsigned int i;
uint8_t seed[KYBER_SYMBYTES];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "polyvec.h"

#define gen_matrix KYBER_NAMESPACE(gen_matrix)
void gen_matrix(ml_kem_params *params, polyvec *a, const uint8_t *seed, int transposed);
void gen_matrix(ml_kem_params *params, polyvec *a, const uint8_t seed[KYBER_SYMBYTES], int transposed);

#define indcpa_keypair_derand KYBER_NAMESPACE(indcpa_keypair_derand)
void indcpa_keypair_derand(ml_kem_params *params,
Expand All @@ -19,7 +19,7 @@ void indcpa_enc(ml_kem_params *params,
uint8_t *c,
const uint8_t *m,
const uint8_t *pk,
const uint8_t *coins);
const uint8_t coins[KYBER_SYMBYTES]);

#define indcpa_dec KYBER_NAMESPACE(indcpa_dec)
void indcpa_dec(ml_kem_params *params,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "cbd.h"
#include "symmetric.h"

#include "../../internal.h"
#include "../../../internal.h"

/*************************************************
* Name: poly_compress
Expand Down
Loading

0 comments on commit 4ec9993

Please sign in to comment.