From 648151a89b87f4ec906203fa0d1f3af9607e92c1 Mon Sep 17 00:00:00 2001 From: Michael Hampton Date: Fri, 1 Sep 2000 06:50:00 +0000 Subject: [PATCH] Changed to use integer macros from typesize.h for specific bit widths --- citadel/configure.in | 7 +++++++ citadel/md5.c | 26 +++++++++++++------------- citadel/md5.h | 8 +++++--- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/citadel/configure.in b/citadel/configure.in index dcdf5db66..d69fa1458 100644 --- a/citadel/configure.in +++ b/citadel/configure.in @@ -207,6 +207,13 @@ AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM +dnl Check the size of various builtin types; see typesize.h (error) +AC_CHECK_SIZEOF(char, 0) +AC_CHECK_SIZEOF(short, 0) +AC_CHECK_SIZEOF(int, 0) +AC_CHECK_SIZEOF(long, 0) +dnl AC_CHECK_SIZEOF(long long, 0) + AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type, [AC_TRY_COMPILE([#include #include ], [struct utmp ut; ut.ut_type;], diff --git a/citadel/md5.c b/citadel/md5.c index 5eb763610..1488a1a4e 100644 --- a/citadel/md5.c +++ b/citadel/md5.c @@ -32,11 +32,11 @@ void byteReverse(unsigned char *buf, unsigned longs); */ void byteReverse(unsigned char *buf, unsigned longs) { - u_int32_t t; + cit_uint32_t t; do { - t = (u_int32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + t = (cit_uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); - *(u_int32_t *) buf = t; + *(cit_uint32_t *) buf = t; buf += 4; } while (--longs); } @@ -66,12 +66,12 @@ void MD5Init(struct MD5Context *ctx) */ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) { - u_int32_t t; + cit_uint32_t t; /* Update bitcount */ t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t) + if ((ctx->bits[0] = t + ((cit_uint32_t) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; @@ -89,7 +89,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) } memcpy(p, buf, t); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (u_int32_t *) ctx->in); + MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); buf += t; len -= t; } @@ -98,7 +98,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (u_int32_t *) ctx->in); + MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); buf += 64; len -= 64; } @@ -133,7 +133,7 @@ void 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); - MD5Transform(ctx->buf, (u_int32_t *) ctx->in); + MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); @@ -144,10 +144,10 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) byteReverse(ctx->in, 14); /* Append length in bits and transform */ - ((u_int32_t *) ctx->in)[14] = ctx->bits[0]; - ((u_int32_t *) ctx->in)[15] = ctx->bits[1]; + ((cit_uint32_t *) ctx->in)[14] = ctx->bits[0]; + ((cit_uint32_t *) ctx->in)[15] = ctx->bits[1]; - MD5Transform(ctx->buf, (u_int32_t *) ctx->in); + MD5Transform(ctx->buf, (cit_uint32_t *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ @@ -177,9 +177,9 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ -void MD5Transform(u_int32_t buf[4], u_int32_t const in[16]) +void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16]) { - register u_int32_t a, b, c, d; + register cit_uint32_t a, b, c, d; a = buf[0]; b = buf[1]; diff --git a/citadel/md5.h b/citadel/md5.h index 401726b32..f81237108 100644 --- a/citadel/md5.h +++ b/citadel/md5.h @@ -1,9 +1,11 @@ #ifndef MD5_H #define MD5_H +#include "typesize.h" + struct MD5Context { - u_int32_t buf[4]; - u_int32_t bits[2]; + cit_uint32_t buf[4]; + cit_uint32_t bits[2]; unsigned char in[64]; }; @@ -11,7 +13,7 @@ void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len); void MD5Final(unsigned char digest[16], struct MD5Context *context); -void MD5Transform(u_int32_t buf[4], u_int32_t const in[16]); +void MD5Transform(cit_uint32_t buf[4], cit_uint32_t const in[16]); char *make_apop_string(char *realpass, char *nonce, u_char *buffer); /* -- 2.39.2