X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d03ab969116fe715d569304c1c474749b2f64529..f41f820e4b3e230d9314cc4323abf59babdd4e67:/rmd160.c diff --git a/rmd160.c b/rmd160.c index a42c21c..3d56e0d 100644 --- a/rmd160.c +++ b/rmd160.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rmd160.c,v 1.1 1999/09/03 08:41:12 mdw Exp $ + * $Id: rmd160.c,v 1.3 2000/06/17 11:31:43 mdw Exp $ * * The RIPEMD-160 message digest function * @@ -30,6 +30,12 @@ /*----- Revision history --------------------------------------------------* * * $Log: rmd160.c,v $ + * Revision 1.3 2000/06/17 11:31:43 mdw + * Portability fix for broken compilers. + * + * Revision 1.2 1999/12/10 23:20:03 mdw + * New hash interface requirements. + * * Revision 1.1 1999/09/03 08:41:12 mdw * Initial import. * @@ -39,6 +45,8 @@ #include +#include "ghash.h" +#include "ghash-def.h" #include "hash.h" #include "rmd160.h" @@ -307,7 +315,7 @@ void rmd160_init(rmd160_ctx *ctx) ctx->d = 0x10325476; ctx->e = 0xc3d2e1f0; ctx->off = 0; - ctx->count = 0; + ctx->nl = ctx->nh = 0; } /* --- @rmd160_set@ --- * @@ -332,7 +340,8 @@ void rmd160_set(rmd160_ctx *ctx, const void *buf, unsigned long count) ctx->d = LOAD32_L(p + 12); ctx->e = LOAD32_L(p + 16); ctx->off = 0; - ctx->count = count; + ctx->nl = U32(count); + ctx->nh = U32(((count & ~MASK32) >> 16) >> 16); } /* --- @rmd160_hash@ --- * @@ -392,9 +401,13 @@ unsigned long rmd160_state(rmd160_ctx *ctx, void *state) STORE32_L(p + 8, ctx->c); STORE32_L(p + 12, ctx->d); STORE32_L(p + 16, ctx->e); - return (ctx->count); + return (ctx->nl | ((ctx->nh << 16) << 16)); } +/* --- Generic interface --- */ + +GHASH_DEF(RMD160, rmd160) + /* --- Test code --- */ HASH_TEST(RMD160, rmd160)