diff --git a/src/kem/kyber/kyber512/clean/indcpa.c b/src/kem/kyber/kyber512/clean/indcpa.c index e90dccd8..76cbda6b 100644 --- a/src/kem/kyber/kyber512/clean/indcpa.c +++ b/src/kem/kyber/kyber512/clean/indcpa.c @@ -7,6 +7,7 @@ #include "symmetric.h" #include #include +#include /************************************************* * Name: pack_pk @@ -224,7 +225,6 @@ void PQCLEAN_KYBER512_CLEAN_indcpa_keypair(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTE PQCLEAN_KYBER512_CLEAN_polyvec_ntt(&skpv); PQCLEAN_KYBER512_CLEAN_polyvec_ntt(&e); - // matrix-vector multiplication for (i = 0; i < KYBER_K; i++) { PQCLEAN_KYBER512_CLEAN_polyvec_basemul_acc_montgomery(&pkpv.vec[i], &a[i], &skpv); diff --git a/src/kem/kyber/kyber512/clean/poly.c b/src/kem/kyber/kyber512/clean/poly.c index f10afd7d..7d49bb29 100644 --- a/src/kem/kyber/kyber512/clean/poly.c +++ b/src/kem/kyber/kyber512/clean/poly.c @@ -5,6 +5,7 @@ #include "reduce.h" #include "symmetric.h" #include +#include /************************************************* * Name: PQCLEAN_KYBER512_CLEAN_poly_compress diff --git a/src/kem/kyber/kyber512/clean/poly.h b/src/kem/kyber/kyber512/clean/poly.h index 5ca491d1..15aa279c 100644 --- a/src/kem/kyber/kyber512/clean/poly.h +++ b/src/kem/kyber/kyber512/clean/poly.h @@ -2,7 +2,12 @@ #define PQCLEAN_KYBER512_CLEAN_POLY_H #include "params.h" #include +#include +static inline void pc(int16_t c[KYBER_N]) { + for(size_t i=0; ivec[i], &b->vec[i]); PQCLEAN_KYBER512_CLEAN_poly_add(r, r, &t); + pc(r->coeffs); } PQCLEAN_KYBER512_CLEAN_poly_reduce(r); diff --git a/test/katrunner/src/main.rs b/test/katrunner/src/main.rs index 00808ec6..336d52ba 100644 --- a/test/katrunner/src/main.rs +++ b/test/katrunner/src/main.rs @@ -161,59 +161,59 @@ fn test_kem_vector(el: &TestVector) { // KAT test register const KATS: &'static[Register] = &[ - REG_SIGN!(DILITHIUM2, "round3/dilithium/dilithium2/PQCsignKAT_2544.rsp"), - REG_SIGN!(DILITHIUM3, "round3/dilithium/dilithium3/PQCsignKAT_4016.rsp"), - REG_SIGN!(DILITHIUM5, "round3/dilithium/dilithium5/PQCsignKAT_4880.rsp"), + //REG_SIGN!(DILITHIUM2, "round3/dilithium/dilithium2/PQCsignKAT_2544.rsp"), + //REG_SIGN!(DILITHIUM3, "round3/dilithium/dilithium3/PQCsignKAT_4016.rsp"), + //REG_SIGN!(DILITHIUM5, "round3/dilithium/dilithium5/PQCsignKAT_4880.rsp"), //REG_SIGN!(FALCON512, "round3/falcon/falcon512-KAT.rsp"), //REG_SIGN!(FALCON1024, "round3/falcon/falcon1024-KAT.rsp"), // Some implementations of sphincs are for round3 - REG_SIGN!(SPHINCSSHA256128SSIMPLE,"round3/sphincs/sphincs-sha256-128s-simple/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHA256128SROBUST,"round3/sphincs/sphincs-sha256-128s-robust/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHA256128FSIMPLE,"round3/sphincs/sphincs-sha256-128f-simple/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHA256128FROBUST,"round3/sphincs/sphincs-sha256-128f-robust/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHA256192SSIMPLE,"round3/sphincs/sphincs-sha256-192s-simple/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHA256192SROBUST,"round3/sphincs/sphincs-sha256-192s-robust/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHA256192FSIMPLE,"round3/sphincs/sphincs-sha256-192f-simple/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHA256192FROBUST,"round3/sphincs/sphincs-sha256-192f-robust/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHA256256SSIMPLE,"round3/sphincs/sphincs-sha256-256s-simple/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHA256256SROBUST,"round3/sphincs/sphincs-sha256-256s-robust/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHA256256FROBUST,"round3/sphincs/sphincs-sha256-256f-robust/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHA256256FSIMPLE,"round3/sphincs/sphincs-sha256-256f-simple/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHAKE256128FSIMPLE,"round3/sphincs/sphincs-shake256-128f-simple/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHAKE256128SSIMPLE,"round3/sphincs/sphincs-shake256-128s-simple/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHAKE256128FROBUST,"round3/sphincs/sphincs-shake256-128f-robust/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHAKE256128SROBUST,"round3/sphincs/sphincs-shake256-128s-robust/PQCsignKAT_64.rsp"), - REG_SIGN!(SPHINCSSHAKE256192FROBUST,"round3/sphincs/sphincs-shake256-192f-robust/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHAKE256192FSIMPLE,"round3/sphincs/sphincs-shake256-192f-simple/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHAKE256192SSIMPLE,"round3/sphincs/sphincs-shake256-192s-simple/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHAKE256192SROBUST,"round3/sphincs/sphincs-shake256-192s-robust/PQCsignKAT_96.rsp"), - REG_SIGN!(SPHINCSSHAKE256256FROBUST,"round3/sphincs/sphincs-shake256-256f-robust/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHAKE256256FSIMPLE,"round3/sphincs/sphincs-shake256-256f-simple/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHAKE256256SSIMPLE,"round3/sphincs/sphincs-shake256-256s-simple/PQCsignKAT_128.rsp"), - REG_SIGN!(SPHINCSSHAKE256256SROBUST,"round3/sphincs/sphincs-shake256-256s-robust/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHA256128SSIMPLE,"round3/sphincs/sphincs-sha256-128s-simple/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHA256128SROBUST,"round3/sphincs/sphincs-sha256-128s-robust/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHA256128FSIMPLE,"round3/sphincs/sphincs-sha256-128f-simple/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHA256128FROBUST,"round3/sphincs/sphincs-sha256-128f-robust/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHA256192SSIMPLE,"round3/sphincs/sphincs-sha256-192s-simple/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHA256192SROBUST,"round3/sphincs/sphincs-sha256-192s-robust/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHA256192FSIMPLE,"round3/sphincs/sphincs-sha256-192f-simple/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHA256192FROBUST,"round3/sphincs/sphincs-sha256-192f-robust/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHA256256SSIMPLE,"round3/sphincs/sphincs-sha256-256s-simple/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHA256256SROBUST,"round3/sphincs/sphincs-sha256-256s-robust/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHA256256FROBUST,"round3/sphincs/sphincs-sha256-256f-robust/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHA256256FSIMPLE,"round3/sphincs/sphincs-sha256-256f-simple/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHAKE256128FSIMPLE,"round3/sphincs/sphincs-shake256-128f-simple/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHAKE256128SSIMPLE,"round3/sphincs/sphincs-shake256-128s-simple/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHAKE256128FROBUST,"round3/sphincs/sphincs-shake256-128f-robust/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHAKE256128SROBUST,"round3/sphincs/sphincs-shake256-128s-robust/PQCsignKAT_64.rsp"), + //REG_SIGN!(SPHINCSSHAKE256192FROBUST,"round3/sphincs/sphincs-shake256-192f-robust/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHAKE256192FSIMPLE,"round3/sphincs/sphincs-shake256-192f-simple/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHAKE256192SSIMPLE,"round3/sphincs/sphincs-shake256-192s-simple/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHAKE256192SROBUST,"round3/sphincs/sphincs-shake256-192s-robust/PQCsignKAT_96.rsp"), + //REG_SIGN!(SPHINCSSHAKE256256FROBUST,"round3/sphincs/sphincs-shake256-256f-robust/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHAKE256256FSIMPLE,"round3/sphincs/sphincs-shake256-256f-simple/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHAKE256256SSIMPLE,"round3/sphincs/sphincs-shake256-256s-simple/PQCsignKAT_128.rsp"), + //REG_SIGN!(SPHINCSSHAKE256256SROBUST,"round3/sphincs/sphincs-shake256-256s-robust/PQCsignKAT_128.rsp"), // KEM Schemes - REG_KEM!(FRODOKEM640SHAKE, "round3/frodokem/PQCkemKAT_19888_shake.rsp"), - REG_KEM!(FRODOKEM976SHAKE, "round3/frodokem/PQCkemKAT_31296_shake.rsp"), - REG_KEM!(FRODOKEM1344SHAKE, "round3/frodokem/PQCkemKAT_43088_shake.rsp"), - REG_KEM!(KYBER768, "round3/kyber/kyber768/PQCkemKAT_2400.rsp"), - REG_KEM!(KYBER1024, "round3/kyber/kyber1024/PQCkemKAT_3168.rsp"), + //REG_KEM!(FRODOKEM640SHAKE, "round3/frodokem/PQCkemKAT_19888_shake.rsp"), + //REG_KEM!(FRODOKEM976SHAKE, "round3/frodokem/PQCkemKAT_31296_shake.rsp"), + //REG_KEM!(FRODOKEM1344SHAKE, "round3/frodokem/PQCkemKAT_43088_shake.rsp"), + //REG_KEM!(KYBER768, "round3/kyber/kyber768/PQCkemKAT_2400.rsp"), + //REG_KEM!(KYBER1024, "round3/kyber/kyber1024/PQCkemKAT_3168.rsp"), REG_KEM!(KYBER512, "round3/kyber/kyber512/PQCkemKAT_1632.rsp"), - REG_KEM!(NTRUHPS4096821, "round3/ntru/ntruhps4096821/PQCkemKAT_1590.rsp"), - REG_KEM!(NTRUHPS2048509, "round3/ntru/ntruhps2048509/PQCkemKAT_935.rsp"), - REG_KEM!(NTRUHRSS701, "round3/ntru/ntruhrss701/PQCkemKAT_1450.rsp"), - REG_KEM!(NTRUHPS2048677, "round3/ntru/ntruhps2048677/PQCkemKAT_1234.rsp"), + //REG_KEM!(NTRUHPS4096821, "round3/ntru/ntruhps4096821/PQCkemKAT_1590.rsp"), + //REG_KEM!(NTRUHPS2048509, "round3/ntru/ntruhps2048509/PQCkemKAT_935.rsp"), + //REG_KEM!(NTRUHRSS701, "round3/ntru/ntruhrss701/PQCkemKAT_1450.rsp"), + //REG_KEM!(NTRUHPS2048677, "round3/ntru/ntruhps2048677/PQCkemKAT_1234.rsp"), // For some reason NTRUL doesn't pass the tests (keygeneration) //REG_KEM!(NTRULPR761, "round3/ntrup/ntrulpr761/kat_kem.rsp"), //REG_KEM!(NTRULPR653, "round3/ntrup/ntrulpr653/kat_kem.rsp"), //REG_KEM!(NTRULPR857, "round3/ntrup/ntrulpr857/kat_kem.rsp"), - REG_KEM!(LIGHTSABER, "round3/saber/LightSaber/PQCkemKAT_1568.rsp"), - REG_KEM!(FIRESABER, "round3/saber/FireSaber/PQCkemKAT_3040.rsp"), - REG_KEM!(SABER, "round3/saber/Saber/PQCkemKAT_2304.rsp"), - REG_KEM!(HQCRMRS128, "round3/hqc/hqc-128/hqc-128_kat.rsp"), - REG_KEM!(HQCRMRS192, "round3/hqc/hqc-192/hqc-192_kat.rsp"), - REG_KEM!(HQCRMRS256, "round3/hqc/hqc-256/hqc-256_kat.rsp"), + //REG_KEM!(LIGHTSABER, "round3/saber/LightSaber/PQCkemKAT_1568.rsp"), + //REG_KEM!(FIRESABER, "round3/saber/FireSaber/PQCkemKAT_3040.rsp"), + //REG_KEM!(SABER, "round3/saber/Saber/PQCkemKAT_2304.rsp"), + //REG_KEM!(HQCRMRS128, "round3/hqc/hqc-128/hqc-128_kat.rsp"), + //REG_KEM!(HQCRMRS192, "round3/hqc/hqc-192/hqc-192_kat.rsp"), + //REG_KEM!(HQCRMRS256, "round3/hqc/hqc-256/hqc-256_kat.rsp"), // Those are Round2. KATs are very big, so skip testing until it makes sense to do so. //REG_SIGN!(RAINBOWVCLASSIC),