* src/base/md5.c, src/base/md5.h: Updated to recent version. * src/base/ftobjs.c: Updated; `md5.c' no longer uses `free'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
diff --git a/ChangeLog b/ChangeLog
index 758a588..5e5e0b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-10-22 Werner Lemberg <wl@gnu.org>
+
+ * src/base/md5.c, src/base/md5.h: Updated to recent version.
+
+ * src/base/ftobjs.c: Updated; `md5.c' no longer uses `free'.
+
2013-10-19 Werner Lemberg <wl@gnu.org>
[autofit] s/SMALL_TOP/X_HEIGHT/.
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 3cb81a6..46429ab 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -56,9 +56,7 @@
#endif /* _MSC_VER */
/* it's easiest to include `md5.c' directly */
-#define free md5_free /* suppress a shadow warning */
#include "md5.c"
-#undef free
#if defined( _MSC_VER )
#pragma warning( pop )
diff --git a/src/base/md5.c b/src/base/md5.c
index 2f01c93..52d96ac 100644
--- a/src/base/md5.c
+++ b/src/base/md5.c
@@ -50,7 +50,8 @@
*/
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define H(x, y, z) (((x) ^ (y)) ^ (z))
+#define H2(x, y, z) ((x) ^ ((y) ^ (z)))
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
/*
@@ -89,13 +90,13 @@
* This processes one or more 64-byte data blocks, but does NOT update
* the bit counters. There are no alignment requirements.
*/
-static void *body(MD5_CTX *ctx, void *data, unsigned long size)
+static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
{
- unsigned char *ptr;
+ const unsigned char *ptr;
MD5_u32plus a, b, c, d;
MD5_u32plus saved_a, saved_b, saved_c, saved_d;
- ptr = (unsigned char *)data;
+ ptr = (const unsigned char *)data;
a = ctx->a;
b = ctx->b;
@@ -146,21 +147,21 @@ static void *body(MD5_CTX *ctx, void *data, unsigned long size)
/* Round 3 */
STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
- STEP(H, d, a, b, c, GET(8), 0x8771f681, 11)
+ STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
- STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23)
+ STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
- STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11)
+ STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
- STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23)
+ STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
- STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11)
+ STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
- STEP(H, b, c, d, a, GET(6), 0x04881d05, 23)
+ STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
- STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11)
+ STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
- STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23)
+ STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
/* Round 4 */
STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
@@ -207,10 +208,10 @@ void MD5_Init(MD5_CTX *ctx)
ctx->hi = 0;
}
-void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
+void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
{
MD5_u32plus saved_lo;
- unsigned long used, free;
+ unsigned long used, available;
saved_lo = ctx->lo;
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
@@ -220,16 +221,16 @@ void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
used = saved_lo & 0x3f;
if (used) {
- free = 64 - used;
+ available = 64 - used;
- if (size < free) {
+ if (size < available) {
memcpy(&ctx->buffer[used], data, size);
return;
}
- memcpy(&ctx->buffer[used], data, free);
- data = (unsigned char *)data + free;
- size -= free;
+ memcpy(&ctx->buffer[used], data, available);
+ data = (const unsigned char *)data + available;
+ size -= available;
body(ctx, ctx->buffer, 64);
}
@@ -243,22 +244,22 @@ void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
{
- unsigned long used, free;
+ unsigned long used, available;
used = ctx->lo & 0x3f;
ctx->buffer[used++] = 0x80;
- free = 64 - used;
+ available = 64 - used;
- if (free < 8) {
- memset(&ctx->buffer[used], 0, free);
+ if (available < 8) {
+ memset(&ctx->buffer[used], 0, available);
body(ctx, ctx->buffer, 64);
used = 0;
- free = 64;
+ available = 64;
}
- memset(&ctx->buffer[used], 0, free - 8);
+ memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
ctx->buffer[56] = ctx->lo;
diff --git a/src/base/md5.h b/src/base/md5.h
index f1a6857..2da44bf 100644
--- a/src/base/md5.h
+++ b/src/base/md5.h
@@ -39,7 +39,7 @@ typedef struct {
} MD5_CTX;
extern void MD5_Init(MD5_CTX *ctx);
-extern void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size);
+extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
#endif