From 8e3f51c400b811b77cfcfbec971997b290ed509a Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 28 Jun 2017 07:06:57 +0200 Subject: [PATCH] Replace u_intxx types with c99 standard uintxx ones --- src/utils/md5.cpp | 24 ++++++++++++------------ src/utils/md5.h | 15 +++++++++------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/utils/md5.cpp b/src/utils/md5.cpp index a1786a8c..ccfd797a 100644 --- a/src/utils/md5.cpp +++ b/src/utils/md5.cpp @@ -20,10 +20,10 @@ #include "autoconfig.h" //#include -#include +#include "md5.h" + #include -#include "md5.h" #define PUT_64BIT_LE(cp, value) do { \ (cp)[7] = (value) >> 56; \ @@ -41,7 +41,7 @@ (cp)[1] = (value) >> 8; \ (cp)[0] = (value); } while (0) -static u_int8_t PADDING[MD5_BLOCK_LENGTH] = { +static uint8_t PADDING[MD5_BLOCK_LENGTH] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -75,7 +75,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len) need = MD5_BLOCK_LENGTH - have; /* Update bitcount */ - ctx->count += (u_int64_t)len << 3; + ctx->count += (uint64_t)len << 3; if (len >= need) { if (have != 0) { @@ -106,7 +106,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len) void MD5Pad(MD5_CTX *ctx) { - u_int8_t count[8]; + uint8_t count[8]; size_t padlen; /* Convert count to 8 bytes in little endian order. */ @@ -156,19 +156,19 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx) * the data and converts bytes into longwords for this routine. */ void -MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH]) +MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH]) { - u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4]; + uint32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4]; #ifndef WORDS_BIGENDIAN memcpy(in, block, sizeof(in)); #else for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) { - in[a] = (u_int32_t)( - (u_int32_t)(block[a * 4 + 0]) | - (u_int32_t)(block[a * 4 + 1]) << 8 | - (u_int32_t)(block[a * 4 + 2]) << 16 | - (u_int32_t)(block[a * 4 + 3]) << 24); + in[a] = (uint32_t)( + (uint32_t)(block[a * 4 + 0]) | + (uint32_t)(block[a * 4 + 1]) << 8 | + (uint32_t)(block[a * 4 + 2]) << 16 | + (uint32_t)(block[a * 4 + 3]) << 24); } #endif diff --git a/src/utils/md5.h b/src/utils/md5.h index f6243603..fcd66036 100644 --- a/src/utils/md5.h +++ b/src/utils/md5.h @@ -15,20 +15,23 @@ #ifndef _MD5_H_ #define _MD5_H_ +#include +#include + #define MD5_BLOCK_LENGTH 64 #define MD5_DIGEST_LENGTH 16 #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1) typedef struct MD5Context { - u_int32_t state[4]; /* state */ - u_int64_t count; /* number of bits, mod 2^64 */ - u_int8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */ + uint32_t state[4]; /* state */ + uint64_t count; /* number of bits, mod 2^64 */ + uint8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */ } MD5_CTX; void MD5Init(MD5_CTX *); -void MD5Update(MD5_CTX *, const u_int8_t *, size_t); +void MD5Update(MD5_CTX *, const uint8_t *, size_t); void MD5Pad(MD5_CTX *); -void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *); -void MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]); +void MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *); +void MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]); #endif /* _MD5_H_ */