* cipher/Makefile.am (libcipher_la_SOURCES): Move kyber.c and kyber.h
to ...
(EXTRA_libcipher_la_SOURCES): ... here.
* cipher/kem.c: [USE_KYBER]: Only include kyber.h when USE_KYBER.
(_gcry_kem_genkey, _gcry_kem_encap, _gcry_kem_decap): [USE_KYBER]:
Enable Kyber when USE_KYBER.
* tests/keygen.c (check_kem_keys): [USE_KYBER]: Enable Kyber when
USE_KYBER.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
---
cipher/Makefile.am | 3 ++-
cipher/kem.c | 8 ++++++++
tests/keygen.c | 2 ++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/cipher/Makefile.am b/cipher/Makefile.am
index d8a3752b..dfffefb5 100644
--- a/cipher/Makefile.am
+++ b/cipher/Makefile.am
@@ -61,7 +61,7 @@ libcipher_la_SOURCES = \
mac.c mac-internal.h \
mac-hmac.c mac-cmac.c mac-gmac.c mac-poly1305.c \
poly1305.c poly1305-internal.h \
- kem.c sntrup761.c sntrup761.h kyber.c kyber.h kem-ecc.c kem-ecc.h \
+ kem.c sntrup761.c sntrup761.h kem-ecc.c kem-ecc.h \
mceliece6688128f.c mceliece6688128f.h \
kdf.c kdf-internal.h \
bithelp.h \
@@ -103,6 +103,7 @@ EXTRA_libcipher_la_SOURCES = \
elgamal.c \
ecc.c ecc-curves.c ecc-misc.c ecc-common.h \
ecc-ecdh.c ecc-ecdsa.c ecc-eddsa.c ecc-gost.c ecc-sm2.c \
+ kyber.c kyber.h \
idea.c \
gost28147.c gost.h \
gostr3411-94.c \
diff --git a/cipher/kem.c b/cipher/kem.c
index b97e6d6e..072249e2 100644
--- a/cipher/kem.c
+++ b/cipher/kem.c
@@ -29,7 +29,9 @@
#include "cipher.h"
#include "sntrup761.h"
#include "mceliece6688128f.h"
+#if USE_KYBER
#include "kyber.h"
+#endif
#include "kem-ecc.h"
@@ -100,6 +102,7 @@ _gcry_kem_genkey (int algo,
mceliece6688128f_keypair (pubkey, seckey);
return 0;
+#if USE_KYBER
case GCRY_KEM_MLKEM512:
if (seckey_len != GCRY_KEM_MLKEM512_SECKEY_LEN
|| pubkey_len != GCRY_KEM_MLKEM512_PUBKEY_LEN
@@ -123,6 +126,7 @@ _gcry_kem_genkey (int algo,
return GPG_ERR_INV_ARG;
kyber_keypair (algo, pubkey, seckey, optional);
return 0;
+#endif
case GCRY_KEM_RAW_X25519:
case GCRY_KEM_RAW_X448:
@@ -170,6 +174,7 @@ _gcry_kem_encap (int algo,
mceliece6688128f_enc (ciphertext, shared, pubkey);
return 0;
+#if USE_KYBER
case GCRY_KEM_MLKEM512:
case GCRY_KEM_MLKEM768:
case GCRY_KEM_MLKEM1024:
@@ -177,6 +182,7 @@ _gcry_kem_encap (int algo,
return GPG_ERR_INV_VALUE;
kyber_encap (algo, ciphertext, shared, pubkey, optional);
return 0;
+#endif
case GCRY_KEM_RAW_X25519:
case GCRY_KEM_RAW_X448:
@@ -230,6 +236,7 @@ _gcry_kem_decap (int algo,
mceliece6688128f_dec (shared, ciphertext, seckey);
return 0;
+#if USE_KYBER
case GCRY_KEM_MLKEM512:
case GCRY_KEM_MLKEM768:
case GCRY_KEM_MLKEM1024:
@@ -237,6 +244,7 @@ _gcry_kem_decap (int algo,
return GPG_ERR_INV_VALUE;
kyber_decap (algo, shared, ciphertext, seckey);
return 0;
+#endif
case GCRY_KEM_RAW_X25519:
case GCRY_KEM_RAW_X448:
diff --git a/tests/keygen.c b/tests/keygen.c
index b04cc7f5..44dfa283 100644
--- a/tests/keygen.c
+++ b/tests/keygen.c
@@ -670,9 +670,11 @@ check_kem_keys (void)
int flags;
} tv[] = {
{ "sntrup761", TEST_NOFIPS },
+#if USE_KYBER
{ "kyber512", TEST_NOFIPS },
{ "kyber768", TEST_NOFIPS },
{ "kyber1024", TEST_NOFIPS },
+#endif
};
int testno;
_______________________________________________
Gcrypt-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gcrypt-devel