From d9a2c66ab5c2b6a446bb2fe07ed4875a39e162f2 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 28 Oct 1997 21:40:10 +0000 Subject: [PATCH] * md5.c: Fix to deal with types longer than 32 bits git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10259 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/md4/ChangeLog | 4 ++++ src/lib/crypto/md4/md4.c | 5 ++++- src/lib/crypto/md5/ChangeLog | 4 ++++ src/lib/crypto/md5/md5.c | 10 +++++++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/lib/crypto/md4/ChangeLog b/src/lib/crypto/md4/ChangeLog index 3653c4509..bcac6ed4b 100644 --- a/src/lib/crypto/md4/ChangeLog +++ b/src/lib/crypto/md4/ChangeLog @@ -1,3 +1,7 @@ +Tue Oct 28 16:36:15 1997 Tom Yu + + * md4.c: Fix to deal with types longer than 32 bits. + Sat Feb 22 18:53:00 1997 Richard Basch * Makefile.in: Use some of the new library list build rules in diff --git a/src/lib/crypto/md4/md4.c b/src/lib/crypto/md4/md4.c index 8714f4a0b..fbfd25625 100644 --- a/src/lib/crypto/md4/md4.c +++ b/src/lib/crypto/md4/md4.c @@ -68,18 +68,21 @@ static unsigned char PADDING[64] = { #define H(x, y, z) ((x) ^ (y) ^ (z)) /* ROTATE_LEFT rotates x left n bits */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) +#define ROTATE_LEFT(x, n) (((x) << (n)) & 0xffffffff | ((x) >> (32-(n)))) /* FF, GG and HH are MD4 transformations for rounds 1, 2 and 3 */ /* Rotation is separate from addition to prevent recomputation */ #define FF(a, b, c, d, x, s) \ {(a) += F ((b), (c), (d)) + (x); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s));} #define GG(a, b, c, d, x, s) \ {(a) += G ((b), (c), (d)) + (x) + UL(013240474631); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s));} #define HH(a, b, c, d, x, s) \ {(a) += H ((b), (c), (d)) + (x) + UL(015666365641); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s));} void diff --git a/src/lib/crypto/md5/ChangeLog b/src/lib/crypto/md5/ChangeLog index 6cbaa4ab8..130adc451 100644 --- a/src/lib/crypto/md5/ChangeLog +++ b/src/lib/crypto/md5/ChangeLog @@ -1,3 +1,7 @@ +Tue Oct 28 16:36:30 1997 Tom Yu + + * md5.c: Fix to deal with types longer than 32 bits. + Sat Feb 22 18:54:09 1997 Richard Basch * Makefile.in: Use some of the new library list build rules in diff --git a/src/lib/crypto/md5/md5.c b/src/lib/crypto/md5/md5.c index a636968d5..95efb77e4 100644 --- a/src/lib/crypto/md5/md5.c +++ b/src/lib/crypto/md5/md5.c @@ -76,29 +76,37 @@ static unsigned char PADDING[64] = { #define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT rotates x left n bits */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) +#define ROTATE_LEFT(x, n) (((x) << (n)) & 0xffffffff | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ /* Rotation is separate from addition to prevent recomputation */ #define FF(a, b, c, d, x, s, ac) \ {(a) += F ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ + (a) &= 0xffffffff; \ } #define GG(a, b, c, d, x, s, ac) \ {(a) += G ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ + (a) &= 0xffffffff; \ } #define HH(a, b, c, d, x, s, ac) \ {(a) += H ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ + (a) &= 0xffffffff; \ } #define II(a, b, c, d, x, s, ac) \ {(a) += I ((b), (c), (d)) + (x) + (krb5_ui_4)(ac); \ + (a) &= 0xffffffff; \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ + (a) &= 0xffffffff; \ } /* The routine krb5_MD5Init initializes the message-digest context -- 2.26.2