diff options
Diffstat (limited to 'src/crypto/keccak.c')
-rw-r--r-- | src/crypto/keccak.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c index 528a5406b..de8e2a5b3 100644 --- a/src/crypto/keccak.c +++ b/src/crypto/keccak.c @@ -92,7 +92,8 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) uint8_t temp[144]; size_t i, rsiz, rsizw; - if (mdlen <= 0 || mdlen > 200 || sizeof(st) != 200) + static_assert(HASH_DATA_AREA <= sizeof(temp), "Bad keccak preconditions"); + if (mdlen <= 0 || (mdlen > 100 && sizeof(st) != (size_t)mdlen)) { local_abort("Bad keccak use"); } @@ -109,7 +110,7 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) } // last block and padding - if (inlen >= sizeof(temp) || inlen > rsiz || rsiz - inlen + inlen + 1 >= sizeof(temp) || rsiz == 0 || rsiz - 1 >= sizeof(temp) || rsizw * 8 > sizeof(temp)) + if (inlen + 1 >= sizeof(temp) || inlen > rsiz || rsiz - inlen + inlen + 1 >= sizeof(temp) || rsiz == 0 || rsiz - 1 >= sizeof(temp) || rsizw * 8 > sizeof(temp)) { local_abort("Bad keccak use"); } |