diff options
Diffstat (limited to 'src/crypto/keccak.c')
-rw-r--r-- | src/crypto/keccak.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c index 533021af3..de8e2a5b3 100644 --- a/src/crypto/keccak.c +++ b/src/crypto/keccak.c @@ -4,9 +4,20 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "hash-ops.h" #include "keccak.h" +static void local_abort(const char *msg) +{ + fprintf(stderr, "%s\n", msg); +#ifdef NDEBUG + _exit(1); +#else + abort(); +#endif +} + const uint64_t keccakf_rndc[24] = { 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, @@ -84,8 +95,7 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) static_assert(HASH_DATA_AREA <= sizeof(temp), "Bad keccak preconditions"); if (mdlen <= 0 || (mdlen > 100 && sizeof(st) != (size_t)mdlen)) { - fprintf(stderr, "Bad keccak use"); - abort(); + local_abort("Bad keccak use"); } rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; @@ -102,8 +112,7 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) // last block and padding if (inlen + 1 >= sizeof(temp) || inlen > rsiz || rsiz - inlen + inlen + 1 >= sizeof(temp) || rsiz == 0 || rsiz - 1 >= sizeof(temp) || rsizw * 8 > sizeof(temp)) { - fprintf(stderr, "Bad keccak use"); - abort(); + local_abort("Bad keccak use"); } memcpy(temp, in, inlen); |