X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/e5b61a8dec3586f96d25bd3ef454176526ff0f69..bd6d65e32b835551677456bf286d09ced6859882:/symm/whirlpool.c diff --git a/symm/whirlpool.c b/symm/whirlpool.c index ff517ce1..f22a366a 100644 --- a/symm/whirlpool.c +++ b/symm/whirlpool.c @@ -206,7 +206,7 @@ void whirlpool_set(whirlpool_ctx *ctx, const void *buf, unsigned long count) } ctx->off = 0; ctx->nl = U32(count); - ctx->nh = U32(((count & ~MASK32) >> 16) >> 16); + ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16); } /* --- @whirlpool_hash@, @whirlpool256_hash@ --- * @@ -294,10 +294,31 @@ unsigned long whirlpool_state(whirlpool_ctx *ctx, void *state) /* --- Generic interface --- */ -GHASH_DEF(WHIRLPOOL, whirlpool) +#define HASHES(_) \ + _(WHIRLPOOL, whirlpool) \ + _(WHIRLPOOL256, whirlpool256) -/* --- Test code --- */ +HASHES(GHASH_DEF) -HASH_TEST(WHIRLPOOL, whirlpool) +/*----- Test rig ----------------------------------------------------------*/ + +#ifdef TEST_RIG + +#include + +HASHES(HASH_VERIFY) + +static const test_chunk defs[] = { + HASHES(HASH_TESTDEFS) + { 0, 0, { 0 } } +}; + +int main(int argc, char *argv[]) +{ + test_run(argc, argv, defs, SRCDIR "/t/whirlpool"); + return (0); +} + +#endif /*----- That's all, folks -------------------------------------------------*/