]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
md4, md5: replace custom types with `uint32_t`
authorViktor Szakats <commit@vsz.me>
Thu, 29 Jan 2026 12:46:24 +0000 (13:46 +0100)
committerViktor Szakats <commit@vsz.me>
Thu, 29 Jan 2026 14:01:16 +0000 (15:01 +0100)
Closes #20469

lib/md4.c
lib/md5.c

index 845cdb6d7ed196f14fa299fb8486a7b4da844e65..80ccb5888b8da9b293d07d3ecb9196cb02af8327 100644 (file)
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -190,14 +190,11 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
  * (This is a heavily cut-down "BSD license".)
  */
 
-/* Any 32-bit or wider unsigned integer data type will do */
-typedef unsigned int MD4_u32plus;
-
 struct md4_ctx {
-  MD4_u32plus lo, hi;
-  MD4_u32plus a, b, c, d;
+  uint32_t lo, hi;
+  uint32_t a, b, c, d;
   unsigned char buffer[64];
-  MD4_u32plus block[16];
+  uint32_t block[16];
 };
 typedef struct md4_ctx MD4_CTX;
 
@@ -227,14 +224,14 @@ typedef struct md4_ctx MD4_CTX;
  * does not work.
  */
 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define MD4_SET(n) (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4])
+#define MD4_SET(n) (*(const uint32_t *)(const void *)&ptr[(n) * 4])
 #define MD4_GET(n) MD4_SET(n)
 #else
 #define MD4_SET(n) (ctx->block[(n)] = \
-   (MD4_u32plus)ptr[(n) * 4] | \
-  ((MD4_u32plus)ptr[(n) * 4 + 1] <<  8) | \
-  ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \
-  ((MD4_u32plus)ptr[(n) * 4 + 3] << 24))
+   (uint32_t)ptr[(n) * 4] | \
+  ((uint32_t)ptr[(n) * 4 + 1] <<  8) | \
+  ((uint32_t)ptr[(n) * 4 + 2] << 16) | \
+  ((uint32_t)ptr[(n) * 4 + 3] << 24))
 #define MD4_GET(n) (ctx->block[(n)])
 #endif
 
@@ -246,7 +243,7 @@ static const void *my_md4_body(MD4_CTX *ctx,
                                const void *data, unsigned long size)
 {
   const unsigned char *ptr;
-  MD4_u32plus a, b, c, d;
+  uint32_t a, b, c, d;
 
   ptr = (const unsigned char *)data;
 
@@ -256,7 +253,7 @@ static const void *my_md4_body(MD4_CTX *ctx,
   d = ctx->d;
 
   do {
-    MD4_u32plus saved_a, saved_b, saved_c, saved_d;
+    uint32_t saved_a, saved_b, saved_c, saved_d;
 
     saved_a = a;
     saved_b = b;
@@ -347,14 +344,14 @@ static int MD4_Init(MD4_CTX *ctx)
 
 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
 {
-  MD4_u32plus saved_lo;
+  uint32_t saved_lo;
   unsigned long used;
 
   saved_lo = ctx->lo;
   ctx->lo = (saved_lo + size) & 0x1fffffff;
   if(ctx->lo < saved_lo)
     ctx->hi++;
-  ctx->hi += (MD4_u32plus)size >> 29;
+  ctx->hi += (uint32_t)size >> 29;
 
   used = saved_lo & 0x3f;
 
index 1c5595ee19c533f53b690bf8a3fa2697bb9876cf..96c18f69cb6cf08248a929064b809dd1f0bd5970 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -276,14 +276,11 @@ static void my_md5_final(unsigned char *digest, void *in)
  * (This is a heavily cut-down "BSD license".)
  */
 
-/* Any 32-bit or wider unsigned integer data type will do */
-typedef unsigned int MD5_u32plus;
-
 struct md5_ctx {
-  MD5_u32plus lo, hi;
-  MD5_u32plus a, b, c, d;
+  uint32_t lo, hi;
+  uint32_t a, b, c, d;
   unsigned char buffer[64];
-  MD5_u32plus block[16];
+  uint32_t block[16];
 };
 typedef struct md5_ctx my_md5_ctx;
 
@@ -317,14 +314,14 @@ typedef struct md5_ctx my_md5_ctx;
  * does not work.
  */
 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define MD5_SET(n) (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4])
+#define MD5_SET(n) (*(const uint32_t *)(const void *)&ptr[(n) * 4])
 #define MD5_GET(n) MD5_SET(n)
 #else
 #define MD5_SET(n) (ctx->block[(n)] = \
-   (MD5_u32plus)ptr[(n) * 4] | \
-  ((MD5_u32plus)ptr[(n) * 4 + 1] <<  8) | \
-  ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
-  ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
+   (uint32_t)ptr[(n) * 4] | \
+  ((uint32_t)ptr[(n) * 4 + 1] <<  8) | \
+  ((uint32_t)ptr[(n) * 4 + 2] << 16) | \
+  ((uint32_t)ptr[(n) * 4 + 3] << 24))
 #define MD5_GET(n) (ctx->block[(n)])
 #endif
 
@@ -336,7 +333,7 @@ static const void *my_md5_body(my_md5_ctx *ctx,
                                const void *data, unsigned long size)
 {
   const unsigned char *ptr;
-  MD5_u32plus a, b, c, d;
+  uint32_t a, b, c, d;
 
   ptr = (const unsigned char *)data;
 
@@ -346,7 +343,7 @@ static const void *my_md5_body(my_md5_ctx *ctx,
   d = ctx->d;
 
   do {
-    MD5_u32plus saved_a, saved_b, saved_c, saved_d;
+    uint32_t saved_a, saved_b, saved_c, saved_d;
 
     saved_a = a;
     saved_b = b;
@@ -458,7 +455,7 @@ static CURLcode my_md5_init(void *in)
 static void my_md5_update(void *in, const unsigned char *data,
                           unsigned int size)
 {
-  MD5_u32plus saved_lo;
+  uint32_t saved_lo;
   unsigned int used;
   my_md5_ctx *ctx = (my_md5_ctx *)in;
 
@@ -466,7 +463,7 @@ static void my_md5_update(void *in, const unsigned char *data,
   ctx->lo = (saved_lo + size) & 0x1fffffff;
   if(ctx->lo < saved_lo)
     ctx->hi++;
-  ctx->hi += (MD5_u32plus)size >> 29;
+  ctx->hi += (uint32_t)size >> 29;
 
   used = saved_lo & 0x3f;