X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/1c64c8e2eafc1085d80485dc5104a73818373773..5d01b1b9514a258c5a3c201e944f676cb2c467f0:/rmd256.c diff --git a/rmd256.c b/rmd256.c index fe6f4c1..e2fc70a 100644 --- a/rmd256.c +++ b/rmd256.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: rmd256.c,v 1.1 2000/07/09 21:30:31 mdw Exp $ + * $Id: rmd256.c,v 1.3 2004/04/08 01:36:15 mdw Exp $ * * The RIPEMD-256 message digest function * * (c) 1998 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,26 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: rmd256.c,v $ - * Revision 1.1 2000/07/09 21:30:31 mdw - * New RIPEMD variants. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -99,13 +91,13 @@ void rmd256_compress(rmd256_ctx *ctx, const void *sbuf) #define G1(w, x, y, z, i, r) T(w, x, y, z, i, r, G, 0x5a827999) #define H1(w, x, y, z, i, r) T(w, x, y, z, i, r, H, 0x6ed9eba1) #define I1(w, x, y, z, i, r) T(w, x, y, z, i, r, I, 0x8f1bbcdc) - + #define F2(w, x, y, z, i, r) T(w, x, y, z, i, r, I, 0x50a28be6) #define G2(w, x, y, z, i, r) T(w, x, y, z, i, r, H, 0x5c4dd124) #define H2(w, x, y, z, i, r) T(w, x, y, z, i, r, G, 0x6d703ef3) #define I2(w, x, y, z, i, r) T(w, x, y, z, i, r, F, 0x00000000) - /* --- First the left hand side --- */ + /* --- We must do both sides together --- */ F1(a, b, c, d, 0, 11); F1(d, a, b, c, 1, 14); @@ -225,7 +217,7 @@ void rmd256_compress(rmd256_ctx *ctx, const void *sbuf) I1(d, A, B, C, 5, 6); I1(C, d, A, B, 6, 5); I1(B, C, d, A, 2, 12); - + I2(a, b, c, D, 8, 15); I2(D, a, b, c, 6, 5); I2(c, D, a, b, 4, 8); @@ -242,7 +234,7 @@ void rmd256_compress(rmd256_ctx *ctx, const void *sbuf) I2(D, a, b, c, 7, 5); I2(c, D, a, b, 10, 15); I2(b, c, D, a, 14, 8); - + /* --- Recombine the two halves --- */ ctx->a += A; @@ -294,9 +286,9 @@ void rmd256_init(rmd256_ctx *ctx) void rmd256_set(rmd256_ctx *ctx, const void *buf, unsigned long count) { const octet *p = buf; - ctx->a = LOAD32_L(p + 0); - ctx->b = LOAD32_L(p + 4); - ctx->c = LOAD32_L(p + 8); + ctx->a = LOAD32_L(p + 0); + ctx->b = LOAD32_L(p + 4); + ctx->c = LOAD32_L(p + 8); ctx->d = LOAD32_L(p + 12); ctx->A = LOAD32_L(p + 16); ctx->B = LOAD32_L(p + 20); @@ -338,9 +330,9 @@ void rmd256_done(rmd256_ctx *ctx, void *hash) { octet *p = hash; HASH_MD5STRENGTH(RMD256, rmd256, ctx); - STORE32_L(p + 0, ctx->a); - STORE32_L(p + 4, ctx->b); - STORE32_L(p + 8, ctx->c); + STORE32_L(p + 0, ctx->a); + STORE32_L(p + 4, ctx->b); + STORE32_L(p + 8, ctx->c); STORE32_L(p + 12, ctx->d); STORE32_L(p + 16, ctx->A); STORE32_L(p + 20, ctx->B); @@ -362,9 +354,9 @@ void rmd256_done(rmd256_ctx *ctx, void *hash) unsigned long rmd256_state(rmd256_ctx *ctx, void *state) { octet *p = state; - STORE32_L(p + 0, ctx->a); - STORE32_L(p + 4, ctx->b); - STORE32_L(p + 8, ctx->c); + STORE32_L(p + 0, ctx->a); + STORE32_L(p + 4, ctx->b); + STORE32_L(p + 8, ctx->c); STORE32_L(p + 12, ctx->d); STORE32_L(p + 16, ctx->A); STORE32_L(p + 20, ctx->B);