diff options
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -5,10 +5,23 @@ # pragma clang diagnostic ignored "-Wcomma" # pragma clang diagnostic ignored "-Wcovered-switch-default" #endif + +#if defined(SUPPORT_SHA0) || defined(SUPPORT_SHA1) +# define LIBHASHSUM_INCLUDE_LIBSHA1_STATE +#endif +#if defined(SUPPORT_SHA2) +# define LIBHASHSUM_INCLUDE_LIBSHA2_STATE +#endif +#if defined(SUPPORT_KECCAK) || defined(SUPPORT_SHA3) || defined(SUPPORT_SHAKE) || defined(SUPPORT_RAWSHAKE) +# define LIBHASHSUM_INCLUDE_LIBKECCAK_STATE +#endif + #include "libhashsum.h" #include <ctype.h> #include <errno.h> #include <limits.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> @@ -17,10 +30,14 @@ __attribute__((__const__)) #endif uint8_t libhashsum_reverse_byte__(uint8_t); +#ifdef LIBHASHSUM_INCLUDE_LIBKECCAK_STATE +int libhashsum_init_keccak__(struct libhashsum_hasher *this, size_t hashbits, void *spec, const char *suffix); +#endif + +#define KECCAKN(N) 1600 - 2 * (N), 2 * (N), (N) + #ifdef TEST -# include <stdlib.h> -# include <stdio.h> struct testcase { size_t input_repeat; @@ -181,6 +198,8 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz fprintf(stderr, "[\033[1;%s\033[m] %s(%zu * \"%s\"%s) = %s\n", caseok ? "32mPASS" : "31mFAIL", name, testcases[i].input_repeat, input, bitstr, hexsum); free(input); + if (hasher.destroy) + hasher.destroy(&hasher); } return !ok; } |