catcrypt.c, catsign.c: Shorten chunk sizes.
[u/mdw/catacomb] / rmd160.c
index 3d56e0d..f481209 100644 (file)
--- a/rmd160.c
+++ b/rmd160.c
@@ -1,13 +1,13 @@
 /* -*-c-*-
  *
- * $Id: rmd160.c,v 1.3 2000/06/17 11:31:43 mdw Exp $
+ * $Id: rmd160.c,v 1.4 2004/04/08 01:36:15 mdw Exp $
  *
  * The RIPEMD-160 message digest function
  *
  * (c) 1998 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Catacomb.
  *
  * 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: 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.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <mLib/bits.h>
@@ -117,19 +103,19 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   F1(e, a, b, c, d,  1, 14);
   F1(d, e, a, b, c,  2, 15);
   F1(c, d, e, a, b,  3, 12);
-  F1(b, c, d, e, a,  4,  5);
-  F1(a, b, c, d, e,  5,  8);
-  F1(e, a, b, c, d,  6,  7);
-  F1(d, e, a, b, c,  7,  9);
+  F1(b, c, d, e, a,  4,         5);
+  F1(a, b, c, d, e,  5,         8);
+  F1(e, a, b, c, d,  6,         7);
+  F1(d, e, a, b, c,  7,         9);
   F1(c, d, e, a, b,  8, 11);
   F1(b, c, d, e, a,  9, 13);
   F1(a, b, c, d, e, 10, 14);
   F1(e, a, b, c, d, 11, 15);
-  F1(d, e, a, b, c, 12,  6);
-  F1(c, d, e, a, b, 13,  7);
-  F1(b, c, d, e, a, 14,  9);
-  F1(a, b, c, d, e, 15,  8);
-                  
+  F1(d, e, a, b, c, 12,         6);
+  F1(c, d, e, a, b, 13,         7);
+  F1(b, c, d, e, a, 14,         9);
+  F1(a, b, c, d, e, 15,         8);
+
   G1(e, a, b, c, d,  7,         7);
   G1(d, e, a, b, c,  4,         6);
   G1(c, d, e, a, b, 13,         8);
@@ -146,7 +132,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   G1(b, c, d, e, a, 14,         7);
   G1(a, b, c, d, e, 11,        13);
   G1(e, a, b, c, d,  8,        12);
-                  
+
   H1(d, e, a, b, c,  3,        11);
   H1(c, d, e, a, b, 10,        13);
   H1(b, c, d, e, a, 14,         6);
@@ -163,7 +149,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   H1(a, b, c, d, e, 11,        12);
   H1(e, a, b, c, d,  5,         7);
   H1(d, e, a, b, c, 12,         5);
-                  
+
   I1(c, d, e, a, b,  1,        11);
   I1(b, c, d, e, a,  9,        12);
   I1(a, b, c, d, e, 11,        14);
@@ -180,7 +166,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   I1(e, a, b, c, d,  5,         6);
   I1(d, e, a, b, c,  6,         5);
   I1(c, d, e, a, b,  2,        12);
-                  
+
   J1(b, c, d, e, a,  4,         9);
   J1(a, b, c, d, e,  0,        15);
   J1(e, a, b, c, d,  5,         5);
@@ -216,7 +202,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   F2(C, D, E, A, B, 10,        14);
   F2(B, C, D, E, A,  3,        12);
   F2(A, B, C, D, E, 12,         6);
-                  
+
   G2(E, A, B, C, D,  6,         9);
   G2(D, E, A, B, C, 11,        13);
   G2(C, D, E, A, B,  3,        15);
@@ -233,7 +219,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   G2(B, C, D, E, A,  9,        15);
   G2(A, B, C, D, E,  1,        13);
   G2(E, A, B, C, D,  2,        11);
-                  
+
   H2(D, E, A, B, C, 15,         9);
   H2(C, D, E, A, B,  5,         7);
   H2(B, C, D, E, A,  1,        15);
@@ -250,7 +236,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   H2(A, B, C, D, E,  0,        13);
   H2(E, A, B, C, D,  4,         7);
   H2(D, E, A, B, C, 13,         5);
-                  
+
   I2(C, D, E, A, B,  8,        15);
   I2(B, C, D, E, A,  6,         5);
   I2(A, B, C, D, E,  4,         8);
@@ -267,7 +253,7 @@ void rmd160_compress(rmd160_ctx *ctx, const void *sbuf)
   I2(E, A, B, C, D,  7,         5);
   I2(D, E, A, B, C, 10,        15);
   I2(C, D, E, A, B, 14,         8);
-                  
+
   J2(B, C, D, E, A, 12,         8);
   J2(A, B, C, D, E, 15,         5);
   J2(E, A, B, C, D, 10,        12);
@@ -334,9 +320,9 @@ void rmd160_init(rmd160_ctx *ctx)
 void rmd160_set(rmd160_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->e = LOAD32_L(p + 16);
   ctx->off = 0;
@@ -375,9 +361,9 @@ void rmd160_done(rmd160_ctx *ctx, void *hash)
 {
   octet *p = hash;
   HASH_MD5STRENGTH(RMD160, rmd160, 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->e);
 }
@@ -396,9 +382,9 @@ void rmd160_done(rmd160_ctx *ctx, void *hash)
 unsigned long rmd160_state(rmd160_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->e);
   return (ctx->nl | ((ctx->nh << 16) << 16));