Get rid of "Good" and "Broken" prefixes on MD5 functions.
authorMichael Poole <mdpoole@troilus.org>
Tue, 5 Oct 2004 22:51:47 +0000 (22:51 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 5 Oct 2004 22:51:47 +0000 (22:51 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1234 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/ircd_md5.h
ircd/ircd_crypt_smd5.c
ircd/ircd_md5.c
ircd/umkpasswd.c

index 8eaac4167f4db05c9f49b30d675bc631a5c91f4d..c52fe54b1164cb55b9492b121e567dbd6b0bce4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
index 732a6e981beb69bc09e71a0ca213367cec7f6ffc..e2e71ce082dcf8f52e98eb138572105462bc6a1a 100644 (file)
@@ -20,9 +20,6 @@
 #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;
 
@@ -33,17 +30,12 @@ struct MD5Context {
        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;
index 3df750a9f511df266f031c5c226bea5ec1b0e639..68b78d87cdd8214cebe1be4577bd270e4d8cf34b 100644 (file)
@@ -110,25 +110,25 @@ unsigned long l;
  /* 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);
@@ -136,9 +136,9 @@ unsigned long l;
  /* 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);
@@ -146,7 +146,7 @@ unsigned long l;
  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
@@ -154,25 +154,25 @@ unsigned long l;
   * 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);
index 1dc912ed0315b322fdf96d9e04fadc0d37bc84a7..fd14a34e083914d23d02a1f1063a8c0be666ee32 100644 (file)
@@ -52,7 +52,7 @@ static void byteReverse(unsigned char *buf, unsigned longs)
 /** 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;
@@ -68,7 +68,7 @@ void MD5Name(MD5Init)(struct MD5Context *ctx)
  * @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;
 
@@ -93,7 +93,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign
                }
                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;
        }
@@ -102,7 +102,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign
        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;
        }
@@ -116,7 +116,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign
  * @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;
@@ -137,7 +137,7 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx)
                /* 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);
@@ -151,7 +151,7 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx)
        ((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 */
@@ -180,7 +180,7 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx)
  * @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;
 
index bf2a075aa48832b5c121ea53714a68861ecb743f..29a2bea29118655be4449688f19f9b225fffe596 100644 (file)
@@ -198,10 +198,10 @@ unsigned char buffer[1024], digest[16];
 
  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));