+2004-10-05 Michael Poole <mdpoole@troilus.org>
+
+ * include/ircd_md5.h, ircd/ircd_md5.c, ircd_crypt_smd5.c,
+ ircd/umkpasswd.c: Get rid of the GoodMD5xxx/BrokenMD5xxx
+ prefixes.
+
2004-10-05 Michael Poole <mdpoole@troilus.org>
* adns, lib/adns: Remove unused adns library.
#ifndef ircd_md5_h
#define ircd_md5_h
-/** Macro to prepend MD5 variant to a function name. */
-#define MD5Name(x) Good##x
-
/** Typedef for an unsigned 32-bit integer. */
typedef unsigned int uint32;
unsigned char in[64]; /**< Residual input buffer. */
};
-void GoodMD5Init(struct MD5Context *);
-void GoodMD5Update(struct MD5Context *, unsigned const char *, unsigned);
-void GoodMD5Final(unsigned char digest[16], struct MD5Context *);
-void GoodMD5Transform(uint32 buf[4], uint32 const in[16]);
-void BrokenMD5Init(struct MD5Context *);
-void BrokenMD5Update(struct MD5Context *, unsigned const char *, unsigned);
-void BrokenMD5Final(unsigned char digest[16], struct MD5Context *);
-void BrokenMD5Transform(uint32 buf[4], uint32 const in[16]);
+void MD5Init(struct MD5Context *);
+void MD5Update(struct MD5Context *, unsigned const char *, unsigned);
+void MD5Final(unsigned char digest[16], struct MD5Context *);
+void MD5Transform(uint32 buf[4], uint32 const in[16]);
-char *Goodcrypt_md5(const char *pw, const char *salt);
-char *Brokencrypt_md5(const char *pw, const char *salt);
+char *crypt_md5(const char *pw, const char *salt);
/** Helper typedef for the MD5 context structure. */
typedef struct MD5Context MD5_CTX;
/* get the length of the true salt */
sl = ep - sp;
- MD5Name(MD5Init)(&ctx);
+ MD5Init(&ctx);
/* The password first, since that is what is most unknown */
- MD5Name(MD5Update)(&ctx,(unsigned const char *)key,strlen(key));
+ MD5Update(&ctx,(unsigned const char *)key,strlen(key));
/* Then our magic string */
- MD5Name(MD5Update)(&ctx,(unsigned const char *)magic,strlen(magic));
+ MD5Update(&ctx,(unsigned const char *)magic,strlen(magic));
/* Then the raw salt */
- MD5Name(MD5Update)(&ctx,(unsigned const char *)sp,sl);
+ MD5Update(&ctx,(unsigned const char *)sp,sl);
/* Then just as many characters of the MD5(key,salt,key) */
- MD5Name(MD5Init)(&ctx1);
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)key,strlen(key));
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)sp,sl);
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)key,strlen(key));
- MD5Name(MD5Final)(final,&ctx1);
+ MD5Init(&ctx1);
+ MD5Update(&ctx1,(unsigned const char *)key,strlen(key));
+ MD5Update(&ctx1,(unsigned const char *)sp,sl);
+ MD5Update(&ctx1,(unsigned const char *)key,strlen(key));
+ MD5Final(final,&ctx1);
for (pl = strlen(key); pl > 0; pl -= 16)
- MD5Name(MD5Update)(&ctx,(unsigned const char *)final,pl>16 ? 16 : pl);
+ MD5Update(&ctx,(unsigned const char *)final,pl>16 ? 16 : pl);
/* Don't leave anything around in vm they could use. */
memset(final, 0, sizeof final);
/* Then something really weird... */
for (j = 0, i = strlen(key); i; i >>= 1)
if (i & 1)
- MD5Name(MD5Update)(&ctx, (unsigned const char *)final+j, 1);
+ MD5Update(&ctx, (unsigned const char *)final+j, 1);
else
- MD5Name(MD5Update)(&ctx, (unsigned const char *)key+j, 1);
+ MD5Update(&ctx, (unsigned const char *)key+j, 1);
/* Now make the output string
strcpy(passwd, magic);
strncpy(passwd, sp, sl);
strcat(passwd, "$");
- MD5Name(MD5Final)(final,&ctx);
+ MD5Final(final,&ctx);
/*
* and now, just to make sure things don't run too fast
* need 30 seconds to build a 1000 entry dictionary...
*/
for (i = 0; i < 1000; i++) {
- MD5Name(MD5Init)(&ctx1);
+ MD5Init(&ctx1);
if (i & 1)
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)key,strlen(key));
+ MD5Update(&ctx1,(unsigned const char *)key,strlen(key));
else
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)final,16);
+ MD5Update(&ctx1,(unsigned const char *)final,16);
if (i % 3)
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)sp,sl);
+ MD5Update(&ctx1,(unsigned const char *)sp,sl);
if (i % 7)
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)key,strlen(key));
+ MD5Update(&ctx1,(unsigned const char *)key,strlen(key));
if (i & 1)
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)final,16);
+ MD5Update(&ctx1,(unsigned const char *)final,16);
else
- MD5Name(MD5Update)(&ctx1,(unsigned const char *)key,strlen(key));
+ MD5Update(&ctx1,(unsigned const char *)key,strlen(key));
- MD5Name(MD5Final)(final,&ctx1);
+ MD5Final(final,&ctx1);
}
p = passwd + strlen(passwd);
/** Iniitalize MD5 context.
* @param[out] ctx MD5 context to initialize.
*/
-void MD5Name(MD5Init)(struct MD5Context *ctx)
+void MD5Init(struct MD5Context *ctx)
{
ctx->buf[0] = 0x67452301U;
ctx->buf[1] = 0xefcdab89U;
* @param[in] buf Input buffer.
* @param[in] len Number of bytes in input buffer.
*/
-void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsigned len)
+void MD5Update(struct MD5Context *ctx, unsigned const char *buf, unsigned len)
{
uint32 t;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += t;
len -= t;
}
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += 64;
len -= 64;
}
* @param[out] digest Receives output hash value.
* @param[in,out] ctx MD5 context to finalize.
*/
-void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx)
+void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
{
unsigned count;
unsigned char *p;
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
((uint32 *) ctx->in)[14] = ctx->bits[0];
((uint32 *) ctx->in)[15] = ctx->bits[1];
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
* @param[in,out] buf Hash value.
* @param[in] in Input buffer.
*/
-void MD5Name(MD5Transform)(uint32 buf[4], uint32 const in[16])
+void MD5Transform(uint32 buf[4], uint32 const in[16])
{
register uint32 a, b, c, d;
if (NULL == (file = fopen(tmp, "r")))
exit(0);
- MD5Name(MD5Init)(&context);
+ MD5Init(&context);
while ((len = fread (buffer, 1, 1024, file)))
- MD5Name(MD5Update)(&context, buffer, len);
- MD5Name(MD5Final)(digest, &context);
+ MD5Update(&context, buffer, len);
+ MD5Final(digest, &context);
fclose(file);
printf("%s: ", basename_into(tmp, (char*)buffer));