Changed to use integer macros from typesize.h for specific bit widths
authorMichael Hampton <io_error@uncensored.citadel.org>
Fri, 1 Sep 2000 06:50:00 +0000 (06:50 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Fri, 1 Sep 2000 06:50:00 +0000 (06:50 +0000)
citadel/configure.in
citadel/md5.c
citadel/md5.h

index dcdf5db66beacdcccca91089c4e167517b40bf4c..d69fa145853f50490067fe4f1ab719001d2da268 100644 (file)
@@ -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 <sys/types.h>
 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
index 5eb763610532d381f1b59f4fd46ef4fa99f4c696..1488a1a4e9e1a814e9a3d582196ba921efcfc2e7 100644 (file)
@@ -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];
index 401726b329292c18693e71977bae4f3394a512d7..f81237108d8f47d5ec7ca0c6f806e19eb8c4c2f4 100644 (file)
@@ -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);
 
 /*