/* -*-c-*-
*
- * $Id: md4.c,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: md4.c,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* The MD4 message digest function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: md4.c,v $
+ * 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.
*
#include <mLib/bits.h>
+#include "ghash.h"
+#include "ghash-def.h"
#include "hash.h"
#include "md4.h"
ctx->c = 0x98badcfe;
ctx->d = 0x10325476;
ctx->off = 0;
- ctx->count = 0;
+ ctx->nl = ctx->nh = 0;
}
/* --- @md4_set@ --- *
ctx->c = LOAD32_L(p + 8);
ctx->d = LOAD32_L(p + 12);
ctx->off = 0;
- ctx->count = count;
+ ctx->nl = U32(count);
+ ctx->nh = U32((count >> 16) >> 16);
}
/* --- @md4_hash@ --- *
STORE32_L(p + 4, ctx->b);
STORE32_L(p + 8, ctx->c);
STORE32_L(p + 12, ctx->d);
- return (ctx->count);
+ return (ctx->nl | ((ctx->nh >> 16) >> 16));
}
+/* --- Generic interface --- */
+
+GHASH_DEF(MD4, md4)
+
/* --- Test rig --- */
HASH_TEST(MD4, md4)
/* -*-c-*-
*
- * $Id: md4.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: md4.h,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* The MD4 message digest function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: md4.h,v $
+ * 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.
*
* cryptographically strong, 'cos it ain't.
*/
-#ifndef MD4_H
-#define MD4_H
+#ifndef CATACOMB_MD4_H
+#define CATACOMB_MD4_H
#ifdef __cplusplus
extern "C" {
#include <mLib/bits.h>
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
/*----- Magic numbers -----------------------------------------------------*/
#define MD4_BUFSZ 64
typedef struct md4_ctx {
uint32 a, b, c, d; /* Chaining variables */
- unsigned long count; /* Byte count so far */
+ uint32 nl, nh; /* Byte count so far */
int off; /* Offset into buffer */
octet buf[MD4_BUFSZ]; /* Accumulation buffer */
} md4_ctx;
extern unsigned long md4_state(md4_ctx */*ctx*/, void */*state*/);
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash md4;
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/* -*-c-*-
*
- * $Id: md5.c,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: md5.c,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* The MD5 message digest function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: md5.c,v $
+ * 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.
*
#include <mLib/bits.h>
+#include "ghash.h"
+#include "ghash-def.h"
#include "hash.h"
#include "md5.h"
ctx->c = 0x98badcfe;
ctx->d = 0x10325476;
ctx->off = 0;
- ctx->count = 0;
+ ctx->nl = ctx->nh = 0;
}
/* --- @md5_set@ --- *
ctx->c = LOAD32_L(p + 8);
ctx->d = LOAD32_L(p + 12);
ctx->off = 0;
- ctx->count = count;
+ ctx->nl = U32(count);
+ ctx->nh = U32((count >> 16) >> 16);
}
/* --- @md5_hash@ --- *
STORE32_L(p + 4, ctx->b);
STORE32_L(p + 8, ctx->c);
STORE32_L(p + 12, ctx->d);
- return (ctx->count);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
}
+/* --- Generic interface --- */
+
+GHASH_DEF(MD5, md5)
+
/* --- Test code --- */
HASH_TEST(MD5, md5)
/* -*-c-*-
*
- * $Id: md5.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: md5.h,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* The MD5 message digest function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: md5.h,v $
+ * 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.
*
* applications. It's also still useful in constructions such as HMAC.
*/
-#ifndef MD5_H
-#define MD5_H
+#ifndef CATACOMB_MD5_H
+#define CATACOMB_MD5_H
#ifdef __cplusplus
extern "C" {
#include <mLib/bits.h>
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
/*----- Magic numbers -----------------------------------------------------*/
#define MD5_BUFSZ 64
typedef struct md5_ctx {
uint32 a, b, c, d; /* Chaining variables */
- unsigned long count; /* Byte count so far */
+ uint32 nl, nh; /* Byte count so far */
int off; /* Offset into buffer */
octet buf[MD5_BUFSZ]; /* Accumulation buffer */
} md5_ctx;
extern unsigned long md5_state(md5_ctx */*ctx*/, void */*state*/);
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash md5;
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/* -*-c-*-
*
- * $Id: rmd160.c,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: rmd160.c,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* The RIPEMD-160 message digest function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rmd160.c,v $
+ * 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.
*
#include <mLib/bits.h>
+#include "ghash.h"
+#include "ghash-def.h"
#include "hash.h"
#include "rmd160.h"
ctx->d = 0x10325476;
ctx->e = 0xc3d2e1f0;
ctx->off = 0;
- ctx->count = 0;
+ ctx->nl = ctx->nh = 0;
}
/* --- @rmd160_set@ --- *
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 >> 16) >> 16);
}
/* --- @rmd160_hash@ --- *
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)
/* -*-c-*-
*
- * $Id: rmd160.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: rmd160.h,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* The RIPEMD-160 message digest function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rmd160.h,v $
+ * 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.
*
* best alternative hash function.
*/
-#ifndef RMD160_H
-#define RMD160_H
+#ifndef CATACOMB_RMD160_H
+#define CATACOMB_RMD160_H
#ifdef __cplusplus
extern "C" {
#include <mLib/bits.h>
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
/*----- Magic numbers -----------------------------------------------------*/
#define RMD160_BUFSZ 64
typedef struct rmd160_ctx {
uint32 a, b, c, d, e; /* Chaining variables */
- unsigned long count; /* Byte count so far */
+ uint32 nl, nh; /* Byte count so far */
int off; /* Offset into buffer */
octet buf[RMD160_BUFSZ]; /* Accumulation buffer */
} rmd160_ctx;
extern unsigned long rmd160_state(rmd160_ctx */*ctx*/, void */*state*/);
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash rmd160;
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/* -*-c-*-
*
- * $Id: sha.c,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: sha.c,v 1.2 1999/12/10 23:20:03 mdw Exp $
*
* Implementation of the SHA-1 hash function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: sha.c,v $
+ * 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.
*
#include <mLib/bits.h>
+#include "ghash.h"
+#include "ghash-def.h"
#include "hash.h"
#include "sha.h"
ctx->d = 0x10325476;
ctx->e = 0xc3d2e1f0;
ctx->off = 0;
- ctx->count = 0;
+ ctx->nl = ctx->nh = 0;
}
/* --- @sha_set@ --- *
ctx->d = LOAD32(p + 12);
ctx->e = LOAD32(p + 16);
ctx->off = 0;
- ctx->count = count;
+ ctx->nl = U32(count);
+ ctx->nh = U32((count >> 16) >> 16);
}
/* --- @sha_hash@ --- *
{
octet *p = hash;
HASH_PAD(SHA, sha, ctx, 0x80, 0, 8);
- STORE32(ctx->buf + SHA_BUFSZ - 8, ctx->count >> 29);
- STORE32(ctx->buf + SHA_BUFSZ - 4, ctx->count << 3);
+ STORE32(ctx->buf + SHA_BUFSZ - 8, (ctx->nl >> 29) | (ctx->nh << 3));
+ STORE32(ctx->buf + SHA_BUFSZ - 4, ctx->nl << 3);
sha_compress(ctx, ctx->buf);
STORE32(p + 0, ctx->a);
STORE32(p + 4, ctx->b);
STORE32(p + 8, ctx->c);
STORE32(p + 12, ctx->d);
STORE32(p + 16, ctx->e);
- return (ctx->count);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
}
+/* --- Generic interface --- */
+
+GHASH_DEF(SHA, sha)
+
/* --- Test code --- */
HASH_TEST(SHA, sha)
/* -*-c-*-
*
- * $Id: sha.h,v 1.2 1999/11/19 13:20:08 mdw Exp $
+ * $Id: sha.h,v 1.3 1999/12/10 23:20:03 mdw Exp $
*
* Implementation of the SHA-1 hash function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: sha.h,v $
+ * Revision 1.3 1999/12/10 23:20:03 mdw
+ * New hash interface requirements.
+ *
* Revision 1.2 1999/11/19 13:20:08 mdw
* Modify notes section slightly.
*
* RIPEMD-160, for no particularly good reasons.
*/
-#ifndef SHA_H
-#define SHA_H
+#ifndef CATACOMB_SHA_H
+#define CATACOMB_SHA_H
#ifdef __cplusplus
extern "C" {
#include <mLib/bits.h>
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
/*----- Magic numbers -----------------------------------------------------*/
#define SHA_BUFSZ 64
typedef struct sha_ctx {
uint32 a, b, c, d, e; /* Chaining variables */
- unsigned long count; /* Byte count so far */
+ uint32 nl, nh; /* Byte count so far */
int off; /* Offset into buffer */
octet buf[SHA_BUFSZ]; /* Accumulation buffer */
} sha_ctx;
extern unsigned long sha_state(sha_ctx */*ctx*/, void */*state*/);
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash sha;
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus