--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: rmd128.c,v 1.1 2000/07/09 21:30:31 mdw Exp $
+ *
+ * The RIPEMD-128 message digest function
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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: rmd128.c,v $
+ * Revision 1.1 2000/07/09 21:30:31 mdw
+ * New RIPEMD variants.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "rmd128.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @rmd128_compress@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: RIPEMD-128 compression function.
+ */
+
+void rmd128_compress(rmd128_ctx *ctx, const void *sbuf)
+{
+ uint32 a, b, c, d;
+ uint32 A, B, C, D;
+ uint32 buf[16];
+
+ /* --- Fetch the chaining variables --- */
+
+ a = A = ctx->a;
+ b = B = ctx->b;
+ c = C = ctx->c;
+ d = D = ctx->d;
+
+ /* --- Fetch the buffer contents --- */
+
+ {
+ int i;
+ const octet *p;
+
+ for (i = 0, p = sbuf; i < 16; i++, p += 4)
+ buf[i] = LOAD32_L(p);
+ }
+
+ /* --- Definitions for round functions --- */
+
+#define F(x, y, z) ((x) ^ (y) ^ (z))
+#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define H(x, y, z) (((x) | ~(y)) ^ (z))
+#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+
+#define T(w, x, y, z, i, r, f, k) do { \
+ uint32 _t = w + f(x, y, z) + buf[i] + k; \
+ w = ROL32(_t, r); \
+} while (0)
+
+#define F1(w, x, y, z, i, r) T(w, x, y, z, i, r, F, 0x00000000)
+#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 --- */
+
+ F1(a, b, c, d, 0, 11);
+ F1(d, a, b, c, 1, 14);
+ F1(c, d, a, b, 2, 15);
+ F1(b, c, d, a, 3, 12);
+ F1(a, b, c, d, 4, 5);
+ F1(d, a, b, c, 5, 8);
+ F1(c, d, a, b, 6, 7);
+ F1(b, c, d, a, 7, 9);
+ F1(a, b, c, d, 8, 11);
+ F1(d, a, b, c, 9, 13);
+ F1(c, d, a, b, 10, 14);
+ F1(b, c, d, a, 11, 15);
+ F1(a, b, c, d, 12, 6);
+ F1(d, a, b, c, 13, 7);
+ F1(c, d, a, b, 14, 9);
+ F1(b, c, d, a, 15, 8);
+
+ G1(a, b, c, d, 7, 7);
+ G1(d, a, b, c, 4, 6);
+ G1(c, d, a, b, 13, 8);
+ G1(b, c, d, a, 1, 13);
+ G1(a, b, c, d, 10, 11);
+ G1(d, a, b, c, 6, 9);
+ G1(c, d, a, b, 15, 7);
+ G1(b, c, d, a, 3, 15);
+ G1(a, b, c, d, 12, 7);
+ G1(d, a, b, c, 0, 12);
+ G1(c, d, a, b, 9, 15);
+ G1(b, c, d, a, 5, 9);
+ G1(a, b, c, d, 2, 11);
+ G1(d, a, b, c, 14, 7);
+ G1(c, d, a, b, 11, 13);
+ G1(b, c, d, a, 8, 12);
+
+ H1(a, b, c, d, 3, 11);
+ H1(d, a, b, c, 10, 13);
+ H1(c, d, a, b, 14, 6);
+ H1(b, c, d, a, 4, 7);
+ H1(a, b, c, d, 9, 14);
+ H1(d, a, b, c, 15, 9);
+ H1(c, d, a, b, 8, 13);
+ H1(b, c, d, a, 1, 15);
+ H1(a, b, c, d, 2, 14);
+ H1(d, a, b, c, 7, 8);
+ H1(c, d, a, b, 0, 13);
+ H1(b, c, d, a, 6, 6);
+ H1(a, b, c, d, 13, 5);
+ H1(d, a, b, c, 11, 12);
+ H1(c, d, a, b, 5, 7);
+ H1(b, c, d, a, 12, 5);
+
+ I1(a, b, c, d, 1, 11);
+ I1(d, a, b, c, 9, 12);
+ I1(c, d, a, b, 11, 14);
+ I1(b, c, d, a, 10, 15);
+ I1(a, b, c, d, 0, 14);
+ I1(d, a, b, c, 8, 15);
+ I1(c, d, a, b, 12, 9);
+ I1(b, c, d, a, 4, 8);
+ I1(a, b, c, d, 13, 9);
+ I1(d, a, b, c, 3, 14);
+ I1(c, d, a, b, 7, 5);
+ I1(b, c, d, a, 15, 6);
+ I1(a, b, c, d, 14, 8);
+ I1(d, a, b, c, 5, 6);
+ I1(c, d, a, b, 6, 5);
+ I1(b, c, d, a, 2, 12);
+
+ /* --- And then the right hand side --- */
+
+ F2(A, B, C, D, 5, 8);
+ F2(D, A, B, C, 14, 9);
+ F2(C, D, A, B, 7, 9);
+ F2(B, C, D, A, 0, 11);
+ F2(A, B, C, D, 9, 13);
+ F2(D, A, B, C, 2, 15);
+ F2(C, D, A, B, 11, 15);
+ F2(B, C, D, A, 4, 5);
+ F2(A, B, C, D, 13, 7);
+ F2(D, A, B, C, 6, 7);
+ F2(C, D, A, B, 15, 8);
+ F2(B, C, D, A, 8, 11);
+ F2(A, B, C, D, 1, 14);
+ F2(D, A, B, C, 10, 14);
+ F2(C, D, A, B, 3, 12);
+ F2(B, C, D, A, 12, 6);
+
+ G2(A, B, C, D, 6, 9);
+ G2(D, A, B, C, 11, 13);
+ G2(C, D, A, B, 3, 15);
+ G2(B, C, D, A, 7, 7);
+ G2(A, B, C, D, 0, 12);
+ G2(D, A, B, C, 13, 8);
+ G2(C, D, A, B, 5, 9);
+ G2(B, C, D, A, 10, 11);
+ G2(A, B, C, D, 14, 7);
+ G2(D, A, B, C, 15, 7);
+ G2(C, D, A, B, 8, 12);
+ G2(B, C, D, A, 12, 7);
+ G2(A, B, C, D, 4, 6);
+ G2(D, A, B, C, 9, 15);
+ G2(C, D, A, B, 1, 13);
+ G2(B, C, D, A, 2, 11);
+
+ H2(A, B, C, D, 15, 9);
+ H2(D, A, B, C, 5, 7);
+ H2(C, D, A, B, 1, 15);
+ H2(B, C, D, A, 3, 11);
+ H2(A, B, C, D, 7, 8);
+ H2(D, A, B, C, 14, 6);
+ H2(C, D, A, B, 6, 6);
+ H2(B, C, D, A, 9, 14);
+ H2(A, B, C, D, 11, 12);
+ H2(D, A, B, C, 8, 13);
+ H2(C, D, A, B, 12, 5);
+ H2(B, C, D, A, 2, 14);
+ H2(A, B, C, D, 10, 13);
+ H2(D, A, B, C, 0, 13);
+ H2(C, D, A, B, 4, 7);
+ H2(B, C, D, A, 13, 5);
+
+ I2(A, B, C, D, 8, 15);
+ I2(D, A, B, C, 6, 5);
+ I2(C, D, A, B, 4, 8);
+ I2(B, C, D, A, 1, 11);
+ I2(A, B, C, D, 3, 14);
+ I2(D, A, B, C, 11, 14);
+ I2(C, D, A, B, 15, 6);
+ I2(B, C, D, A, 0, 14);
+ I2(A, B, C, D, 5, 6);
+ I2(D, A, B, C, 12, 9);
+ I2(C, D, A, B, 2, 12);
+ I2(B, C, D, A, 13, 9);
+ I2(A, B, C, D, 9, 12);
+ 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 --- */
+
+ {
+ uint32
+ tmp = ctx->b + c + D;
+ ctx->b = ctx->c + d + A;
+ ctx->c = ctx->d + a + B;
+ ctx->d = ctx->a + b + C;
+ ctx->a = tmp;
+ }
+}
+
+/* --- @rmd128_init@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+void rmd128_init(rmd128_ctx *ctx)
+{
+ ctx->a = 0x67452301;
+ ctx->b = 0xefcdab89;
+ ctx->c = 0x98badcfe;
+ ctx->d = 0x10325476;
+ ctx->off = 0;
+ ctx->nl = ctx->nh = 0;
+}
+
+/* --- @rmd128_set@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+void rmd128_set(rmd128_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->d = LOAD32_L(p + 12);
+ ctx->off = 0;
+ ctx->nl = U32(count);
+ ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+}
+
+/* --- @rmd128_hash@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+void rmd128_hash(rmd128_ctx *ctx, const void *buf, size_t sz)
+{
+ HASH_BUFFER(RMD128, rmd128, ctx, buf, sz);
+}
+
+/* --- @rmd128_done@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+void rmd128_done(rmd128_ctx *ctx, void *hash)
+{
+ octet *p = hash;
+ HASH_MD5STRENGTH(RMD128, rmd128, ctx);
+ STORE32_L(p + 0, ctx->a);
+ STORE32_L(p + 4, ctx->b);
+ STORE32_L(p + 8, ctx->c);
+ STORE32_L(p + 12, ctx->d);
+}
+
+/* --- @rmd128_state@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @rmd128_set@.
+ */
+
+unsigned long rmd128_state(rmd128_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 + 12, ctx->d);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
+}
+
+/* --- Generic interface --- */
+
+GHASH_DEF(RMD128, rmd128)
+
+/* --- Test code --- */
+
+HASH_TEST(RMD128, rmd128)
+
+/*----- That's all, folks -------------------------------------------------*/
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: rmd128.h,v 1.1 2000/07/09 21:30:31 mdw Exp $
+ *
+ * The RIPEMD-128 message digest function
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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: rmd128.h,v $
+ * Revision 1.1 2000/07/09 21:30:31 mdw
+ * New RIPEMD variants.
+ *
+ */
+
+/*----- Notes on the RIPEMD-128 hash function -----------------------------*
+ *
+ * RIPEMD-128 was invented by Hans Dobbertin, Antoon Bosselaers and Bart
+ * Preneel, as a drop-in replacement for MD5 (with the same sized output).
+ * It's a cut-down version of RIPEMD-160, which should be used in preference.
+ */
+
+#ifndef CATACOMB_RMD128_H
+#define CATACOMB_RMD128_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
+/*----- Magic numbers -----------------------------------------------------*/
+
+#define RMD128_BUFSZ 64
+#define RMD128_HASHSZ 16
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct rmd128_ctx {
+ uint32 a, b, c, d; /* Chaining variables */
+ uint32 nl, nh; /* Byte count so far */
+ unsigned off; /* Offset into buffer */
+ octet buf[RMD128_BUFSZ]; /* Accumulation buffer */
+} rmd128_ctx;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @rmd128_compress@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: RIPEMD-128 compression function.
+ */
+
+extern void rmd128_compress(rmd128_ctx */*ctx*/, const void */*sbuf*/);
+
+/* --- @rmd128_init@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+extern void rmd128_init(rmd128_ctx */*ctx*/);
+
+/* --- @rmd128_set@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+extern void rmd128_set(rmd128_ctx */*ctx*/,
+ const void */*buf*/, unsigned long /*count*/);
+
+/* --- @rmd128_hash@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+extern void rmd128_hash(rmd128_ctx */*ctx*/,
+ const void */*buf*/, size_t /*sz*/);
+
+/* --- @rmd128_done@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+extern void rmd128_done(rmd128_ctx */*ctx*/, void */*hash*/);
+
+/* --- @rmd128_state@ --- *
+ *
+ * Arguments: @rmd128_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @rmd128_set@.
+ */
+
+extern unsigned long rmd128_state(rmd128_ctx */*ctx*/, void */*state*/);
+
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash rmd128;
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: rmd256.c,v 1.1 2000/07/09 21:30:31 mdw Exp $
+ *
+ * The RIPEMD-256 message digest function
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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 <mLib/bits.h>
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "rmd256.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @rmd256_compress@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: RIPEMD-256 compression function.
+ */
+
+void rmd256_compress(rmd256_ctx *ctx, const void *sbuf)
+{
+ uint32 a, b, c, d;
+ uint32 A, B, C, D;
+ uint32 buf[16];
+
+ /* --- Fetch the chaining variables --- */
+
+ a = ctx->a;
+ b = ctx->b;
+ c = ctx->c;
+ d = ctx->d;
+ A = ctx->A;
+ B = ctx->B;
+ C = ctx->C;
+ D = ctx->D;
+
+ /* --- Fetch the buffer contents --- */
+
+ {
+ int i;
+ const octet *p;
+
+ for (i = 0, p = sbuf; i < 16; i++, p += 4)
+ buf[i] = LOAD32_L(p);
+ }
+
+ /* --- Definitions for round functions --- */
+
+#define F(x, y, z) ((x) ^ (y) ^ (z))
+#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define H(x, y, z) (((x) | ~(y)) ^ (z))
+#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+
+#define T(w, x, y, z, i, r, f, k) do { \
+ uint32 _t = w + f(x, y, z) + buf[i] + k; \
+ w = ROL32(_t, r); \
+} while (0)
+
+#define F1(w, x, y, z, i, r) T(w, x, y, z, i, r, F, 0x00000000)
+#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 --- */
+
+ F1(a, b, c, d, 0, 11);
+ F1(d, a, b, c, 1, 14);
+ F1(c, d, a, b, 2, 15);
+ F1(b, c, d, a, 3, 12);
+ F1(a, b, c, d, 4, 5);
+ F1(d, a, b, c, 5, 8);
+ F1(c, d, a, b, 6, 7);
+ F1(b, c, d, a, 7, 9);
+ F1(a, b, c, d, 8, 11);
+ F1(d, a, b, c, 9, 13);
+ F1(c, d, a, b, 10, 14);
+ F1(b, c, d, a, 11, 15);
+ F1(a, b, c, d, 12, 6);
+ F1(d, a, b, c, 13, 7);
+ F1(c, d, a, b, 14, 9);
+ F1(b, c, d, a, 15, 8);
+
+ F2(A, B, C, D, 5, 8);
+ F2(D, A, B, C, 14, 9);
+ F2(C, D, A, B, 7, 9);
+ F2(B, C, D, A, 0, 11);
+ F2(A, B, C, D, 9, 13);
+ F2(D, A, B, C, 2, 15);
+ F2(C, D, A, B, 11, 15);
+ F2(B, C, D, A, 4, 5);
+ F2(A, B, C, D, 13, 7);
+ F2(D, A, B, C, 6, 7);
+ F2(C, D, A, B, 15, 8);
+ F2(B, C, D, A, 8, 11);
+ F2(A, B, C, D, 1, 14);
+ F2(D, A, B, C, 10, 14);
+ F2(C, D, A, B, 3, 12);
+ F2(B, C, D, A, 12, 6);
+
+ G1(A, b, c, d, 7, 7);
+ G1(d, A, b, c, 4, 6);
+ G1(c, d, A, b, 13, 8);
+ G1(b, c, d, A, 1, 13);
+ G1(A, b, c, d, 10, 11);
+ G1(d, A, b, c, 6, 9);
+ G1(c, d, A, b, 15, 7);
+ G1(b, c, d, A, 3, 15);
+ G1(A, b, c, d, 12, 7);
+ G1(d, A, b, c, 0, 12);
+ G1(c, d, A, b, 9, 15);
+ G1(b, c, d, A, 5, 9);
+ G1(A, b, c, d, 2, 11);
+ G1(d, A, b, c, 14, 7);
+ G1(c, d, A, b, 11, 13);
+ G1(b, c, d, A, 8, 12);
+
+ G2(a, B, C, D, 6, 9);
+ G2(D, a, B, C, 11, 13);
+ G2(C, D, a, B, 3, 15);
+ G2(B, C, D, a, 7, 7);
+ G2(a, B, C, D, 0, 12);
+ G2(D, a, B, C, 13, 8);
+ G2(C, D, a, B, 5, 9);
+ G2(B, C, D, a, 10, 11);
+ G2(a, B, C, D, 14, 7);
+ G2(D, a, B, C, 15, 7);
+ G2(C, D, a, B, 8, 12);
+ G2(B, C, D, a, 12, 7);
+ G2(a, B, C, D, 4, 6);
+ G2(D, a, B, C, 9, 15);
+ G2(C, D, a, B, 1, 13);
+ G2(B, C, D, a, 2, 11);
+
+ H1(A, B, c, d, 3, 11);
+ H1(d, A, B, c, 10, 13);
+ H1(c, d, A, B, 14, 6);
+ H1(B, c, d, A, 4, 7);
+ H1(A, B, c, d, 9, 14);
+ H1(d, A, B, c, 15, 9);
+ H1(c, d, A, B, 8, 13);
+ H1(B, c, d, A, 1, 15);
+ H1(A, B, c, d, 2, 14);
+ H1(d, A, B, c, 7, 8);
+ H1(c, d, A, B, 0, 13);
+ H1(B, c, d, A, 6, 6);
+ H1(A, B, c, d, 13, 5);
+ H1(d, A, B, c, 11, 12);
+ H1(c, d, A, B, 5, 7);
+ H1(B, c, d, A, 12, 5);
+
+ H2(a, b, C, D, 15, 9);
+ H2(D, a, b, C, 5, 7);
+ H2(C, D, a, b, 1, 15);
+ H2(b, C, D, a, 3, 11);
+ H2(a, b, C, D, 7, 8);
+ H2(D, a, b, C, 14, 6);
+ H2(C, D, a, b, 6, 6);
+ H2(b, C, D, a, 9, 14);
+ H2(a, b, C, D, 11, 12);
+ H2(D, a, b, C, 8, 13);
+ H2(C, D, a, b, 12, 5);
+ H2(b, C, D, a, 2, 14);
+ H2(a, b, C, D, 10, 13);
+ H2(D, a, b, C, 0, 13);
+ H2(C, D, a, b, 4, 7);
+ H2(b, C, D, a, 13, 5);
+
+ I1(A, B, C, d, 1, 11);
+ I1(d, A, B, C, 9, 12);
+ I1(C, d, A, B, 11, 14);
+ I1(B, C, d, A, 10, 15);
+ I1(A, B, C, d, 0, 14);
+ I1(d, A, B, C, 8, 15);
+ I1(C, d, A, B, 12, 9);
+ I1(B, C, d, A, 4, 8);
+ I1(A, B, C, d, 13, 9);
+ I1(d, A, B, C, 3, 14);
+ I1(C, d, A, B, 7, 5);
+ I1(B, C, d, A, 15, 6);
+ I1(A, B, C, d, 14, 8);
+ 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);
+ I2(b, c, D, a, 1, 11);
+ I2(a, b, c, D, 3, 14);
+ I2(D, a, b, c, 11, 14);
+ I2(c, D, a, b, 15, 6);
+ I2(b, c, D, a, 0, 14);
+ I2(a, b, c, D, 5, 6);
+ I2(D, a, b, c, 12, 9);
+ I2(c, D, a, b, 2, 12);
+ I2(b, c, D, a, 13, 9);
+ I2(a, b, c, D, 9, 12);
+ 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;
+ ctx->b += B;
+ ctx->c += C;
+ ctx->d += D;
+ ctx->A += a;
+ ctx->B += b;
+ ctx->C += c;
+ ctx->D += d;
+}
+
+/* --- @rmd256_init@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+void rmd256_init(rmd256_ctx *ctx)
+{
+ ctx->a = 0x67452301;
+ ctx->b = 0xefcdab89;
+ ctx->c = 0x98badcfe;
+ ctx->d = 0x10325476;
+ ctx->A = 0x76543210;
+ ctx->B = 0xfedcba98;
+ ctx->C = 0x89abcdef;
+ ctx->D = 0x01234567;
+ ctx->off = 0;
+ ctx->nl = ctx->nh = 0;
+}
+
+/* --- @rmd256_set@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+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->d = LOAD32_L(p + 12);
+ ctx->A = LOAD32_L(p + 16);
+ ctx->B = LOAD32_L(p + 20);
+ ctx->C = LOAD32_L(p + 24);
+ ctx->D = LOAD32_L(p + 28);
+ ctx->off = 0;
+ ctx->nl = U32(count);
+ ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+}
+
+/* --- @rmd256_hash@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+void rmd256_hash(rmd256_ctx *ctx, const void *buf, size_t sz)
+{
+ HASH_BUFFER(RMD256, rmd256, ctx, buf, sz);
+}
+
+/* --- @rmd256_done@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+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 + 12, ctx->d);
+ STORE32_L(p + 16, ctx->A);
+ STORE32_L(p + 20, ctx->B);
+ STORE32_L(p + 24, ctx->C);
+ STORE32_L(p + 28, ctx->D);
+}
+
+/* --- @rmd256_state@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @rmd256_set@.
+ */
+
+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 + 12, ctx->d);
+ STORE32_L(p + 16, ctx->A);
+ STORE32_L(p + 20, ctx->B);
+ STORE32_L(p + 24, ctx->C);
+ STORE32_L(p + 28, ctx->D);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
+}
+
+/* --- Generic interface --- */
+
+GHASH_DEF(RMD256, rmd256)
+
+/* --- Test code --- */
+
+HASH_TEST(RMD256, rmd256)
+
+/*----- That's all, folks -------------------------------------------------*/
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: rmd256.h,v 1.1 2000/07/09 21:30:31 mdw Exp $
+ *
+ * The RIPEMD-256 message digest function
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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.h,v $
+ * Revision 1.1 2000/07/09 21:30:31 mdw
+ * New RIPEMD variants.
+ *
+ */
+
+/*----- Notes on the RIPEMD-256 hash function -----------------------------*
+ *
+ * RIPEMD-256 was invented by Hans Dobbertin, Antoon Bosselaers and Bart
+ * Preneel. It's a double-width version of RIPEMD-128, constructed simply by
+ * not gluing together the two parallel computations which RIPEMD-128 usually
+ * does in its compression function. The authors warn that, while its output
+ * is twice as wide as that of RIPEMD-128, they don't expect it to offer any
+ * more security.
+ */
+
+#ifndef CATACOMB_RMD256_H
+#define CATACOMB_RMD256_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
+/*----- Magic numbers -----------------------------------------------------*/
+
+#define RMD256_BUFSZ 64
+#define RMD256_HASHSZ 32
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct rmd256_ctx {
+ uint32 a, b, c, d; /* Chaining variables */
+ uint32 A, B, C, D; /* More chaining variables */
+ uint32 nl, nh; /* Byte count so far */
+ unsigned off; /* Offset into buffer */
+ octet buf[RMD256_BUFSZ]; /* Accumulation buffer */
+} rmd256_ctx;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @rmd256_compress@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: RIPEMD-256 compression function.
+ */
+
+extern void rmd256_compress(rmd256_ctx */*ctx*/, const void */*sbuf*/);
+
+/* --- @rmd256_init@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+extern void rmd256_init(rmd256_ctx */*ctx*/);
+
+/* --- @rmd256_set@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+extern void rmd256_set(rmd256_ctx */*ctx*/,
+ const void */*buf*/, unsigned long /*count*/);
+
+/* --- @rmd256_hash@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+extern void rmd256_hash(rmd256_ctx */*ctx*/,
+ const void */*buf*/, size_t /*sz*/);
+
+/* --- @rmd256_done@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+extern void rmd256_done(rmd256_ctx */*ctx*/, void */*hash*/);
+
+/* --- @rmd256_state@ --- *
+ *
+ * Arguments: @rmd256_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @rmd256_set@.
+ */
+
+extern unsigned long rmd256_state(rmd256_ctx */*ctx*/, void */*state*/);
+
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash rmd256;
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: rmd320.c,v 1.1 2000/07/09 21:30:31 mdw Exp $
+ *
+ * The RIPEMD-320 message digest function
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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: rmd320.c,v $
+ * Revision 1.1 2000/07/09 21:30:31 mdw
+ * New RIPEMD variants.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "rmd320.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @rmd320_compress@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: RIPEMD-320 compression function.
+ */
+
+void rmd320_compress(rmd320_ctx *ctx, const void *sbuf)
+{
+ uint32 a, b, c, d, e;
+ uint32 A, B, C, D, E;
+ uint32 buf[16];
+
+ /* --- Fetch the chaining variables --- */
+
+ a = ctx->a;
+ b = ctx->b;
+ c = ctx->c;
+ d = ctx->d;
+ e = ctx->e;
+
+ A = ctx->A;
+ B = ctx->B;
+ C = ctx->C;
+ D = ctx->D;
+ E = ctx->E;
+
+ /* --- Fetch the buffer contents --- */
+
+ {
+ int i;
+ const octet *p;
+
+ for (i = 0, p = sbuf; i < 16; i++, p += 4)
+ buf[i] = LOAD32_L(p);
+ }
+
+ /* --- Definitions for round functions --- */
+
+#define F(x, y, z) ((x) ^ (y) ^ (z))
+#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define H(x, y, z) (((x) | ~(y)) ^ (z))
+#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define J(x, y, z) ((x) ^ ((y) | ~(z)))
+
+#define T(v, w, x, y, z, i, r, f, k) do { \
+ uint32 _t = v + f(w, x, y) + buf[i] + k; \
+ v = ROL32(_t, r) + z; x = ROL32(x, 10); \
+} while (0)
+
+#define F1(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, F, 0x00000000)
+#define G1(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, G, 0x5a827999)
+#define H1(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, H, 0x6ed9eba1)
+#define I1(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, I, 0x8f1bbcdc)
+#define J1(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, J, 0xa953fd4e)
+
+#define F2(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, J, 0x50a28be6)
+#define G2(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, I, 0x5c4dd124)
+#define H2(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, H, 0x6d703ef3)
+#define I2(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, G, 0x7a6d76e9)
+#define J2(v, w, x, y, z, i, r) T(v, w, x, y, z, i, r, F, 0x00000000)
+
+ /* --- We must do both lines together --- */
+
+ F1(a, b, c, d, e, 0, 11);
+ 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(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);
+
+ F2(A, B, C, D, E, 5, 8);
+ F2(E, A, B, C, D, 14, 9);
+ F2(D, E, A, B, C, 7, 9);
+ F2(C, D, E, A, B, 0, 11);
+ F2(B, C, D, E, A, 9, 13);
+ F2(A, B, C, D, E, 2, 15);
+ F2(E, A, B, C, D, 11, 15);
+ F2(D, E, A, B, C, 4, 5);
+ F2(C, D, E, A, B, 13, 7);
+ F2(B, C, D, E, A, 6, 7);
+ F2(A, B, C, D, E, 15, 8);
+ F2(E, A, B, C, D, 8, 11);
+ F2(D, E, A, B, C, 1, 14);
+ F2(C, D, E, A, B, 10, 14);
+ F2(B, C, D, E, A, 3, 12);
+ F2(A, B, C, D, E, 12, 6);
+
+ G1(e, A, b, c, d, 7, 7);
+ G1(d, e, A, b, c, 4, 6);
+ G1(c, d, e, A, b, 13, 8);
+ G1(b, c, d, e, A, 1, 13);
+ G1(A, b, c, d, e, 10, 11);
+ G1(e, A, b, c, d, 6, 9);
+ G1(d, e, A, b, c, 15, 7);
+ G1(c, d, e, A, b, 3, 15);
+ G1(b, c, d, e, A, 12, 7);
+ G1(A, b, c, d, e, 0, 12);
+ G1(e, A, b, c, d, 9, 15);
+ G1(d, e, A, b, c, 5, 9);
+ G1(c, d, e, A, b, 2, 11);
+ G1(b, c, d, e, A, 14, 7);
+ G1(A, b, c, d, e, 11, 13);
+ G1(e, A, b, c, d, 8, 12);
+
+ G2(E, a, B, C, D, 6, 9);
+ G2(D, E, a, B, C, 11, 13);
+ G2(C, D, E, a, B, 3, 15);
+ G2(B, C, D, E, a, 7, 7);
+ G2(a, B, C, D, E, 0, 12);
+ G2(E, a, B, C, D, 13, 8);
+ G2(D, E, a, B, C, 5, 9);
+ G2(C, D, E, a, B, 10, 11);
+ G2(B, C, D, E, a, 14, 7);
+ G2(a, B, C, D, E, 15, 7);
+ G2(E, a, B, C, D, 8, 12);
+ G2(D, E, a, B, C, 12, 7);
+ G2(C, D, E, a, B, 4, 6);
+ G2(B, C, D, E, a, 9, 15);
+ G2(a, B, C, D, E, 1, 13);
+ G2(E, a, B, C, D, 2, 11);
+
+ H1(d, e, A, B, c, 3, 11);
+ H1(c, d, e, A, B, 10, 13);
+ H1(B, c, d, e, A, 14, 6);
+ H1(A, B, c, d, e, 4, 7);
+ H1(e, A, B, c, d, 9, 14);
+ H1(d, e, A, B, c, 15, 9);
+ H1(c, d, e, A, B, 8, 13);
+ H1(B, c, d, e, A, 1, 15);
+ H1(A, B, c, d, e, 2, 14);
+ H1(e, A, B, c, d, 7, 8);
+ H1(d, e, A, B, c, 0, 13);
+ H1(c, d, e, A, B, 6, 6);
+ H1(B, c, d, e, A, 13, 5);
+ H1(A, B, c, d, e, 11, 12);
+ H1(e, A, B, c, d, 5, 7);
+ H1(d, e, A, B, c, 12, 5);
+
+ H2(D, E, a, b, C, 15, 9);
+ H2(C, D, E, a, b, 5, 7);
+ H2(b, C, D, E, a, 1, 15);
+ H2(a, b, C, D, E, 3, 11);
+ H2(E, a, b, C, D, 7, 8);
+ H2(D, E, a, b, C, 14, 6);
+ H2(C, D, E, a, b, 6, 6);
+ H2(b, C, D, E, a, 9, 14);
+ H2(a, b, C, D, E, 11, 12);
+ H2(E, a, b, C, D, 8, 13);
+ H2(D, E, a, b, C, 12, 5);
+ H2(C, D, E, a, b, 2, 14);
+ H2(b, C, D, E, a, 10, 13);
+ H2(a, b, C, D, E, 0, 13);
+ H2(E, a, b, C, D, 4, 7);
+ H2(D, E, a, b, C, 13, 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);
+ I1(e, A, B, C, d, 10, 15);
+ I1(d, e, A, B, C, 0, 14);
+ I1(C, d, e, A, B, 8, 15);
+ I1(B, C, d, e, A, 12, 9);
+ I1(A, B, C, d, e, 4, 8);
+ I1(e, A, B, C, d, 13, 9);
+ I1(d, e, A, B, C, 3, 14);
+ I1(C, d, e, A, B, 7, 5);
+ I1(B, C, d, e, A, 15, 6);
+ I1(A, B, C, d, e, 14, 8);
+ I1(e, A, B, C, d, 5, 6);
+ I1(d, e, A, B, C, 6, 5);
+ I1(C, d, e, A, B, 2, 12);
+
+ I2(c, D, E, a, b, 8, 15);
+ I2(b, c, D, E, a, 6, 5);
+ I2(a, b, c, D, E, 4, 8);
+ I2(E, a, b, c, D, 1, 11);
+ I2(D, E, a, b, c, 3, 14);
+ I2(c, D, E, a, b, 11, 14);
+ I2(b, c, D, E, a, 15, 6);
+ I2(a, b, c, D, E, 0, 14);
+ I2(E, a, b, c, D, 5, 6);
+ I2(D, E, a, b, c, 12, 9);
+ I2(c, D, E, a, b, 2, 12);
+ I2(b, c, D, E, a, 13, 9);
+ I2(a, b, c, D, E, 9, 12);
+ I2(E, a, b, c, D, 7, 5);
+ I2(D, E, a, b, c, 10, 15);
+ I2(c, D, E, a, b, 14, 8);
+
+ J1(B, C, D, e, A, 4, 9);
+ J1(A, B, C, D, e, 0, 15);
+ J1(e, A, B, C, D, 5, 5);
+ J1(D, e, A, B, C, 9, 11);
+ J1(C, D, e, A, B, 7, 6);
+ J1(B, C, D, e, A, 12, 8);
+ J1(A, B, C, D, e, 2, 13);
+ J1(e, A, B, C, D, 10, 12);
+ J1(D, e, A, B, C, 14, 5);
+ J1(C, D, e, A, B, 1, 12);
+ J1(B, C, D, e, A, 3, 13);
+ J1(A, B, C, D, e, 8, 14);
+ J1(e, A, B, C, D, 11, 11);
+ J1(D, e, A, B, C, 6, 8);
+ J1(C, D, e, A, B, 15, 5);
+ J1(B, C, D, e, A, 13, 6);
+
+ J2(b, c, d, E, a, 12, 8);
+ J2(a, b, c, d, E, 15, 5);
+ J2(E, a, b, c, d, 10, 12);
+ J2(d, E, a, b, c, 4, 9);
+ J2(c, d, E, a, b, 1, 12);
+ J2(b, c, d, E, a, 5, 5);
+ J2(a, b, c, d, E, 8, 14);
+ J2(E, a, b, c, d, 7, 6);
+ J2(d, E, a, b, c, 6, 8);
+ J2(c, d, E, a, b, 2, 13);
+ J2(b, c, d, E, a, 13, 6);
+ J2(a, b, c, d, E, 14, 5);
+ J2(E, a, b, c, d, 0, 15);
+ J2(d, E, a, b, c, 3, 13);
+ J2(c, d, E, a, b, 9, 11);
+ J2(b, c, d, E, a, 11, 11);
+
+ /* --- Write out the result --- */
+
+ ctx->a += A;
+ ctx->b += B;
+ ctx->c += C;
+ ctx->d += D;
+ ctx->e += E;
+ ctx->A += a;
+ ctx->B += b;
+ ctx->C += c;
+ ctx->D += d;
+ ctx->E += e;
+}
+
+/* --- @rmd320_init@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+void rmd320_init(rmd320_ctx *ctx)
+{
+ ctx->a = 0x67452301;
+ ctx->b = 0xefcdab89;
+ ctx->c = 0x98badcfe;
+ ctx->d = 0x10325476;
+ ctx->e = 0xc3d2e1f0;
+ ctx->A = 0x76543210;
+ ctx->B = 0xfedcba98;
+ ctx->C = 0x89abcdef;
+ ctx->D = 0x01234567;
+ ctx->E = 0x3c2d1e0f;
+ ctx->off = 0;
+ ctx->nl = ctx->nh = 0;
+}
+
+/* --- @rmd320_set@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+void rmd320_set(rmd320_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->d = LOAD32_L(p + 12);
+ ctx->e = LOAD32_L(p + 16);
+ ctx->A = LOAD32_L(p + 20);
+ ctx->B = LOAD32_L(p + 24);
+ ctx->C = LOAD32_L(p + 28);
+ ctx->D = LOAD32_L(p + 32);
+ ctx->E = LOAD32_L(p + 36);
+ ctx->off = 0;
+ ctx->nl = U32(count);
+ ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+}
+
+/* --- @rmd320_hash@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+void rmd320_hash(rmd320_ctx *ctx, const void *buf, size_t sz)
+{
+ HASH_BUFFER(RMD320, rmd320, ctx, buf, sz);
+}
+
+/* --- @rmd320_done@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+void rmd320_done(rmd320_ctx *ctx, void *hash)
+{
+ octet *p = hash;
+ HASH_MD5STRENGTH(RMD320, rmd320, ctx);
+ 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);
+ STORE32_L(p + 20, ctx->A);
+ STORE32_L(p + 24, ctx->B);
+ STORE32_L(p + 28, ctx->C);
+ STORE32_L(p + 32, ctx->D);
+ STORE32_L(p + 36, ctx->E);
+}
+
+/* --- @rmd320_state@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @rmd320_set@.
+ */
+
+unsigned long rmd320_state(rmd320_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 + 12, ctx->d);
+ STORE32_L(p + 16, ctx->e);
+ STORE32_L(p + 20, ctx->A);
+ STORE32_L(p + 24, ctx->B);
+ STORE32_L(p + 28, ctx->C);
+ STORE32_L(p + 32, ctx->D);
+ STORE32_L(p + 36, ctx->E);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
+}
+
+/* --- Generic interface --- */
+
+GHASH_DEF(RMD320, rmd320)
+
+/* --- Test code --- */
+
+HASH_TEST(RMD320, rmd320)
+
+/*----- That's all, folks -------------------------------------------------*/
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: rmd320.h,v 1.1 2000/07/09 21:30:31 mdw Exp $
+ *
+ * The RIPEMD-320 message digest function
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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: rmd320.h,v $
+ * Revision 1.1 2000/07/09 21:30:31 mdw
+ * New RIPEMD variants.
+ *
+ */
+
+/*----- Notes on the RIPEMD-320 hash function -----------------------------*
+ *
+ * RIPEMD-320 was invented by Hans Dobbertin, Antoon Bosselaers and Bart
+ * Preneel. It's a double-width version of RIPEMD-160, constructed simply by
+ * not gluing together the two parallel computations which RIPEMD-160 usually
+ * does in its compression function. The authors warn that, while its output
+ * is twice as wide as that of RIPEMD-160, they don't expect it to offer any
+ * more security.
+ */
+
+#ifndef CATACOMB_RMD320_H
+#define CATACOMB_RMD320_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
+/*----- Magic numbers -----------------------------------------------------*/
+
+#define RMD320_BUFSZ 64
+#define RMD320_HASHSZ 40
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct rmd320_ctx {
+ uint32 a, b, c, d, e; /* Chaining variables */
+ uint32 A, B, C, D, E; /* More chaining variables */
+ uint32 nl, nh; /* Byte count so far */
+ unsigned off; /* Offset into buffer */
+ octet buf[RMD320_BUFSZ]; /* Accumulation buffer */
+} rmd320_ctx;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @rmd320_compress@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: RIPEMD-320 compression function.
+ */
+
+extern void rmd320_compress(rmd320_ctx */*ctx*/, const void */*sbuf*/);
+
+/* --- @rmd320_init@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+extern void rmd320_init(rmd320_ctx */*ctx*/);
+
+/* --- @rmd320_set@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+extern void rmd320_set(rmd320_ctx */*ctx*/,
+ const void */*buf*/, unsigned long /*count*/);
+
+/* --- @rmd320_hash@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+extern void rmd320_hash(rmd320_ctx */*ctx*/,
+ const void */*buf*/, size_t /*sz*/);
+
+/* --- @rmd320_done@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+extern void rmd320_done(rmd320_ctx */*ctx*/, void */*hash*/);
+
+/* --- @rmd320_state@ --- *
+ *
+ * Arguments: @rmd320_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @rmd320_set@.
+ */
+
+extern unsigned long rmd320_state(rmd320_ctx */*ctx*/, void */*state*/);
+
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash rmd320;
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
--- /dev/null
+# Test vectors for RIPEMD-160
+#
+# $Id: rmd128,v 1.1 2000/07/09 21:30:34 mdw Exp $
+
+# --- Basic hash function ---
+#
+# Taken from the authors' web pages.
+
+rmd128 {
+ "" cdf26213a150dc3ecb610f18f6b38b46;
+ "a" 86be7afa339d0fc7cfc785e72f578d33;
+ "abc" c14a12199c66e4ba84636b0f69144c77;
+ "message digest" 9e327b3d6e523062afc1132d7df9d1b8;
+ "abcdefghijklmnopqrstuvwxyz"
+ fd2aa607f71dc8f510714922b371834e;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ a1aa0689d0fafa2ddc22e88b49133a06;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ d1e959eb179c911faea4624c60c5c702;
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ 3f45ef194732c2dbb2c4a2c769795fa3;
+}
+
+# --- HMAC mode ---
+#
+# Test vectors from RFC2286.
+
+rmd128-hmac {
+
+ "Hi There"
+ 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ fbf61f9492aa4bbf81c172e84e0734db;
+
+ "what do ya want for nothing?"
+ 4a656665
+ 875f828862b6b334b427c55f9f7ff09b;
+
+ "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 09f0b2846d2f543da363cbec8d62a38d;
+
+ "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+ 0102030405060708090a0b0c0d0e0f10111213141516171819
+ bdbbd7cf03e44b5aa60af815be4d2294;
+
+ "Test With Truncation"
+ 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ e79808f24b25fd031c155f0d551d9a3a;
+
+ "Test Using Larger Than Block-Size Key - Hash Key First"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ dc732928de98104a1f59d373c150acbb;
+
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5c6bec96793e16d40690c237635f30c5;
+}
--- /dev/null
+# Test vectors for RIPEMD-256
+#
+# $Id: rmd256,v 1.1 2000/07/09 21:30:34 mdw Exp $
+
+# --- Basic hash function ---
+#
+# Taken from the authors' web pages.
+
+rmd256 {
+ ""
+ 02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d;
+ "a"
+ f9333e45d857f5d90a91bab70a1eba0cfb1be4b0783c9acfcd883a9134692925;
+ "abc"
+ afbd6e228b9d8cbbcef5ca2d03e6dba10ac0bc7dcbe4680e1e42d2e975459b65;
+ "message digest"
+ 87e971759a1ce47a514d5c914c392c9018c7c46bc14465554afcdf54a5070c0e;
+ "abcdefghijklmnopqrstuvwxyz"
+ 649d3034751ea216776bf9a18acc81bc7896118a5197968782dd1fd97d8d5133;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 3843045583aac6c8c8d9128573e7a9809afb2a0f34ccc36ea9e72f16f6368e3f;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ 5740a408ac16b720b84424ae931cbb1fe363d1d0bf4017f1a89f7ea6de77a0b8;
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ 06fdcc7a409548aaf91368c06a6275b553e3f099bf0ea4edfd6778df89a890dd;
+}
+
+# --- HMAC mode ---
+#
+# I couldn't find any official test vectors. These are therefore generated
+# using the Catacomb implementation.
+
+rmd256-hmac {
+
+ "Hi There"
+ 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ c1829c0d5a203bbf6e874a721d55ffec22456f3a0987e30a4861a40cad5dc9e7;
+
+ "what do ya want for nothing?"
+ 4a656665
+ 932d3e799272765675dd63c33f8d2815ea38181494f43271dd52fde91392619f;
+
+ "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ a30051679681f54ad62088438a308c3dd38cc0eb2d352fbdcfb2811abf9c1e29;
+
+ "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+ 0102030405060708090a0b0c0d0e0f10111213141516171819
+ d55d1a9b2082105103d8331581d9522d17b4cce92e95f0f4654ce8da187ffbbb;
+
+ "Test With Truncation"
+ 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ cc8e435de509ef9a974cecb40cdecf55c8e6a22d5458e74cb7b0a306453ad67d;
+
+ "Test Using Larger Than Block-Size Key - Hash Key First"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 821543a295eccf093af9b461f630d7c49206fb2158e5ac89e73a02cf089528ed;
+
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ ca26edc0129a781f1224cc6c9f655052f120edb5842bcfcf4b8d0f8b8be551bd;
+}
--- /dev/null
+# Test vectors for RIPEMD-320
+#
+# $Id: rmd320,v 1.1 2000/07/09 21:30:34 mdw Exp $
+
+# --- Basic hash function ---
+#
+# Taken from the authors' web pages.
+
+rmd320 {
+ ""
+ 22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8;
+ "a"
+ ce78850638f92658a5a585097579926dda667a5716562cfcf6fbe77f63542f99b04705d6970dff5d;
+ "abc"
+ de4c01b3054f8930a79d09ae738e92301e5a17085beffdc1b8d116713e74f82fa942d64cdbc4682d;
+ "message digest"
+ 3a8e28502ed45d422f68844f9dd316e7b98533fa3f2a91d29f84d425c88d6b4eff727df66a7c0197;
+ "abcdefghijklmnopqrstuvwxyz"
+ cabdb1810b92470a2093aa6bce05952c28348cf43ff60841975166bb40ed234004b8824463e6b009;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ d034a7950cf722021ba4b84df769a5de2060e259df4c9bb4a4268c0e935bbc7470a969c9d072a1ac;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ ed544940c86d67f250d232c30b7b3e5770e0c60c8cb9a4cafe3b11388af9920e1b99230b843c86a4;
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ 557888af5f6d8ed62ab66945c6d2a0a47ecd5341e915eb8fea1d0524955f825dc717e4a008ab2d42;
+}
+
+# --- HMAC mode ---
+#
+# I couldn't find any official test vectors. These are therefore generated
+# using the Catacomb implementation.
+
+rmd320-hmac {
+
+ "Hi There"
+ 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ 03ec929cb94837c2acd709d03f4a26c3e38c7cec4fe2f5caff3b64e168321c8591b1d3ffeb87b9f4;
+
+ "what do ya want for nothing?"
+ 4a656665
+ e440b00b6326e4f7dad3a6591e8189e9708fc17e3cab306fc67efaf70947aad2ea89e28f79d03bd3;
+
+ "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8c7ee84fb76703386f01f088cbe0ed9a694d6e0c9bfbe1c7785f56cafc5908db2e16afcb0721edae;
+
+ "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+ 0102030405060708090a0b0c0d0e0f10111213141516171819
+ 714f482ff865edbbcbfb344948ce3c8b9d2308650f2f0ed2111a6983509c967416e092e9f6b307d0;
+
+ "Test With Truncation"
+ 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ f0b1c83e3cec672db53c259746de4d13841e01dd6266c360fda76f3197ac47582c5e9b59d7a8a7b9;
+
+ "Test Using Larger Than Block-Size Key - Hash Key First"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ a61c1123c1a23ffdd9af5fb28b62b95f989876ac322452f5e4f4470c25182ef4816aaec7f0377167;
+
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5e5d0fe86d7f8ff85108bbf75cf25dd99e8029237b93ff0d93fb779264a103082cc62ad8914feed3;
+}