[PATCH] MD4/MD5 fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The attached patches fix MD4 and MD5 hash functions.  It seems these 
are just conversion mistakes:

http://cvs.savannah.gnu.org/viewcvs/gnu-crypto/source/gnu/crypto/hash/MD4.java?root=gnu-crypto&r1=1.4&r2=1.5&diff_format=u
http://cvs.savannah.gnu.org/viewcvs/gnu-crypto/source/gnu/crypto/hash/MD5.java?root=gnu-crypto&r1=1.5&r2=1.6&diff_format=u

FYI,

Jung-uk Kim
--- gnu/java/security/hash/MD4.java.orig	Sun Jun 18 02:59:24 2006
+++ gnu/java/security/hash/MD4.java	Fri Jan  5 19:17:32 2007
@@ -231,103 +231,103 @@
     dd = d;
 
     aa += ((bb & cc) | ((~bb) & dd)) + X0;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & bb) | ((~aa) & cc)) + X1;
-    dd = dd << 7 | dd >>> -7;
+    dd = dd << 7 | dd >>> (32 - 7);
     cc += ((dd & aa) | ((~dd) & bb)) + X2;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += ((cc & dd) | ((~cc) & aa)) + X3;
-    bb = bb << 19 | bb >>> -19;
+    bb = bb << 19 | bb >>> (32 - 19);
     aa += ((bb & cc) | ((~bb) & dd)) + X4;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & bb) | ((~aa) & cc)) + X5;
-    dd = dd << 7 | dd >>> -7;
+    dd = dd << 7 | dd >>> (32 - 7);
     cc += ((dd & aa) | ((~dd) & bb)) + X6;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += ((cc & dd) | ((~cc) & aa)) + X7;
-    bb = bb << 19 | bb >>> -19;
+    bb = bb << 19 | bb >>> (32 - 19);
     aa += ((bb & cc) | ((~bb) & dd)) + X8;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & bb) | ((~aa) & cc)) + X9;
-    dd = dd << 7 | dd >>> -7;
+    dd = dd << 7 | dd >>> (32 - 7);
     cc += ((dd & aa) | ((~dd) & bb)) + X10;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += ((cc & dd) | ((~cc) & aa)) + X11;
-    bb = bb << 19 | bb >>> -19;
+    bb = bb << 19 | bb >>> (32 - 19);
     aa += ((bb & cc) | ((~bb) & dd)) + X12;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & bb) | ((~aa) & cc)) + X13;
-    dd = dd << 7 | dd >>> -7;
+    dd = dd << 7 | dd >>> (32 - 7);
     cc += ((dd & aa) | ((~dd) & bb)) + X14;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += ((cc & dd) | ((~cc) & aa)) + X15;
-    bb = bb << 19 | bb >>> -19;
+    bb = bb << 19 | bb >>> (32 - 19);
 
     aa += ((bb & (cc | dd)) | (cc & dd)) + X0 + 0x5a827999;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & (bb | cc)) | (bb & cc)) + X4 + 0x5a827999;
-    dd = dd << 5 | dd >>> -5;
+    dd = dd << 5 | dd >>> (32 - 5);
     cc += ((dd & (aa | bb)) | (aa & bb)) + X8 + 0x5a827999;
-    cc = cc << 9 | cc >>> -9;
+    cc = cc << 9 | cc >>> (32 - 9);
     bb += ((cc & (dd | aa)) | (dd & aa)) + X12 + 0x5a827999;
-    bb = bb << 13 | bb >>> -13;
+    bb = bb << 13 | bb >>> (32 - 13);
     aa += ((bb & (cc | dd)) | (cc & dd)) + X1 + 0x5a827999;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & (bb | cc)) | (bb & cc)) + X5 + 0x5a827999;
-    dd = dd << 5 | dd >>> -5;
+    dd = dd << 5 | dd >>> (32 - 5);
     cc += ((dd & (aa | bb)) | (aa & bb)) + X9 + 0x5a827999;
-    cc = cc << 9 | cc >>> -9;
+    cc = cc << 9 | cc >>> (32 - 9);
     bb += ((cc & (dd | aa)) | (dd & aa)) + X13 + 0x5a827999;
-    bb = bb << 13 | bb >>> -13;
+    bb = bb << 13 | bb >>> (32 - 13);
     aa += ((bb & (cc | dd)) | (cc & dd)) + X2 + 0x5a827999;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & (bb | cc)) | (bb & cc)) + X6 + 0x5a827999;
-    dd = dd << 5 | dd >>> -5;
+    dd = dd << 5 | dd >>> (32 - 5);
     cc += ((dd & (aa | bb)) | (aa & bb)) + X10 + 0x5a827999;
-    cc = cc << 9 | cc >>> -9;
+    cc = cc << 9 | cc >>> (32 - 9);
     bb += ((cc & (dd | aa)) | (dd & aa)) + X14 + 0x5a827999;
-    bb = bb << 13 | bb >>> -13;
+    bb = bb << 13 | bb >>> (32 - 13);
     aa += ((bb & (cc | dd)) | (cc & dd)) + X3 + 0x5a827999;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += ((aa & (bb | cc)) | (bb & cc)) + X7 + 0x5a827999;
-    dd = dd << 5 | dd >>> -5;
+    dd = dd << 5 | dd >>> (32 - 5);
     cc += ((dd & (aa | bb)) | (aa & bb)) + X11 + 0x5a827999;
-    cc = cc << 9 | cc >>> -9;
+    cc = cc << 9 | cc >>> (32 - 9);
     bb += ((cc & (dd | aa)) | (dd & aa)) + X15 + 0x5a827999;
-    bb = bb << 13 | bb >>> -13;
+    bb = bb << 13 | bb >>> (32 - 13);
 
     aa += (bb ^ cc ^ dd) + X0 + 0x6ed9eba1;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += (aa ^ bb ^ cc) + X8 + 0x6ed9eba1;
-    dd = dd << 9 | dd >>> -9;
+    dd = dd << 9 | dd >>> (32 - 9);
     cc += (dd ^ aa ^ bb) + X4 + 0x6ed9eba1;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += (cc ^ dd ^ aa) + X12 + 0x6ed9eba1;
-    bb = bb << 15 | bb >>> -15;
+    bb = bb << 15 | bb >>> (32 - 15);
     aa += (bb ^ cc ^ dd) + X2 + 0x6ed9eba1;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += (aa ^ bb ^ cc) + X10 + 0x6ed9eba1;
-    dd = dd << 9 | dd >>> -9;
+    dd = dd << 9 | dd >>> (32 - 9);
     cc += (dd ^ aa ^ bb) + X6 + 0x6ed9eba1;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += (cc ^ dd ^ aa) + X14 + 0x6ed9eba1;
-    bb = bb << 15 | bb >>> -15;
+    bb = bb << 15 | bb >>> (32 - 15);
     aa += (bb ^ cc ^ dd) + X1 + 0x6ed9eba1;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += (aa ^ bb ^ cc) + X9 + 0x6ed9eba1;
-    dd = dd << 9 | dd >>> -9;
+    dd = dd << 9 | dd >>> (32 - 9);
     cc += (dd ^ aa ^ bb) + X5 + 0x6ed9eba1;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += (cc ^ dd ^ aa) + X13 + 0x6ed9eba1;
-    bb = bb << 15 | bb >>> -15;
+    bb = bb << 15 | bb >>> (32 - 15);
     aa += (bb ^ cc ^ dd) + X3 + 0x6ed9eba1;
-    aa = aa << 3 | aa >>> -3;
+    aa = aa << 3 | aa >>> (32 - 3);
     dd += (aa ^ bb ^ cc) + X11 + 0x6ed9eba1;
-    dd = dd << 9 | dd >>> -9;
+    dd = dd << 9 | dd >>> (32 - 9);
     cc += (dd ^ aa ^ bb) + X7 + 0x6ed9eba1;
-    cc = cc << 11 | cc >>> -11;
+    cc = cc << 11 | cc >>> (32 - 11);
     bb += (cc ^ dd ^ aa) + X15 + 0x6ed9eba1;
-    bb = bb << 15 | bb >>> -15;
+    bb = bb << 15 | bb >>> (32 - 15);
 
     a += aa;
     b += bb;
--- gnu/java/security/hash/MD5.java.orig	Sun Jun 18 02:59:24 2006
+++ gnu/java/security/hash/MD5.java	Fri Jan  5 19:10:56 2007
@@ -169,151 +169,151 @@
     // hex constants are from md5.c in FSF Gnu Privacy Guard 0.9.2
     // round 1
     A += ((B & C) | (~B & D)) + X0 + 0xD76AA478;
-    A = B + (A << 7 | A >>> -7);
+    A = B + (A << 7 | A >>> (32 - 7));
     D += ((A & B) | (~A & C)) + X1 + 0xE8C7B756;
-    D = A + (D << 12 | D >>> -12);
+    D = A + (D << 12 | D >>> (32 - 12));
     C += ((D & A) | (~D & B)) + X2 + 0x242070DB;
-    C = D + (C << 17 | C >>> -17);
+    C = D + (C << 17 | C >>> (32 - 17));
     B += ((C & D) | (~C & A)) + X3 + 0xC1BDCEEE;
-    B = C + (B << 22 | B >>> -22);
+    B = C + (B << 22 | B >>> (32 - 22));
 
     A += ((B & C) | (~B & D)) + X4 + 0xF57C0FAF;
-    A = B + (A << 7 | A >>> -7);
+    A = B + (A << 7 | A >>> (32 - 7));
     D += ((A & B) | (~A & C)) + X5 + 0x4787C62A;
-    D = A + (D << 12 | D >>> -12);
+    D = A + (D << 12 | D >>> (32 - 12));
     C += ((D & A) | (~D & B)) + X6 + 0xA8304613;
-    C = D + (C << 17 | C >>> -17);
+    C = D + (C << 17 | C >>> (32 - 17));
     B += ((C & D) | (~C & A)) + X7 + 0xFD469501;
-    B = C + (B << 22 | B >>> -22);
+    B = C + (B << 22 | B >>> (32 - 22));
 
     A += ((B & C) | (~B & D)) + X8 + 0x698098D8;
-    A = B + (A << 7 | A >>> -7);
+    A = B + (A << 7 | A >>> (32 - 7));
     D += ((A & B) | (~A & C)) + X9 + 0x8B44F7AF;
-    D = A + (D << 12 | D >>> -12);
+    D = A + (D << 12 | D >>> (32 - 12));
     C += ((D & A) | (~D & B)) + X10 + 0xFFFF5BB1;
-    C = D + (C << 17 | C >>> -17);
+    C = D + (C << 17 | C >>> (32 - 17));
     B += ((C & D) | (~C & A)) + X11 + 0x895CD7BE;
-    B = C + (B << 22 | B >>> -22);
+    B = C + (B << 22 | B >>> (32 - 22));
 
     A += ((B & C) | (~B & D)) + X12 + 0x6B901122;
-    A = B + (A << 7 | A >>> -7);
+    A = B + (A << 7 | A >>> (32 - 7));
     D += ((A & B) | (~A & C)) + X13 + 0xFD987193;
-    D = A + (D << 12 | D >>> -12);
+    D = A + (D << 12 | D >>> (32 - 12));
     C += ((D & A) | (~D & B)) + X14 + 0xA679438E;
-    C = D + (C << 17 | C >>> -17);
+    C = D + (C << 17 | C >>> (32 - 17));
     B += ((C & D) | (~C & A)) + X15 + 0x49B40821;
-    B = C + (B << 22 | B >>> -22);
+    B = C + (B << 22 | B >>> (32 - 22));
 
     // round 2
     A += ((B & D) | (C & ~D)) + X1 + 0xF61E2562;
-    A = B + (A << 5 | A >>> -5);
+    A = B + (A << 5 | A >>> (32 - 5));
     D += ((A & C) | (B & ~C)) + X6 + 0xC040B340;
-    D = A + (D << 9 | D >>> -9);
+    D = A + (D << 9 | D >>> (32 - 9));
     C += ((D & B) | (A & ~B)) + X11 + 0x265E5A51;
-    C = D + (C << 14 | C >>> -14);
+    C = D + (C << 14 | C >>> (32 - 14));
     B += ((C & A) | (D & ~A)) + X0 + 0xE9B6C7AA;
-    B = C + (B << 20 | B >>> -20);
+    B = C + (B << 20 | B >>> (32 - 20));
 
     A += ((B & D) | (C & ~D)) + X5 + 0xD62F105D;
-    A = B + (A << 5 | A >>> -5);
+    A = B + (A << 5 | A >>> (32 - 5));
     D += ((A & C) | (B & ~C)) + X10 + 0x02441453;
-    D = A + (D << 9 | D >>> -9);
+    D = A + (D << 9 | D >>> (32 - 9));
     C += ((D & B) | (A & ~B)) + X15 + 0xD8A1E681;
-    C = D + (C << 14 | C >>> -14);
+    C = D + (C << 14 | C >>> (32 - 14));
     B += ((C & A) | (D & ~A)) + X4 + 0xE7D3FBC8;
-    B = C + (B << 20 | B >>> -20);
+    B = C + (B << 20 | B >>> (32 - 20));
 
     A += ((B & D) | (C & ~D)) + X9 + 0x21E1CDE6;
-    A = B + (A << 5 | A >>> -5);
+    A = B + (A << 5 | A >>> (32 - 5));
     D += ((A & C) | (B & ~C)) + X14 + 0xC33707D6;
-    D = A + (D << 9 | D >>> -9);
+    D = A + (D << 9 | D >>> (32 - 9));
     C += ((D & B) | (A & ~B)) + X3 + 0xF4D50D87;
-    C = D + (C << 14 | C >>> -14);
+    C = D + (C << 14 | C >>> (32 - 14));
     B += ((C & A) | (D & ~A)) + X8 + 0x455A14ED;
-    B = C + (B << 20 | B >>> -20);
+    B = C + (B << 20 | B >>> (32 - 20));
 
     A += ((B & D) | (C & ~D)) + X13 + 0xA9E3E905;
-    A = B + (A << 5 | A >>> -5);
+    A = B + (A << 5 | A >>> (32 - 5));
     D += ((A & C) | (B & ~C)) + X2 + 0xFCEFA3F8;
-    D = A + (D << 9 | D >>> -9);
+    D = A + (D << 9 | D >>> (32 - 9));
     C += ((D & B) | (A & ~B)) + X7 + 0x676F02D9;
-    C = D + (C << 14 | C >>> -14);
+    C = D + (C << 14 | C >>> (32 - 14));
     B += ((C & A) | (D & ~A)) + X12 + 0x8D2A4C8A;
-    B = C + (B << 20 | B >>> -20);
+    B = C + (B << 20 | B >>> (32 - 20));
 
     // round 3
     A += (B ^ C ^ D) + X5 + 0xFFFA3942;
-    A = B + (A << 4 | A >>> -4);
+    A = B + (A << 4 | A >>> (32 - 4));
     D += (A ^ B ^ C) + X8 + 0x8771F681;
-    D = A + (D << 11 | D >>> -11);
+    D = A + (D << 11 | D >>> (32 - 11));
     C += (D ^ A ^ B) + X11 + 0x6D9D6122;
-    C = D + (C << 16 | C >>> -16);
+    C = D + (C << 16 | C >>> (32 - 16));
     B += (C ^ D ^ A) + X14 + 0xFDE5380C;
-    B = C + (B << 23 | B >>> -23);
+    B = C + (B << 23 | B >>> (32 - 23));
 
     A += (B ^ C ^ D) + X1 + 0xA4BEEA44;
-    A = B + (A << 4 | A >>> -4);
+    A = B + (A << 4 | A >>> (32 - 4));
     D += (A ^ B ^ C) + X4 + 0x4BDECFA9;
-    D = A + (D << 11 | D >>> -11);
+    D = A + (D << 11 | D >>> (32 - 11));
     C += (D ^ A ^ B) + X7 + 0xF6BB4B60;
-    C = D + (C << 16 | C >>> -16);
+    C = D + (C << 16 | C >>> (32 - 16));
     B += (C ^ D ^ A) + X10 + 0xBEBFBC70;
-    B = C + (B << 23 | B >>> -23);
+    B = C + (B << 23 | B >>> (32 - 23));
 
     A += (B ^ C ^ D) + X13 + 0x289B7EC6;
-    A = B + (A << 4 | A >>> -4);
+    A = B + (A << 4 | A >>> (32 - 4));
     D += (A ^ B ^ C) + X0 + 0xEAA127FA;
-    D = A + (D << 11 | D >>> -11);
+    D = A + (D << 11 | D >>> (32 - 11));
     C += (D ^ A ^ B) + X3 + 0xD4EF3085;
-    C = D + (C << 16 | C >>> -16);
+    C = D + (C << 16 | C >>> (32 - 16));
     B += (C ^ D ^ A) + X6 + 0x04881D05;
-    B = C + (B << 23 | B >>> -23);
+    B = C + (B << 23 | B >>> (32 - 23));
 
     A += (B ^ C ^ D) + X9 + 0xD9D4D039;
-    A = B + (A << 4 | A >>> -4);
+    A = B + (A << 4 | A >>> (32 - 4));
     D += (A ^ B ^ C) + X12 + 0xE6DB99E5;
-    D = A + (D << 11 | D >>> -11);
+    D = A + (D << 11 | D >>> (32 - 11));
     C += (D ^ A ^ B) + X15 + 0x1FA27CF8;
-    C = D + (C << 16 | C >>> -16);
+    C = D + (C << 16 | C >>> (32 - 16));
     B += (C ^ D ^ A) + X2 + 0xC4AC5665;
-    B = C + (B << 23 | B >>> -23);
+    B = C + (B << 23 | B >>> (32 - 23));
 
     // round 4
     A += (C ^ (B | ~D)) + X0 + 0xF4292244;
-    A = B + (A << 6 | A >>> -6);
+    A = B + (A << 6 | A >>> (32 - 6));
     D += (B ^ (A | ~C)) + X7 + 0x432AFF97;
-    D = A + (D << 10 | D >>> -10);
+    D = A + (D << 10 | D >>> (32 - 10));
     C += (A ^ (D | ~B)) + X14 + 0xAB9423A7;
-    C = D + (C << 15 | C >>> -15);
+    C = D + (C << 15 | C >>> (32 - 15));
     B += (D ^ (C | ~A)) + X5 + 0xFC93A039;
-    B = C + (B << 21 | B >>> -21);
+    B = C + (B << 21 | B >>> (32 - 21));
 
     A += (C ^ (B | ~D)) + X12 + 0x655B59C3;
-    A = B + (A << 6 | A >>> -6);
+    A = B + (A << 6 | A >>> (32 - 6));
     D += (B ^ (A | ~C)) + X3 + 0x8F0CCC92;
-    D = A + (D << 10 | D >>> -10);
+    D = A + (D << 10 | D >>> (32 - 10));
     C += (A ^ (D | ~B)) + X10 + 0xFFEFF47D;
-    C = D + (C << 15 | C >>> -15);
+    C = D + (C << 15 | C >>> (32 - 15));
     B += (D ^ (C | ~A)) + X1 + 0x85845dd1;
-    B = C + (B << 21 | B >>> -21);
+    B = C + (B << 21 | B >>> (32 - 21));
 
     A += (C ^ (B | ~D)) + X8 + 0x6FA87E4F;
-    A = B + (A << 6 | A >>> -6);
+    A = B + (A << 6 | A >>> (32 - 6));
     D += (B ^ (A | ~C)) + X15 + 0xFE2CE6E0;
-    D = A + (D << 10 | D >>> -10);
+    D = A + (D << 10 | D >>> (32 - 10));
     C += (A ^ (D | ~B)) + X6 + 0xA3014314;
-    C = D + (C << 15 | C >>> -15);
+    C = D + (C << 15 | C >>> (32 - 15));
     B += (D ^ (C | ~A)) + X13 + 0x4E0811A1;
-    B = C + (B << 21 | B >>> -21);
+    B = C + (B << 21 | B >>> (32 - 21));
 
     A += (C ^ (B | ~D)) + X4 + 0xF7537E82;
-    A = B + (A << 6 | A >>> -6);
+    A = B + (A << 6 | A >>> (32 - 6));
     D += (B ^ (A | ~C)) + X11 + 0xBD3AF235;
-    D = A + (D << 10 | D >>> -10);
+    D = A + (D << 10 | D >>> (32 - 10));
     C += (A ^ (D | ~B)) + X2 + 0x2AD7D2BB;
-    C = D + (C << 15 | C >>> -15);
+    C = D + (C << 15 | C >>> (32 - 15));
     B += (D ^ (C | ~A)) + X9 + 0xEB86D391;
-    B = C + (B << 21 | B >>> -21);
+    B = C + (B << 21 | B >>> (32 - 21));
 
     h0 += A;
     h1 += B;

[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux