Converted _a3 kernels, use SIMD for CPU and GPU
[hashcat.git] / OpenCL / m00020_a3.cl
index ed59626..0efc98a 100644 (file)
@@ -65,6 +65,51 @@ static void m00020m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   const u32 pw_salt_len = pw_len + salt_len;
 
+  /**
+   * prepend salt
+   */
+
+  u32 w0_t[4];
+  u32 w1_t[4];
+  u32 w2_t[4];
+  u32 w3_t[4];
+
+  w0_t[0] = w0[0];
+  w0_t[1] = w0[1];
+  w0_t[2] = w0[2];
+  w0_t[3] = w0[3];
+  w1_t[0] = w1[0];
+  w1_t[1] = w1[1];
+  w1_t[2] = w1[2];
+  w1_t[3] = w1[3];
+  w2_t[0] = w2[0];
+  w2_t[1] = w2[1];
+  w2_t[2] = w2[2];
+  w2_t[3] = w2[3];
+  w3_t[0] = w3[0];
+  w3_t[1] = w3[1];
+  w3_t[2] = w3[2];
+  w3_t[3] = w3[3];
+
+  switch_buffer_by_offset_le_S (w0_t, w1_t, w2_t, w3_t, salt_len);
+
+  w0_t[0] |= salt_buf0[0];
+  w0_t[1] |= salt_buf0[1];
+  w0_t[2] |= salt_buf0[2];
+  w0_t[3] |= salt_buf0[3];
+  w1_t[0] |= salt_buf1[0];
+  w1_t[1] |= salt_buf1[1];
+  w1_t[2] |= salt_buf1[2];
+  w1_t[3] |= salt_buf1[3];
+  w2_t[0] |= salt_buf2[0];
+  w2_t[1] |= salt_buf2[1];
+  w2_t[2] |= salt_buf2[2];
+  w2_t[3] |= salt_buf2[3];
+  w3_t[0] |= salt_buf3[0];
+  w3_t[1] |= salt_buf3[1];
+  w3_t[2] |= salt_buf3[2];
+  w3_t[3] |= salt_buf3[3];
+
   /**
    * loop
    */
@@ -73,64 +118,52 @@ static void m00020m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos += VECT_SIZE)
   {
-    #if   VECT_SIZE == 1
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i);
-    #elif VECT_SIZE == 2
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i, bfs_buf[il_pos + 1].i);
-    #elif VECT_SIZE == 4
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i, bfs_buf[il_pos + 1].i, bfs_buf[il_pos + 2].i, bfs_buf[il_pos + 3].i);
-    #elif VECT_SIZE == 8
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i, bfs_buf[il_pos + 1].i, bfs_buf[il_pos + 2].i, bfs_buf[il_pos + 3].i, bfs_buf[il_pos + 4].i, bfs_buf[il_pos + 5].i, bfs_buf[il_pos + 6].i, bfs_buf[il_pos + 7].i);
-    #endif
+    const u32x w0r = w0r_create_bft (bfs_buf, il_pos);
 
     const u32x w0lr = w0l | w0r;
 
-    /**
-     * prepend salt
-     */
+    u32x wx[16];
+
+    wx[ 0] = w0_t[0];
+    wx[ 1] = w0_t[1];
+    wx[ 2] = w0_t[2];
+    wx[ 3] = w0_t[3];
+    wx[ 4] = w1_t[0];
+    wx[ 5] = w1_t[1];
+    wx[ 6] = w1_t[2];
+    wx[ 7] = w1_t[3];
+    wx[ 8] = w2_t[0];
+    wx[ 9] = w2_t[1];
+    wx[10] = w2_t[2];
+    wx[11] = w2_t[3];
+    wx[12] = w3_t[0];
+    wx[13] = w3_t[1];
+    wx[14] = w3_t[2];
+    wx[15] = w3_t[3];
+
+    overwrite_at_le (wx, w0lr, salt_len);
 
     u32x w0_t[4];
     u32x w1_t[4];
     u32x w2_t[4];
     u32x w3_t[4];
 
-    w0_t[0] = w0lr;
-    w0_t[1] = w0[1];
-    w0_t[2] = w0[2];
-    w0_t[3] = w0[3];
-    w1_t[0] = w1[0];
-    w1_t[1] = w1[1];
-    w1_t[2] = w1[2];
-    w1_t[3] = w1[3];
-    w2_t[0] = w2[0];
-    w2_t[1] = w2[1];
-    w2_t[2] = w2[2];
-    w2_t[3] = w2[3];
-    w3_t[0] = w3[0];
-    w3_t[1] = w3[1];
-    w3_t[2] = w3[2];
-    w3_t[3] = w3[3];
-
-    switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
-
+    w0_t[0] = wx[ 0];
+    w0_t[1] = wx[ 1];
+    w0_t[2] = wx[ 2];
+    w0_t[3] = wx[ 3];
+    w1_t[0] = wx[ 4];
+    w1_t[1] = wx[ 5];
+    w1_t[2] = wx[ 6];
+    w1_t[3] = wx[ 7];
+    w2_t[0] = wx[ 8];
+    w2_t[1] = wx[ 9];
+    w2_t[2] = wx[10];
+    w2_t[3] = wx[11];
+    w3_t[0] = wx[12];
+    w3_t[1] = wx[13];
     w3_t[2] = pw_salt_len * 8;
-
-    w0_t[0] |= salt_buf0[0];
-    w0_t[1] |= salt_buf0[1];
-    w0_t[2] |= salt_buf0[2];
-    w0_t[3] |= salt_buf0[3];
-    w1_t[0] |= salt_buf1[0];
-    w1_t[1] |= salt_buf1[1];
-    w1_t[2] |= salt_buf1[2];
-    w1_t[3] |= salt_buf1[3];
-    w2_t[0] |= salt_buf2[0];
-    w2_t[1] |= salt_buf2[1];
-    w2_t[2] |= salt_buf2[2];
-    w2_t[3] |= salt_buf2[3];
-    w3_t[0] |= salt_buf3[0];
-    w3_t[1] |= salt_buf3[1];
-    w3_t[2] |= salt_buf3[2];
-    w3_t[3] |= salt_buf3[3];
+    w3_t[3] = 0;
 
     /**
      * md5
@@ -272,6 +305,51 @@ static void m00020s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   const u32 pw_salt_len = pw_len + salt_len;
 
+  /**
+   * prepend salt
+   */
+
+  u32 w0_t[4];
+  u32 w1_t[4];
+  u32 w2_t[4];
+  u32 w3_t[4];
+
+  w0_t[0] = w0[0];
+  w0_t[1] = w0[1];
+  w0_t[2] = w0[2];
+  w0_t[3] = w0[3];
+  w1_t[0] = w1[0];
+  w1_t[1] = w1[1];
+  w1_t[2] = w1[2];
+  w1_t[3] = w1[3];
+  w2_t[0] = w2[0];
+  w2_t[1] = w2[1];
+  w2_t[2] = w2[2];
+  w2_t[3] = w2[3];
+  w3_t[0] = w3[0];
+  w3_t[1] = w3[1];
+  w3_t[2] = w3[2];
+  w3_t[3] = w3[3];
+
+  switch_buffer_by_offset_le_S (w0_t, w1_t, w2_t, w3_t, salt_len);
+
+  w0_t[0] |= salt_buf0[0];
+  w0_t[1] |= salt_buf0[1];
+  w0_t[2] |= salt_buf0[2];
+  w0_t[3] |= salt_buf0[3];
+  w1_t[0] |= salt_buf1[0];
+  w1_t[1] |= salt_buf1[1];
+  w1_t[2] |= salt_buf1[2];
+  w1_t[3] |= salt_buf1[3];
+  w2_t[0] |= salt_buf2[0];
+  w2_t[1] |= salt_buf2[1];
+  w2_t[2] |= salt_buf2[2];
+  w2_t[3] |= salt_buf2[3];
+  w3_t[0] |= salt_buf3[0];
+  w3_t[1] |= salt_buf3[1];
+  w3_t[2] |= salt_buf3[2];
+  w3_t[3] |= salt_buf3[3];
+
   /**
    * loop
    */
@@ -280,64 +358,52 @@ static void m00020s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos += VECT_SIZE)
   {
-    #if   VECT_SIZE == 1
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i);
-    #elif VECT_SIZE == 2
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i, bfs_buf[il_pos + 1].i);
-    #elif VECT_SIZE == 4
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i, bfs_buf[il_pos + 1].i, bfs_buf[il_pos + 2].i, bfs_buf[il_pos + 3].i);
-    #elif VECT_SIZE == 8
-    const u32x w0r = (u32x) (bfs_buf[il_pos + 0].i, bfs_buf[il_pos + 1].i, bfs_buf[il_pos + 2].i, bfs_buf[il_pos + 3].i, bfs_buf[il_pos + 4].i, bfs_buf[il_pos + 5].i, bfs_buf[il_pos + 6].i, bfs_buf[il_pos + 7].i);
-    #endif
+    const u32x w0r = w0r_create_bft (bfs_buf, il_pos);
 
     const u32x w0lr = w0l | w0r;
 
-    /**
-     * prepend salt
-     */
+    u32x wx[16];
+
+    wx[ 0] = w0_t[0];
+    wx[ 1] = w0_t[1];
+    wx[ 2] = w0_t[2];
+    wx[ 3] = w0_t[3];
+    wx[ 4] = w1_t[0];
+    wx[ 5] = w1_t[1];
+    wx[ 6] = w1_t[2];
+    wx[ 7] = w1_t[3];
+    wx[ 8] = w2_t[0];
+    wx[ 9] = w2_t[1];
+    wx[10] = w2_t[2];
+    wx[11] = w2_t[3];
+    wx[12] = w3_t[0];
+    wx[13] = w3_t[1];
+    wx[14] = w3_t[2];
+    wx[15] = w3_t[3];
+
+    overwrite_at_le (wx, w0lr, salt_len);
 
     u32x w0_t[4];
     u32x w1_t[4];
     u32x w2_t[4];
     u32x w3_t[4];
 
-    w0_t[0] = w0lr;
-    w0_t[1] = w0[1];
-    w0_t[2] = w0[2];
-    w0_t[3] = w0[3];
-    w1_t[0] = w1[0];
-    w1_t[1] = w1[1];
-    w1_t[2] = w1[2];
-    w1_t[3] = w1[3];
-    w2_t[0] = w2[0];
-    w2_t[1] = w2[1];
-    w2_t[2] = w2[2];
-    w2_t[3] = w2[3];
-    w3_t[0] = w3[0];
-    w3_t[1] = w3[1];
-    w3_t[2] = w3[2];
-    w3_t[3] = w3[3];
-
-    switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
-
+    w0_t[0] = wx[ 0];
+    w0_t[1] = wx[ 1];
+    w0_t[2] = wx[ 2];
+    w0_t[3] = wx[ 3];
+    w1_t[0] = wx[ 4];
+    w1_t[1] = wx[ 5];
+    w1_t[2] = wx[ 6];
+    w1_t[3] = wx[ 7];
+    w2_t[0] = wx[ 8];
+    w2_t[1] = wx[ 9];
+    w2_t[2] = wx[10];
+    w2_t[3] = wx[11];
+    w3_t[0] = wx[12];
+    w3_t[1] = wx[13];
     w3_t[2] = pw_salt_len * 8;
-
-    w0_t[0] |= salt_buf0[0];
-    w0_t[1] |= salt_buf0[1];
-    w0_t[2] |= salt_buf0[2];
-    w0_t[3] |= salt_buf0[3];
-    w1_t[0] |= salt_buf1[0];
-    w1_t[1] |= salt_buf1[1];
-    w1_t[2] |= salt_buf1[2];
-    w1_t[3] |= salt_buf1[3];
-    w2_t[0] |= salt_buf2[0];
-    w2_t[1] |= salt_buf2[1];
-    w2_t[2] |= salt_buf2[2];
-    w2_t[3] |= salt_buf2[3];
-    w3_t[0] |= salt_buf3[0];
-    w3_t[1] |= salt_buf3[1];
-    w3_t[2] |= salt_buf3[2];
-    w3_t[3] |= salt_buf3[3];
+    w3_t[3] = 0;
 
     /**
      * md5