From 6cb332cae5d32944dad95f0a6a6bf8e8498410f7 Mon Sep 17 00:00:00 2001 From: Joost Rijneveld Date: Tue, 9 Apr 2019 17:32:28 +0200 Subject: [PATCH] Remove conditional preprocessor statements --- .../clean/address.c | 3 -- .../clean/hash_shake256.c | 4 --- .../clean/params.h | 32 ++----------------- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/address.c b/crypto_sign/sphincs-shake256-128f-simple/clean/address.c index 50badab5..0cf69534 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/address.c +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/address.c @@ -20,9 +20,6 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_set_layer_addr( void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_set_tree_addr( uint32_t addr[8], uint64_t tree) { - #if (SPX_TREE_HEIGHT * (SPX_D - 1)) > 64 -#error Subtree addressing is currently limited to at most 2^64 trees - #endif addr[1] = 0; addr[2] = (uint32_t) (tree >> 32); addr[3] = (uint32_t) tree; diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/hash_shake256.c b/crypto_sign/sphincs-shake256-128f-simple/clean/hash_shake256.c index 82256c22..a7ab8e15 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/hash_shake256.c +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/hash_shake256.c @@ -75,10 +75,6 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message( memcpy(digest, bufp, SPX_FORS_MSG_BYTES); bufp += SPX_FORS_MSG_BYTES; - #if SPX_TREE_BITS > 64 -#error For given height and depth, 64 bits cannot represent all subtrees - #endif - *tree = PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull( bufp, SPX_TREE_BYTES); *tree &= (~(uint64_t)0) >> (64 - SPX_TREE_BITS); diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/params.h b/crypto_sign/sphincs-shake256-128f-simple/clean/params.h index 1efe4dba..367ef88d 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/params.h +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/params.h @@ -20,36 +20,12 @@ #define SPX_ADDR_BYTES 32 /* WOTS parameters. */ -#if SPX_WOTS_W == 256 - #define SPX_WOTS_LOGW 8 -#elif SPX_WOTS_W == 16 - #define SPX_WOTS_LOGW 4 -#else - #error SPX_WOTS_W assumed 16 or 256 -#endif +#define SPX_WOTS_LOGW 4 #define SPX_WOTS_LEN1 (8 * SPX_N / SPX_WOTS_LOGW) /* SPX_WOTS_LEN2 is floor(log(len_1 * (w - 1)) / log(w)) + 1; we precompute */ -#if SPX_WOTS_W == 256 - #if SPX_N <= 1 - #define SPX_WOTS_LEN2 1 - #elif SPX_N <= 256 - #define SPX_WOTS_LEN2 2 - #else - #error Did not precompute SPX_WOTS_LEN2 for n outside {2, .., 256} - #endif -#elif SPX_WOTS_W == 16 - #if SPX_N <= 8 - #define SPX_WOTS_LEN2 2 - #elif SPX_N <= 136 - #define SPX_WOTS_LEN2 3 - #elif SPX_N <= 256 - #define SPX_WOTS_LEN2 4 - #else - #error Did not precompute SPX_WOTS_LEN2 for n outside {2, .., 256} - #endif -#endif +#define SPX_WOTS_LEN2 3 #define SPX_WOTS_LEN (SPX_WOTS_LEN1 + SPX_WOTS_LEN2) #define SPX_WOTS_BYTES (SPX_WOTS_LEN * SPX_N) @@ -58,10 +34,6 @@ /* Subtree size. */ #define SPX_TREE_HEIGHT (SPX_FULL_HEIGHT / SPX_D) -#if SPX_TREE_HEIGHT * SPX_D != SPX_FULL_HEIGHT - #error SPX_D should always divide SPX_FULL_HEIGHT -#endif - /* FORS parameters. */ #define SPX_FORS_MSG_BYTES ((SPX_FORS_HEIGHT * SPX_FORS_TREES + 7) / 8) #define SPX_FORS_BYTES ((SPX_FORS_HEIGHT + 1) * SPX_FORS_TREES * SPX_N)