Fix m 60 a 3 mangle code
authorDavid Llewellyn-Jones <david@flypig.co.uk>
Fri, 26 Aug 2016 17:56:57 +0000 (17:56 +0000)
committerDavid Llewellyn-Jones <david@flypig.co.uk>
Fri, 26 Aug 2016 17:56:57 +0000 (17:56 +0000)
The broken code was overwriting the w0[0] value and this appeared
to be causing problems. Rearranging the code to avoid this has
allowed HMAC-MD5 (6) mode with attack 3 to work.

OpenCL/m00060_a3_m.cl

index 0a4c2f2..2f1f558 100644 (file)
@@ -278,13 +278,7 @@ void m00060m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __gl
 
     const u32x w0lr = w0l | w0r;
 
-       w0[0] = w0lr;
-       
-       u32x out_len = mangle(w0, w1, pw_len);
-
-    append_0x80_2x4_VV (w0, w1, out_len);
-
-    w0_t[0] = w0[0];
+    w0_t[0] = w0lr;
     w0_t[1] = w0[1];
     w0_t[2] = w0[2];
     w0_t[3] = w0[3];
@@ -292,6 +286,11 @@ void m00060m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __gl
     w1_t[1] = w1[1];
     w1_t[2] = w1[2];
     w1_t[3] = w1[3];
+
+    u32x out_len = mangle(w0_t, w1_t, pw_len);
+
+    append_0x80_2x4_VV (w0_t, w1_t, out_len);
+
     w2_t[0] = 0;
     w2_t[1] = 0;
     w2_t[2] = 0;
@@ -401,13 +400,7 @@ void m00060s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __gl
 
     const u32x w0lr = w0l | w0r;
 
-       w0[0] = w0lr;
-       
-       u32x out_len = mangle(w0, w1, pw_len);
-
-    append_0x80_2x4_VV (w0, w1, out_len);
-
-    w0_t[0] = w0[0];
+    w0_t[0] = w0lr;
     w0_t[1] = w0[1];
     w0_t[2] = w0[2];
     w0_t[3] = w0[3];
@@ -415,6 +408,11 @@ void m00060s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __gl
     w1_t[1] = w1[1];
     w1_t[2] = w1[2];
     w1_t[3] = w1[3];
+
+    u32x out_len = mangle(w0_t, w1_t, pw_len);
+
+    append_0x80_2x4_VV (w0_t, w1_t, out_len);
+
     w2_t[0] = 0;
     w2_t[1] = 0;
     w2_t[2] = 0;