Renamed MD4* to fr_MD4*, in order to avoid issues with OpenSSL
authoraland <aland>
Fri, 23 Nov 2007 12:38:26 +0000 (12:38 +0000)
committeraland <aland>
Fri, 23 Nov 2007 12:38:26 +0000 (12:38 +0000)
src/include/md4.h
src/lib/md4.c
src/modules/rlm_cram/rlm_cram.c
src/modules/rlm_eap/types/rlm_eap_leap/eap_leap.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_mschap/smbencrypt.c

index 06db9d4..5442ad6 100644 (file)
@@ -26,7 +26,7 @@ RCSIDH(md4_h, "$Id$")
 
 #include <string.h>
 
-void md4_calc (unsigned char *, const unsigned char *, unsigned int);
+void fr_md4_calc (unsigned char *, const unsigned char *, unsigned int);
 
 /*  The below was retrieved from
  *  http://www.openbsd.org/cgi-bin/cvsweb/src/include/md4.h?rev=1.12
@@ -59,30 +59,23 @@ void md4_calc (unsigned char *, const unsigned char *, unsigned int);
 #define        MD4_DIGEST_LENGTH               16
 #define        MD4_DIGEST_STRING_LENGTH        (MD4_DIGEST_LENGTH * 2 + 1)
 
-typedef struct MD4Context {
+typedef struct FR_MD4Context {
        uint32_t state[4];                      /* state */
        uint32_t count[2];                      /* number of bits, mod 2^64 */
        uint8_t buffer[MD4_BLOCK_LENGTH];       /* input buffer */
-} MD4_CTX;
+} FR_MD4_CTX;
 
 /*#include <sys/cdefs.h>*/
 
 /*__BEGIN_DECLS*/
-void    MD4Init(MD4_CTX *);
-void    MD4Update(MD4_CTX *, const uint8_t *, size_t)
+void    fr_MD4Init(FR_MD4_CTX *);
+void    fr_MD4Update(FR_MD4_CTX *, const uint8_t *, size_t)
 /*             __attribute__((__bounded__(__string__,2,3)))*/;
-void    MD4Final(uint8_t [MD4_DIGEST_LENGTH], MD4_CTX *)
+void    fr_MD4Final(uint8_t [MD4_DIGEST_LENGTH], FR_MD4_CTX *)
 /*             __attribute__((__bounded__(__minbytes__,1,MD4_DIGEST_LENGTH)))*/;
-void    MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
+void    fr_MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
 /*             __attribute__((__bounded__(__minbytes__,1,4)))
                __attribute__((__bounded__(__minbytes__,2,MD4_BLOCK_LENGTH)))*/;
-/*char *MD4End(MD4_CTX *, char [MD4_DIGEST_STRING_LENGTH])
-               __attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH)));
-char   *MD4File(char *, char [MD4_DIGEST_STRING_LENGTH])
-               __attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH)));
-char   *MD4Data(const uint8_t *, size_t, char [MD4_DIGEST_STRING_LENGTH])
-               __attribute__((__bounded__(__string__,1,2)))
-               __attribute__((__bounded__(__minbytes__,3,MD4_DIGEST_STRING_LENGTH)));*/
 /*__END_DECLS*/
 
 #endif /* _LRAD_MD4_H */
index 64520d9..cc602e5 100644 (file)
@@ -18,16 +18,16 @@ RCSID("$Id$")
  */
 #include "../include/md4.h"
 
-void md4_calc(output, input, inlen)
+void fr_md4_calc(output, input, inlen)
 unsigned char *output;
 const unsigned char *input;                       /* input block */
 unsigned int inlen;                     /* length of input block */
 {
-       MD4_CTX context;
+       FR_MD4_CTX      context;
 
-       MD4Init(&context);
-       MD4Update(&context, input, inlen);
-       MD4Final(output, &context);
+       fr_MD4Init(&context);
+       fr_MD4Update(&context, input, inlen);
+       fr_MD4Final(output, &context);
 }
 
 /*     The below was retrieved from
@@ -55,8 +55,8 @@ unsigned int inlen;                     /* length of input block */
  * with every copy.
  *
  * To compute the message digest of a chunk of bytes, declare an
- * MD4Context structure, pass it to MD4Init, call MD4Update as
- * needed on buffers full of bytes, and then call MD4Final, which
+ * MD4Context structure, pass it to fr_MD4Init, call fr_MD4Update as
+ * needed on buffers full of bytes, and then call fr_MD4Final, which
  * will fill a supplied 16-byte array with the digest.
  */
 
@@ -129,7 +129,7 @@ unsigned int inlen;                     /* length of input block */
  * Set bit count to 0 and buffer to mysterious initialization constants.
  */
 void
-MD4Init(MD4_CTX *ctx)
+fr_MD4Init(FR_MD4_CTX *ctx)
 {
        ctx->count[0] = 0;
        ctx->count[1] = 0;
@@ -144,7 +144,7 @@ MD4Init(MD4_CTX *ctx)
  * of bytes.
  */
 void
-MD4Update(MD4_CTX *ctx, const unsigned char *buf, size_t len)
+fr_MD4Update(FR_MD4_CTX *ctx, const unsigned char *buf, size_t len)
 {
        uint32_t count;
 
@@ -170,7 +170,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *buf, size_t len)
                }
                memcpy(p, buf, count);
                htole32_16((uint32_t *)ctx->buffer);
-               MD4Transform(ctx->state, ctx->buffer);
+               fr_MD4Transform(ctx->state, ctx->buffer);
                buf += count;
                len -= count;
        }
@@ -179,7 +179,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *buf, size_t len)
        while (len >= MD4_BLOCK_LENGTH) {
                memcpy(ctx->buffer, buf, MD4_BLOCK_LENGTH);
                htole32_16((uint32_t *)ctx->buffer);
-               MD4Transform(ctx->state, ctx->buffer);
+               fr_MD4Transform(ctx->state, ctx->buffer);
                buf += MD4_BLOCK_LENGTH;
                len -= MD4_BLOCK_LENGTH;
        }
@@ -193,7 +193,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *buf, size_t len)
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
 void
-MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_CTX *ctx)
+fr_MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], FR_MD4_CTX *ctx)
 {
        uint32_t count;
        unsigned char *p;
@@ -216,7 +216,7 @@ MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_CTX *ctx)
                /* Two lots of padding:  Pad the first block to 64 bytes */
                memset(p, 0, count);
                htole32_16((uint32_t *)ctx->buffer);
-               MD4Transform(ctx->state, ctx->buffer);
+               fr_MD4Transform(ctx->state, ctx->buffer);
 
                /* Now fill the next block with 56 bytes */
                memset(ctx->buffer, 0, 56);
@@ -230,7 +230,7 @@ MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_CTX *ctx)
        ((uint32_t *)ctx->buffer)[14] = ctx->count[0];
        ((uint32_t *)ctx->buffer)[15] = ctx->count[1];
 
-       MD4Transform(ctx->state, ctx->buffer);
+       fr_MD4Transform(ctx->state, ctx->buffer);
        htole32_4(ctx->state);
        memcpy(digest, ctx->state, MD4_DIGEST_LENGTH);
        memset(ctx, 0, sizeof(*ctx));   /* in case it's sensitive */
@@ -250,11 +250,11 @@ MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_CTX *ctx)
 
 /*
  * The core of the MD4 algorithm, this alters an existing MD4 hash to
- * reflect the addition of 16 longwords of new data.  MD4Update blocks
+ * reflect the addition of 16 longwords of new data.  fr_MD4Update blocks
  * the data and converts bytes into longwords for this routine.
  */
 void
-MD4Transform(uint32_t buf[4], const unsigned char inc[MD4_BLOCK_LENGTH])
+fr_MD4Transform(uint32_t buf[4], const unsigned char inc[MD4_BLOCK_LENGTH])
 {
        uint32_t a, b, c, d;
        const uint32_t *in = (const uint32_t *)inc;
index 0ccc170..3516a3e 100644 (file)
@@ -91,20 +91,20 @@ static void calc_md5_digest(char * buffer, const char * challenge, int challen,
 static void calc_md4_digest(char * buffer, const char * challenge, int challen, const char * password){
        char buf[1024];
        int i;
-       MD4_CTX Context;
+       FR_MD4_CTX Context;
 
        memset(buf, 0, 1024);
        memset(buf, 0x36, 64);
        for(i=0; i<64 && password[i]; i++) buf[i]^=password[i];
        memcpy(buf+64, challenge, challen);
-       MD4Init(&Context);
-       MD4Update(&Context,buf,64+challen);
+       fr_MD4Init(&Context);
+       fr_MD4Update(&Context,buf,64+challen);
        memset(buf, 0x5c, 64);
        for(i=0; i<64 && password[i]; i++) buf[i]^=password[i];
-        MD4Final(buf+64,&Context);
-       MD4Init(&Context);
-       MD4Update(&Context,buf,64+16);
-        MD4Final(buffer,&Context);
+        fr_MD4Final(buf+64,&Context);
+       fr_MD4Init(&Context);
+       fr_MD4Update(&Context,buf,64+16);
+        fr_MD4Final(buffer,&Context);
 }
 
 static void calc_sha1_digest(char * buffer, const char * challenge, int challen, const char * password){
index 5fef8c0..449848a 100644 (file)
@@ -221,7 +221,7 @@ static int eapleap_ntpwdhash(unsigned char *ntpwdhash, VALUE_PAIR *password)
                /*
                 *  Get the NT Password hash.
                 */
-               md4_calc(ntpwdhash, unicode, password->length * 2);
+               fr_md4_calc(ntpwdhash, unicode, password->length * 2);
 
        } else {                /* MUST be NT-Password */
                if (password->length == 32) {
@@ -334,7 +334,7 @@ LEAP_PACKET *eapleap_stage6(LEAP_PACKET *packet, REQUEST *request,
                eapleap_free(&reply);
                return NULL;
        }
-       md4_calc(ntpwdhashhash, ntpwdhash, 16);
+       fr_md4_calc(ntpwdhashhash, ntpwdhash, 16);
 
        /*
         *      Calculate our response, to authenticate ourselves
index 76d4341..accb520 100644 (file)
@@ -167,7 +167,7 @@ static void ntpwdhash (unsigned char *szHash, const char *szPassword)
        }
 
        /* Encrypt Unicode password to a 16-byte MD4 hash */
-       md4_calc(szHash, szUnicodePass, (nPasswordLen<<1) );
+       fr_md4_calc(szHash, szUnicodePass, (nPasswordLen<<1) );
 }
 
 
@@ -786,7 +786,7 @@ static int do_mschap(rlm_mschap_t *inst,
                 *      here minimizes work for later.
                 */
                if (password && (password->attribute == PW_NT_PASSWORD)) {
-                       md4_calc(nthashhash, password->vp_strvalue, 16);
+                       fr_md4_calc(nthashhash, password->vp_strvalue, 16);
                } else {
                        memset(nthashhash, 0, 16);
                }
index dd299a1..e182ca9 100644 (file)
@@ -59,7 +59,7 @@ static void ntpwdhash (char *szHash, const char *szPassword)
        }
 
        /* Encrypt Unicode password to a 16-byte MD4 hash */
-       md4_calc(szHash, szUnicodePass, (nPasswordLen<<1) );
+       fr_md4_calc(szHash, szUnicodePass, (nPasswordLen<<1) );
 }