/*
- * $Id: md5.h,v 1.10 2001/10/08 16:18:31 hno Exp $
+ * $Id: md5.h,v 1.11 2001/10/17 13:30:49 hno Exp $
*/
#ifndef SQUID_MD5_H
} MD5_CTX;
void MD5Init(MD5_CTX *);
-void MD5Update(MD5_CTX *, const unsigned char *, unsigned int);
-void MD5Final(unsigned char[16], MD5_CTX *);
+void MD5Update(MD5_CTX *, const void *, unsigned long);
+void MD5Final(unsigned char *, MD5_CTX *);
#define MD5_DIGEST_CHARS 16
/*
- * $Id: ntlmauth.h,v 1.6 2001/10/08 16:18:31 hno Exp $
+ * $Id: ntlmauth.h,v 1.7 2001/10/17 13:30:49 hno Exp $
*
* * * * * * * * Legal stuff * * * * * * *
*
#define bswap16(x) bswap_16(x)
#define bswap32(x) bswap_32(x)
#else /* HAVE_BISTWAP_H */
-#define bswap16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#define bswap16(x) (((((uint16_t)x) >> 8) & 0xff) | ((((uint16_t)x) & 0xff) << 8))
#define bswap32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+ (((((uint32_t)x) & 0xff000000) >> 24) | ((((uint32_t)x) & 0x00ff0000) >> 8) | \
+ ((((uint32_t)x) & 0x0000ff00) << 8) | ((((uint32_t)x) & 0x000000ff) << 24))
#endif /* HAVE_BITSWAP_H */
/* Used internally. Microsoft seems to think this is right, I believe them.
/*
- * $Id: md5.c,v 1.12 2001/04/14 00:03:20 hno Exp $
+ * $Id: md5.c,v 1.13 2001/10/17 13:30:50 hno Exp $
*/
/* taken from RFC-1321/Appendix A.3 */
* processing another message block, and updating the context.
*/
void
-MD5Update(MD5_CTX * context, const unsigned char *input, unsigned int inputLen)
+MD5Update(MD5_CTX * context, const void *input_p, unsigned long inputLen)
{
unsigned int i, index, partLen;
+ const unsigned char *input = input_p;
/* Compute number of bytes mod 64 */
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
* message digest and zeroizing the context.
*/
void
-MD5Final(unsigned char digest[16], MD5_CTX * context)
+MD5Final(unsigned char *digest, MD5_CTX * context)
{
unsigned char bits[8];
unsigned int index, padLen;
/*
- * $Id: rfc2617.c,v 1.4 2001/10/17 12:41:48 hno Exp $
+ * $Id: rfc2617.c,v 1.5 2001/10/17 13:30:50 hno Exp $
*
* DEBUG:
* AUTHOR: RFC 2617 & Robert Collins
Hex[i * 2 + 1] = (j + '0');
else
Hex[i * 2 + 1] = (j + 'a' - 10);
- };
+ }
Hex[HASHHEXLEN] = '\0';
-};
+}
void
CvtBin(const HASHHEX Hex, HASH Bin)
Bin[i / 2] |= ((j - '0') << ((i % 2 == 0) ? 4 : 0));
else
Bin[i / 2] |= ((j - 'a' + 10) << ((i % 2 == 0) ? 4 : 0));
- };
+ }
Bin[HASHLEN] = '\0';
-};
+}
/* calculate H(A1) as per spec */
MD5Update(&Md5Ctx, pszRealm, strlen(pszRealm));
MD5Update(&Md5Ctx, ":", 1);
MD5Update(&Md5Ctx, pszPassword, strlen(pszPassword));
- MD5Final(HA1, &Md5Ctx);
+ MD5Final((unsigned char *)HA1, &Md5Ctx);
}
if (strcasecmp(pszAlg, "md5-sess") == 0) {
MD5Init(&Md5Ctx);
MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
MD5Update(&Md5Ctx, ":", 1);
MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
- MD5Final(HA1, &Md5Ctx);
- };
+ MD5Final((unsigned char *)HA1, &Md5Ctx);
+ }
CvtHex(HA1, SessionKey);
-};
+}
/* calculate request-digest/response-digest as per HTTP Digest spec */
void
if (strcasecmp(pszQop, "auth-int") == 0) {
MD5Update(&Md5Ctx, ":", 1);
MD5Update(&Md5Ctx, HEntity, HASHHEXLEN);
- };
- MD5Final(HA2, &Md5Ctx);
+ }
+ MD5Final((unsigned char *)HA2, &Md5Ctx);
CvtHex(HA2, HA2Hex);
/* calculate response
MD5Update(&Md5Ctx, ":", 1);
MD5Update(&Md5Ctx, pszQop, strlen(pszQop));
MD5Update(&Md5Ctx, ":", 1);
- };
+ }
MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
- MD5Final(RespHash, &Md5Ctx);
+ MD5Final((unsigned char *)RespHash, &Md5Ctx);
CvtHex(RespHash, Response);
-};
+}