From 7dc03bfc44ba883472a72f9f7893264f92a45e23 Mon Sep 17 00:00:00 2001 From: Thom Wiggers Date: Thu, 12 Dec 2019 14:11:12 +0100 Subject: [PATCH] Specify arrays with sizes again --- crypto_sign/dilithium2/avx2/api.h | 1 + crypto_sign/dilithium2/avx2/packing.c | 28 +++++++++++----------- crypto_sign/dilithium2/avx2/packing.h | 32 +++++++++++++++----------- crypto_sign/dilithium2/avx2/params.h | 4 ---- crypto_sign/dilithium2/clean/api.h | 1 + crypto_sign/dilithium2/clean/packing.c | 28 +++++++++++----------- crypto_sign/dilithium2/clean/packing.h | 32 +++++++++++++++----------- crypto_sign/dilithium2/clean/params.h | 4 ---- crypto_sign/dilithium3/avx2/api.h | 1 + crypto_sign/dilithium3/avx2/packing.c | 28 +++++++++++----------- crypto_sign/dilithium3/avx2/packing.h | 32 +++++++++++++++----------- crypto_sign/dilithium3/avx2/params.h | 4 ---- crypto_sign/dilithium3/clean/api.h | 1 + crypto_sign/dilithium3/clean/packing.c | 28 +++++++++++----------- crypto_sign/dilithium3/clean/packing.h | 32 +++++++++++++++----------- crypto_sign/dilithium3/clean/params.h | 4 ---- crypto_sign/dilithium4/avx2/api.h | 1 + crypto_sign/dilithium4/avx2/packing.c | 28 +++++++++++----------- crypto_sign/dilithium4/avx2/packing.h | 32 +++++++++++++++----------- crypto_sign/dilithium4/avx2/params.h | 4 ---- crypto_sign/dilithium4/clean/api.h | 1 + crypto_sign/dilithium4/clean/packing.c | 28 +++++++++++----------- crypto_sign/dilithium4/clean/packing.h | 32 +++++++++++++++----------- crypto_sign/dilithium4/clean/params.h | 4 ---- 24 files changed, 204 insertions(+), 186 deletions(-) diff --git a/crypto_sign/dilithium2/avx2/api.h b/crypto_sign/dilithium2/avx2/api.h index d4c2bc08..c8375d00 100644 --- a/crypto_sign/dilithium2/avx2/api.h +++ b/crypto_sign/dilithium2/avx2/api.h @@ -4,6 +4,7 @@ #include #include + #define PQCLEAN_DILITHIUM2_AVX2_CRYPTO_PUBLICKEYBYTES 1184U #define PQCLEAN_DILITHIUM2_AVX2_CRYPTO_SECRETKEYBYTES 2800U #define PQCLEAN_DILITHIUM2_AVX2_CRYPTO_BYTES 2044U diff --git a/crypto_sign/dilithium2/avx2/packing.c b/crypto_sign/dilithium2/avx2/packing.c index d322ae88..aedef4e7 100644 --- a/crypto_sign/dilithium2/avx2/packing.c +++ b/crypto_sign/dilithium2/avx2/packing.c @@ -13,8 +13,8 @@ * - const polyveck *t1: pointer to vector t1 **************************************************/ void PQCLEAN_DILITHIUM2_AVX2_pack_pk( - uint8_t *pk, - const uint8_t *rho, + uint8_t pk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1) { for (size_t i = 0; i < SEEDBYTES; ++i) { pk[i] = rho[i]; @@ -36,9 +36,9 @@ void PQCLEAN_DILITHIUM2_AVX2_pack_pk( * - uint8_t pk[]: byte array containing bit-packed pk **************************************************/ void PQCLEAN_DILITHIUM2_AVX2_unpack_pk( - uint8_t *rho, + uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t *pk) { + const uint8_t pk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_PUBLICKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = pk[i]; } @@ -63,10 +63,10 @@ void PQCLEAN_DILITHIUM2_AVX2_unpack_pk( * - const polyveck *t0: pointer to vector t0 **************************************************/ void PQCLEAN_DILITHIUM2_AVX2_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0) { @@ -114,13 +114,13 @@ void PQCLEAN_DILITHIUM2_AVX2_pack_sk( * - uint8_t sk[]: byte array containing bit-packed sk **************************************************/ void PQCLEAN_DILITHIUM2_AVX2_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, - const uint8_t *sk) { + const uint8_t sk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_SECRETKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = sk[i]; } @@ -162,7 +162,7 @@ void PQCLEAN_DILITHIUM2_AVX2_unpack_sk( * - const poly *c: pointer to challenge polynomial **************************************************/ void PQCLEAN_DILITHIUM2_AVX2_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c) { @@ -228,7 +228,7 @@ int PQCLEAN_DILITHIUM2_AVX2_unpack_sig( polyvecl *z, polyveck *h, poly *c, - const uint8_t *sig) { + const uint8_t sig[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_BYTES]) { size_t k; uint64_t signs; diff --git a/crypto_sign/dilithium2/avx2/packing.h b/crypto_sign/dilithium2/avx2/packing.h index c8f90729..42e97930 100644 --- a/crypto_sign/dilithium2/avx2/packing.h +++ b/crypto_sign/dilithium2/avx2/packing.h @@ -1,36 +1,42 @@ #ifndef PQCLEAN_DILITHIUM2_AVX2_PACKING_H #define PQCLEAN_DILITHIUM2_AVX2_PACKING_H +#include "api.h" #include "params.h" #include "polyvec.h" void PQCLEAN_DILITHIUM2_AVX2_pack_pk( - uint8_t *pk, - const uint8_t *rho, const polyveck *t1); + uint8_t pk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1); void PQCLEAN_DILITHIUM2_AVX2_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[SEEDBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0); void PQCLEAN_DILITHIUM2_AVX2_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c); void PQCLEAN_DILITHIUM2_AVX2_unpack_pk( - uint8_t *rho, polyveck *t1, - const uint8_t *pk); + uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_PUBLICKEYBYTES]); void PQCLEAN_DILITHIUM2_AVX2_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, const uint8_t *sk); int PQCLEAN_DILITHIUM2_AVX2_unpack_sig( - polyvecl *z, polyveck *h, poly *c, const uint8_t *sig); + polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[PQCLEAN_DILITHIUM2_AVX2_CRYPTO_BYTES]); #endif diff --git a/crypto_sign/dilithium2/avx2/params.h b/crypto_sign/dilithium2/avx2/params.h index dc6f130b..5d5068cd 100644 --- a/crypto_sign/dilithium2/avx2/params.h +++ b/crypto_sign/dilithium2/avx2/params.h @@ -26,8 +26,4 @@ #define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) #define POLW1_SIZE_PACKED ((N*4)/8) -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - #endif diff --git a/crypto_sign/dilithium2/clean/api.h b/crypto_sign/dilithium2/clean/api.h index ce2d43ae..1053371a 100644 --- a/crypto_sign/dilithium2/clean/api.h +++ b/crypto_sign/dilithium2/clean/api.h @@ -4,6 +4,7 @@ #include #include + #define PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_PUBLICKEYBYTES 1184U #define PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_SECRETKEYBYTES 2800U #define PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_BYTES 2044U diff --git a/crypto_sign/dilithium2/clean/packing.c b/crypto_sign/dilithium2/clean/packing.c index d86e9fe2..d91fe1ab 100644 --- a/crypto_sign/dilithium2/clean/packing.c +++ b/crypto_sign/dilithium2/clean/packing.c @@ -13,8 +13,8 @@ * - const polyveck *t1: pointer to vector t1 **************************************************/ void PQCLEAN_DILITHIUM2_CLEAN_pack_pk( - uint8_t *pk, - const uint8_t *rho, + uint8_t pk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1) { for (size_t i = 0; i < SEEDBYTES; ++i) { pk[i] = rho[i]; @@ -36,9 +36,9 @@ void PQCLEAN_DILITHIUM2_CLEAN_pack_pk( * - uint8_t pk[]: byte array containing bit-packed pk **************************************************/ void PQCLEAN_DILITHIUM2_CLEAN_unpack_pk( - uint8_t *rho, + uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t *pk) { + const uint8_t pk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_PUBLICKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = pk[i]; } @@ -63,10 +63,10 @@ void PQCLEAN_DILITHIUM2_CLEAN_unpack_pk( * - const polyveck *t0: pointer to vector t0 **************************************************/ void PQCLEAN_DILITHIUM2_CLEAN_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0) { @@ -114,13 +114,13 @@ void PQCLEAN_DILITHIUM2_CLEAN_pack_sk( * - uint8_t sk[]: byte array containing bit-packed sk **************************************************/ void PQCLEAN_DILITHIUM2_CLEAN_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, - const uint8_t *sk) { + const uint8_t sk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_SECRETKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = sk[i]; } @@ -162,7 +162,7 @@ void PQCLEAN_DILITHIUM2_CLEAN_unpack_sk( * - const poly *c: pointer to challenge polynomial **************************************************/ void PQCLEAN_DILITHIUM2_CLEAN_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c) { @@ -228,7 +228,7 @@ int PQCLEAN_DILITHIUM2_CLEAN_unpack_sig( polyvecl *z, polyveck *h, poly *c, - const uint8_t *sig) { + const uint8_t sig[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_BYTES]) { size_t k; uint64_t signs; diff --git a/crypto_sign/dilithium2/clean/packing.h b/crypto_sign/dilithium2/clean/packing.h index 7207a66c..16377f9c 100644 --- a/crypto_sign/dilithium2/clean/packing.h +++ b/crypto_sign/dilithium2/clean/packing.h @@ -1,36 +1,42 @@ #ifndef PQCLEAN_DILITHIUM2_CLEAN_PACKING_H #define PQCLEAN_DILITHIUM2_CLEAN_PACKING_H +#include "api.h" #include "params.h" #include "polyvec.h" void PQCLEAN_DILITHIUM2_CLEAN_pack_pk( - uint8_t *pk, - const uint8_t *rho, const polyveck *t1); + uint8_t pk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1); void PQCLEAN_DILITHIUM2_CLEAN_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[SEEDBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0); void PQCLEAN_DILITHIUM2_CLEAN_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c); void PQCLEAN_DILITHIUM2_CLEAN_unpack_pk( - uint8_t *rho, polyveck *t1, - const uint8_t *pk); + uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_PUBLICKEYBYTES]); void PQCLEAN_DILITHIUM2_CLEAN_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, const uint8_t *sk); int PQCLEAN_DILITHIUM2_CLEAN_unpack_sig( - polyvecl *z, polyveck *h, poly *c, const uint8_t *sig); + polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[PQCLEAN_DILITHIUM2_CLEAN_CRYPTO_BYTES]); #endif diff --git a/crypto_sign/dilithium2/clean/params.h b/crypto_sign/dilithium2/clean/params.h index b7505cbe..5d31774d 100644 --- a/crypto_sign/dilithium2/clean/params.h +++ b/crypto_sign/dilithium2/clean/params.h @@ -26,8 +26,4 @@ #define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) #define POLW1_SIZE_PACKED ((N*4)/8) -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - #endif diff --git a/crypto_sign/dilithium3/avx2/api.h b/crypto_sign/dilithium3/avx2/api.h index b5e5cbf7..a3f7603e 100644 --- a/crypto_sign/dilithium3/avx2/api.h +++ b/crypto_sign/dilithium3/avx2/api.h @@ -4,6 +4,7 @@ #include #include + #define PQCLEAN_DILITHIUM3_AVX2_CRYPTO_PUBLICKEYBYTES 1472U #define PQCLEAN_DILITHIUM3_AVX2_CRYPTO_SECRETKEYBYTES 3504U #define PQCLEAN_DILITHIUM3_AVX2_CRYPTO_BYTES 2701U diff --git a/crypto_sign/dilithium3/avx2/packing.c b/crypto_sign/dilithium3/avx2/packing.c index a65d8ff5..24b2bfff 100644 --- a/crypto_sign/dilithium3/avx2/packing.c +++ b/crypto_sign/dilithium3/avx2/packing.c @@ -13,8 +13,8 @@ * - const polyveck *t1: pointer to vector t1 **************************************************/ void PQCLEAN_DILITHIUM3_AVX2_pack_pk( - uint8_t *pk, - const uint8_t *rho, + uint8_t pk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1) { for (size_t i = 0; i < SEEDBYTES; ++i) { pk[i] = rho[i]; @@ -36,9 +36,9 @@ void PQCLEAN_DILITHIUM3_AVX2_pack_pk( * - uint8_t pk[]: byte array containing bit-packed pk **************************************************/ void PQCLEAN_DILITHIUM3_AVX2_unpack_pk( - uint8_t *rho, + uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t *pk) { + const uint8_t pk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_PUBLICKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = pk[i]; } @@ -63,10 +63,10 @@ void PQCLEAN_DILITHIUM3_AVX2_unpack_pk( * - const polyveck *t0: pointer to vector t0 **************************************************/ void PQCLEAN_DILITHIUM3_AVX2_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0) { @@ -114,13 +114,13 @@ void PQCLEAN_DILITHIUM3_AVX2_pack_sk( * - uint8_t sk[]: byte array containing bit-packed sk **************************************************/ void PQCLEAN_DILITHIUM3_AVX2_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, - const uint8_t *sk) { + const uint8_t sk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_SECRETKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = sk[i]; } @@ -162,7 +162,7 @@ void PQCLEAN_DILITHIUM3_AVX2_unpack_sk( * - const poly *c: pointer to challenge polynomial **************************************************/ void PQCLEAN_DILITHIUM3_AVX2_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c) { @@ -228,7 +228,7 @@ int PQCLEAN_DILITHIUM3_AVX2_unpack_sig( polyvecl *z, polyveck *h, poly *c, - const uint8_t *sig) { + const uint8_t sig[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_BYTES]) { size_t k; uint64_t signs; diff --git a/crypto_sign/dilithium3/avx2/packing.h b/crypto_sign/dilithium3/avx2/packing.h index 5fb7dc00..afee9223 100644 --- a/crypto_sign/dilithium3/avx2/packing.h +++ b/crypto_sign/dilithium3/avx2/packing.h @@ -1,36 +1,42 @@ #ifndef PQCLEAN_DILITHIUM3_AVX2_PACKING_H #define PQCLEAN_DILITHIUM3_AVX2_PACKING_H +#include "api.h" #include "params.h" #include "polyvec.h" void PQCLEAN_DILITHIUM3_AVX2_pack_pk( - uint8_t *pk, - const uint8_t *rho, const polyveck *t1); + uint8_t pk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1); void PQCLEAN_DILITHIUM3_AVX2_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[SEEDBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0); void PQCLEAN_DILITHIUM3_AVX2_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c); void PQCLEAN_DILITHIUM3_AVX2_unpack_pk( - uint8_t *rho, polyveck *t1, - const uint8_t *pk); + uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_PUBLICKEYBYTES]); void PQCLEAN_DILITHIUM3_AVX2_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, const uint8_t *sk); int PQCLEAN_DILITHIUM3_AVX2_unpack_sig( - polyvecl *z, polyveck *h, poly *c, const uint8_t *sig); + polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[PQCLEAN_DILITHIUM3_AVX2_CRYPTO_BYTES]); #endif diff --git a/crypto_sign/dilithium3/avx2/params.h b/crypto_sign/dilithium3/avx2/params.h index 727bee85..6096eaf1 100644 --- a/crypto_sign/dilithium3/avx2/params.h +++ b/crypto_sign/dilithium3/avx2/params.h @@ -26,8 +26,4 @@ #define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) #define POLW1_SIZE_PACKED ((N*4)/8) -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - #endif diff --git a/crypto_sign/dilithium3/clean/api.h b/crypto_sign/dilithium3/clean/api.h index 18def166..77809909 100644 --- a/crypto_sign/dilithium3/clean/api.h +++ b/crypto_sign/dilithium3/clean/api.h @@ -4,6 +4,7 @@ #include #include + #define PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_PUBLICKEYBYTES 1472U #define PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_SECRETKEYBYTES 3504U #define PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_BYTES 2701U diff --git a/crypto_sign/dilithium3/clean/packing.c b/crypto_sign/dilithium3/clean/packing.c index 8e3ab8c5..ebaee136 100644 --- a/crypto_sign/dilithium3/clean/packing.c +++ b/crypto_sign/dilithium3/clean/packing.c @@ -13,8 +13,8 @@ * - const polyveck *t1: pointer to vector t1 **************************************************/ void PQCLEAN_DILITHIUM3_CLEAN_pack_pk( - uint8_t *pk, - const uint8_t *rho, + uint8_t pk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1) { for (size_t i = 0; i < SEEDBYTES; ++i) { pk[i] = rho[i]; @@ -36,9 +36,9 @@ void PQCLEAN_DILITHIUM3_CLEAN_pack_pk( * - uint8_t pk[]: byte array containing bit-packed pk **************************************************/ void PQCLEAN_DILITHIUM3_CLEAN_unpack_pk( - uint8_t *rho, + uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t *pk) { + const uint8_t pk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_PUBLICKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = pk[i]; } @@ -63,10 +63,10 @@ void PQCLEAN_DILITHIUM3_CLEAN_unpack_pk( * - const polyveck *t0: pointer to vector t0 **************************************************/ void PQCLEAN_DILITHIUM3_CLEAN_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0) { @@ -114,13 +114,13 @@ void PQCLEAN_DILITHIUM3_CLEAN_pack_sk( * - uint8_t sk[]: byte array containing bit-packed sk **************************************************/ void PQCLEAN_DILITHIUM3_CLEAN_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, - const uint8_t *sk) { + const uint8_t sk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_SECRETKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = sk[i]; } @@ -162,7 +162,7 @@ void PQCLEAN_DILITHIUM3_CLEAN_unpack_sk( * - const poly *c: pointer to challenge polynomial **************************************************/ void PQCLEAN_DILITHIUM3_CLEAN_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c) { @@ -228,7 +228,7 @@ int PQCLEAN_DILITHIUM3_CLEAN_unpack_sig( polyvecl *z, polyveck *h, poly *c, - const uint8_t *sig) { + const uint8_t sig[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_BYTES]) { size_t k; uint64_t signs; diff --git a/crypto_sign/dilithium3/clean/packing.h b/crypto_sign/dilithium3/clean/packing.h index 298dac16..2900e869 100644 --- a/crypto_sign/dilithium3/clean/packing.h +++ b/crypto_sign/dilithium3/clean/packing.h @@ -1,36 +1,42 @@ #ifndef PQCLEAN_DILITHIUM3_CLEAN_PACKING_H #define PQCLEAN_DILITHIUM3_CLEAN_PACKING_H +#include "api.h" #include "params.h" #include "polyvec.h" void PQCLEAN_DILITHIUM3_CLEAN_pack_pk( - uint8_t *pk, - const uint8_t *rho, const polyveck *t1); + uint8_t pk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1); void PQCLEAN_DILITHIUM3_CLEAN_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[SEEDBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0); void PQCLEAN_DILITHIUM3_CLEAN_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c); void PQCLEAN_DILITHIUM3_CLEAN_unpack_pk( - uint8_t *rho, polyveck *t1, - const uint8_t *pk); + uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_PUBLICKEYBYTES]); void PQCLEAN_DILITHIUM3_CLEAN_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, const uint8_t *sk); int PQCLEAN_DILITHIUM3_CLEAN_unpack_sig( - polyvecl *z, polyveck *h, poly *c, const uint8_t *sig); + polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[PQCLEAN_DILITHIUM3_CLEAN_CRYPTO_BYTES]); #endif diff --git a/crypto_sign/dilithium3/clean/params.h b/crypto_sign/dilithium3/clean/params.h index 8632ac0f..a6b3739d 100644 --- a/crypto_sign/dilithium3/clean/params.h +++ b/crypto_sign/dilithium3/clean/params.h @@ -26,8 +26,4 @@ #define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) #define POLW1_SIZE_PACKED ((N*4)/8) -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - #endif diff --git a/crypto_sign/dilithium4/avx2/api.h b/crypto_sign/dilithium4/avx2/api.h index bfdd2770..b3d8059a 100644 --- a/crypto_sign/dilithium4/avx2/api.h +++ b/crypto_sign/dilithium4/avx2/api.h @@ -4,6 +4,7 @@ #include #include + #define PQCLEAN_DILITHIUM4_AVX2_CRYPTO_PUBLICKEYBYTES 1760U #define PQCLEAN_DILITHIUM4_AVX2_CRYPTO_SECRETKEYBYTES 3856U #define PQCLEAN_DILITHIUM4_AVX2_CRYPTO_BYTES 3366U diff --git a/crypto_sign/dilithium4/avx2/packing.c b/crypto_sign/dilithium4/avx2/packing.c index e9f6ca32..0e73aa8c 100644 --- a/crypto_sign/dilithium4/avx2/packing.c +++ b/crypto_sign/dilithium4/avx2/packing.c @@ -13,8 +13,8 @@ * - const polyveck *t1: pointer to vector t1 **************************************************/ void PQCLEAN_DILITHIUM4_AVX2_pack_pk( - uint8_t *pk, - const uint8_t *rho, + uint8_t pk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1) { for (size_t i = 0; i < SEEDBYTES; ++i) { pk[i] = rho[i]; @@ -36,9 +36,9 @@ void PQCLEAN_DILITHIUM4_AVX2_pack_pk( * - uint8_t pk[]: byte array containing bit-packed pk **************************************************/ void PQCLEAN_DILITHIUM4_AVX2_unpack_pk( - uint8_t *rho, + uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t *pk) { + const uint8_t pk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_PUBLICKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = pk[i]; } @@ -63,10 +63,10 @@ void PQCLEAN_DILITHIUM4_AVX2_unpack_pk( * - const polyveck *t0: pointer to vector t0 **************************************************/ void PQCLEAN_DILITHIUM4_AVX2_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0) { @@ -114,13 +114,13 @@ void PQCLEAN_DILITHIUM4_AVX2_pack_sk( * - uint8_t sk[]: byte array containing bit-packed sk **************************************************/ void PQCLEAN_DILITHIUM4_AVX2_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, - const uint8_t *sk) { + const uint8_t sk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_SECRETKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = sk[i]; } @@ -162,7 +162,7 @@ void PQCLEAN_DILITHIUM4_AVX2_unpack_sk( * - const poly *c: pointer to challenge polynomial **************************************************/ void PQCLEAN_DILITHIUM4_AVX2_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c) { @@ -228,7 +228,7 @@ int PQCLEAN_DILITHIUM4_AVX2_unpack_sig( polyvecl *z, polyveck *h, poly *c, - const uint8_t *sig) { + const uint8_t sig[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_BYTES]) { size_t k; uint64_t signs; diff --git a/crypto_sign/dilithium4/avx2/packing.h b/crypto_sign/dilithium4/avx2/packing.h index bcb234bd..979ec810 100644 --- a/crypto_sign/dilithium4/avx2/packing.h +++ b/crypto_sign/dilithium4/avx2/packing.h @@ -1,36 +1,42 @@ #ifndef PQCLEAN_DILITHIUM4_AVX2_PACKING_H #define PQCLEAN_DILITHIUM4_AVX2_PACKING_H +#include "api.h" #include "params.h" #include "polyvec.h" void PQCLEAN_DILITHIUM4_AVX2_pack_pk( - uint8_t *pk, - const uint8_t *rho, const polyveck *t1); + uint8_t pk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1); void PQCLEAN_DILITHIUM4_AVX2_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[SEEDBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0); void PQCLEAN_DILITHIUM4_AVX2_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c); void PQCLEAN_DILITHIUM4_AVX2_unpack_pk( - uint8_t *rho, polyveck *t1, - const uint8_t *pk); + uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_PUBLICKEYBYTES]); void PQCLEAN_DILITHIUM4_AVX2_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, const uint8_t *sk); int PQCLEAN_DILITHIUM4_AVX2_unpack_sig( - polyvecl *z, polyveck *h, poly *c, const uint8_t *sig); + polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[PQCLEAN_DILITHIUM4_AVX2_CRYPTO_BYTES]); #endif diff --git a/crypto_sign/dilithium4/avx2/params.h b/crypto_sign/dilithium4/avx2/params.h index 831285ee..54acba57 100644 --- a/crypto_sign/dilithium4/avx2/params.h +++ b/crypto_sign/dilithium4/avx2/params.h @@ -26,8 +26,4 @@ #define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) #define POLW1_SIZE_PACKED ((N*4)/8) -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - #endif diff --git a/crypto_sign/dilithium4/clean/api.h b/crypto_sign/dilithium4/clean/api.h index 75eca0bd..8231600f 100644 --- a/crypto_sign/dilithium4/clean/api.h +++ b/crypto_sign/dilithium4/clean/api.h @@ -4,6 +4,7 @@ #include #include + #define PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_PUBLICKEYBYTES 1760U #define PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_SECRETKEYBYTES 3856U #define PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_BYTES 3366U diff --git a/crypto_sign/dilithium4/clean/packing.c b/crypto_sign/dilithium4/clean/packing.c index 64826a42..4513baaa 100644 --- a/crypto_sign/dilithium4/clean/packing.c +++ b/crypto_sign/dilithium4/clean/packing.c @@ -13,8 +13,8 @@ * - const polyveck *t1: pointer to vector t1 **************************************************/ void PQCLEAN_DILITHIUM4_CLEAN_pack_pk( - uint8_t *pk, - const uint8_t *rho, + uint8_t pk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], const polyveck *t1) { for (size_t i = 0; i < SEEDBYTES; ++i) { pk[i] = rho[i]; @@ -36,9 +36,9 @@ void PQCLEAN_DILITHIUM4_CLEAN_pack_pk( * - uint8_t pk[]: byte array containing bit-packed pk **************************************************/ void PQCLEAN_DILITHIUM4_CLEAN_unpack_pk( - uint8_t *rho, + uint8_t rho[SEEDBYTES], polyveck *t1, - const uint8_t *pk) { + const uint8_t pk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_PUBLICKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = pk[i]; } @@ -63,10 +63,10 @@ void PQCLEAN_DILITHIUM4_CLEAN_unpack_pk( * - const polyveck *t0: pointer to vector t0 **************************************************/ void PQCLEAN_DILITHIUM4_CLEAN_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[CRHBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0) { @@ -114,13 +114,13 @@ void PQCLEAN_DILITHIUM4_CLEAN_pack_sk( * - uint8_t sk[]: byte array containing bit-packed sk **************************************************/ void PQCLEAN_DILITHIUM4_CLEAN_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, - const uint8_t *sk) { + const uint8_t sk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_SECRETKEYBYTES]) { for (size_t i = 0; i < SEEDBYTES; ++i) { rho[i] = sk[i]; } @@ -162,7 +162,7 @@ void PQCLEAN_DILITHIUM4_CLEAN_unpack_sk( * - const poly *c: pointer to challenge polynomial **************************************************/ void PQCLEAN_DILITHIUM4_CLEAN_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c) { @@ -228,7 +228,7 @@ int PQCLEAN_DILITHIUM4_CLEAN_unpack_sig( polyvecl *z, polyveck *h, poly *c, - const uint8_t *sig) { + const uint8_t sig[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_BYTES]) { size_t k; uint64_t signs; diff --git a/crypto_sign/dilithium4/clean/packing.h b/crypto_sign/dilithium4/clean/packing.h index 63b4856b..bc9929e4 100644 --- a/crypto_sign/dilithium4/clean/packing.h +++ b/crypto_sign/dilithium4/clean/packing.h @@ -1,36 +1,42 @@ #ifndef PQCLEAN_DILITHIUM4_CLEAN_PACKING_H #define PQCLEAN_DILITHIUM4_CLEAN_PACKING_H +#include "api.h" #include "params.h" #include "polyvec.h" void PQCLEAN_DILITHIUM4_CLEAN_pack_pk( - uint8_t *pk, - const uint8_t *rho, const polyveck *t1); + uint8_t pk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_PUBLICKEYBYTES], + const uint8_t rho[SEEDBYTES], + const polyveck *t1); void PQCLEAN_DILITHIUM4_CLEAN_pack_sk( - uint8_t *sk, - const uint8_t *rho, - const uint8_t *key, - const uint8_t *tr, + uint8_t sk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_SECRETKEYBYTES], + const uint8_t rho[SEEDBYTES], + const uint8_t key[SEEDBYTES], + const uint8_t tr[SEEDBYTES], const polyvecl *s1, const polyveck *s2, const polyveck *t0); void PQCLEAN_DILITHIUM4_CLEAN_pack_sig( - uint8_t *sig, + uint8_t sig[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_SECRETKEYBYTES], const polyvecl *z, const polyveck *h, const poly *c); void PQCLEAN_DILITHIUM4_CLEAN_unpack_pk( - uint8_t *rho, polyveck *t1, - const uint8_t *pk); + uint8_t rho[SEEDBYTES], + polyveck *t1, + const uint8_t pk[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_PUBLICKEYBYTES]); void PQCLEAN_DILITHIUM4_CLEAN_unpack_sk( - uint8_t *rho, - uint8_t *key, - uint8_t *tr, + uint8_t rho[SEEDBYTES], + uint8_t key[SEEDBYTES], + uint8_t tr[CRHBYTES], polyvecl *s1, polyveck *s2, polyveck *t0, const uint8_t *sk); int PQCLEAN_DILITHIUM4_CLEAN_unpack_sig( - polyvecl *z, polyveck *h, poly *c, const uint8_t *sig); + polyvecl *z, + polyveck *h, + poly *c, + const uint8_t sig[PQCLEAN_DILITHIUM4_CLEAN_CRYPTO_BYTES]); #endif diff --git a/crypto_sign/dilithium4/clean/params.h b/crypto_sign/dilithium4/clean/params.h index 5cfade78..ce21782d 100644 --- a/crypto_sign/dilithium4/clean/params.h +++ b/crypto_sign/dilithium4/clean/params.h @@ -26,8 +26,4 @@ #define POLZ_SIZE_PACKED ((N*(QBITS - 3))/8) #define POLW1_SIZE_PACKED ((N*4)/8) -#define CRYPTO_PUBLICKEYBYTES (SEEDBYTES + K*POLT1_SIZE_PACKED) -#define CRYPTO_SECRETKEYBYTES (2*SEEDBYTES + (L + K)*POLETA_SIZE_PACKED + CRHBYTES + K*POLT0_SIZE_PACKED) -#define CRYPTO_BYTES (L*POLZ_SIZE_PACKED + (OMEGA + K) + (N/8 + 8)) - #endif