static const char *sp, *ep;
unsigned char final[16];
int sl, pl, i, j;
- MD5_CTX ctx, ctx1;
+ SquidMD5_CTX ctx, ctx1;
unsigned long l;
if (*salt == '$') {
/* get the length of the true salt */
sl = ep - sp;
- xMD5Init(&ctx);
+ SquidMD5Init(&ctx);
/* The password first, since that is what is most unknown */
- xMD5Update(&ctx, (unsigned const char *) pw, strlen(pw));
+ SquidMD5Update(&ctx, (unsigned const char *) pw, strlen(pw));
/* Then our magic string */
- xMD5Update(&ctx, (unsigned const char *) magic, magiclen);
+ SquidMD5Update(&ctx, (unsigned const char *) magic, magiclen);
/* Then the raw salt */
- xMD5Update(&ctx, (unsigned const char *) sp, sl);
+ SquidMD5Update(&ctx, (unsigned const char *) sp, sl);
/* Then just as many characters of the MD5(pw,salt,pw) */
- xMD5Init(&ctx1);
- xMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
- xMD5Update(&ctx1, (unsigned const char *) sp, sl);
- xMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
- xMD5Final(final, &ctx1);
+ SquidMD5Init(&ctx1);
+ SquidMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
+ SquidMD5Update(&ctx1, (unsigned const char *) sp, sl);
+ SquidMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
+ SquidMD5Final(final, &ctx1);
for (pl = strlen(pw); pl > 0; pl -= 16)
- xMD5Update(&ctx, (unsigned const char *) final, pl > 16 ? 16 : pl);
+ SquidMD5Update(&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(pw); i; i >>= 1)
if (i & 1)
- xMD5Update(&ctx, (unsigned const char *) final + j, 1);
+ SquidMD5Update(&ctx, (unsigned const char *) final + j, 1);
else
- xMD5Update(&ctx, (unsigned const char *) pw + j, 1);
+ SquidMD5Update(&ctx, (unsigned const char *) pw + j, 1);
/* Now make the output string */
memset(passwd, 0, sizeof(passwd));
strncat(passwd, sp, sl);
strcat(passwd, "$");
- xMD5Final(final, &ctx);
+ SquidMD5Final(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++) {
- xMD5Init(&ctx1);
+ SquidMD5Init(&ctx1);
if (i & 1)
- xMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
+ SquidMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
else
- xMD5Update(&ctx1, (unsigned const char *) final, 16);
+ SquidMD5Update(&ctx1, (unsigned const char *) final, 16);
if (i % 3)
- xMD5Update(&ctx1, (unsigned const char *) sp, sl);
+ SquidMD5Update(&ctx1, (unsigned const char *) sp, sl);
if (i % 7)
- xMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
+ SquidMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
if (i & 1)
- xMD5Update(&ctx1, (unsigned const char *) final, 16);
+ SquidMD5Update(&ctx1, (unsigned const char *) final, 16);
else
- xMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
- xMD5Final(final, &ctx1);
+ SquidMD5Update(&ctx1, (unsigned const char *) pw, strlen(pw));
+ SquidMD5Final(final, &ctx1);
}
p = passwd + strlen(passwd);
*/
char *md5sum(const char *s){
static unsigned char digest[16];
- MD5_CTX ctx;
+ SquidMD5_CTX ctx;
int idx;
static char sum[33];
memset(digest,0,16);
- xMD5Init(&ctx);
- xMD5Update(&ctx,(const unsigned char *)s,strlen(s));
- xMD5Final(digest,&ctx);
+ SquidMD5Init(&ctx);
+ SquidMD5Update(&ctx,(const unsigned char *)s,strlen(s));
+ SquidMD5Final(digest,&ctx);
for(idx=0;idx<16;idx++)
sprintf(&sum[idx*2],"%02x",digest[idx]);
#ifndef SQUID_MD5_H
#define SQUID_MD5_H
-#if USE_OPENSSL && HAVE_OPENSSL_MD5_H
-
-/*
- * If Squid is compiled with OpenSSL then we use the MD5 routines
- * from there via some wrapper macros, and the rest of this file is ignored..
- */
-#include <openssl/md5.h>
-
-#define xMD5Init MD5_Init
-#define xMD5Update MD5_Update
-#define xMD5Final MD5_Final
-
-#elif USE_OPENSSL && !HAVE_OPENSSL_MD5_H
-#error Cannot find OpenSSL MD5 headers
-
-#elif HAVE_SYS_MD5_H
-/*
- * Solaris 10 provides MD5 as part of the system.
- * So do other OS - but without MD5_DIGEST_LENGTH defined
- * for them we need to still use the bunded version
- */
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <sys/md5.h>
-
-#endif
-
-/* according to CacheDigest.cc squid REQUIRES 16-byte here for hash keys */
-#if MD5_DIGEST_LENGTH == 16
-
- /* We found a nice usable version. No need for ours */
-#define USE_SQUID_MD5 0
-
- /* adopt the supplied version we are able to use. */
-#define xMD5Init MD5Init
-#define xMD5Update MD5Update
-#define xMD5Final MD5Final
-#define MD5_DIGEST_CHARS MD5_DIGEST_LENGTH
-
-#else /* NEED squid bundled version */
-
- /* Turn on internal MD5 code */
-#define USE_SQUID_MD5 1
-
- /* remove MD5_CTX which may have been defined. */
-#undef MD5_CTX
-
/*
* This is the header file for the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
#include "squid_types.h"
-typedef struct MD5Context {
+typedef struct SquidMD5Context {
uint32_t buf[4];
uint32_t bytes[2];
uint32_t in[16];
-} MD5_CTX;
-
-SQUIDCEXTERN void xMD5Init(struct MD5Context *context);
-SQUIDCEXTERN void xMD5Update(struct MD5Context *context, const void *buf, unsigned len);
-SQUIDCEXTERN void xMD5Final(uint8_t digest[16], struct MD5Context *context);
-SQUIDCEXTERN void xMD5Transform(uint32_t buf[4], uint32_t const in[16]);
+} SquidMD5_CTX;
-#endif /* MD5_DIGEST_CHARS != 16 */
+SQUIDCEXTERN void SquidMD5Init(struct SquidMD5Context *context);
+SQUIDCEXTERN void SquidMD5Update(struct SquidMD5Context *context, const void *buf, unsigned len);
+SQUIDCEXTERN void SquidMD5Final(uint8_t digest[16], struct SquidMD5Context *context);
+SQUIDCEXTERN void SquidMD5Transform(uint32_t buf[4], uint32_t const in[16]);
+#define SQUID_MD5_DIGEST_LENGTH 16
#endif /* SQUID_MD5_H */
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
+ * SquidMD5Context structure, pass it to SquidMD5Init, call
+ * SquidMD5Update as needed on buffers full of bytes, and then call
+ * SquidMD5Final, which will fill a supplied 16-byte array with the
+ * digest.
*
* Changed so as no longer to depend on Colin Plumb's `usual.h' header
* definitions; now uses stuff from dpkg's config.h.
* - Ian Jackson <ian@chiark.greenend.org.uk>.
* Still in the public domain.
*
- * Changed MD5Update to take a void * for easier use and some other
- * minor cleanup. - Henrik Nordstrom <henrik@henriknordstrom.net>.
+ * Changed SquidMD5Update to take a void * for easier use and some
+ * other minor cleanup. - Henrik Nordstrom <henrik@henriknordstrom.net>.
+ * Still in the public domain.
+ *
+ * Prefixed all symbols with "Squid" so they don't collide with
+ * other libraries. Duane Wessels <wessels@squid-cache.org>.
* Still in the public domain.
*
*/
#include "md5.h"
-/*
- * Now that we have several alternatives the MD5 files are
- * passed in by default. But a header-selection decides whether
- * this provided version is to be built.
- * TODO: may obsolete the MSV #if below.
- */
-#if USE_SQUID_MD5
-
-/* MS VisualStudio Projects are monolithic, so we need USE_SSL
- * #if to exclude the MD5 code from compile process when we are
- * building the SSL support.
- */
-#if !USE_SSL
-
#if HAVE_STRING_H
#include <string.h> /* for memcpy() */
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h> /* for stupid systems */
#endif
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h> /* for ntohl() */
-#endif
#ifdef WORDS_BIGENDIAN
-void byteSwap(uint32_t *, unsigned);
-
void
-byteSwap(uint32_t * buf, unsigned words)
+static byteSwap(uint32_t * buf, unsigned words)
{
uint8_t *p = (uint8_t *) buf;
* initialization constants.
*/
void
-xMD5Init(struct MD5Context *ctx)
+SquidMD5Init(struct SquidMD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
* of bytes.
*/
void
-xMD5Update(struct MD5Context *ctx, const void *_buf, unsigned len)
+SquidMD5Update(struct SquidMD5Context *ctx, const void *_buf, unsigned len)
{
uint8_t const *buf = _buf;
uint32_t t;
/* First chunk is an odd size */
memcpy((uint8_t *) ctx->in + 64 - t, buf, t);
byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
+ SquidMD5Transform(ctx->buf, ctx->in);
buf += t;
len -= t;
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
+ SquidMD5Transform(ctx->buf, ctx->in);
buf += 64;
len -= 64;
}
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void
-xMD5Final(unsigned char digest[16], struct MD5Context *ctx)
+SquidMD5Final(unsigned char digest[16], struct SquidMD5Context *ctx)
{
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
uint8_t *p = (uint8_t *) ctx->in + count;
if (count < 0) { /* Padding forces an extra block */
memset(p, 0, count + 8);
byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
+ SquidMD5Transform(ctx->buf, ctx->in);
p = (uint8_t *) ctx->in;
count = 56;
}
/* Append length in bits and transform */
ctx->in[14] = ctx->bytes[0] << 3;
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
- MD5Transform(ctx->buf, ctx->in);
+ SquidMD5Transform(ctx->buf, ctx->in);
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
+ * reflect the addition of 16 longwords of new data. SquidMD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void
-xMD5Transform(uint32_t buf[4], uint32_t const in[16])
+SquidMD5Transform(uint32_t buf[4], uint32_t const in[16])
{
register uint32_t a, b, c, d;
}
#endif /* !ASM_MD5 */
-#endif /* !USE_SSL */
-#endif /* !USE_SQUID_MD5 */
/*
- * $Id: rfc2617.c,v 1.11 2007/11/15 09:18:05 amosjeffries Exp $
+ * $Id: rfc2617.c,v 1.12 2007/11/15 16:47:34 wessels Exp $
*
* DEBUG:
* AUTHOR: RFC 2617 & Robert Collins
HASHHEX SessionKey
)
{
- MD5_CTX Md5Ctx;
+ SquidMD5_CTX Md5Ctx;
if (pszUserName) {
- xMD5Init(&Md5Ctx);
- xMD5Update(&Md5Ctx, pszUserName, strlen(pszUserName));
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszRealm, strlen(pszRealm));
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszPassword, strlen(pszPassword));
- xMD5Final((unsigned char *) HA1, &Md5Ctx);
+ SquidMD5Init(&Md5Ctx);
+ SquidMD5Update(&Md5Ctx, pszUserName, strlen(pszUserName));
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszRealm, strlen(pszRealm));
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszPassword, strlen(pszPassword));
+ SquidMD5Final((unsigned char *) HA1, &Md5Ctx);
}
if (strcasecmp(pszAlg, "md5-sess") == 0) {
HASHHEX HA1Hex;
CvtHex(HA1, HA1Hex); /* RFC2617 errata */
- xMD5Init(&Md5Ctx);
- xMD5Update(&Md5Ctx, HA1Hex, HASHHEXLEN);
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
- xMD5Final((unsigned char *) HA1, &Md5Ctx);
+ SquidMD5Init(&Md5Ctx);
+ SquidMD5Update(&Md5Ctx, HA1Hex, HASHHEXLEN);
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
+ SquidMD5Final((unsigned char *) HA1, &Md5Ctx);
}
CvtHex(HA1, SessionKey);
}
HASHHEX Response /* request-digest or response-digest */
)
{
- MD5_CTX Md5Ctx;
+ SquidMD5_CTX Md5Ctx;
HASH HA2;
HASH RespHash;
HASHHEX HA2Hex;
/* calculate H(A2)
*/
- xMD5Init(&Md5Ctx);
- xMD5Update(&Md5Ctx, pszMethod, strlen(pszMethod));
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));
+ SquidMD5Init(&Md5Ctx);
+ SquidMD5Update(&Md5Ctx, pszMethod, strlen(pszMethod));
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));
if (strcasecmp(pszQop, "auth-int") == 0) {
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, HEntity, HASHHEXLEN);
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, HEntity, HASHHEXLEN);
}
- xMD5Final((unsigned char *) HA2, &Md5Ctx);
+ SquidMD5Final((unsigned char *) HA2, &Md5Ctx);
CvtHex(HA2, HA2Hex);
/* calculate response
*/
- xMD5Init(&Md5Ctx);
- xMD5Update(&Md5Ctx, HA1, HASHHEXLEN);
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
- xMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Init(&Md5Ctx);
+ SquidMD5Update(&Md5Ctx, HA1, HASHHEXLEN);
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
+ SquidMD5Update(&Md5Ctx, ":", 1);
if (*pszQop) {
- xMD5Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
- xMD5Update(&Md5Ctx, ":", 1);
- xMD5Update(&Md5Ctx, pszQop, strlen(pszQop));
- xMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
+ SquidMD5Update(&Md5Ctx, ":", 1);
+ SquidMD5Update(&Md5Ctx, pszQop, strlen(pszQop));
+ SquidMD5Update(&Md5Ctx, ":", 1);
}
- xMD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
- xMD5Final((unsigned char *) RespHash, &Md5Ctx);
+ SquidMD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
+ SquidMD5Final((unsigned char *) RespHash, &Md5Ctx);
CvtHex(RespHash, Response);
}
/*
- * $Id: CacheDigest.cc,v 1.39 2007/04/28 22:26:37 hno Exp $
+ * $Id: CacheDigest.cc,v 1.40 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 70 Cache Digest
* AUTHOR: Alex Rousskov
cacheDigestCreate(int capacity, int bpe)
{
CacheDigest *cd = (CacheDigest *)memAllocate(MEM_CACHE_DIGEST);
- assert(MD5_DIGEST_CHARS == 16); /* our hash functions rely on 16 byte keys */
+ assert(SQUID_MD5_DIGEST_LENGTH == 16); /* our hash functions rely on 16 byte keys */
cacheDigestInit(cd, capacity, bpe);
return cd;
}
/*
- * $Id: MemObject.cc,v 1.31 2007/11/15 09:18:12 amosjeffries Exp $
+ * $Id: MemObject.cc,v 1.32 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 19 Store Memory Primitives
* AUTHOR: Robert Collins
url_checksum(const char *url)
{
unsigned int ck;
- MD5_CTX M;
+ SquidMD5_CTX M;
static unsigned char digest[16];
- xMD5Init(&M);
- xMD5Update(&M, (unsigned char *) url, strlen(url));
- xMD5Final(digest, &M);
+ SquidMD5Init(&M);
+ SquidMD5Update(&M, (unsigned char *) url, strlen(url));
+ SquidMD5Final(digest, &M);
xmemcpy(&ck, digest, sizeof(ck));
return ck;
}
/*
- * $Id: StoreMetaMD5.cc,v 1.5 2007/04/28 22:26:37 hno Exp $
+ * $Id: StoreMetaMD5.cc,v 1.6 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 20 Storage Manager Swapfile Metadata
* AUTHOR: Kostas Anagnostakis
bool
StoreMetaMD5::validLength(int len) const
{
- return len == MD5_DIGEST_CHARS;
+ return len == SQUID_MD5_DIGEST_LENGTH;
}
int StoreMetaMD5::md5_mismatches = 0;
StoreMetaMD5::checkConsistency(StoreEntry *e) const
{
assert (getType() == STORE_META_KEY_MD5);
- assert(length == MD5_DIGEST_CHARS);
+ assert(length == SQUID_MD5_DIGEST_LENGTH);
if (!EBIT_TEST(e->flags, KEY_PRIVATE) &&
- memcmp(value, e->key, MD5_DIGEST_CHARS)) {
+ memcmp(value, e->key, SQUID_MD5_DIGEST_LENGTH)) {
debugs(20, 2, "storeClientReadHeader: swapin MD5 mismatch");
// debugs(20, 2, "\t" << storeKeyText((const cache_key *)value));
debugs(20, 2, "\t" << e->getMD5Text());
/*
- * $Id: StoreSwapLogData.h,v 1.4 2007/08/13 17:20:51 hno Exp $
+ * $Id: StoreSwapLogData.h,v 1.5 2007/11/15 16:47:35 wessels Exp $
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* ----------------------------------------------------------
uint64_t swap_file_sz;
u_short refcount;
u_short flags;
- unsigned char key[MD5_DIGEST_CHARS];
+ unsigned char key[SQUID_MD5_DIGEST_LENGTH];
};
MEMPROXY_CLASS_INLINE(StoreSwapLogData)
/*
- * $Id: cache_diff.cc,v 1.20 2003/07/15 11:33:22 robertc Exp $
+ * $Id: cache_diff.cc,v 1.21 2007/11/15 16:47:35 wessels Exp $
*
* AUTHOR: Alex Rousskov
*
struct _CacheEntry *next;
/* StoreSwapLogData s; */
- unsigned char key_arr[MD5_DIGEST_CHARS];
+ unsigned char key_arr[SQUID_MD5_DIGEST_LENGTH];
}
CacheEntry;
CacheEntry *e = xcalloc(1, sizeof(CacheEntry));
assert(s);
/* e->s = *s; */
- xmemcpy(e->key_arr, s->key, MD5_DIGEST_CHARS);
+ xmemcpy(e->key_arr, s->key, SQUID_MD5_DIGEST_LENGTH);
e->key = &e->key_arr[0];
return e;
}
/*
- * $Id: store_dir_coss.cc,v 1.76 2007/08/13 17:20:56 hno Exp $
+ * $Id: store_dir_coss.cc,v 1.77 2007/11/15 16:47:36 wessels Exp $
* vim: set et :
*
* DEBUG: section 47 Store COSS Directory Routines
s.swap_file_sz = e.swap_file_sz;
s.refcount = e.refcount;
s.flags = e.flags;
- xmemcpy(&s.key, e.key, MD5_DIGEST_CHARS);
+ xmemcpy(&s.key, e.key, SQUID_MD5_DIGEST_LENGTH);
xmemcpy(outbuf + outbuf_offset, &s, ss);
outbuf_offset += ss;
/* buffered write */
s->swap_file_sz = e.swap_file_sz;
s->refcount = e.refcount;
s->flags = e.flags;
- xmemcpy(s->key, e.key, MD5_DIGEST_CHARS);
+ xmemcpy(s->key, e.key, SQUID_MD5_DIGEST_LENGTH);
file_write(swaplog_fd,
-1,
s,
/*
- * $Id: store_dir_ufs.cc,v 1.85 2007/08/13 17:20:57 hno Exp $
+ * $Id: store_dir_ufs.cc,v 1.86 2007/11/15 16:47:38 wessels Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
s.swap_file_sz = e.swap_file_sz;
s.refcount = e.refcount;
s.flags = e.flags;
- xmemcpy(&s.key, e.key, MD5_DIGEST_CHARS);
+ xmemcpy(&s.key, e.key, SQUID_MD5_DIGEST_LENGTH);
xmemcpy(outbuf + outbuf_offset, &s, ss);
outbuf_offset += ss;
/* buffered write */
s->swap_file_sz = e.swap_file_sz;
s->refcount = e.refcount;
s->flags = e.flags;
- xmemcpy(s->key, e.key, MD5_DIGEST_CHARS);
+ xmemcpy(s->key, e.key, SQUID_MD5_DIGEST_LENGTH);
file_write(swaplog_fd,
-1,
s,
/*
- * $Id: ufscommon.cc,v 1.14 2007/08/15 15:07:41 rousskov Exp $
+ * $Id: ufscommon.cc,v 1.15 2007/11/15 16:47:38 wessels Exp $
* vim: set et :
*
* DEBUG: section 47 Store Directory Routines
size_t swap_file_sz;
u_short refcount;
u_short flags;
- unsigned char key[MD5_DIGEST_CHARS];
+ unsigned char key[SQUID_MD5_DIGEST_LENGTH];
};
UFSSwapLogParser_old(FILE *fp):UFSSwapLogParser(fp)
{
swapData.swap_file_sz = readData.swap_file_sz;
swapData.refcount = readData.refcount;
swapData.flags = readData.flags;
- xmemcpy(swapData.key, readData.key, MD5_DIGEST_CHARS);
+ xmemcpy(swapData.key, readData.key, SQUID_MD5_DIGEST_LENGTH);
return true;
}
switch (x.getType()) {
case STORE_META_KEY:
- assert(x.length == MD5_DIGEST_CHARS);
- xmemcpy(index, x.value, MD5_DIGEST_CHARS);
+ assert(x.length == SQUID_MD5_DIGEST_LENGTH);
+ xmemcpy(index, x.value, SQUID_MD5_DIGEST_LENGTH);
break;
case STORE_META_STD:
{
LOCAL_ARRAY(char, hdr_buf, SM_PAGE_SIZE);
currentEntry(NULL);
- cache_key key[MD5_DIGEST_CHARS];
+ cache_key key[SQUID_MD5_DIGEST_LENGTH];
struct stat sb;
int swap_hdr_len;
}
debugs(47, 3, "commonUfsDirRebuildFromDirectory: successful swap meta unpacking");
- memset(key, '\0', MD5_DIGEST_CHARS);
+ memset(key, '\0', SQUID_MD5_DIGEST_LENGTH);
StoreEntry tmpe;
InitStoreEntry visitor(&tmpe, key);
/*
- * $Id: htcp.cc,v 1.76 2007/04/30 16:56:09 wessels Exp $
+ * $Id: htcp.cc,v 1.77 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 31 Hypertext Caching Protocol
* AUTHOR: Duane Wesssels
static int htcpOutSocket = -1;
#define N_QUERIED_KEYS 8192
static u_int32_t queried_id[N_QUERIED_KEYS];
-static cache_key queried_keys[N_QUERIED_KEYS][MD5_DIGEST_CHARS];
+static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH];
static struct sockaddr_in queried_addr[N_QUERIED_KEYS];
static MemAllocator *htcpDetailPool = NULL;
/*
- * $Id: icp_v2.cc,v 1.100 2007/11/13 23:25:34 rousskov Exp $
+ * $Id: icp_v2.cc,v 1.101 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 12 Internet Cache Protocol
* AUTHOR: Duane Wessels
#define N_QUERIED_KEYS 8192
#define N_QUERIED_KEYS_MASK 8191
-static cache_key queried_keys[N_QUERIED_KEYS][MD5_DIGEST_CHARS];
+static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH];
int
icpSetCacheKey(const cache_key * key)
/*
- * $Id: mem.cc,v 1.105 2007/05/22 16:40:06 rousskov Exp $
+ * $Id: mem.cc,v 1.106 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 13 High Level Memory Pool Management
* AUTHOR: Harvest Derived
memDataInit(MEM_NET_DB_NAME, "net_db_name", sizeof(net_db_name), 0);
memDataInit(MEM_RELIST, "relist", sizeof(relist), 0);
memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0);
- memDataInit(MEM_MD5_DIGEST, "MD5 digest", MD5_DIGEST_CHARS, 0);
+ memDataInit(MEM_MD5_DIGEST, "MD5 digest", SQUID_MD5_DIGEST_LENGTH, 0);
MemPools[MEM_MD5_DIGEST]->setChunkSize(512 * 1024);
/* init string pools */
/*
- * $Id: store_key_md5.cc,v 1.35 2007/11/15 09:18:12 amosjeffries Exp $
+ * $Id: store_key_md5.cc,v 1.36 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 20 Storage Manager MD5 Cache Keys
* AUTHOR: Duane Wessels
#include "squid.h"
#include "HttpRequest.h"
-static cache_key null_key[MD5_DIGEST_CHARS];
+static cache_key null_key[SQUID_MD5_DIGEST_LENGTH];
const char *
storeKeyText(const cache_key *key)
{
- static char buf[MD5_DIGEST_CHARS * 2+1];
+ static char buf[SQUID_MD5_DIGEST_LENGTH * 2+1];
int i;
- for (i = 0; i < MD5_DIGEST_CHARS; i++)
+ for (i = 0; i < SQUID_MD5_DIGEST_LENGTH; i++)
snprintf(&buf[i*2],sizeof(buf) - i*2, "%02X", *(key + i));
return buf;
const cache_key *
storeKeyScan(const char *buf)
{
- static unsigned char digest[MD5_DIGEST_CHARS];
+ static unsigned char digest[SQUID_MD5_DIGEST_LENGTH];
int i;
int j = 0;
char t[3];
- for (i = 0; i < MD5_DIGEST_CHARS; i++) {
+ for (i = 0; i < SQUID_MD5_DIGEST_LENGTH; i++) {
t[0] = *(buf + (j++));
t[1] = *(buf + (j++));
t[2] = '\0';
const unsigned char *B = (const unsigned char *)b;
int i;
- for (i = 0; i < MD5_DIGEST_CHARS; i++) {
+ for (i = 0; i < SQUID_MD5_DIGEST_LENGTH; i++) {
if (A[i] < B[i])
return -1;
const cache_key *
storeKeyPrivate(const char *url, method_t method, int id)
{
- static cache_key digest[MD5_DIGEST_CHARS];
- MD5_CTX M;
+ static cache_key digest[SQUID_MD5_DIGEST_LENGTH];
+ SquidMD5_CTX M;
assert(id > 0);
debugs(20, 3, "storeKeyPrivate: " << RequestMethodStr[method] << " " << url);
- xMD5Init(&M);
- xMD5Update(&M, (unsigned char *) &id, sizeof(id));
- xMD5Update(&M, (unsigned char *) &method, sizeof(method));
- xMD5Update(&M, (unsigned char *) url, strlen(url));
- xMD5Final(digest, &M);
+ SquidMD5Init(&M);
+ SquidMD5Update(&M, (unsigned char *) &id, sizeof(id));
+ SquidMD5Update(&M, (unsigned char *) &method, sizeof(method));
+ SquidMD5Update(&M, (unsigned char *) url, strlen(url));
+ SquidMD5Final(digest, &M);
return digest;
}
const cache_key *
storeKeyPublic(const char *url, const method_t method)
{
- static cache_key digest[MD5_DIGEST_CHARS];
+ static cache_key digest[SQUID_MD5_DIGEST_LENGTH];
unsigned char m = (unsigned char) method;
- MD5_CTX M;
- xMD5Init(&M);
- xMD5Update(&M, &m, sizeof(m));
- xMD5Update(&M, (unsigned char *) url, strlen(url));
- xMD5Final(digest, &M);
+ SquidMD5_CTX M;
+ SquidMD5Init(&M);
+ SquidMD5Update(&M, &m, sizeof(m));
+ SquidMD5Update(&M, (unsigned char *) url, strlen(url));
+ SquidMD5Final(digest, &M);
return digest;
}
const cache_key *
storeKeyPublicByRequestMethod(HttpRequest * request, const method_t method)
{
- static cache_key digest[MD5_DIGEST_CHARS];
+ static cache_key digest[SQUID_MD5_DIGEST_LENGTH];
unsigned char m = (unsigned char) method;
const char *url = urlCanonical(request);
- MD5_CTX M;
- xMD5Init(&M);
- xMD5Update(&M, &m, sizeof(m));
- xMD5Update(&M, (unsigned char *) url, strlen(url));
+ SquidMD5_CTX M;
+ SquidMD5Init(&M);
+ SquidMD5Update(&M, &m, sizeof(m));
+ SquidMD5Update(&M, (unsigned char *) url, strlen(url));
if (request->vary_headers)
- xMD5Update(&M, (unsigned char *) request->vary_headers, strlen(request->vary_headers));
+ SquidMD5Update(&M, (unsigned char *) request->vary_headers, strlen(request->vary_headers));
- xMD5Final(digest, &M);
+ SquidMD5Final(digest, &M);
return digest;
}
storeKeyDup(const cache_key * key)
{
cache_key *dup = (cache_key *)memAllocate(MEM_MD5_DIGEST);
- xmemcpy(dup, key, MD5_DIGEST_CHARS);
+ xmemcpy(dup, key, SQUID_MD5_DIGEST_LENGTH);
return dup;
}
cache_key *
storeKeyCopy(cache_key * dst, const cache_key * src)
{
- xmemcpy(dst, src, MD5_DIGEST_CHARS);
+ xmemcpy(dst, src, SQUID_MD5_DIGEST_LENGTH);
return dst;
}
int
storeKeyNull(const cache_key * key)
{
- if (memcmp(key, null_key, MD5_DIGEST_CHARS) == 0)
+ if (memcmp(key, null_key, SQUID_MD5_DIGEST_LENGTH) == 0)
return 1;
else
return 0;
void
storeKeyInit(void)
{
- memset(null_key, '\0', MD5_DIGEST_CHARS);
+ memset(null_key, '\0', SQUID_MD5_DIGEST_LENGTH);
}
/*
- * $Id: store_swapmeta.cc,v 1.26 2007/08/13 17:20:51 hno Exp $
+ * $Id: store_swapmeta.cc,v 1.27 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 20 Storage Manager Swapfile Metadata
* AUTHOR: Kostas Anagnostakis
assert(e->swap_status == SWAPOUT_WRITING);
url = e->url();
debugs(20, 3, "storeSwapMetaBuild: " << url );
- tlv *t = StoreMeta::Factory (STORE_META_KEY,MD5_DIGEST_CHARS, e->key);
+ tlv *t = StoreMeta::Factory (STORE_META_KEY,SQUID_MD5_DIGEST_LENGTH, e->key);
if (!t) {
storeSwapTLVFree(TLV);
/*
- * $Id: test_cache_digest.cc,v 1.33 2004/12/20 16:30:36 robertc Exp $
+ * $Id: test_cache_digest.cc,v 1.34 2007/11/15 16:47:35 wessels Exp $
*
* AUTHOR: Alex Rousskov
*
const cache_key *key;
struct _CacheEntry *next;
- unsigned char key_arr[MD5_DIGEST_CHARS];
+ unsigned char key_arr[SQUID_MD5_DIGEST_LENGTH];
/* storeSwapLogData s; */
}
typedef struct
{
- cache_key key[MD5_DIGEST_CHARS];
+ cache_key key[SQUID_MD5_DIGEST_LENGTH];
time_t timestamp;
short int use_icp; /* true/false */
}
CacheEntry *e = (CacheEntry *)xcalloc(1, sizeof(CacheEntry));
assert(s);
/* e->s = *s; */
- xmemcpy(e->key_arr, s->key, MD5_DIGEST_CHARS);
+ xmemcpy(e->key_arr, s->key, SQUID_MD5_DIGEST_LENGTH);
e->key = &e->key_arr[0];
return e;
}
/*
- * $Id: ufsdump.cc,v 1.10 2007/08/13 17:20:51 hno Exp $
+ * $Id: ufsdump.cc,v 1.11 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 0 UFS Store Dump
* AUTHOR: Robert Collins
metadata = aBuilder.createStoreMeta ();
- cache_key key[MD5_DIGEST_CHARS];
+ cache_key key[SQUID_MD5_DIGEST_LENGTH];
- memset(key, '\0', MD5_DIGEST_CHARS);
+ memset(key, '\0', SQUID_MD5_DIGEST_LENGTH);
DumpStoreMeta dumper;
/*
- * $Id: wccp2.cc,v 1.18 2007/11/15 09:18:12 amosjeffries Exp $
+ * $Id: wccp2.cc,v 1.19 2007/11/15 16:47:35 wessels Exp $
*
* DEBUG: section 80 WCCP Support
* AUTHOR: Steven Wilton
{
u_int8_t md5_digest[16];
char pwd[WCCP2_PASSWORD_LEN];
- MD5_CTX M;
+ SquidMD5_CTX M;
struct wccp2_security_md5_t *ws;
/* XXX eventually we should be able to kill md5_digest and blit it directly in */
memset(ws->security_implementation, 0, sizeof(ws->security_implementation));
- xMD5Init(&M);
+ SquidMD5Init(&M);
- xMD5Update(&M, pwd, 8);
+ SquidMD5Update(&M, pwd, 8);
- xMD5Update(&M, packet, len);
+ SquidMD5Update(&M, packet, len);
- xMD5Final(md5_digest, &M);
+ SquidMD5Final(md5_digest, &M);
memcpy(ws->security_implementation, md5_digest, sizeof(md5_digest));
struct wccp2_security_md5_t *ws = (struct wccp2_security_md5_t *) security;
u_int8_t md5_digest[16], md5_challenge[16];
char pwd[WCCP2_PASSWORD_LEN];
- MD5_CTX M;
+ SquidMD5_CTX M;
/* Make sure the security type matches what we expect */
memset(ws->security_implementation, 0, sizeof(ws->security_implementation));
- xMD5Init(&M);
+ SquidMD5Init(&M);
- xMD5Update(&M, pwd, 8);
+ SquidMD5Update(&M, pwd, 8);
- xMD5Update(&M, packet, len);
+ SquidMD5Update(&M, packet, len);
- xMD5Final(md5_digest, &M);
+ SquidMD5Final(md5_digest, &M);
return (memcmp(md5_digest, md5_challenge, 16) == 0);
}