diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/hash.h b/crypto_sign/sphincs-shake256-128f-simple/clean/hash.h index aa2c0e97..e6675ac1 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/hash.h +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/hash.h @@ -12,11 +12,11 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_prf_addr( void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_gen_message_random( unsigned char *R, const unsigned char *sk_prf, const unsigned char *optrand, - const unsigned char *m, unsigned long long mlen); + const unsigned char *m, size_t mlen); void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message( unsigned char *digest, uint64_t *tree, uint32_t *leaf_idx, const unsigned char *R, const unsigned char *pk, - const unsigned char *m, unsigned long long mlen); + const unsigned char *m, size_t mlen); #endif 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 4206e917..82256c22 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/hash_shake256.c +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/hash_shake256.c @@ -35,7 +35,7 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_prf_addr( void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_gen_message_random( unsigned char *R, const unsigned char *sk_prf, const unsigned char *optrand, - const unsigned char *m, unsigned long long mlen) { + const unsigned char *m, size_t mlen) { uint64_t s_inc[26]; shake256_inc_init(s_inc); @@ -54,7 +54,7 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_gen_message_random( void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message( unsigned char *digest, uint64_t *tree, uint32_t *leaf_idx, const unsigned char *R, const unsigned char *pk, - const unsigned char *m, unsigned long long mlen) { + const unsigned char *m, size_t mlen) { #define SPX_TREE_BITS (SPX_TREE_HEIGHT * (SPX_D - 1)) #define SPX_TREE_BYTES ((SPX_TREE_BITS + 7) / 8) #define SPX_LEAF_BITS SPX_TREE_HEIGHT @@ -84,7 +84,7 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message( *tree &= (~(uint64_t)0) >> (64 - SPX_TREE_BITS); bufp += SPX_TREE_BYTES; - *leaf_idx = PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull( + *leaf_idx = (uint32_t)PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull( bufp, SPX_LEAF_BYTES); *leaf_idx &= (~(uint32_t)0) >> (32 - SPX_LEAF_BITS); } diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/sign.c b/crypto_sign/sphincs-shake256-128f-simple/clean/sign.c index 2ccc587f..156157db 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/sign.c +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/sign.c @@ -135,7 +135,7 @@ int PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_crypto_sign_signature( unsigned char optrand[SPX_N]; unsigned char mhash[SPX_FORS_MSG_BYTES]; unsigned char root[SPX_N]; - unsigned long long i; + uint32_t i; uint64_t tree; uint32_t idx_leaf; uint32_t wots_addr[8] = {0}; diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/utils.c b/crypto_sign/sphincs-shake256-128f-simple/clean/utils.c index ad1fd0f2..89bc884c 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/utils.c +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/utils.c @@ -1,21 +1,21 @@ +#include #include -#include "utils.h" #include "address.h" #include "hash.h" #include "params.h" #include "thash.h" +#include "utils.h" /** * Converts the value of 'in' to 'outlen' bytes in big-endian byte order. */ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_ull_to_bytes( - unsigned char *out, unsigned int outlen, unsigned long long in) { - int i; + unsigned char *out, size_t outlen, unsigned long long in) { /* Iterate over out in decreasing order, for big-endianness. */ - for (i = outlen - 1; i >= 0; i--) { - out[i] = in & 0xff; + for (size_t i = outlen; i > 0; i--) { + out[i - 1] = in & 0xff; in = in >> 8; } } @@ -24,11 +24,10 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_ull_to_bytes( * Converts the inlen bytes in 'in' from big-endian byte order to an integer. */ unsigned long long PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull( - const unsigned char *in, unsigned int inlen) { + const unsigned char *in, size_t inlen) { unsigned long long retval = 0; - unsigned int i; - for (i = 0; i < inlen; i++) { + for (size_t i = 0; i < inlen; i++) { retval |= ((unsigned long long)in[i]) << (8 * (inlen - 1 - i)); } return retval; diff --git a/crypto_sign/sphincs-shake256-128f-simple/clean/utils.h b/crypto_sign/sphincs-shake256-128f-simple/clean/utils.h index 6df8d916..05c32eb7 100644 --- a/crypto_sign/sphincs-shake256-128f-simple/clean/utils.h +++ b/crypto_sign/sphincs-shake256-128f-simple/clean/utils.h @@ -2,19 +2,20 @@ #define SPX_UTILS_H #include "params.h" +#include #include /** * Converts the value of 'in' to 'outlen' bytes in big-endian byte order. */ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_ull_to_bytes( - unsigned char *out, unsigned int outlen, unsigned long long in); + unsigned char *out, size_t outlen, unsigned long long in); /** * Converts the inlen bytes in 'in' from big-endian byte order to an integer. */ unsigned long long PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull( - const unsigned char *in, unsigned int inlen); + const unsigned char *in, size_t inlen); /** * Computes a root node given a leaf and an auth path.