aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2013-05-11 01:43:50 +0200
committerTimo Weingärtner <timo@tiwe.de>2013-05-12 18:44:18 +0200
commitbe53f76279d158aa3e5fb2960f9ae4da52201857 (patch)
tree3141fc41a434875f3c833dafc9f3d641a45f5a0f
parentce9367b3202477b3cc914cabfe0cb2a856f3a51d (diff)
downloadlibpam-pwdfile-be53f76279d158aa3e5fb2960f9ae4da52201857.tar.gz
replace self-defined uint32 with uint32_t from stdint.h
unsigned int is not guaranteed to have 32 bits
-rw-r--r--md5.c22
-rw-r--r--md5.h10
2 files changed, 16 insertions, 16 deletions
diff --git a/md5.c b/md5.c
index 94f1e2a..2bc558e 100644
--- a/md5.c
+++ b/md5.c
@@ -27,7 +27,7 @@
#else
static void byteReverse(unsigned char *buf, unsigned longs) {
for (; longs; --longs, buf +=4)
- *((uint32 *) buf) = bswap_32(*((uint32 *) buf));
+ *((uint32_t *) buf) = bswap_32(*((uint32_t *) buf));
}
#endif
@@ -52,12 +52,12 @@ void MD5Name(MD5Init)(struct MD5Context *ctx)
*/
void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsigned len)
{
- uint32 t;
+ uint32_t t;
/* Update bitcount */
t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
@@ -75,7 +75,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in);
buf += t;
len -= t;
}
@@ -84,7 +84,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in);
buf += 64;
len -= 64;
}
@@ -119,7 +119,7 @@ void MD5Name(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);
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
@@ -130,10 +130,10 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx)
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
- ((uint32 *) ctx->in)[14] = ctx->bits[0];
- ((uint32 *) ctx->in)[15] = ctx->bits[1];
+ ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+ ((uint32_t *) ctx->in)[15] = ctx->bits[1];
- MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
+ MD5Name(MD5Transform)(ctx->buf, (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 */
@@ -156,9 +156,9 @@ void MD5Name(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 MD5Name(MD5Transform)(uint32 buf[4], uint32 const in[16])
+void MD5Name(MD5Transform)(uint32_t buf[4], uint32_t const in[16])
{
- register uint32 a, b, c, d;
+ register uint32_t a, b, c, d;
a = buf[0];
b = buf[1];
diff --git a/md5.h b/md5.h
index 103f168..b48edea 100644
--- a/md5.h
+++ b/md5.h
@@ -2,22 +2,22 @@
#ifndef MD5_H
#define MD5_H
-typedef unsigned int uint32;
+#include <stdint.h>
struct MD5Context {
- uint32 buf[4];
- uint32 bits[2];
+ uint32_t buf[4];
+ uint32_t bits[2];
unsigned char in[64];
};
void GoodMD5Init(struct MD5Context *);
void GoodMD5Update(struct MD5Context *, unsigned const char *, unsigned);
void GoodMD5Final(unsigned char digest[16], struct MD5Context *);
-void GoodMD5Transform(uint32 buf[4], uint32 const in[16]);
+void GoodMD5Transform(uint32_t buf[4], uint32_t const in[16]);
void BrokenMD5Init(struct MD5Context *);
void BrokenMD5Update(struct MD5Context *, unsigned const char *, unsigned);
void BrokenMD5Final(unsigned char digest[16], struct MD5Context *);
-void BrokenMD5Transform(uint32 buf[4], uint32 const in[16]);
+void BrokenMD5Transform(uint32_t buf[4], uint32_t const in[16]);
char *Goodcrypt_md5(const char *pw, const char *salt);
char *Brokencrypt_md5(const char *pw, const char *salt);