From 38b38dcde2926552e69542bf4a26f8e5cf81b887 Mon Sep 17 00:00:00 2001 From: Spencer Wilson Date: Fri, 7 Feb 2025 08:53:23 -0500 Subject: [PATCH] Run copy_from_upstream [full tests] [extended tests] Signed-off-by: Spencer Wilson --- docs/algorithms/kem/bike.md | 10 +-- docs/algorithms/kem/classic_mceliece.md | 24 +++---- docs/algorithms/kem/frodokem.md | 16 ++--- docs/algorithms/kem/hqc.md | 10 +-- docs/algorithms/kem/kyber.md | 10 +-- docs/algorithms/kem/ml_kem.md | 12 ++-- docs/algorithms/kem/ntruprime.md | 6 +- .../kem_classic_mceliece_348864.c | 1 + .../kem_classic_mceliece_348864f.c | 1 + .../kem_classic_mceliece_460896.c | 1 + .../kem_classic_mceliece_460896f.c | 1 + .../kem_classic_mceliece_6688128.c | 1 + .../kem_classic_mceliece_6688128f.c | 1 + .../kem_classic_mceliece_6960119.c | 1 + .../kem_classic_mceliece_6960119f.c | 1 + .../kem_classic_mceliece_8192128.c | 1 + .../kem_classic_mceliece_8192128f.c | 1 + src/kem/hqc/kem_hqc_128.c | 1 + src/kem/hqc/kem_hqc_192.c | 1 + src/kem/hqc/kem_hqc_256.c | 1 + src/kem/kyber/kem_kyber_1024.c | 1 + src/kem/kyber/kem_kyber_512.c | 2 + src/kem/kyber/kem_kyber_768.c | 2 + src/kem/ml_kem/kem_ml_kem.h | 6 ++ src/kem/ml_kem/kem_ml_kem_1024.c | 66 +++++++++++++++++++ src/kem/ml_kem/kem_ml_kem_512.c | 66 +++++++++++++++++++ src/kem/ml_kem/kem_ml_kem_768.c | 66 +++++++++++++++++++ 27 files changed, 266 insertions(+), 44 deletions(-) diff --git a/docs/algorithms/kem/bike.md b/docs/algorithms/kem/bike.md index 139dc9f9c2..7c4d024100 100644 --- a/docs/algorithms/kem/bike.md +++ b/docs/algorithms/kem/bike.md @@ -13,11 +13,11 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | -|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| -| BIKE-L1 | NA | IND-CPA | 1 | 1541 | 5223 | 1573 | 32 | 0 | 0 | -| BIKE-L3 | NA | IND-CPA | 3 | 3083 | 10105 | 3115 | 32 | 0 | 0 | -| BIKE-L5 | NA | IND-CPA | 5 | 5122 | 16494 | 5154 | 32 | 0 | 0 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|:------------------------|:------------------------------| +| BIKE-L1 | NA | IND-CPA | 1 | 1541 | 5223 | 1573 | 32 | NA | NA | +| BIKE-L3 | NA | IND-CPA | 3 | 3083 | 10105 | 3115 | 32 | NA | NA | +| BIKE-L5 | NA | IND-CPA | 5 | 5122 | 16494 | 5154 | 32 | NA | NA | ## BIKE-L1 implementation characteristics diff --git a/docs/algorithms/kem/classic_mceliece.md b/docs/algorithms/kem/classic_mceliece.md index 42c60a2a60..a17b8469a0 100644 --- a/docs/algorithms/kem/classic_mceliece.md +++ b/docs/algorithms/kem/classic_mceliece.md @@ -18,18 +18,18 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | -|:-------------------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| -| Classic-McEliece-348864 | NA | IND-CCA2 | 1 | 261120 | 6492 | 96 | 32 | 0 | 0 | -| Classic-McEliece-348864f | NA | IND-CCA2 | 1 | 261120 | 6492 | 96 | 32 | 0 | 0 | -| Classic-McEliece-460896 | NA | IND-CCA2 | 3 | 524160 | 13608 | 156 | 32 | 0 | 0 | -| Classic-McEliece-460896f | NA | IND-CCA2 | 3 | 524160 | 13608 | 156 | 32 | 0 | 0 | -| Classic-McEliece-6688128 | NA | IND-CCA2 | 5 | 1044992 | 13932 | 208 | 32 | 0 | 0 | -| Classic-McEliece-6688128f | NA | IND-CCA2 | 5 | 1044992 | 13932 | 208 | 32 | 0 | 0 | -| Classic-McEliece-6960119 | NA | IND-CCA2 | 5 | 1047319 | 13948 | 194 | 32 | 0 | 0 | -| Classic-McEliece-6960119f | NA | IND-CCA2 | 5 | 1047319 | 13948 | 194 | 32 | 0 | 0 | -| Classic-McEliece-8192128 | NA | IND-CCA2 | 5 | 1357824 | 14120 | 208 | 32 | 0 | 0 | -| Classic-McEliece-8192128f | NA | IND-CCA2 | 5 | 1357824 | 14120 | 208 | 32 | 0 | 0 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:-------------------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|:------------------------|:------------------------------| +| Classic-McEliece-348864 | NA | IND-CCA2 | 1 | 261120 | 6492 | 96 | 32 | NA | NA | +| Classic-McEliece-348864f | NA | IND-CCA2 | 1 | 261120 | 6492 | 96 | 32 | NA | NA | +| Classic-McEliece-460896 | NA | IND-CCA2 | 3 | 524160 | 13608 | 156 | 32 | NA | NA | +| Classic-McEliece-460896f | NA | IND-CCA2 | 3 | 524160 | 13608 | 156 | 32 | NA | NA | +| Classic-McEliece-6688128 | NA | IND-CCA2 | 5 | 1044992 | 13932 | 208 | 32 | NA | NA | +| Classic-McEliece-6688128f | NA | IND-CCA2 | 5 | 1044992 | 13932 | 208 | 32 | NA | NA | +| Classic-McEliece-6960119 | NA | IND-CCA2 | 5 | 1047319 | 13948 | 194 | 32 | NA | NA | +| Classic-McEliece-6960119f | NA | IND-CCA2 | 5 | 1047319 | 13948 | 194 | 32 | NA | NA | +| Classic-McEliece-8192128 | NA | IND-CCA2 | 5 | 1357824 | 14120 | 208 | 32 | NA | NA | +| Classic-McEliece-8192128f | NA | IND-CCA2 | 5 | 1357824 | 14120 | 208 | 32 | NA | NA | ## Classic-McEliece-348864 implementation characteristics diff --git a/docs/algorithms/kem/frodokem.md b/docs/algorithms/kem/frodokem.md index 25ea44fab4..25fb65345d 100644 --- a/docs/algorithms/kem/frodokem.md +++ b/docs/algorithms/kem/frodokem.md @@ -12,14 +12,14 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | -|:-------------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| -| FrodoKEM-640-AES | NA | IND-CCA2 | 1 | 9616 | 19888 | 9720 | 16 | 0 | 0 | -| FrodoKEM-640-SHAKE | NA | IND-CCA2 | 1 | 9616 | 19888 | 9720 | 16 | 0 | 0 | -| FrodoKEM-976-AES | NA | IND-CCA2 | 3 | 15632 | 31296 | 15744 | 24 | 0 | 0 | -| FrodoKEM-976-SHAKE | NA | IND-CCA2 | 3 | 15632 | 31296 | 15744 | 24 | 0 | 0 | -| FrodoKEM-1344-AES | NA | IND-CCA2 | 5 | 21520 | 43088 | 21632 | 32 | 0 | 0 | -| FrodoKEM-1344-SHAKE | NA | IND-CCA2 | 5 | 21520 | 43088 | 21632 | 32 | 0 | 0 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:-------------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|:------------------------|:------------------------------| +| FrodoKEM-640-AES | NA | IND-CCA2 | 1 | 9616 | 19888 | 9720 | 16 | NA | NA | +| FrodoKEM-640-SHAKE | NA | IND-CCA2 | 1 | 9616 | 19888 | 9720 | 16 | NA | NA | +| FrodoKEM-976-AES | NA | IND-CCA2 | 3 | 15632 | 31296 | 15744 | 24 | NA | NA | +| FrodoKEM-976-SHAKE | NA | IND-CCA2 | 3 | 15632 | 31296 | 15744 | 24 | NA | NA | +| FrodoKEM-1344-AES | NA | IND-CCA2 | 5 | 21520 | 43088 | 21632 | 32 | NA | NA | +| FrodoKEM-1344-SHAKE | NA | IND-CCA2 | 5 | 21520 | 43088 | 21632 | 32 | NA | NA | ## FrodoKEM-640-AES implementation characteristics diff --git a/docs/algorithms/kem/hqc.md b/docs/algorithms/kem/hqc.md index ee205ae8ab..8931e2987a 100644 --- a/docs/algorithms/kem/hqc.md +++ b/docs/algorithms/kem/hqc.md @@ -14,11 +14,11 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | -|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| -| HQC-128 | NA | IND-CCA2 | 1 | 2249 | 2305 | 4433 | 64 | 0 | 0 | -| HQC-192 | NA | IND-CCA2 | 3 | 4522 | 4586 | 8978 | 64 | 0 | 0 | -| HQC-256 | NA | IND-CCA2 | 5 | 7245 | 7317 | 14421 | 64 | 0 | 0 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|:------------------------|:------------------------------| +| HQC-128 | NA | IND-CCA2 | 1 | 2249 | 2305 | 4433 | 64 | NA | NA | +| HQC-192 | NA | IND-CCA2 | 3 | 4522 | 4586 | 8978 | 64 | NA | NA | +| HQC-256 | NA | IND-CCA2 | 5 | 7245 | 7317 | 14421 | 64 | NA | NA | ## HQC-128 implementation characteristics diff --git a/docs/algorithms/kem/kyber.md b/docs/algorithms/kem/kyber.md index 9ba9df8300..772f1dd09c 100644 --- a/docs/algorithms/kem/kyber.md +++ b/docs/algorithms/kem/kyber.md @@ -21,11 +21,11 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | -|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| -| Kyber512 | NA | IND-CCA2 | 1 | 800 | 1632 | 768 | 32 | 0 | 0 | -| Kyber768 | NA | IND-CCA2 | 3 | 1184 | 2400 | 1088 | 32 | 0 | 0 | -| Kyber1024 | NA | IND-CCA2 | 5 | 1568 | 3168 | 1568 | 32 | 0 | 0 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|:------------------------|:------------------------------| +| Kyber512 | NA | IND-CCA2 | 1 | 800 | 1632 | 768 | 32 | NA | NA | +| Kyber768 | NA | IND-CCA2 | 3 | 1184 | 2400 | 1088 | 32 | NA | NA | +| Kyber1024 | NA | IND-CCA2 | 5 | 1568 | 3168 | 1568 | 32 | NA | NA | ## Kyber512 implementation characteristics diff --git a/docs/algorithms/kem/ml_kem.md b/docs/algorithms/kem/ml_kem.md index 8ccc2f99e3..986b4fd054 100644 --- a/docs/algorithms/kem/ml_kem.md +++ b/docs/algorithms/kem/ml_kem.md @@ -17,11 +17,11 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | -|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:| -| ML-KEM-512 | NA | IND-CCA2 | 1 | 800 | 1632 | 768 | 32 | -| ML-KEM-768 | NA | IND-CCA2 | 3 | 1184 | 2400 | 1088 | 32 | -| ML-KEM-1024 | NA | IND-CCA2 | 5 | 1568 | 3168 | 1568 | 32 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| +| ML-KEM-512 | NA | IND-CCA2 | 1 | 800 | 1632 | 768 | 32 | 64 | 32 | +| ML-KEM-768 | NA | IND-CCA2 | 3 | 1184 | 2400 | 1088 | 32 | 64 | 32 | +| ML-KEM-1024 | NA | IND-CCA2 | 5 | 1568 | 3168 | 1568 | 32 | 64 | 32 | ## ML-KEM-512 implementation characteristics @@ -60,4 +60,4 @@ Are implementations chosen based on runtime CPU feature detection? **Yes**. ## Explanation of Terms -- **Large Stack Usage**: Implementations identified as having such may cause failures when running in threads or in constrained environments. +- **Large Stack Usage**: Implementations identified as having such may cause failures when running in threads or in constrained environments. \ No newline at end of file diff --git a/docs/algorithms/kem/ntruprime.md b/docs/algorithms/kem/ntruprime.md index a195238750..2804212093 100644 --- a/docs/algorithms/kem/ntruprime.md +++ b/docs/algorithms/kem/ntruprime.md @@ -14,9 +14,9 @@ ## Parameter set summary -| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | -|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|------------------------:|------------------------------:| -| sntrup761 | NA | IND-CCA2 | 2 | 1158 | 1763 | 1039 | 32 | 0 | 0 | +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Ciphertext size (bytes) | Shared secret size (bytes) | Keypair coins (bytes) | Encapsulation coins (bytes) | +|:---------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|--------------------------:|-----------------------------:|:------------------------|:------------------------------| +| sntrup761 | NA | IND-CCA2 | 2 | 1158 | 1763 | 1039 | 32 | NA | NA | ## sntrup761 implementation characteristics diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_348864.c b/src/kem/classic_mceliece/kem_classic_mceliece_348864.c index 323654c620..642cc1d903 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_348864.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_348864.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_348864_new(void) { return kem; } + extern int PQCLEAN_MCELIECE348864_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE348864_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE348864_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_348864f.c b/src/kem/classic_mceliece/kem_classic_mceliece_348864f.c index 0fdbf19345..6f14284e8c 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_348864f.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_348864f.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_348864f_new(void) { return kem; } + extern int PQCLEAN_MCELIECE348864F_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE348864F_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE348864F_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_460896.c b/src/kem/classic_mceliece/kem_classic_mceliece_460896.c index bf0a6ba3fd..eeccb1c3cc 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_460896.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_460896.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_460896_new(void) { return kem; } + extern int PQCLEAN_MCELIECE460896_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE460896_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE460896_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_460896f.c b/src/kem/classic_mceliece/kem_classic_mceliece_460896f.c index 9ef0f95374..a9d56dab6c 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_460896f.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_460896f.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_460896f_new(void) { return kem; } + extern int PQCLEAN_MCELIECE460896F_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE460896F_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE460896F_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_6688128.c b/src/kem/classic_mceliece/kem_classic_mceliece_6688128.c index 27bd796608..904001127b 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_6688128.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_6688128.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_6688128_new(void) { return kem; } + extern int PQCLEAN_MCELIECE6688128_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE6688128_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE6688128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_6688128f.c b/src/kem/classic_mceliece/kem_classic_mceliece_6688128f.c index 5e39d4a359..193f5e7a47 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_6688128f.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_6688128f.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_6688128f_new(void) { return kem; } + extern int PQCLEAN_MCELIECE6688128F_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE6688128F_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE6688128F_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_6960119.c b/src/kem/classic_mceliece/kem_classic_mceliece_6960119.c index 4dbabbe557..0f30d79d60 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_6960119.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_6960119.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_6960119_new(void) { return kem; } + extern int PQCLEAN_MCELIECE6960119_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE6960119_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE6960119_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_6960119f.c b/src/kem/classic_mceliece/kem_classic_mceliece_6960119f.c index 8422e4d452..063f488f54 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_6960119f.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_6960119f.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_6960119f_new(void) { return kem; } + extern int PQCLEAN_MCELIECE6960119F_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE6960119F_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE6960119F_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_8192128.c b/src/kem/classic_mceliece/kem_classic_mceliece_8192128.c index fa02793b2a..3d8c75186d 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_8192128.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_8192128.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_8192128_new(void) { return kem; } + extern int PQCLEAN_MCELIECE8192128_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE8192128_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE8192128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/classic_mceliece/kem_classic_mceliece_8192128f.c b/src/kem/classic_mceliece/kem_classic_mceliece_8192128f.c index c4dc2bac1f..649325584f 100644 --- a/src/kem/classic_mceliece/kem_classic_mceliece_8192128f.c +++ b/src/kem/classic_mceliece/kem_classic_mceliece_8192128f.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_classic_mceliece_8192128f_new(void) { return kem; } + extern int PQCLEAN_MCELIECE8192128F_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_MCELIECE8192128F_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_MCELIECE8192128F_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/hqc/kem_hqc_128.c b/src/kem/hqc/kem_hqc_128.c index f266dfdd40..639d4741c8 100644 --- a/src/kem/hqc/kem_hqc_128.c +++ b/src/kem/hqc/kem_hqc_128.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_hqc_128_new(void) { return kem; } + extern int PQCLEAN_HQC128_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_HQC128_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_HQC128_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/hqc/kem_hqc_192.c b/src/kem/hqc/kem_hqc_192.c index b3814cfb9e..29b29a0c35 100644 --- a/src/kem/hqc/kem_hqc_192.c +++ b/src/kem/hqc/kem_hqc_192.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_hqc_192_new(void) { return kem; } + extern int PQCLEAN_HQC192_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_HQC192_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_HQC192_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/hqc/kem_hqc_256.c b/src/kem/hqc/kem_hqc_256.c index b244e828f6..c48c49320b 100644 --- a/src/kem/hqc/kem_hqc_256.c +++ b/src/kem/hqc/kem_hqc_256.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_hqc_256_new(void) { return kem; } + extern int PQCLEAN_HQC256_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk); extern int PQCLEAN_HQC256_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCLEAN_HQC256_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/kyber/kem_kyber_1024.c b/src/kem/kyber/kem_kyber_1024.c index 137f681ff1..c5db669f71 100644 --- a/src/kem/kyber/kem_kyber_1024.c +++ b/src/kem/kyber/kem_kyber_1024.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_kyber_1024_new(void) { return kem; } + extern int pqcrystals_kyber1024_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_kyber1024_ref_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_kyber1024_ref_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); diff --git a/src/kem/kyber/kem_kyber_512.c b/src/kem/kyber/kem_kyber_512.c index 8c5fc34d96..af5ffb00b0 100644 --- a/src/kem/kyber/kem_kyber_512.c +++ b/src/kem/kyber/kem_kyber_512.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_kyber_512_new(void) { return kem; } + extern int pqcrystals_kyber512_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_kyber512_ref_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_kyber512_ref_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); @@ -61,6 +62,7 @@ extern int libjade_kyber512_avx2_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk extern int libjade_kyber512_avx2_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif + OQS_API OQS_STATUS OQS_KEM_kyber_512_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins) { (void)public_key; (void)secret_key; diff --git a/src/kem/kyber/kem_kyber_768.c b/src/kem/kyber/kem_kyber_768.c index 571c500215..27be9505a6 100644 --- a/src/kem/kyber/kem_kyber_768.c +++ b/src/kem/kyber/kem_kyber_768.c @@ -33,6 +33,7 @@ OQS_KEM *OQS_KEM_kyber_768_new(void) { return kem; } + extern int pqcrystals_kyber768_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_kyber768_ref_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_kyber768_ref_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); @@ -61,6 +62,7 @@ extern int libjade_kyber768_avx2_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk extern int libjade_kyber768_avx2_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif + OQS_API OQS_STATUS OQS_KEM_kyber_768_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins) { (void)public_key; (void)secret_key; diff --git a/src/kem/ml_kem/kem_ml_kem.h b/src/kem/ml_kem/kem_ml_kem.h index d1c58b584b..d7d2a57d42 100644 --- a/src/kem/ml_kem/kem_ml_kem.h +++ b/src/kem/ml_kem/kem_ml_kem.h @@ -10,6 +10,8 @@ #define OQS_KEM_ml_kem_512_length_secret_key 1632 #define OQS_KEM_ml_kem_512_length_ciphertext 768 #define OQS_KEM_ml_kem_512_length_shared_secret 32 +#define OQS_KEM_ml_kem_512_length_keypair_coins 64 +#define OQS_KEM_ml_kem_512_length_encaps_coins 32 OQS_KEM *OQS_KEM_ml_kem_512_new(void); OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins); OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secret_key); @@ -23,6 +25,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_decaps(uint8_t *shared_secret, const uint8 #define OQS_KEM_ml_kem_768_length_secret_key 2400 #define OQS_KEM_ml_kem_768_length_ciphertext 1088 #define OQS_KEM_ml_kem_768_length_shared_secret 32 +#define OQS_KEM_ml_kem_768_length_keypair_coins 64 +#define OQS_KEM_ml_kem_768_length_encaps_coins 32 OQS_KEM *OQS_KEM_ml_kem_768_new(void); OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins); OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secret_key); @@ -36,6 +40,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_decaps(uint8_t *shared_secret, const uint8 #define OQS_KEM_ml_kem_1024_length_secret_key 3168 #define OQS_KEM_ml_kem_1024_length_ciphertext 1568 #define OQS_KEM_ml_kem_1024_length_shared_secret 32 +#define OQS_KEM_ml_kem_1024_length_keypair_coins 64 +#define OQS_KEM_ml_kem_1024_length_encaps_coins 32 OQS_KEM *OQS_KEM_ml_kem_1024_new(void); OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins); OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *secret_key); diff --git a/src/kem/ml_kem/kem_ml_kem_1024.c b/src/kem/ml_kem/kem_ml_kem_1024.c index 52f6de69cd..9c883930e6 100644 --- a/src/kem/ml_kem/kem_ml_kem_1024.c +++ b/src/kem/ml_kem/kem_ml_kem_1024.c @@ -22,26 +22,36 @@ OQS_KEM *OQS_KEM_ml_kem_1024_new(void) { kem->length_secret_key = OQS_KEM_ml_kem_1024_length_secret_key; kem->length_ciphertext = OQS_KEM_ml_kem_1024_length_ciphertext; kem->length_shared_secret = OQS_KEM_ml_kem_1024_length_shared_secret; + kem->length_keypair_coins = OQS_KEM_ml_kem_1024_length_keypair_coins; + kem->length_encaps_coins = OQS_KEM_ml_kem_1024_length_encaps_coins; + kem->keypair_derand = OQS_KEM_ml_kem_1024_keypair_derand; kem->keypair = OQS_KEM_ml_kem_1024_keypair; + kem->encaps_derand = OQS_KEM_ml_kem_1024_encaps_derand; kem->encaps = OQS_KEM_ml_kem_1024_encaps; kem->decaps = OQS_KEM_ml_kem_1024_decaps; return kem; } +extern int PQCP_MLKEM_NATIVE_MLKEM1024_C_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM1024_C_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM1024_C_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM1024_C_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM1024_C_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) +extern int PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif #if defined(OQS_ENABLE_KEM_ml_kem_1024_aarch64) +extern int PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif @@ -54,6 +64,34 @@ extern int cupqc_ml_kem_1024_dec(uint8_t *ss, const uint8_t *ct, const uint8_t * #endif #endif /* OQS_USE_CUPQC */ +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins) { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_keypair_derand(public_key, secret_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_keypair_derand(public_key, secret_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_1024_aarch64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_ARM_NEON)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_keypair_derand(public_key, secret_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_keypair_derand(public_key, secret_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM1024_CUDA_crypto_kem_keypair_derand(public_key, secret_key, coins); +#else + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_keypair_derand(public_key, secret_key, coins); +#endif +} + OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *secret_key) { #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) return (OQS_STATUS) cupqc_ml_kem_1024_keypair(public_key, secret_key); @@ -83,6 +121,34 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *sec #endif } +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_encaps_derand(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key, const uint8_t *coins) { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_X86_64_DEFAULT_enc_derand(ciphertext, shared_secret, public_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_enc_derand(ciphertext, shared_secret, public_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_1024_aarch64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_ARM_NEON)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_AARCH64_OPT_enc_derand(ciphertext, shared_secret, public_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_enc_derand(ciphertext, shared_secret, public_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM1024_CUDA_crypto_kem_enc_derand(ciphertext, shared_secret, public_key, coins); +#else + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_enc_derand(ciphertext, shared_secret, public_key, coins); +#endif +} + OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) return (OQS_STATUS) cupqc_ml_kem_1024_enc(ciphertext, shared_secret, public_key); diff --git a/src/kem/ml_kem/kem_ml_kem_512.c b/src/kem/ml_kem/kem_ml_kem_512.c index 8f451b0fd1..cba65f81ba 100644 --- a/src/kem/ml_kem/kem_ml_kem_512.c +++ b/src/kem/ml_kem/kem_ml_kem_512.c @@ -22,26 +22,36 @@ OQS_KEM *OQS_KEM_ml_kem_512_new(void) { kem->length_secret_key = OQS_KEM_ml_kem_512_length_secret_key; kem->length_ciphertext = OQS_KEM_ml_kem_512_length_ciphertext; kem->length_shared_secret = OQS_KEM_ml_kem_512_length_shared_secret; + kem->length_keypair_coins = OQS_KEM_ml_kem_512_length_keypair_coins; + kem->length_encaps_coins = OQS_KEM_ml_kem_512_length_encaps_coins; + kem->keypair_derand = OQS_KEM_ml_kem_512_keypair_derand; kem->keypair = OQS_KEM_ml_kem_512_keypair; + kem->encaps_derand = OQS_KEM_ml_kem_512_encaps_derand; kem->encaps = OQS_KEM_ml_kem_512_encaps; kem->decaps = OQS_KEM_ml_kem_512_decaps; return kem; } +extern int PQCP_MLKEM_NATIVE_MLKEM512_C_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM512_C_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM512_C_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM512_C_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM512_C_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) +extern int PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif #if defined(OQS_ENABLE_KEM_ml_kem_512_aarch64) +extern int PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif @@ -54,6 +64,34 @@ extern int cupqc_ml_kem_512_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *s #endif #endif /* OQS_USE_CUPQC */ +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins) { +#if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_keypair_derand(public_key, secret_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_keypair_derand(public_key, secret_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_512_aarch64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_ARM_NEON)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_keypair_derand(public_key, secret_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_keypair_derand(public_key, secret_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_512_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM512_CUDA_crypto_kem_keypair_derand(public_key, secret_key, coins); +#else + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_keypair_derand(public_key, secret_key, coins); +#endif +} + OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secret_key) { #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_512_cuda) return (OQS_STATUS) cupqc_ml_kem_512_keypair(public_key, secret_key); @@ -83,6 +121,34 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secr #endif } +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_encaps_derand(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key, const uint8_t *coins) { +#if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_X86_64_DEFAULT_enc_derand(ciphertext, shared_secret, public_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_enc_derand(ciphertext, shared_secret, public_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_512_aarch64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_ARM_NEON)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_AARCH64_OPT_enc_derand(ciphertext, shared_secret, public_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_enc_derand(ciphertext, shared_secret, public_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_512_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM512_CUDA_crypto_kem_enc_derand(ciphertext, shared_secret, public_key, coins); +#else + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_enc_derand(ciphertext, shared_secret, public_key, coins); +#endif +} + OQS_API OQS_STATUS OQS_KEM_ml_kem_512_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_512_cuda) return (OQS_STATUS) cupqc_ml_kem_512_enc(ciphertext, shared_secret, public_key); diff --git a/src/kem/ml_kem/kem_ml_kem_768.c b/src/kem/ml_kem/kem_ml_kem_768.c index ef64c5c406..f88e8bea22 100644 --- a/src/kem/ml_kem/kem_ml_kem_768.c +++ b/src/kem/ml_kem/kem_ml_kem_768.c @@ -22,26 +22,36 @@ OQS_KEM *OQS_KEM_ml_kem_768_new(void) { kem->length_secret_key = OQS_KEM_ml_kem_768_length_secret_key; kem->length_ciphertext = OQS_KEM_ml_kem_768_length_ciphertext; kem->length_shared_secret = OQS_KEM_ml_kem_768_length_shared_secret; + kem->length_keypair_coins = OQS_KEM_ml_kem_768_length_keypair_coins; + kem->length_encaps_coins = OQS_KEM_ml_kem_768_length_encaps_coins; + kem->keypair_derand = OQS_KEM_ml_kem_768_keypair_derand; kem->keypair = OQS_KEM_ml_kem_768_keypair; + kem->encaps_derand = OQS_KEM_ml_kem_768_encaps_derand; kem->encaps = OQS_KEM_ml_kem_768_encaps; kem->decaps = OQS_KEM_ml_kem_768_decaps; return kem; } +extern int PQCP_MLKEM_NATIVE_MLKEM768_C_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM768_C_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM768_C_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM768_C_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM768_C_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) +extern int PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif #if defined(OQS_ENABLE_KEM_ml_kem_768_aarch64) +extern int PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_keypair(uint8_t *pk, uint8_t *sk); +extern int PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins); extern int PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif @@ -54,6 +64,34 @@ extern int cupqc_ml_kem_768_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *s #endif #endif /* OQS_USE_CUPQC */ +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *coins) { +#if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_keypair_derand(public_key, secret_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_keypair_derand(public_key, secret_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_768_aarch64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_ARM_NEON)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_keypair_derand(public_key, secret_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_keypair_derand(public_key, secret_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_768_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM768_CUDA_crypto_kem_keypair_derand(public_key, secret_key, coins); +#else + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_keypair_derand(public_key, secret_key, coins); +#endif +} + OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secret_key) { #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_768_cuda) return (OQS_STATUS) cupqc_ml_kem_768_keypair(public_key, secret_key); @@ -83,6 +121,34 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secr #endif } +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_encaps_derand(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key, const uint8_t *coins) { +#if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_X86_64_DEFAULT_enc_derand(ciphertext, shared_secret, public_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_enc_derand(ciphertext, shared_secret, public_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_768_aarch64) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_ARM_NEON)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_AARCH64_OPT_enc_derand(ciphertext, shared_secret, public_key, coins); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_enc_derand(ciphertext, shared_secret, public_key, coins); + } +#endif /* OQS_DIST_BUILD */ +#elif defined(OQS_ENABLE_KEM_ml_kem_768_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM768_CUDA_crypto_kem_enc_derand(ciphertext, shared_secret, public_key, coins); +#else + return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_enc_derand(ciphertext, shared_secret, public_key, coins); +#endif +} + OQS_API OQS_STATUS OQS_KEM_ml_kem_768_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_768_cuda) return (OQS_STATUS) cupqc_ml_kem_768_enc(ciphertext, shared_secret, public_key);