diff --git a/OpenCL/inc_cipher_aes.cl b/OpenCL/inc_cipher_aes.cl index 266382ee1..c0e2513de 100644 --- a/OpenCL/inc_cipher_aes.cl +++ b/OpenCL/inc_cipher_aes.cl @@ -683,44 +683,98 @@ __constant u32a td4[256] = 0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d, }; -__constant u32a rcon[10] = -{ - 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000, 0x40000000, 0x80000000, - 0x1b000000, 0x36000000, -}; - // 128 bit key +DECLSPEC void aes128_ExpandKey (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void aes128_ExpandKey (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { - ks[0] = ukey[0]; - ks[1] = ukey[1]; - ks[2] = ukey[2]; - ks[3] = ukey[3]; - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0, j = 0; i < 10; i += 1, j += 4) - { - u32 temp = ks[j + 3]; - - temp = (s_te2[(temp >> 16) & 0xff] & 0xff000000) - ^ (s_te3[(temp >> 8) & 0xff] & 0x00ff0000) - ^ (s_te0[(temp >> 0) & 0xff] & 0x0000ff00) - ^ (s_te1[(temp >> 24) & 0xff] & 0x000000ff); - - ks[j + 4] = ks[j + 0] - ^ temp - ^ rcon[i]; - - ks[j + 5] = ks[j + 1] ^ ks[j + 4]; - ks[j + 6] = ks[j + 2] ^ ks[j + 5]; - ks[j + 7] = ks[j + 3] ^ ks[j + 6]; - } + ks[ 0] = ukey[0]; + ks[ 1] = ukey[1]; + ks[ 2] = ukey[2]; + ks[ 3] = ukey[3]; + ks[ 4] = ks[ 0] ^ 0x01000000 + ^ (s_te2[(ks[ 3] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[ 3] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[ 3] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[ 3] >> 24) & 0xff] & 0x000000ff); + ks[ 5] = ks[ 1] ^ ks[ 4]; + ks[ 6] = ks[ 2] ^ ks[ 5]; + ks[ 7] = ks[ 3] ^ ks[ 6]; + ks[ 8] = ks[ 4] ^ 0x02000000 + ^ (s_te2[(ks[ 7] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[ 7] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[ 7] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[ 7] >> 24) & 0xff] & 0x000000ff); + ks[ 9] = ks[ 5] ^ ks[ 8]; + ks[10] = ks[ 6] ^ ks[ 9]; + ks[11] = ks[ 7] ^ ks[10]; + ks[12] = ks[ 8] ^ 0x04000000 + ^ (s_te2[(ks[11] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[11] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[11] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[11] >> 24) & 0xff] & 0x000000ff); + ks[13] = ks[ 9] ^ ks[12]; + ks[14] = ks[10] ^ ks[13]; + ks[15] = ks[11] ^ ks[14]; + ks[16] = ks[12] ^ 0x08000000 + ^ (s_te2[(ks[15] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[15] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[15] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[15] >> 24) & 0xff] & 0x000000ff); + ks[17] = ks[13] ^ ks[16]; + ks[18] = ks[14] ^ ks[17]; + ks[19] = ks[15] ^ ks[18]; + ks[20] = ks[16] ^ 0x10000000 + ^ (s_te2[(ks[19] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[19] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[19] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[19] >> 24) & 0xff] & 0x000000ff); + ks[21] = ks[17] ^ ks[20]; + ks[22] = ks[18] ^ ks[21]; + ks[23] = ks[19] ^ ks[22]; + ks[24] = ks[20] ^ 0x20000000 + ^ (s_te2[(ks[23] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[23] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[23] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[23] >> 24) & 0xff] & 0x000000ff); + ks[25] = ks[21] ^ ks[24]; + ks[26] = ks[22] ^ ks[25]; + ks[27] = ks[23] ^ ks[26]; + ks[28] = ks[24] ^ 0x40000000 + ^ (s_te2[(ks[27] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[27] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[27] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[27] >> 24) & 0xff] & 0x000000ff); + ks[29] = ks[25] ^ ks[28]; + ks[30] = ks[26] ^ ks[29]; + ks[31] = ks[27] ^ ks[30]; + ks[32] = ks[28] ^ 0x80000000 + ^ (s_te2[(ks[31] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[31] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[31] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[31] >> 24) & 0xff] & 0x000000ff); + ks[33] = ks[29] ^ ks[32]; + ks[34] = ks[30] ^ ks[33]; + ks[35] = ks[31] ^ ks[34]; + ks[36] = ks[32] ^ 0x1b000000 + ^ (s_te2[(ks[35] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[35] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[35] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[35] >> 24) & 0xff] & 0x000000ff); + ks[37] = ks[33] ^ ks[36]; + ks[38] = ks[34] ^ ks[37]; + ks[39] = ks[35] ^ ks[38]; + ks[40] = ks[36] ^ 0x36000000 + ^ (s_te2[(ks[39] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[39] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[39] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[39] >> 24) & 0xff] & 0x000000ff); + ks[41] = ks[37] ^ ks[40]; + ks[42] = ks[38] ^ ks[41]; + ks[43] = ks[39] ^ ks[42]; } +DECLSPEC void aes128_InvertKey (u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes128_InvertKey (u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 temp; @@ -746,54 +800,45 @@ DECLSPEC void aes128_InvertKey (u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te temp = ks[18]; ks[18] = ks[26]; ks[26] = temp; temp = ks[19]; ks[19] = ks[27]; ks[27] = temp; - #ifdef _unroll - #pragma unroll - #endif - for (int i = 1, j = 4; i < 10; i += 1, j += 4) - { - const u32 x0s0 = (ks[j + 0] >> 0) & 0xff; - const u32 x0s1 = (ks[j + 0] >> 8) & 0xff; - const u32 x0s2 = (ks[j + 0] >> 16) & 0xff; - const u32 x0s3 = (ks[j + 0] >> 24) & 0xff; - const u32 x1s0 = (ks[j + 1] >> 0) & 0xff; - const u32 x1s1 = (ks[j + 1] >> 8) & 0xff; - const u32 x1s2 = (ks[j + 1] >> 16) & 0xff; - const u32 x1s3 = (ks[j + 1] >> 24) & 0xff; - const u32 x2s0 = (ks[j + 2] >> 0) & 0xff; - const u32 x2s1 = (ks[j + 2] >> 8) & 0xff; - const u32 x2s2 = (ks[j + 2] >> 16) & 0xff; - const u32 x2s3 = (ks[j + 2] >> 24) & 0xff; - const u32 x3s0 = (ks[j + 3] >> 0) & 0xff; - const u32 x3s1 = (ks[j + 3] >> 8) & 0xff; - const u32 x3s2 = (ks[j + 3] >> 16) & 0xff; - const u32 x3s3 = (ks[j + 3] >> 24) & 0xff; - - ks[j + 0] = - s_td0[s_te1[x0s3] & 0xff] ^ - s_td1[s_te1[x0s2] & 0xff] ^ - s_td2[s_te1[x0s1] & 0xff] ^ - s_td3[s_te1[x0s0] & 0xff]; - - ks[j + 1] = - s_td0[s_te1[x1s3] & 0xff] ^ - s_td1[s_te1[x1s2] & 0xff] ^ - s_td2[s_te1[x1s1] & 0xff] ^ - s_td3[s_te1[x1s0] & 0xff]; - - ks[j + 2] = - s_td0[s_te1[x2s3] & 0xff] ^ - s_td1[s_te1[x2s2] & 0xff] ^ - s_td2[s_te1[x2s1] & 0xff] ^ - s_td3[s_te1[x2s0] & 0xff]; - - ks[j + 3] = - s_td0[s_te1[x3s3] & 0xff] ^ - s_td1[s_te1[x3s2] & 0xff] ^ - s_td2[s_te1[x3s1] & 0xff] ^ - s_td3[s_te1[x3s0] & 0xff]; - } + ks[ 4] = td0[te1[(ks[ 4] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 4] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 4] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 4] >> 0) & 0xff] & 0xff]; + ks[ 5] = td0[te1[(ks[ 5] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 5] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 5] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 5] >> 0) & 0xff] & 0xff]; + ks[ 6] = td0[te1[(ks[ 6] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 6] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 6] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 6] >> 0) & 0xff] & 0xff]; + ks[ 7] = td0[te1[(ks[ 7] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 7] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 7] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 7] >> 0) & 0xff] & 0xff]; + ks[ 8] = td0[te1[(ks[ 8] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 8] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 8] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 8] >> 0) & 0xff] & 0xff]; + ks[ 9] = td0[te1[(ks[ 9] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 9] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 9] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 9] >> 0) & 0xff] & 0xff]; + ks[10] = td0[te1[(ks[10] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[10] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[10] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[10] >> 0) & 0xff] & 0xff]; + ks[11] = td0[te1[(ks[11] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[11] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[11] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[11] >> 0) & 0xff] & 0xff]; + ks[12] = td0[te1[(ks[12] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[12] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[12] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[12] >> 0) & 0xff] & 0xff]; + ks[13] = td0[te1[(ks[13] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[13] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[13] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[13] >> 0) & 0xff] & 0xff]; + ks[14] = td0[te1[(ks[14] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[14] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[14] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[14] >> 0) & 0xff] & 0xff]; + ks[15] = td0[te1[(ks[15] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[15] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[15] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[15] >> 0) & 0xff] & 0xff]; + ks[16] = td0[te1[(ks[16] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[16] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[16] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[16] >> 0) & 0xff] & 0xff]; + ks[17] = td0[te1[(ks[17] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[17] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[17] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[17] >> 0) & 0xff] & 0xff]; + ks[18] = td0[te1[(ks[18] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[18] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[18] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[18] >> 0) & 0xff] & 0xff]; + ks[19] = td0[te1[(ks[19] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[19] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[19] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[19] >> 0) & 0xff] & 0xff]; + ks[20] = td0[te1[(ks[20] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[20] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[20] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[20] >> 0) & 0xff] & 0xff]; + ks[21] = td0[te1[(ks[21] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[21] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[21] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[21] >> 0) & 0xff] & 0xff]; + ks[22] = td0[te1[(ks[22] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[22] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[22] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[22] >> 0) & 0xff] & 0xff]; + ks[23] = td0[te1[(ks[23] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[23] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[23] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[23] >> 0) & 0xff] & 0xff]; + ks[24] = td0[te1[(ks[24] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[24] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[24] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[24] >> 0) & 0xff] & 0xff]; + ks[25] = td0[te1[(ks[25] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[25] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[25] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[25] >> 0) & 0xff] & 0xff]; + ks[26] = td0[te1[(ks[26] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[26] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[26] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[26] >> 0) & 0xff] & 0xff]; + ks[27] = td0[te1[(ks[27] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[27] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[27] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[27] >> 0) & 0xff] & 0xff]; + ks[28] = td0[te1[(ks[28] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[28] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[28] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[28] >> 0) & 0xff] & 0xff]; + ks[29] = td0[te1[(ks[29] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[29] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[29] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[29] >> 0) & 0xff] & 0xff]; + ks[30] = td0[te1[(ks[30] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[30] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[30] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[30] >> 0) & 0xff] & 0xff]; + ks[31] = td0[te1[(ks[31] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[31] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[31] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[31] >> 0) & 0xff] & 0xff]; + ks[32] = td0[te1[(ks[32] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[32] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[32] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[32] >> 0) & 0xff] & 0xff]; + ks[33] = td0[te1[(ks[33] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[33] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[33] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[33] >> 0) & 0xff] & 0xff]; + ks[34] = td0[te1[(ks[34] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[34] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[34] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[34] >> 0) & 0xff] & 0xff]; + ks[35] = td0[te1[(ks[35] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[35] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[35] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[35] >> 0) & 0xff] & 0xff]; + ks[36] = td0[te1[(ks[36] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[36] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[36] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[36] >> 0) & 0xff] & 0xff]; + ks[37] = td0[te1[(ks[37] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[37] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[37] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[37] >> 0) & 0xff] & 0xff]; + ks[38] = td0[te1[(ks[38] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[38] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[38] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[38] >> 0) & 0xff] & 0xff]; + ks[39] = td0[te1[(ks[39] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[39] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[39] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[39] >> 0) & 0xff] & 0xff]; } +DECLSPEC void aes128_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void aes128_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 ukey_s[4]; @@ -806,6 +851,7 @@ DECLSPEC void aes128_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes128_ExpandKey (ks, ukey_s, s_te0, s_te1, s_te2, s_te3, s_te4); } +DECLSPEC void aes128_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes128_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ukey_s[4]; @@ -820,85 +866,85 @@ DECLSPEC void aes128_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes128_InvertKey (ks, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); } +DECLSPEC void aes128_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void aes128_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { - const u32 in_s0 = swap32_S (in[0]); - const u32 in_s1 = swap32_S (in[1]); - const u32 in_s2 = swap32_S (in[2]); - const u32 in_s3 = swap32_S (in[3]); + u32 in_s[4]; - u32 t0 = in_s0 ^ ks[0]; - u32 t1 = in_s1 ^ ks[1]; - u32 t2 = in_s2 ^ ks[2]; - u32 t3 = in_s3 ^ ks[3]; + in_s[0] = swap32_S (in[0]); + in_s[1] = swap32_S (in[1]); + in_s[2] = swap32_S (in[2]); + in_s[3] = swap32_S (in[3]); - #ifdef _unroll - #pragma unroll - #endif - for (int i = 4; i < 40; i += 4) - { - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + u32 s0 = in_s[0] ^ ks[0]; + u32 s1 = in_s[1] ^ ks[1]; + u32 s2 = in_s[2] ^ ks[2]; + u32 s3 = in_s[3] ^ ks[3]; - t0 = s_te0[x0s3] ^ s_te1[x1s2] ^ s_te2[x2s1] ^ s_te3[x3s0] ^ ks[i + 0]; - t1 = s_te0[x1s3] ^ s_te1[x2s2] ^ s_te2[x3s1] ^ s_te3[x0s0] ^ ks[i + 1]; - t2 = s_te0[x2s3] ^ s_te1[x3s2] ^ s_te2[x0s1] ^ s_te3[x1s0] ^ ks[i + 2]; - t3 = s_te0[x3s3] ^ s_te1[x0s2] ^ s_te2[x1s1] ^ s_te3[x2s0] ^ ks[i + 3]; - } + u32 t0; + u32 t1; + u32 t2; + u32 t3; - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[ 4]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[ 5]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[ 6]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[ 7]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[ 8]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[ 9]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[10]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[11]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[12]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[13]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[14]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[15]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[16]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[17]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[18]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[19]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[20]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[21]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[22]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[23]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[24]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[25]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[26]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[27]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[28]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[29]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[30]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[31]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[32]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[33]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[34]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[35]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[36]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[37]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[38]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[39]; - out[0] = (s_te4[x0s3] & 0xff000000) - ^ (s_te4[x1s2] & 0x00ff0000) - ^ (s_te4[x2s1] & 0x0000ff00) - ^ (s_te4[x3s0] & 0x000000ff) + out[0] = (s_te4[(t0 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t1 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t2 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t3 >> 0) & 0xff] & 0x000000ff) ^ ks[40]; - out[1] = (s_te4[x1s3] & 0xff000000) - ^ (s_te4[x2s2] & 0x00ff0000) - ^ (s_te4[x3s1] & 0x0000ff00) - ^ (s_te4[x0s0] & 0x000000ff) + out[1] = (s_te4[(t1 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t2 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t3 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t0 >> 0) & 0xff] & 0x000000ff) ^ ks[41]; - out[2] = (s_te4[x2s3] & 0xff000000) - ^ (s_te4[x3s2] & 0x00ff0000) - ^ (s_te4[x0s1] & 0x0000ff00) - ^ (s_te4[x1s0] & 0x000000ff) + out[2] = (s_te4[(t2 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t3 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t0 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t1 >> 0) & 0xff] & 0x000000ff) ^ ks[42]; - out[3] = (s_te4[x3s3] & 0xff000000) - ^ (s_te4[x0s2] & 0x00ff0000) - ^ (s_te4[x1s1] & 0x0000ff00) - ^ (s_te4[x2s0] & 0x000000ff) + out[3] = (s_te4[(t3 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t0 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t1 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t2 >> 0) & 0xff] & 0x000000ff) ^ ks[43]; out[0] = swap32_S (out[0]); @@ -907,85 +953,85 @@ DECLSPEC void aes128_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u out[3] = swap32_S (out[3]); } +DECLSPEC void aes128_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes128_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { - const u32 in_s0 = swap32_S (in[0]); - const u32 in_s1 = swap32_S (in[1]); - const u32 in_s2 = swap32_S (in[2]); - const u32 in_s3 = swap32_S (in[3]); + u32 in_s[4]; - u32 t0 = in_s0 ^ ks[0]; - u32 t1 = in_s1 ^ ks[1]; - u32 t2 = in_s2 ^ ks[2]; - u32 t3 = in_s3 ^ ks[3]; + in_s[0] = swap32_S (in[0]); + in_s[1] = swap32_S (in[1]); + in_s[2] = swap32_S (in[2]); + in_s[3] = swap32_S (in[3]); - #ifdef _unroll - #pragma unroll - #endif - for (int i = 4; i < 40; i += 4) - { - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + u32 s0 = in_s[0] ^ ks[0]; + u32 s1 = in_s[1] ^ ks[1]; + u32 s2 = in_s[2] ^ ks[2]; + u32 s3 = in_s[3] ^ ks[3]; - t0 = s_td0[x0s3] ^ s_td1[x3s2] ^ s_td2[x2s1] ^ s_td3[x1s0] ^ ks[i + 0]; - t1 = s_td0[x1s3] ^ s_td1[x0s2] ^ s_td2[x3s1] ^ s_td3[x2s0] ^ ks[i + 1]; - t2 = s_td0[x2s3] ^ s_td1[x1s2] ^ s_td2[x0s1] ^ s_td3[x3s0] ^ ks[i + 2]; - t3 = s_td0[x3s3] ^ s_td1[x2s2] ^ s_td2[x1s1] ^ s_td3[x0s0] ^ ks[i + 3]; - } + u32 t0; + u32 t1; + u32 t2; + u32 t3; - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[ 4]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[ 5]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[ 6]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[ 7]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[ 8]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[ 9]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[10]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[11]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[12]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[13]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[14]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[15]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[16]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[17]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[18]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[19]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[20]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[21]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[22]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[23]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[24]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[25]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[26]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[27]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[28]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[29]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[30]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[31]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[32]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[33]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[34]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[35]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[36]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[37]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[38]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[39]; - out[0] = (s_td4[x0s3] & 0xff000000) - ^ (s_td4[x3s2] & 0x00ff0000) - ^ (s_td4[x2s1] & 0x0000ff00) - ^ (s_td4[x1s0] & 0x000000ff) + out[0] = (s_td4[(t0 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t3 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t2 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t1 >> 0) & 0xff] & 0x000000ff) ^ ks[40]; - out[1] = (s_td4[x1s3] & 0xff000000) - ^ (s_td4[x0s2] & 0x00ff0000) - ^ (s_td4[x3s1] & 0x0000ff00) - ^ (s_td4[x2s0] & 0x000000ff) + out[1] = (s_td4[(t1 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t0 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t3 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t2 >> 0) & 0xff] & 0x000000ff) ^ ks[41]; - out[2] = (s_td4[x2s3] & 0xff000000) - ^ (s_td4[x1s2] & 0x00ff0000) - ^ (s_td4[x0s1] & 0x0000ff00) - ^ (s_td4[x3s0] & 0x000000ff) + out[2] = (s_td4[(t2 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t1 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t0 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t3 >> 0) & 0xff] & 0x000000ff) ^ ks[42]; - out[3] = (s_td4[x3s3] & 0xff000000) - ^ (s_td4[x2s2] & 0x00ff0000) - ^ (s_td4[x1s1] & 0x0000ff00) - ^ (s_td4[x0s0] & 0x000000ff) + out[3] = (s_td4[(t3 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t2 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t1 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t0 >> 0) & 0xff] & 0x000000ff) ^ ks[43]; out[0] = swap32_S (out[0]); @@ -996,54 +1042,124 @@ DECLSPEC void aes128_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u // 256 bit key +DECLSPEC void aes256_ExpandKey (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void aes256_ExpandKey (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { - ks[0] = ukey[0]; - ks[1] = ukey[1]; - ks[2] = ukey[2]; - ks[3] = ukey[3]; - ks[4] = ukey[4]; - ks[5] = ukey[5]; - ks[6] = ukey[6]; - ks[7] = ukey[7]; - - int i; - int j; - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0, j = 0; i < 7; i += 1, j += 8) - { - const u32 temp1 = ks[j + 7]; - - ks[j + 8] = ks[j + 0] - ^ (s_te2[(temp1 >> 16) & 0xff] & 0xff000000) - ^ (s_te3[(temp1 >> 8) & 0xff] & 0x00ff0000) - ^ (s_te0[(temp1 >> 0) & 0xff] & 0x0000ff00) - ^ (s_te1[(temp1 >> 24) & 0xff] & 0x000000ff) - ^ rcon[i]; - - ks[j + 9] = ks[j + 1] ^ ks[j + 8]; - ks[j + 10] = ks[j + 2] ^ ks[j + 9]; - ks[j + 11] = ks[j + 3] ^ ks[j + 10]; - - if (i == 6) break; - - const u32 temp2 = ks[j + 11]; - - ks[j + 12] = ks[j + 4] - ^ (s_te2[(temp2 >> 24) & 0xff] & 0xff000000) - ^ (s_te3[(temp2 >> 16) & 0xff] & 0x00ff0000) - ^ (s_te0[(temp2 >> 8) & 0xff] & 0x0000ff00) - ^ (s_te1[(temp2 >> 0) & 0xff] & 0x000000ff); - - ks[j + 13] = ks[j + 5] ^ ks[j + 12]; - ks[j + 14] = ks[j + 6] ^ ks[j + 13]; - ks[j + 15] = ks[j + 7] ^ ks[j + 14]; - } + ks[ 0] = ukey[0]; + ks[ 1] = ukey[1]; + ks[ 2] = ukey[2]; + ks[ 3] = ukey[3]; + ks[ 4] = ukey[4]; + ks[ 5] = ukey[5]; + ks[ 6] = ukey[6]; + ks[ 7] = ukey[7]; + ks[ 8] = ks[ 0] ^ 0x01000000 + ^ (s_te2[(ks[ 7] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[ 7] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[ 7] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[ 7] >> 24) & 0xff] & 0x000000ff); + ks[ 9] = ks[ 1] ^ ks[ 8]; + ks[10] = ks[ 2] ^ ks[ 9]; + ks[11] = ks[ 3] ^ ks[10]; + ks[12] = ks[ 4] ^ 0 + ^ (s_te2[(ks[11] >> 24) & 0xff] & 0xff000000) + ^ (s_te3[(ks[11] >> 16) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[11] >> 8) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[11] >> 0) & 0xff] & 0x000000ff); + ks[13] = ks[ 5] ^ ks[12]; + ks[14] = ks[ 6] ^ ks[13]; + ks[15] = ks[ 7] ^ ks[14]; + ks[16] = ks[ 8] ^ 0x02000000 + ^ (s_te2[(ks[15] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[15] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[15] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[15] >> 24) & 0xff] & 0x000000ff); + ks[17] = ks[ 9] ^ ks[16]; + ks[18] = ks[10] ^ ks[17]; + ks[19] = ks[11] ^ ks[18]; + ks[20] = ks[12] ^ 0 + ^ (s_te2[(ks[19] >> 24) & 0xff] & 0xff000000) + ^ (s_te3[(ks[19] >> 16) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[19] >> 8) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[19] >> 0) & 0xff] & 0x000000ff); + ks[21] = ks[13] ^ ks[20]; + ks[22] = ks[14] ^ ks[21]; + ks[23] = ks[15] ^ ks[22]; + ks[24] = ks[16] ^ 0x04000000 + ^ (s_te2[(ks[23] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[23] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[23] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[23] >> 24) & 0xff] & 0x000000ff); + ks[25] = ks[17] ^ ks[24]; + ks[26] = ks[18] ^ ks[25]; + ks[27] = ks[19] ^ ks[26]; + ks[28] = ks[20] ^ 0 + ^ (s_te2[(ks[27] >> 24) & 0xff] & 0xff000000) + ^ (s_te3[(ks[27] >> 16) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[27] >> 8) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[27] >> 0) & 0xff] & 0x000000ff); + ks[29] = ks[21] ^ ks[28]; + ks[30] = ks[22] ^ ks[29]; + ks[31] = ks[23] ^ ks[30]; + ks[32] = ks[24] ^ 0x08000000 + ^ (s_te2[(ks[31] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[31] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[31] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[31] >> 24) & 0xff] & 0x000000ff); + ks[33] = ks[25] ^ ks[32]; + ks[34] = ks[26] ^ ks[33]; + ks[35] = ks[27] ^ ks[34]; + ks[36] = ks[28] ^ 0 + ^ (s_te2[(ks[35] >> 24) & 0xff] & 0xff000000) + ^ (s_te3[(ks[35] >> 16) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[35] >> 8) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[35] >> 0) & 0xff] & 0x000000ff); + ks[37] = ks[29] ^ ks[36]; + ks[38] = ks[30] ^ ks[37]; + ks[39] = ks[31] ^ ks[38]; + ks[40] = ks[32] ^ 0x10000000 + ^ (s_te2[(ks[39] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[39] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[39] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[39] >> 24) & 0xff] & 0x000000ff); + ks[41] = ks[33] ^ ks[40]; + ks[42] = ks[34] ^ ks[41]; + ks[43] = ks[35] ^ ks[42]; + ks[44] = ks[36] ^ 0 + ^ (s_te2[(ks[43] >> 24) & 0xff] & 0xff000000) + ^ (s_te3[(ks[43] >> 16) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[43] >> 8) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[43] >> 0) & 0xff] & 0x000000ff); + ks[45] = ks[37] ^ ks[44]; + ks[46] = ks[38] ^ ks[45]; + ks[47] = ks[39] ^ ks[46]; + ks[48] = ks[40] ^ 0x20000000 + ^ (s_te2[(ks[47] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[47] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[47] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[47] >> 24) & 0xff] & 0x000000ff); + ks[49] = ks[41] ^ ks[48]; + ks[50] = ks[42] ^ ks[49]; + ks[51] = ks[43] ^ ks[50]; + ks[52] = ks[44] ^ 0 + ^ (s_te2[(ks[51] >> 24) & 0xff] & 0xff000000) + ^ (s_te3[(ks[51] >> 16) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[51] >> 8) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[51] >> 0) & 0xff] & 0x000000ff); + ks[53] = ks[45] ^ ks[52]; + ks[54] = ks[46] ^ ks[53]; + ks[55] = ks[47] ^ ks[54]; + ks[56] = ks[48] ^ 0x40000000 + ^ (s_te2[(ks[55] >> 16) & 0xff] & 0xff000000) + ^ (s_te3[(ks[55] >> 8) & 0xff] & 0x00ff0000) + ^ (s_te0[(ks[55] >> 0) & 0xff] & 0x0000ff00) + ^ (s_te1[(ks[55] >> 24) & 0xff] & 0x000000ff); + ks[57] = ks[49] ^ ks[56]; + ks[58] = ks[50] ^ ks[57]; + ks[59] = ks[51] ^ ks[58]; } +DECLSPEC void aes256_InvertKey (u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_InvertKey (u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 temp; @@ -1077,54 +1193,61 @@ DECLSPEC void aes256_InvertKey (u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te temp = ks[26]; ks[26] = ks[34]; ks[34] = temp; temp = ks[27]; ks[27] = ks[35]; ks[35] = temp; - #ifdef _unroll - #pragma unroll - #endif - for (int i = 1, j = 4; i < 14; i += 1, j += 4) - { - const u32 x0s0 = (ks[j + 0] >> 0) & 0xff; - const u32 x0s1 = (ks[j + 0] >> 8) & 0xff; - const u32 x0s2 = (ks[j + 0] >> 16) & 0xff; - const u32 x0s3 = (ks[j + 0] >> 24) & 0xff; - const u32 x1s0 = (ks[j + 1] >> 0) & 0xff; - const u32 x1s1 = (ks[j + 1] >> 8) & 0xff; - const u32 x1s2 = (ks[j + 1] >> 16) & 0xff; - const u32 x1s3 = (ks[j + 1] >> 24) & 0xff; - const u32 x2s0 = (ks[j + 2] >> 0) & 0xff; - const u32 x2s1 = (ks[j + 2] >> 8) & 0xff; - const u32 x2s2 = (ks[j + 2] >> 16) & 0xff; - const u32 x2s3 = (ks[j + 2] >> 24) & 0xff; - const u32 x3s0 = (ks[j + 3] >> 0) & 0xff; - const u32 x3s1 = (ks[j + 3] >> 8) & 0xff; - const u32 x3s2 = (ks[j + 3] >> 16) & 0xff; - const u32 x3s3 = (ks[j + 3] >> 24) & 0xff; - - ks[j + 0] = - s_td0[s_te1[x0s3] & 0xff] ^ - s_td1[s_te1[x0s2] & 0xff] ^ - s_td2[s_te1[x0s1] & 0xff] ^ - s_td3[s_te1[x0s0] & 0xff]; - - ks[j + 1] = - s_td0[s_te1[x1s3] & 0xff] ^ - s_td1[s_te1[x1s2] & 0xff] ^ - s_td2[s_te1[x1s1] & 0xff] ^ - s_td3[s_te1[x1s0] & 0xff]; - - ks[j + 2] = - s_td0[s_te1[x2s3] & 0xff] ^ - s_td1[s_te1[x2s2] & 0xff] ^ - s_td2[s_te1[x2s1] & 0xff] ^ - s_td3[s_te1[x2s0] & 0xff]; - - ks[j + 3] = - s_td0[s_te1[x3s3] & 0xff] ^ - s_td1[s_te1[x3s2] & 0xff] ^ - s_td2[s_te1[x3s1] & 0xff] ^ - s_td3[s_te1[x3s0] & 0xff]; - } + ks[ 4] = td0[te1[(ks[ 4] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 4] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 4] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 4] >> 0) & 0xff] & 0xff]; + ks[ 5] = td0[te1[(ks[ 5] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 5] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 5] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 5] >> 0) & 0xff] & 0xff]; + ks[ 6] = td0[te1[(ks[ 6] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 6] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 6] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 6] >> 0) & 0xff] & 0xff]; + ks[ 7] = td0[te1[(ks[ 7] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 7] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 7] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 7] >> 0) & 0xff] & 0xff]; + ks[ 8] = td0[te1[(ks[ 8] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 8] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 8] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 8] >> 0) & 0xff] & 0xff]; + ks[ 9] = td0[te1[(ks[ 9] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[ 9] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[ 9] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[ 9] >> 0) & 0xff] & 0xff]; + ks[10] = td0[te1[(ks[10] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[10] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[10] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[10] >> 0) & 0xff] & 0xff]; + ks[11] = td0[te1[(ks[11] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[11] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[11] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[11] >> 0) & 0xff] & 0xff]; + ks[12] = td0[te1[(ks[12] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[12] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[12] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[12] >> 0) & 0xff] & 0xff]; + ks[13] = td0[te1[(ks[13] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[13] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[13] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[13] >> 0) & 0xff] & 0xff]; + ks[14] = td0[te1[(ks[14] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[14] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[14] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[14] >> 0) & 0xff] & 0xff]; + ks[15] = td0[te1[(ks[15] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[15] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[15] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[15] >> 0) & 0xff] & 0xff]; + ks[16] = td0[te1[(ks[16] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[16] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[16] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[16] >> 0) & 0xff] & 0xff]; + ks[17] = td0[te1[(ks[17] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[17] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[17] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[17] >> 0) & 0xff] & 0xff]; + ks[18] = td0[te1[(ks[18] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[18] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[18] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[18] >> 0) & 0xff] & 0xff]; + ks[19] = td0[te1[(ks[19] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[19] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[19] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[19] >> 0) & 0xff] & 0xff]; + ks[20] = td0[te1[(ks[20] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[20] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[20] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[20] >> 0) & 0xff] & 0xff]; + ks[21] = td0[te1[(ks[21] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[21] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[21] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[21] >> 0) & 0xff] & 0xff]; + ks[22] = td0[te1[(ks[22] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[22] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[22] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[22] >> 0) & 0xff] & 0xff]; + ks[23] = td0[te1[(ks[23] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[23] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[23] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[23] >> 0) & 0xff] & 0xff]; + ks[24] = td0[te1[(ks[24] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[24] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[24] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[24] >> 0) & 0xff] & 0xff]; + ks[25] = td0[te1[(ks[25] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[25] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[25] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[25] >> 0) & 0xff] & 0xff]; + ks[26] = td0[te1[(ks[26] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[26] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[26] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[26] >> 0) & 0xff] & 0xff]; + ks[27] = td0[te1[(ks[27] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[27] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[27] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[27] >> 0) & 0xff] & 0xff]; + ks[28] = td0[te1[(ks[28] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[28] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[28] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[28] >> 0) & 0xff] & 0xff]; + ks[29] = td0[te1[(ks[29] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[29] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[29] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[29] >> 0) & 0xff] & 0xff]; + ks[30] = td0[te1[(ks[30] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[30] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[30] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[30] >> 0) & 0xff] & 0xff]; + ks[31] = td0[te1[(ks[31] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[31] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[31] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[31] >> 0) & 0xff] & 0xff]; + ks[32] = td0[te1[(ks[32] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[32] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[32] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[32] >> 0) & 0xff] & 0xff]; + ks[33] = td0[te1[(ks[33] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[33] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[33] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[33] >> 0) & 0xff] & 0xff]; + ks[34] = td0[te1[(ks[34] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[34] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[34] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[34] >> 0) & 0xff] & 0xff]; + ks[35] = td0[te1[(ks[35] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[35] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[35] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[35] >> 0) & 0xff] & 0xff]; + ks[36] = td0[te1[(ks[36] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[36] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[36] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[36] >> 0) & 0xff] & 0xff]; + ks[37] = td0[te1[(ks[37] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[37] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[37] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[37] >> 0) & 0xff] & 0xff]; + ks[38] = td0[te1[(ks[38] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[38] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[38] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[38] >> 0) & 0xff] & 0xff]; + ks[39] = td0[te1[(ks[39] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[39] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[39] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[39] >> 0) & 0xff] & 0xff]; + ks[40] = td0[te1[(ks[40] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[40] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[40] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[40] >> 0) & 0xff] & 0xff]; + ks[41] = td0[te1[(ks[41] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[41] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[41] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[41] >> 0) & 0xff] & 0xff]; + ks[42] = td0[te1[(ks[42] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[42] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[42] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[42] >> 0) & 0xff] & 0xff]; + ks[43] = td0[te1[(ks[43] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[43] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[43] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[43] >> 0) & 0xff] & 0xff]; + ks[44] = td0[te1[(ks[44] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[44] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[44] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[44] >> 0) & 0xff] & 0xff]; + ks[45] = td0[te1[(ks[45] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[45] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[45] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[45] >> 0) & 0xff] & 0xff]; + ks[46] = td0[te1[(ks[46] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[46] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[46] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[46] >> 0) & 0xff] & 0xff]; + ks[47] = td0[te1[(ks[47] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[47] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[47] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[47] >> 0) & 0xff] & 0xff]; + ks[48] = td0[te1[(ks[48] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[48] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[48] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[48] >> 0) & 0xff] & 0xff]; + ks[49] = td0[te1[(ks[49] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[49] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[49] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[49] >> 0) & 0xff] & 0xff]; + ks[50] = td0[te1[(ks[50] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[50] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[50] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[50] >> 0) & 0xff] & 0xff]; + ks[51] = td0[te1[(ks[51] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[51] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[51] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[51] >> 0) & 0xff] & 0xff]; + ks[52] = td0[te1[(ks[52] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[52] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[52] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[52] >> 0) & 0xff] & 0xff]; + ks[53] = td0[te1[(ks[53] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[53] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[53] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[53] >> 0) & 0xff] & 0xff]; + ks[54] = td0[te1[(ks[54] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[54] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[54] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[54] >> 0) & 0xff] & 0xff]; + ks[55] = td0[te1[(ks[55] >> 24) & 0xff] & 0xff] ^ td1[te1[(ks[55] >> 16) & 0xff] & 0xff] ^ td2[te1[(ks[55] >> 8) & 0xff] & 0xff] ^ td3[te1[(ks[55] >> 0) & 0xff] & 0xff]; } +DECLSPEC void aes256_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void aes256_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 ukey_s[8]; @@ -1141,6 +1264,7 @@ DECLSPEC void aes256_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes256_ExpandKey (ks, ukey_s, s_te0, s_te1, s_te2, s_te3, s_te4); } +DECLSPEC void aes256_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ukey_s[8]; @@ -1159,85 +1283,101 @@ DECLSPEC void aes256_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes256_InvertKey (ks, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); } +DECLSPEC void aes256_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void aes256_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { - const u32 in_s0 = swap32_S (in[0]); - const u32 in_s1 = swap32_S (in[1]); - const u32 in_s2 = swap32_S (in[2]); - const u32 in_s3 = swap32_S (in[3]); + u32 in_s[4]; - u32 t0 = in_s0 ^ ks[0]; - u32 t1 = in_s1 ^ ks[1]; - u32 t2 = in_s2 ^ ks[2]; - u32 t3 = in_s3 ^ ks[3]; + in_s[0] = swap32_S (in[0]); + in_s[1] = swap32_S (in[1]); + in_s[2] = swap32_S (in[2]); + in_s[3] = swap32_S (in[3]); - #ifdef _unroll - #pragma unroll - #endif - for (int i = 4; i < 56; i += 4) - { - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + u32 s0 = in_s[0] ^ ks[0]; + u32 s1 = in_s[1] ^ ks[1]; + u32 s2 = in_s[2] ^ ks[2]; + u32 s3 = in_s[3] ^ ks[3]; - t0 = s_te0[x0s3] ^ s_te1[x1s2] ^ s_te2[x2s1] ^ s_te3[x3s0] ^ ks[i + 0]; - t1 = s_te0[x1s3] ^ s_te1[x2s2] ^ s_te2[x3s1] ^ s_te3[x0s0] ^ ks[i + 1]; - t2 = s_te0[x2s3] ^ s_te1[x3s2] ^ s_te2[x0s1] ^ s_te3[x1s0] ^ ks[i + 2]; - t3 = s_te0[x3s3] ^ s_te1[x0s2] ^ s_te2[x1s1] ^ s_te3[x2s0] ^ ks[i + 3]; - } + u32 t0; + u32 t1; + u32 t2; + u32 t3; - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[ 4]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[ 5]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[ 6]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[ 7]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[ 8]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[ 9]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[10]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[11]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[12]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[13]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[14]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[15]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[16]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[17]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[18]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[19]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[20]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[21]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[22]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[23]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[24]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[25]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[26]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[27]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[28]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[29]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[30]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[31]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[32]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[33]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[34]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[35]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[36]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[37]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[38]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[39]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[40]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[41]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[42]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[43]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[44]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[45]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[46]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[47]; + s0 = s_te0[t0 >> 24] ^ s_te1[(t1 >> 16) & 0xff] ^ s_te2[(t2 >> 8) & 0xff] ^ s_te3[t3 & 0xff] ^ ks[48]; + s1 = s_te0[t1 >> 24] ^ s_te1[(t2 >> 16) & 0xff] ^ s_te2[(t3 >> 8) & 0xff] ^ s_te3[t0 & 0xff] ^ ks[49]; + s2 = s_te0[t2 >> 24] ^ s_te1[(t3 >> 16) & 0xff] ^ s_te2[(t0 >> 8) & 0xff] ^ s_te3[t1 & 0xff] ^ ks[50]; + s3 = s_te0[t3 >> 24] ^ s_te1[(t0 >> 16) & 0xff] ^ s_te2[(t1 >> 8) & 0xff] ^ s_te3[t2 & 0xff] ^ ks[51]; + t0 = s_te0[s0 >> 24] ^ s_te1[(s1 >> 16) & 0xff] ^ s_te2[(s2 >> 8) & 0xff] ^ s_te3[s3 & 0xff] ^ ks[52]; + t1 = s_te0[s1 >> 24] ^ s_te1[(s2 >> 16) & 0xff] ^ s_te2[(s3 >> 8) & 0xff] ^ s_te3[s0 & 0xff] ^ ks[53]; + t2 = s_te0[s2 >> 24] ^ s_te1[(s3 >> 16) & 0xff] ^ s_te2[(s0 >> 8) & 0xff] ^ s_te3[s1 & 0xff] ^ ks[54]; + t3 = s_te0[s3 >> 24] ^ s_te1[(s0 >> 16) & 0xff] ^ s_te2[(s1 >> 8) & 0xff] ^ s_te3[s2 & 0xff] ^ ks[55]; - out[0] = (s_te4[x0s3] & 0xff000000) - ^ (s_te4[x1s2] & 0x00ff0000) - ^ (s_te4[x2s1] & 0x0000ff00) - ^ (s_te4[x3s0] & 0x000000ff) + out[0] = (s_te4[(t0 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t1 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t2 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t3 >> 0) & 0xff] & 0x000000ff) ^ ks[56]; - out[1] = (s_te4[x1s3] & 0xff000000) - ^ (s_te4[x2s2] & 0x00ff0000) - ^ (s_te4[x3s1] & 0x0000ff00) - ^ (s_te4[x0s0] & 0x000000ff) + out[1] = (s_te4[(t1 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t2 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t3 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t0 >> 0) & 0xff] & 0x000000ff) ^ ks[57]; - out[2] = (s_te4[x2s3] & 0xff000000) - ^ (s_te4[x3s2] & 0x00ff0000) - ^ (s_te4[x0s1] & 0x0000ff00) - ^ (s_te4[x1s0] & 0x000000ff) + out[2] = (s_te4[(t2 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t3 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t0 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t1 >> 0) & 0xff] & 0x000000ff) ^ ks[58]; - out[3] = (s_te4[x3s3] & 0xff000000) - ^ (s_te4[x0s2] & 0x00ff0000) - ^ (s_te4[x1s1] & 0x0000ff00) - ^ (s_te4[x2s0] & 0x000000ff) + out[3] = (s_te4[(t3 >> 24) & 0xff] & 0xff000000) + ^ (s_te4[(t0 >> 16) & 0xff] & 0x00ff0000) + ^ (s_te4[(t1 >> 8) & 0xff] & 0x0000ff00) + ^ (s_te4[(t2 >> 0) & 0xff] & 0x000000ff) ^ ks[59]; out[0] = swap32_S (out[0]); @@ -1246,85 +1386,101 @@ DECLSPEC void aes256_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u out[3] = swap32_S (out[3]); } +DECLSPEC void aes256_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { - const u32 in_s0 = swap32_S (in[0]); - const u32 in_s1 = swap32_S (in[1]); - const u32 in_s2 = swap32_S (in[2]); - const u32 in_s3 = swap32_S (in[3]); + u32 in_s[4]; - u32 t0 = in_s0 ^ ks[0]; - u32 t1 = in_s1 ^ ks[1]; - u32 t2 = in_s2 ^ ks[2]; - u32 t3 = in_s3 ^ ks[3]; + in_s[0] = swap32_S (in[0]); + in_s[1] = swap32_S (in[1]); + in_s[2] = swap32_S (in[2]); + in_s[3] = swap32_S (in[3]); - #ifdef _unroll - #pragma unroll - #endif - for (int i = 4; i < 56; i += 4) - { - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + u32 s0 = in_s[0] ^ ks[0]; + u32 s1 = in_s[1] ^ ks[1]; + u32 s2 = in_s[2] ^ ks[2]; + u32 s3 = in_s[3] ^ ks[3]; - t0 = s_td0[x0s3] ^ s_td1[x3s2] ^ s_td2[x2s1] ^ s_td3[x1s0] ^ ks[i + 0]; - t1 = s_td0[x1s3] ^ s_td1[x0s2] ^ s_td2[x3s1] ^ s_td3[x2s0] ^ ks[i + 1]; - t2 = s_td0[x2s3] ^ s_td1[x1s2] ^ s_td2[x0s1] ^ s_td3[x3s0] ^ ks[i + 2]; - t3 = s_td0[x3s3] ^ s_td1[x2s2] ^ s_td2[x1s1] ^ s_td3[x0s0] ^ ks[i + 3]; - } + u32 t0; + u32 t1; + u32 t2; + u32 t3; - const u32 x0s0 = (t0 >> 0) & 0xff; - const u32 x0s1 = (t0 >> 8) & 0xff; - const u32 x0s2 = (t0 >> 16) & 0xff; - const u32 x0s3 = (t0 >> 24) & 0xff; - const u32 x1s0 = (t1 >> 0) & 0xff; - const u32 x1s1 = (t1 >> 8) & 0xff; - const u32 x1s2 = (t1 >> 16) & 0xff; - const u32 x1s3 = (t1 >> 24) & 0xff; - const u32 x2s0 = (t2 >> 0) & 0xff; - const u32 x2s1 = (t2 >> 8) & 0xff; - const u32 x2s2 = (t2 >> 16) & 0xff; - const u32 x2s3 = (t2 >> 24) & 0xff; - const u32 x3s0 = (t3 >> 0) & 0xff; - const u32 x3s1 = (t3 >> 8) & 0xff; - const u32 x3s2 = (t3 >> 16) & 0xff; - const u32 x3s3 = (t3 >> 24) & 0xff; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[ 4]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[ 5]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[ 6]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[ 7]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[ 8]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[ 9]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[10]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[11]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[12]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[13]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[14]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[15]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[16]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[17]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[18]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[19]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[20]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[21]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[22]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[23]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[24]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[25]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[26]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[27]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[28]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[29]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[30]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[31]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[32]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[33]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[34]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[35]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[36]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[37]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[38]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[39]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[40]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[41]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[42]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[43]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[44]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[45]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[46]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[47]; + s0 = s_td0[t0 >> 24] ^ s_td1[(t3 >> 16) & 0xff] ^ s_td2[(t2 >> 8) & 0xff] ^ s_td3[t1 & 0xff] ^ ks[48]; + s1 = s_td0[t1 >> 24] ^ s_td1[(t0 >> 16) & 0xff] ^ s_td2[(t3 >> 8) & 0xff] ^ s_td3[t2 & 0xff] ^ ks[49]; + s2 = s_td0[t2 >> 24] ^ s_td1[(t1 >> 16) & 0xff] ^ s_td2[(t0 >> 8) & 0xff] ^ s_td3[t3 & 0xff] ^ ks[50]; + s3 = s_td0[t3 >> 24] ^ s_td1[(t2 >> 16) & 0xff] ^ s_td2[(t1 >> 8) & 0xff] ^ s_td3[t0 & 0xff] ^ ks[51]; + t0 = s_td0[s0 >> 24] ^ s_td1[(s3 >> 16) & 0xff] ^ s_td2[(s2 >> 8) & 0xff] ^ s_td3[s1 & 0xff] ^ ks[52]; + t1 = s_td0[s1 >> 24] ^ s_td1[(s0 >> 16) & 0xff] ^ s_td2[(s3 >> 8) & 0xff] ^ s_td3[s2 & 0xff] ^ ks[53]; + t2 = s_td0[s2 >> 24] ^ s_td1[(s1 >> 16) & 0xff] ^ s_td2[(s0 >> 8) & 0xff] ^ s_td3[s3 & 0xff] ^ ks[54]; + t3 = s_td0[s3 >> 24] ^ s_td1[(s2 >> 16) & 0xff] ^ s_td2[(s1 >> 8) & 0xff] ^ s_td3[s0 & 0xff] ^ ks[55]; - out[0] = (s_td4[x0s3] & 0xff000000) - ^ (s_td4[x3s2] & 0x00ff0000) - ^ (s_td4[x2s1] & 0x0000ff00) - ^ (s_td4[x1s0] & 0x000000ff) + out[0] = (s_td4[(t0 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t3 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t2 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t1 >> 0) & 0xff] & 0x000000ff) ^ ks[56]; - out[1] = (s_td4[x1s3] & 0xff000000) - ^ (s_td4[x0s2] & 0x00ff0000) - ^ (s_td4[x3s1] & 0x0000ff00) - ^ (s_td4[x2s0] & 0x000000ff) + out[1] = (s_td4[(t1 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t0 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t3 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t2 >> 0) & 0xff] & 0x000000ff) ^ ks[57]; - out[2] = (s_td4[x2s3] & 0xff000000) - ^ (s_td4[x1s2] & 0x00ff0000) - ^ (s_td4[x0s1] & 0x0000ff00) - ^ (s_td4[x3s0] & 0x000000ff) + out[2] = (s_td4[(t2 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t1 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t0 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t3 >> 0) & 0xff] & 0x000000ff) ^ ks[58]; - out[3] = (s_td4[x3s3] & 0xff000000) - ^ (s_td4[x2s2] & 0x00ff0000) - ^ (s_td4[x1s1] & 0x0000ff00) - ^ (s_td4[x0s0] & 0x000000ff) + out[3] = (s_td4[(t3 >> 24) & 0xff] & 0xff000000) + ^ (s_td4[(t2 >> 16) & 0xff] & 0x00ff0000) + ^ (s_td4[(t1 >> 8) & 0xff] & 0x0000ff00) + ^ (s_td4[(t0 >> 0) & 0xff] & 0x000000ff) ^ ks[59]; out[0] = swap32_S (out[0]); @@ -1335,6 +1491,7 @@ DECLSPEC void aes256_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u // wrapper to avoid swap32_S() confusion in the kernel code +DECLSPEC void AES128_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void AES128_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 ukey_s[4]; @@ -1347,6 +1504,7 @@ DECLSPEC void AES128_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes128_set_encrypt_key (ks, ukey_s, s_te0, s_te1, s_te2, s_te3, s_te4); } +DECLSPEC void AES128_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void AES128_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ukey_s[4]; @@ -1359,6 +1517,7 @@ DECLSPEC void AES128_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes128_set_decrypt_key (ks, ukey_s, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); } +DECLSPEC void AES128_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void AES128_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 in_s[4]; @@ -1378,6 +1537,7 @@ DECLSPEC void AES128_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u out[3] = swap32_S (out_s[3]); } +DECLSPEC void AES128_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void AES128_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 in_s[4]; @@ -1397,6 +1557,7 @@ DECLSPEC void AES128_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u out[3] = swap32_S (out_s[3]); } +DECLSPEC void AES256_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void AES256_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 ukey_s[8]; @@ -1413,6 +1574,7 @@ DECLSPEC void AES256_set_encrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes256_set_encrypt_key (ks, ukey_s, s_te0, s_te1, s_te2, s_te3, s_te4); } +DECLSPEC void AES256_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void AES256_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ukey_s[8]; @@ -1429,6 +1591,7 @@ DECLSPEC void AES256_set_decrypt_key (u32 *ks, const u32 *ukey, SHM_TYPE u32 *s_ aes256_set_decrypt_key (ks, ukey_s, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); } +DECLSPEC void AES256_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4); DECLSPEC void AES256_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 in_s[4]; @@ -1448,6 +1611,7 @@ DECLSPEC void AES256_encrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u out[3] = swap32_S (out_s[3]); } +DECLSPEC void AES256_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void AES256_decrypt (const u32 *ks, const u32 *in, u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 in_s[4]; diff --git a/OpenCL/inc_cipher_camellia.cl b/OpenCL/inc_cipher_camellia.cl index 152239441..ad849ad04 100644 --- a/OpenCL/inc_cipher_camellia.cl +++ b/OpenCL/inc_cipher_camellia.cl @@ -60,6 +60,7 @@ __constant const u32a c_sbox[256] = #define extract_byte(x,n) (((x) >> (8 * (n))) & 0xff) +DECLSPEC void cam_feistel (const u32 *x, const u32 *k, u32 *y); DECLSPEC void cam_feistel (const u32 *x, const u32 *k, u32 *y) { u32 b[8]; @@ -89,6 +90,7 @@ DECLSPEC void cam_feistel (const u32 *x, const u32 *k, u32 *y) y[1] ^= tmp[1]; } +DECLSPEC void cam_fl (u32 *x, const u32 *kl, const u32 *kr); DECLSPEC void cam_fl (u32 *x, const u32 *kl, const u32 *kr) { u32 t[4]; @@ -125,6 +127,7 @@ DECLSPEC void cam_fl (u32 *x, const u32 *kl, const u32 *kr) x[3] = swap32_S (t[3]); } +DECLSPEC void camellia256_set_key (u32 *ks, const u32 *ukey); DECLSPEC void camellia256_set_key (u32 *ks, const u32 *ukey) { const u32 sigma[12] = @@ -260,6 +263,7 @@ DECLSPEC void camellia256_set_key (u32 *ks, const u32 *ukey) ks[67] = cam_rotate (14, 15, 15); } +DECLSPEC void camellia256_encrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void camellia256_encrypt (const u32 *ks, const u32 *in, u32 *out) { out[0] = in[0] ^ ks[0]; @@ -312,6 +316,7 @@ DECLSPEC void camellia256_encrypt (const u32 *ks, const u32 *in, u32 *out) out[3] = tmp[1] ^ ks[67]; } +DECLSPEC void camellia256_decrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void camellia256_decrypt (const u32 *ks, const u32 *in, u32 *out) { out[0] = in[0] ^ ks[64]; diff --git a/OpenCL/inc_cipher_des.cl b/OpenCL/inc_cipher_des.cl new file mode 100644 index 000000000..503221532 --- /dev/null +++ b/OpenCL/inc_cipher_des.cl @@ -0,0 +1,524 @@ + +__constant u32a c_SPtrans[8][64] = +{ + { + /* nibble 0 */ + 0x02080800, 0x00080000, 0x02000002, 0x02080802, + 0x02000000, 0x00080802, 0x00080002, 0x02000002, + 0x00080802, 0x02080800, 0x02080000, 0x00000802, + 0x02000802, 0x02000000, 0x00000000, 0x00080002, + 0x00080000, 0x00000002, 0x02000800, 0x00080800, + 0x02080802, 0x02080000, 0x00000802, 0x02000800, + 0x00000002, 0x00000800, 0x00080800, 0x02080002, + 0x00000800, 0x02000802, 0x02080002, 0x00000000, + 0x00000000, 0x02080802, 0x02000800, 0x00080002, + 0x02080800, 0x00080000, 0x00000802, 0x02000800, + 0x02080002, 0x00000800, 0x00080800, 0x02000002, + 0x00080802, 0x00000002, 0x02000002, 0x02080000, + 0x02080802, 0x00080800, 0x02080000, 0x02000802, + 0x02000000, 0x00000802, 0x00080002, 0x00000000, + 0x00080000, 0x02000000, 0x02000802, 0x02080800, + 0x00000002, 0x02080002, 0x00000800, 0x00080802, + }, + { + /* nibble 1 */ + 0x40108010, 0x00000000, 0x00108000, 0x40100000, + 0x40000010, 0x00008010, 0x40008000, 0x00108000, + 0x00008000, 0x40100010, 0x00000010, 0x40008000, + 0x00100010, 0x40108000, 0x40100000, 0x00000010, + 0x00100000, 0x40008010, 0x40100010, 0x00008000, + 0x00108010, 0x40000000, 0x00000000, 0x00100010, + 0x40008010, 0x00108010, 0x40108000, 0x40000010, + 0x40000000, 0x00100000, 0x00008010, 0x40108010, + 0x00100010, 0x40108000, 0x40008000, 0x00108010, + 0x40108010, 0x00100010, 0x40000010, 0x00000000, + 0x40000000, 0x00008010, 0x00100000, 0x40100010, + 0x00008000, 0x40000000, 0x00108010, 0x40008010, + 0x40108000, 0x00008000, 0x00000000, 0x40000010, + 0x00000010, 0x40108010, 0x00108000, 0x40100000, + 0x40100010, 0x00100000, 0x00008010, 0x40008000, + 0x40008010, 0x00000010, 0x40100000, 0x00108000, + }, + { + /* nibble 2 */ + 0x04000001, 0x04040100, 0x00000100, 0x04000101, + 0x00040001, 0x04000000, 0x04000101, 0x00040100, + 0x04000100, 0x00040000, 0x04040000, 0x00000001, + 0x04040101, 0x00000101, 0x00000001, 0x04040001, + 0x00000000, 0x00040001, 0x04040100, 0x00000100, + 0x00000101, 0x04040101, 0x00040000, 0x04000001, + 0x04040001, 0x04000100, 0x00040101, 0x04040000, + 0x00040100, 0x00000000, 0x04000000, 0x00040101, + 0x04040100, 0x00000100, 0x00000001, 0x00040000, + 0x00000101, 0x00040001, 0x04040000, 0x04000101, + 0x00000000, 0x04040100, 0x00040100, 0x04040001, + 0x00040001, 0x04000000, 0x04040101, 0x00000001, + 0x00040101, 0x04000001, 0x04000000, 0x04040101, + 0x00040000, 0x04000100, 0x04000101, 0x00040100, + 0x04000100, 0x00000000, 0x04040001, 0x00000101, + 0x04000001, 0x00040101, 0x00000100, 0x04040000, + }, + { + /* nibble 3 */ + 0x00401008, 0x10001000, 0x00000008, 0x10401008, + 0x00000000, 0x10400000, 0x10001008, 0x00400008, + 0x10401000, 0x10000008, 0x10000000, 0x00001008, + 0x10000008, 0x00401008, 0x00400000, 0x10000000, + 0x10400008, 0x00401000, 0x00001000, 0x00000008, + 0x00401000, 0x10001008, 0x10400000, 0x00001000, + 0x00001008, 0x00000000, 0x00400008, 0x10401000, + 0x10001000, 0x10400008, 0x10401008, 0x00400000, + 0x10400008, 0x00001008, 0x00400000, 0x10000008, + 0x00401000, 0x10001000, 0x00000008, 0x10400000, + 0x10001008, 0x00000000, 0x00001000, 0x00400008, + 0x00000000, 0x10400008, 0x10401000, 0x00001000, + 0x10000000, 0x10401008, 0x00401008, 0x00400000, + 0x10401008, 0x00000008, 0x10001000, 0x00401008, + 0x00400008, 0x00401000, 0x10400000, 0x10001008, + 0x00001008, 0x10000000, 0x10000008, 0x10401000, + }, + { + /* nibble 4 */ + 0x08000000, 0x00010000, 0x00000400, 0x08010420, + 0x08010020, 0x08000400, 0x00010420, 0x08010000, + 0x00010000, 0x00000020, 0x08000020, 0x00010400, + 0x08000420, 0x08010020, 0x08010400, 0x00000000, + 0x00010400, 0x08000000, 0x00010020, 0x00000420, + 0x08000400, 0x00010420, 0x00000000, 0x08000020, + 0x00000020, 0x08000420, 0x08010420, 0x00010020, + 0x08010000, 0x00000400, 0x00000420, 0x08010400, + 0x08010400, 0x08000420, 0x00010020, 0x08010000, + 0x00010000, 0x00000020, 0x08000020, 0x08000400, + 0x08000000, 0x00010400, 0x08010420, 0x00000000, + 0x00010420, 0x08000000, 0x00000400, 0x00010020, + 0x08000420, 0x00000400, 0x00000000, 0x08010420, + 0x08010020, 0x08010400, 0x00000420, 0x00010000, + 0x00010400, 0x08010020, 0x08000400, 0x00000420, + 0x00000020, 0x00010420, 0x08010000, 0x08000020, + }, + { + /* nibble 5 */ + 0x80000040, 0x00200040, 0x00000000, 0x80202000, + 0x00200040, 0x00002000, 0x80002040, 0x00200000, + 0x00002040, 0x80202040, 0x00202000, 0x80000000, + 0x80002000, 0x80000040, 0x80200000, 0x00202040, + 0x00200000, 0x80002040, 0x80200040, 0x00000000, + 0x00002000, 0x00000040, 0x80202000, 0x80200040, + 0x80202040, 0x80200000, 0x80000000, 0x00002040, + 0x00000040, 0x00202000, 0x00202040, 0x80002000, + 0x00002040, 0x80000000, 0x80002000, 0x00202040, + 0x80202000, 0x00200040, 0x00000000, 0x80002000, + 0x80000000, 0x00002000, 0x80200040, 0x00200000, + 0x00200040, 0x80202040, 0x00202000, 0x00000040, + 0x80202040, 0x00202000, 0x00200000, 0x80002040, + 0x80000040, 0x80200000, 0x00202040, 0x00000000, + 0x00002000, 0x80000040, 0x80002040, 0x80202000, + 0x80200000, 0x00002040, 0x00000040, 0x80200040, + }, + { + /* nibble 6 */ + 0x00004000, 0x00000200, 0x01000200, 0x01000004, + 0x01004204, 0x00004004, 0x00004200, 0x00000000, + 0x01000000, 0x01000204, 0x00000204, 0x01004000, + 0x00000004, 0x01004200, 0x01004000, 0x00000204, + 0x01000204, 0x00004000, 0x00004004, 0x01004204, + 0x00000000, 0x01000200, 0x01000004, 0x00004200, + 0x01004004, 0x00004204, 0x01004200, 0x00000004, + 0x00004204, 0x01004004, 0x00000200, 0x01000000, + 0x00004204, 0x01004000, 0x01004004, 0x00000204, + 0x00004000, 0x00000200, 0x01000000, 0x01004004, + 0x01000204, 0x00004204, 0x00004200, 0x00000000, + 0x00000200, 0x01000004, 0x00000004, 0x01000200, + 0x00000000, 0x01000204, 0x01000200, 0x00004200, + 0x00000204, 0x00004000, 0x01004204, 0x01000000, + 0x01004200, 0x00000004, 0x00004004, 0x01004204, + 0x01000004, 0x01004200, 0x01004000, 0x00004004, + }, + { + /* nibble 7 */ + 0x20800080, 0x20820000, 0x00020080, 0x00000000, + 0x20020000, 0x00800080, 0x20800000, 0x20820080, + 0x00000080, 0x20000000, 0x00820000, 0x00020080, + 0x00820080, 0x20020080, 0x20000080, 0x20800000, + 0x00020000, 0x00820080, 0x00800080, 0x20020000, + 0x20820080, 0x20000080, 0x00000000, 0x00820000, + 0x20000000, 0x00800000, 0x20020080, 0x20800080, + 0x00800000, 0x00020000, 0x20820000, 0x00000080, + 0x00800000, 0x00020000, 0x20000080, 0x20820080, + 0x00020080, 0x20000000, 0x00000000, 0x00820000, + 0x20800080, 0x20020080, 0x20020000, 0x00800080, + 0x20820000, 0x00000080, 0x00800080, 0x20020000, + 0x20820080, 0x00800000, 0x20800000, 0x20000080, + 0x00820000, 0x00020080, 0x20020080, 0x20800000, + 0x00000080, 0x20820000, 0x00820080, 0x00000000, + 0x20000000, 0x20800080, 0x00020000, 0x00820080, + }, +}; + +__constant u32a c_skb[8][64] = +{ + { + 0x00000000, 0x00000010, 0x20000000, 0x20000010, + 0x00010000, 0x00010010, 0x20010000, 0x20010010, + 0x00000800, 0x00000810, 0x20000800, 0x20000810, + 0x00010800, 0x00010810, 0x20010800, 0x20010810, + 0x00000020, 0x00000030, 0x20000020, 0x20000030, + 0x00010020, 0x00010030, 0x20010020, 0x20010030, + 0x00000820, 0x00000830, 0x20000820, 0x20000830, + 0x00010820, 0x00010830, 0x20010820, 0x20010830, + 0x00080000, 0x00080010, 0x20080000, 0x20080010, + 0x00090000, 0x00090010, 0x20090000, 0x20090010, + 0x00080800, 0x00080810, 0x20080800, 0x20080810, + 0x00090800, 0x00090810, 0x20090800, 0x20090810, + 0x00080020, 0x00080030, 0x20080020, 0x20080030, + 0x00090020, 0x00090030, 0x20090020, 0x20090030, + 0x00080820, 0x00080830, 0x20080820, 0x20080830, + 0x00090820, 0x00090830, 0x20090820, 0x20090830, + }, + { + 0x00000000, 0x02000000, 0x00002000, 0x02002000, + 0x00200000, 0x02200000, 0x00202000, 0x02202000, + 0x00000004, 0x02000004, 0x00002004, 0x02002004, + 0x00200004, 0x02200004, 0x00202004, 0x02202004, + 0x00000400, 0x02000400, 0x00002400, 0x02002400, + 0x00200400, 0x02200400, 0x00202400, 0x02202400, + 0x00000404, 0x02000404, 0x00002404, 0x02002404, + 0x00200404, 0x02200404, 0x00202404, 0x02202404, + 0x10000000, 0x12000000, 0x10002000, 0x12002000, + 0x10200000, 0x12200000, 0x10202000, 0x12202000, + 0x10000004, 0x12000004, 0x10002004, 0x12002004, + 0x10200004, 0x12200004, 0x10202004, 0x12202004, + 0x10000400, 0x12000400, 0x10002400, 0x12002400, + 0x10200400, 0x12200400, 0x10202400, 0x12202400, + 0x10000404, 0x12000404, 0x10002404, 0x12002404, + 0x10200404, 0x12200404, 0x10202404, 0x12202404, + }, + { + 0x00000000, 0x00000001, 0x00040000, 0x00040001, + 0x01000000, 0x01000001, 0x01040000, 0x01040001, + 0x00000002, 0x00000003, 0x00040002, 0x00040003, + 0x01000002, 0x01000003, 0x01040002, 0x01040003, + 0x00000200, 0x00000201, 0x00040200, 0x00040201, + 0x01000200, 0x01000201, 0x01040200, 0x01040201, + 0x00000202, 0x00000203, 0x00040202, 0x00040203, + 0x01000202, 0x01000203, 0x01040202, 0x01040203, + 0x08000000, 0x08000001, 0x08040000, 0x08040001, + 0x09000000, 0x09000001, 0x09040000, 0x09040001, + 0x08000002, 0x08000003, 0x08040002, 0x08040003, + 0x09000002, 0x09000003, 0x09040002, 0x09040003, + 0x08000200, 0x08000201, 0x08040200, 0x08040201, + 0x09000200, 0x09000201, 0x09040200, 0x09040201, + 0x08000202, 0x08000203, 0x08040202, 0x08040203, + 0x09000202, 0x09000203, 0x09040202, 0x09040203, + }, + { + 0x00000000, 0x00100000, 0x00000100, 0x00100100, + 0x00000008, 0x00100008, 0x00000108, 0x00100108, + 0x00001000, 0x00101000, 0x00001100, 0x00101100, + 0x00001008, 0x00101008, 0x00001108, 0x00101108, + 0x04000000, 0x04100000, 0x04000100, 0x04100100, + 0x04000008, 0x04100008, 0x04000108, 0x04100108, + 0x04001000, 0x04101000, 0x04001100, 0x04101100, + 0x04001008, 0x04101008, 0x04001108, 0x04101108, + 0x00020000, 0x00120000, 0x00020100, 0x00120100, + 0x00020008, 0x00120008, 0x00020108, 0x00120108, + 0x00021000, 0x00121000, 0x00021100, 0x00121100, + 0x00021008, 0x00121008, 0x00021108, 0x00121108, + 0x04020000, 0x04120000, 0x04020100, 0x04120100, + 0x04020008, 0x04120008, 0x04020108, 0x04120108, + 0x04021000, 0x04121000, 0x04021100, 0x04121100, + 0x04021008, 0x04121008, 0x04021108, 0x04121108, + }, + { + 0x00000000, 0x10000000, 0x00010000, 0x10010000, + 0x00000004, 0x10000004, 0x00010004, 0x10010004, + 0x20000000, 0x30000000, 0x20010000, 0x30010000, + 0x20000004, 0x30000004, 0x20010004, 0x30010004, + 0x00100000, 0x10100000, 0x00110000, 0x10110000, + 0x00100004, 0x10100004, 0x00110004, 0x10110004, + 0x20100000, 0x30100000, 0x20110000, 0x30110000, + 0x20100004, 0x30100004, 0x20110004, 0x30110004, + 0x00001000, 0x10001000, 0x00011000, 0x10011000, + 0x00001004, 0x10001004, 0x00011004, 0x10011004, + 0x20001000, 0x30001000, 0x20011000, 0x30011000, + 0x20001004, 0x30001004, 0x20011004, 0x30011004, + 0x00101000, 0x10101000, 0x00111000, 0x10111000, + 0x00101004, 0x10101004, 0x00111004, 0x10111004, + 0x20101000, 0x30101000, 0x20111000, 0x30111000, + 0x20101004, 0x30101004, 0x20111004, 0x30111004, + }, + { + 0x00000000, 0x08000000, 0x00000008, 0x08000008, + 0x00000400, 0x08000400, 0x00000408, 0x08000408, + 0x00020000, 0x08020000, 0x00020008, 0x08020008, + 0x00020400, 0x08020400, 0x00020408, 0x08020408, + 0x00000001, 0x08000001, 0x00000009, 0x08000009, + 0x00000401, 0x08000401, 0x00000409, 0x08000409, + 0x00020001, 0x08020001, 0x00020009, 0x08020009, + 0x00020401, 0x08020401, 0x00020409, 0x08020409, + 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, + 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, + 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, + 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, + 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, + 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, + 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, + 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, + }, + { + 0x00000000, 0x00000100, 0x00080000, 0x00080100, + 0x01000000, 0x01000100, 0x01080000, 0x01080100, + 0x00000010, 0x00000110, 0x00080010, 0x00080110, + 0x01000010, 0x01000110, 0x01080010, 0x01080110, + 0x00200000, 0x00200100, 0x00280000, 0x00280100, + 0x01200000, 0x01200100, 0x01280000, 0x01280100, + 0x00200010, 0x00200110, 0x00280010, 0x00280110, + 0x01200010, 0x01200110, 0x01280010, 0x01280110, + 0x00000200, 0x00000300, 0x00080200, 0x00080300, + 0x01000200, 0x01000300, 0x01080200, 0x01080300, + 0x00000210, 0x00000310, 0x00080210, 0x00080310, + 0x01000210, 0x01000310, 0x01080210, 0x01080310, + 0x00200200, 0x00200300, 0x00280200, 0x00280300, + 0x01200200, 0x01200300, 0x01280200, 0x01280300, + 0x00200210, 0x00200310, 0x00280210, 0x00280310, + 0x01200210, 0x01200310, 0x01280210, 0x01280310, + }, + { + 0x00000000, 0x04000000, 0x00040000, 0x04040000, + 0x00000002, 0x04000002, 0x00040002, 0x04040002, + 0x00002000, 0x04002000, 0x00042000, 0x04042000, + 0x00002002, 0x04002002, 0x00042002, 0x04042002, + 0x00000020, 0x04000020, 0x00040020, 0x04040020, + 0x00000022, 0x04000022, 0x00040022, 0x04040022, + 0x00002020, 0x04002020, 0x00042020, 0x04042020, + 0x00002022, 0x04002022, 0x00042022, 0x04042022, + 0x00000800, 0x04000800, 0x00040800, 0x04040800, + 0x00000802, 0x04000802, 0x00040802, 0x04040802, + 0x00002800, 0x04002800, 0x00042800, 0x04042800, + 0x00002802, 0x04002802, 0x00042802, 0x04042802, + 0x00000820, 0x04000820, 0x00040820, 0x04040820, + 0x00000822, 0x04000822, 0x00040822, 0x04040822, + 0x00002820, 0x04002820, 0x00042820, 0x04042820, + 0x00002822, 0x04002822, 0x00042822, 0x04042822 + } +}; + +#define PERM_OP(a,b,n,m) \ +{ \ + u32x t; \ + t = a >> n; \ + t = t ^ b; \ + t = t & m; \ + b = b ^ t; \ + t = t << n; \ + a = a ^ t; \ +} + +#define HPERM_OP(a,n,m) \ +{ \ + u32x t; \ + t = a << (16 + n); \ + t = t ^ a; \ + t = t & m; \ + a = a ^ t; \ + t = t >> (16 + n); \ + a = a ^ t; \ +} + +#define DES_IP(l,r) \ +{ \ + PERM_OP (r, l, 4, 0x0f0f0f0f); \ + PERM_OP (l, r, 16, 0x0000ffff); \ + PERM_OP (r, l, 2, 0x33333333); \ + PERM_OP (l, r, 8, 0x00ff00ff); \ + PERM_OP (r, l, 1, 0x55555555); \ +} + +#define DES_FP(l,r) \ +{ \ + PERM_OP (l, r, 1, 0x55555555); \ + PERM_OP (r, l, 8, 0x00ff00ff); \ + PERM_OP (l, r, 2, 0x33333333); \ + PERM_OP (r, l, 16, 0x0000ffff); \ + PERM_OP (l, r, 4, 0x0f0f0f0f); \ +} + +#if VECT_SIZE == 1 +#define DES_BOX(i,n,S) (S)[(n)][(i)] +#elif VECT_SIZE == 2 +#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1]) +#elif VECT_SIZE == 4 +#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3]) +#elif VECT_SIZE == 8 +#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) +#elif VECT_SIZE == 16 +#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) +#endif + +DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]); +DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) +{ + u32x r = data[0]; + u32x l = data[1]; + + DES_IP (r, l); + + r = rotl32 (r, 3u); + l = rotl32 (l, 3u); + + for (u32 i = 0; i < 16; i += 2) + { + u32x u; + u32x t; + + u = Kc[i + 0] ^ r; + t = Kd[i + 0] ^ rotl32 (r, 28u); + + l ^= DES_BOX (((u >> 2) & 0x3f), 0, s_SPtrans) + | DES_BOX (((u >> 10) & 0x3f), 2, s_SPtrans) + | DES_BOX (((u >> 18) & 0x3f), 4, s_SPtrans) + | DES_BOX (((u >> 26) & 0x3f), 6, s_SPtrans) + | DES_BOX (((t >> 2) & 0x3f), 1, s_SPtrans) + | DES_BOX (((t >> 10) & 0x3f), 3, s_SPtrans) + | DES_BOX (((t >> 18) & 0x3f), 5, s_SPtrans) + | DES_BOX (((t >> 26) & 0x3f), 7, s_SPtrans); + + u = Kc[i + 1] ^ l; + t = Kd[i + 1] ^ rotl32 (l, 28u); + + r ^= DES_BOX (((u >> 2) & 0x3f), 0, s_SPtrans) + | DES_BOX (((u >> 10) & 0x3f), 2, s_SPtrans) + | DES_BOX (((u >> 18) & 0x3f), 4, s_SPtrans) + | DES_BOX (((u >> 26) & 0x3f), 6, s_SPtrans) + | DES_BOX (((t >> 2) & 0x3f), 1, s_SPtrans) + | DES_BOX (((t >> 10) & 0x3f), 3, s_SPtrans) + | DES_BOX (((t >> 18) & 0x3f), 5, s_SPtrans) + | DES_BOX (((t >> 26) & 0x3f), 7, s_SPtrans); + } + + l = rotl32 (l, 29u); + r = rotl32 (r, 29u); + + DES_FP (r, l); + + iv[0] = l; + iv[1] = r; +} + +DECLSPEC void _des_crypt_decrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]); +DECLSPEC void _des_crypt_decrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) +{ + u32x r = data[0]; + u32x l = data[1]; + + DES_IP (r, l); + + r = rotl32 (r, 3u); + l = rotl32 (l, 3u); + + for (u32 i = 16; i > 0; i -= 2) + { + u32x u; + u32x t; + + u = Kc[i - 1] ^ r; + t = Kd[i - 1] ^ rotl32 (r, 28u); + + l ^= DES_BOX (((u >> 2) & 0x3f), 0, s_SPtrans) + | DES_BOX (((u >> 10) & 0x3f), 2, s_SPtrans) + | DES_BOX (((u >> 18) & 0x3f), 4, s_SPtrans) + | DES_BOX (((u >> 26) & 0x3f), 6, s_SPtrans) + | DES_BOX (((t >> 2) & 0x3f), 1, s_SPtrans) + | DES_BOX (((t >> 10) & 0x3f), 3, s_SPtrans) + | DES_BOX (((t >> 18) & 0x3f), 5, s_SPtrans) + | DES_BOX (((t >> 26) & 0x3f), 7, s_SPtrans); + + u = Kc[i - 2] ^ l; + t = Kd[i - 2] ^ rotl32 (l, 28u); + + r ^= DES_BOX (((u >> 2) & 0x3f), 0, s_SPtrans) + | DES_BOX (((u >> 10) & 0x3f), 2, s_SPtrans) + | DES_BOX (((u >> 18) & 0x3f), 4, s_SPtrans) + | DES_BOX (((u >> 26) & 0x3f), 6, s_SPtrans) + | DES_BOX (((t >> 2) & 0x3f), 1, s_SPtrans) + | DES_BOX (((t >> 10) & 0x3f), 3, s_SPtrans) + | DES_BOX (((t >> 18) & 0x3f), 5, s_SPtrans) + | DES_BOX (((t >> 26) & 0x3f), 7, s_SPtrans); + } + + l = rotl32 (l, 29u); + r = rotl32 (r, 29u); + + DES_FP (r, l); + + iv[0] = l; + iv[1] = r; +} + +DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_skb)[64]); +DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_skb)[64]) +{ + PERM_OP (d, c, 4, 0x0f0f0f0f); + HPERM_OP (c, 2, 0xcccc0000); + HPERM_OP (d, 2, 0xcccc0000); + PERM_OP (d, c, 1, 0x55555555); + PERM_OP (c, d, 8, 0x00ff00ff); + PERM_OP (d, c, 1, 0x55555555); + + d = ((d & 0x000000ff) << 16) + | ((d & 0x0000ff00) << 0) + | ((d & 0x00ff0000) >> 16) + | ((c & 0xf0000000) >> 4); + + c = c & 0x0fffffff; + + for (u32 i = 0; i < 16; i++) + { + if ((i < 2) || (i == 8) || (i == 15)) + { + c = ((c >> 1) | (c << 27)); + d = ((d >> 1) | (d << 27)); + } + else + { + c = ((c >> 2) | (c << 26)); + d = ((d >> 2) | (d << 26)); + } + + c = c & 0x0fffffff; + d = d & 0x0fffffff; + + const u32x c00 = (c >> 0) & 0x0000003f; + const u32x c06 = (c >> 6) & 0x00383003; + const u32x c07 = (c >> 7) & 0x0000003c; + const u32x c13 = (c >> 13) & 0x0000060f; + const u32x c20 = (c >> 20) & 0x00000001; + + u32x s = DES_BOX (((c00 >> 0) & 0xff), 0, s_skb) + | DES_BOX (((c06 >> 0) & 0xff) + |((c07 >> 0) & 0xff), 1, s_skb) + | DES_BOX (((c13 >> 0) & 0xff) + |((c06 >> 8) & 0xff), 2, s_skb) + | DES_BOX (((c20 >> 0) & 0xff) + |((c13 >> 8) & 0xff) + |((c06 >> 16) & 0xff), 3, s_skb); + + const u32x d00 = (d >> 0) & 0x00003c3f; + const u32x d07 = (d >> 7) & 0x00003f03; + const u32x d21 = (d >> 21) & 0x0000000f; + const u32x d22 = (d >> 22) & 0x00000030; + + u32x t = DES_BOX (((d00 >> 0) & 0xff), 4, s_skb) + | DES_BOX (((d07 >> 0) & 0xff) + |((d00 >> 8) & 0xff), 5, s_skb) + | DES_BOX (((d07 >> 8) & 0xff), 6, s_skb) + | DES_BOX (((d21 >> 0) & 0xff) + |((d22 >> 0) & 0xff), 7, s_skb); + + Kc[i] = ((t << 16) | (s & 0x0000ffff)); + Kd[i] = ((s >> 16) | (t & 0xffff0000)); + + Kc[i] = rotl32 (Kc[i], 2u); + Kd[i] = rotl32 (Kd[i], 2u); + } +} diff --git a/OpenCL/inc_cipher_kuznyechik.cl b/OpenCL/inc_cipher_kuznyechik.cl index 7bbbd119f..d532168c5 100644 --- a/OpenCL/inc_cipher_kuznyechik.cl +++ b/OpenCL/inc_cipher_kuznyechik.cl @@ -101,6 +101,7 @@ __constant const u32a k_sbox_inv[256] = x &= 0xff; \ } +DECLSPEC void kuznyechik_linear (u32 *w); DECLSPEC void kuznyechik_linear (u32 *w) { // used in k_xor macro @@ -137,6 +138,7 @@ DECLSPEC void kuznyechik_linear (u32 *w) } } +DECLSPEC void kuznyechik_linear_inv (u32 *w); DECLSPEC void kuznyechik_linear_inv (u32 *w) { // used in k_xor macro @@ -174,6 +176,7 @@ DECLSPEC void kuznyechik_linear_inv (u32 *w) } } +DECLSPEC void kuznyechik_set_key (u32 *ks, const u32 *ukey); DECLSPEC void kuznyechik_set_key (u32 *ks, const u32 *ukey) { u32 counter[4]; @@ -248,6 +251,7 @@ DECLSPEC void kuznyechik_set_key (u32 *ks, const u32 *ukey) } } +DECLSPEC void kuznyechik_encrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void kuznyechik_encrypt (const u32 *ks, const u32 *in, u32 *out) { out[0] = in[0]; @@ -273,6 +277,7 @@ DECLSPEC void kuznyechik_encrypt (const u32 *ks, const u32 *in, u32 *out) out[3] ^= ks[4 * 9 + 3]; } +DECLSPEC void kuznyechik_decrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void kuznyechik_decrypt (const u32 *ks, const u32 *in, u32 *out) { out[0] = in[0]; diff --git a/OpenCL/inc_cipher_serpent.cl b/OpenCL/inc_cipher_serpent.cl index 423a177dd..19aadd954 100644 --- a/OpenCL/inc_cipher_serpent.cl +++ b/OpenCL/inc_cipher_serpent.cl @@ -403,33 +403,149 @@ // 128 bit key +DECLSPEC void serpent128_set_key (u32 *ks, const u32 *ukey); DECLSPEC void serpent128_set_key (u32 *ks, const u32 *ukey) { - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 4; i++) - { - ks[i] = ukey[i]; - } - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 4; i < 8; i++) - { - ks[i] = 0; - } - - ks[4] = 1; - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 132; i++) - { - ks[i + 8] = rotl32_S (ks[i + 7] ^ ks[i + 5] ^ ks[i + 3] ^ ks[i + 0] ^ 0x9e3779b9 ^ i, 11); - } + ks[ 0] = ukey[0]; + ks[ 1] = ukey[1]; + ks[ 2] = ukey[2]; + ks[ 3] = ukey[3]; + ks[ 4] = 1; + ks[ 5] = 0; + ks[ 6] = 0; + ks[ 7] = 0; + ks[ 8] = rotl32_S ((ks[ 7] ^ ks[ 5] ^ ks[ 3] ^ ks[ 0] ^ 0x9e3779b9 ^ 0), 11); + ks[ 9] = rotl32_S ((ks[ 8] ^ ks[ 6] ^ ks[ 4] ^ ks[ 1] ^ 0x9e3779b9 ^ 1), 11); + ks[ 10] = rotl32_S ((ks[ 9] ^ ks[ 7] ^ ks[ 5] ^ ks[ 2] ^ 0x9e3779b9 ^ 2), 11); + ks[ 11] = rotl32_S ((ks[ 10] ^ ks[ 8] ^ ks[ 6] ^ ks[ 3] ^ 0x9e3779b9 ^ 3), 11); + ks[ 12] = rotl32_S ((ks[ 11] ^ ks[ 9] ^ ks[ 7] ^ ks[ 4] ^ 0x9e3779b9 ^ 4), 11); + ks[ 13] = rotl32_S ((ks[ 12] ^ ks[ 10] ^ ks[ 8] ^ ks[ 5] ^ 0x9e3779b9 ^ 5), 11); + ks[ 14] = rotl32_S ((ks[ 13] ^ ks[ 11] ^ ks[ 9] ^ ks[ 6] ^ 0x9e3779b9 ^ 6), 11); + ks[ 15] = rotl32_S ((ks[ 14] ^ ks[ 12] ^ ks[ 10] ^ ks[ 7] ^ 0x9e3779b9 ^ 7), 11); + ks[ 16] = rotl32_S ((ks[ 15] ^ ks[ 13] ^ ks[ 11] ^ ks[ 8] ^ 0x9e3779b9 ^ 8), 11); + ks[ 17] = rotl32_S ((ks[ 16] ^ ks[ 14] ^ ks[ 12] ^ ks[ 9] ^ 0x9e3779b9 ^ 9), 11); + ks[ 18] = rotl32_S ((ks[ 17] ^ ks[ 15] ^ ks[ 13] ^ ks[ 10] ^ 0x9e3779b9 ^ 10), 11); + ks[ 19] = rotl32_S ((ks[ 18] ^ ks[ 16] ^ ks[ 14] ^ ks[ 11] ^ 0x9e3779b9 ^ 11), 11); + ks[ 20] = rotl32_S ((ks[ 19] ^ ks[ 17] ^ ks[ 15] ^ ks[ 12] ^ 0x9e3779b9 ^ 12), 11); + ks[ 21] = rotl32_S ((ks[ 20] ^ ks[ 18] ^ ks[ 16] ^ ks[ 13] ^ 0x9e3779b9 ^ 13), 11); + ks[ 22] = rotl32_S ((ks[ 21] ^ ks[ 19] ^ ks[ 17] ^ ks[ 14] ^ 0x9e3779b9 ^ 14), 11); + ks[ 23] = rotl32_S ((ks[ 22] ^ ks[ 20] ^ ks[ 18] ^ ks[ 15] ^ 0x9e3779b9 ^ 15), 11); + ks[ 24] = rotl32_S ((ks[ 23] ^ ks[ 21] ^ ks[ 19] ^ ks[ 16] ^ 0x9e3779b9 ^ 16), 11); + ks[ 25] = rotl32_S ((ks[ 24] ^ ks[ 22] ^ ks[ 20] ^ ks[ 17] ^ 0x9e3779b9 ^ 17), 11); + ks[ 26] = rotl32_S ((ks[ 25] ^ ks[ 23] ^ ks[ 21] ^ ks[ 18] ^ 0x9e3779b9 ^ 18), 11); + ks[ 27] = rotl32_S ((ks[ 26] ^ ks[ 24] ^ ks[ 22] ^ ks[ 19] ^ 0x9e3779b9 ^ 19), 11); + ks[ 28] = rotl32_S ((ks[ 27] ^ ks[ 25] ^ ks[ 23] ^ ks[ 20] ^ 0x9e3779b9 ^ 20), 11); + ks[ 29] = rotl32_S ((ks[ 28] ^ ks[ 26] ^ ks[ 24] ^ ks[ 21] ^ 0x9e3779b9 ^ 21), 11); + ks[ 30] = rotl32_S ((ks[ 29] ^ ks[ 27] ^ ks[ 25] ^ ks[ 22] ^ 0x9e3779b9 ^ 22), 11); + ks[ 31] = rotl32_S ((ks[ 30] ^ ks[ 28] ^ ks[ 26] ^ ks[ 23] ^ 0x9e3779b9 ^ 23), 11); + ks[ 32] = rotl32_S ((ks[ 31] ^ ks[ 29] ^ ks[ 27] ^ ks[ 24] ^ 0x9e3779b9 ^ 24), 11); + ks[ 33] = rotl32_S ((ks[ 32] ^ ks[ 30] ^ ks[ 28] ^ ks[ 25] ^ 0x9e3779b9 ^ 25), 11); + ks[ 34] = rotl32_S ((ks[ 33] ^ ks[ 31] ^ ks[ 29] ^ ks[ 26] ^ 0x9e3779b9 ^ 26), 11); + ks[ 35] = rotl32_S ((ks[ 34] ^ ks[ 32] ^ ks[ 30] ^ ks[ 27] ^ 0x9e3779b9 ^ 27), 11); + ks[ 36] = rotl32_S ((ks[ 35] ^ ks[ 33] ^ ks[ 31] ^ ks[ 28] ^ 0x9e3779b9 ^ 28), 11); + ks[ 37] = rotl32_S ((ks[ 36] ^ ks[ 34] ^ ks[ 32] ^ ks[ 29] ^ 0x9e3779b9 ^ 29), 11); + ks[ 38] = rotl32_S ((ks[ 37] ^ ks[ 35] ^ ks[ 33] ^ ks[ 30] ^ 0x9e3779b9 ^ 30), 11); + ks[ 39] = rotl32_S ((ks[ 38] ^ ks[ 36] ^ ks[ 34] ^ ks[ 31] ^ 0x9e3779b9 ^ 31), 11); + ks[ 40] = rotl32_S ((ks[ 39] ^ ks[ 37] ^ ks[ 35] ^ ks[ 32] ^ 0x9e3779b9 ^ 32), 11); + ks[ 41] = rotl32_S ((ks[ 40] ^ ks[ 38] ^ ks[ 36] ^ ks[ 33] ^ 0x9e3779b9 ^ 33), 11); + ks[ 42] = rotl32_S ((ks[ 41] ^ ks[ 39] ^ ks[ 37] ^ ks[ 34] ^ 0x9e3779b9 ^ 34), 11); + ks[ 43] = rotl32_S ((ks[ 42] ^ ks[ 40] ^ ks[ 38] ^ ks[ 35] ^ 0x9e3779b9 ^ 35), 11); + ks[ 44] = rotl32_S ((ks[ 43] ^ ks[ 41] ^ ks[ 39] ^ ks[ 36] ^ 0x9e3779b9 ^ 36), 11); + ks[ 45] = rotl32_S ((ks[ 44] ^ ks[ 42] ^ ks[ 40] ^ ks[ 37] ^ 0x9e3779b9 ^ 37), 11); + ks[ 46] = rotl32_S ((ks[ 45] ^ ks[ 43] ^ ks[ 41] ^ ks[ 38] ^ 0x9e3779b9 ^ 38), 11); + ks[ 47] = rotl32_S ((ks[ 46] ^ ks[ 44] ^ ks[ 42] ^ ks[ 39] ^ 0x9e3779b9 ^ 39), 11); + ks[ 48] = rotl32_S ((ks[ 47] ^ ks[ 45] ^ ks[ 43] ^ ks[ 40] ^ 0x9e3779b9 ^ 40), 11); + ks[ 49] = rotl32_S ((ks[ 48] ^ ks[ 46] ^ ks[ 44] ^ ks[ 41] ^ 0x9e3779b9 ^ 41), 11); + ks[ 50] = rotl32_S ((ks[ 49] ^ ks[ 47] ^ ks[ 45] ^ ks[ 42] ^ 0x9e3779b9 ^ 42), 11); + ks[ 51] = rotl32_S ((ks[ 50] ^ ks[ 48] ^ ks[ 46] ^ ks[ 43] ^ 0x9e3779b9 ^ 43), 11); + ks[ 52] = rotl32_S ((ks[ 51] ^ ks[ 49] ^ ks[ 47] ^ ks[ 44] ^ 0x9e3779b9 ^ 44), 11); + ks[ 53] = rotl32_S ((ks[ 52] ^ ks[ 50] ^ ks[ 48] ^ ks[ 45] ^ 0x9e3779b9 ^ 45), 11); + ks[ 54] = rotl32_S ((ks[ 53] ^ ks[ 51] ^ ks[ 49] ^ ks[ 46] ^ 0x9e3779b9 ^ 46), 11); + ks[ 55] = rotl32_S ((ks[ 54] ^ ks[ 52] ^ ks[ 50] ^ ks[ 47] ^ 0x9e3779b9 ^ 47), 11); + ks[ 56] = rotl32_S ((ks[ 55] ^ ks[ 53] ^ ks[ 51] ^ ks[ 48] ^ 0x9e3779b9 ^ 48), 11); + ks[ 57] = rotl32_S ((ks[ 56] ^ ks[ 54] ^ ks[ 52] ^ ks[ 49] ^ 0x9e3779b9 ^ 49), 11); + ks[ 58] = rotl32_S ((ks[ 57] ^ ks[ 55] ^ ks[ 53] ^ ks[ 50] ^ 0x9e3779b9 ^ 50), 11); + ks[ 59] = rotl32_S ((ks[ 58] ^ ks[ 56] ^ ks[ 54] ^ ks[ 51] ^ 0x9e3779b9 ^ 51), 11); + ks[ 60] = rotl32_S ((ks[ 59] ^ ks[ 57] ^ ks[ 55] ^ ks[ 52] ^ 0x9e3779b9 ^ 52), 11); + ks[ 61] = rotl32_S ((ks[ 60] ^ ks[ 58] ^ ks[ 56] ^ ks[ 53] ^ 0x9e3779b9 ^ 53), 11); + ks[ 62] = rotl32_S ((ks[ 61] ^ ks[ 59] ^ ks[ 57] ^ ks[ 54] ^ 0x9e3779b9 ^ 54), 11); + ks[ 63] = rotl32_S ((ks[ 62] ^ ks[ 60] ^ ks[ 58] ^ ks[ 55] ^ 0x9e3779b9 ^ 55), 11); + ks[ 64] = rotl32_S ((ks[ 63] ^ ks[ 61] ^ ks[ 59] ^ ks[ 56] ^ 0x9e3779b9 ^ 56), 11); + ks[ 65] = rotl32_S ((ks[ 64] ^ ks[ 62] ^ ks[ 60] ^ ks[ 57] ^ 0x9e3779b9 ^ 57), 11); + ks[ 66] = rotl32_S ((ks[ 65] ^ ks[ 63] ^ ks[ 61] ^ ks[ 58] ^ 0x9e3779b9 ^ 58), 11); + ks[ 67] = rotl32_S ((ks[ 66] ^ ks[ 64] ^ ks[ 62] ^ ks[ 59] ^ 0x9e3779b9 ^ 59), 11); + ks[ 68] = rotl32_S ((ks[ 67] ^ ks[ 65] ^ ks[ 63] ^ ks[ 60] ^ 0x9e3779b9 ^ 60), 11); + ks[ 69] = rotl32_S ((ks[ 68] ^ ks[ 66] ^ ks[ 64] ^ ks[ 61] ^ 0x9e3779b9 ^ 61), 11); + ks[ 70] = rotl32_S ((ks[ 69] ^ ks[ 67] ^ ks[ 65] ^ ks[ 62] ^ 0x9e3779b9 ^ 62), 11); + ks[ 71] = rotl32_S ((ks[ 70] ^ ks[ 68] ^ ks[ 66] ^ ks[ 63] ^ 0x9e3779b9 ^ 63), 11); + ks[ 72] = rotl32_S ((ks[ 71] ^ ks[ 69] ^ ks[ 67] ^ ks[ 64] ^ 0x9e3779b9 ^ 64), 11); + ks[ 73] = rotl32_S ((ks[ 72] ^ ks[ 70] ^ ks[ 68] ^ ks[ 65] ^ 0x9e3779b9 ^ 65), 11); + ks[ 74] = rotl32_S ((ks[ 73] ^ ks[ 71] ^ ks[ 69] ^ ks[ 66] ^ 0x9e3779b9 ^ 66), 11); + ks[ 75] = rotl32_S ((ks[ 74] ^ ks[ 72] ^ ks[ 70] ^ ks[ 67] ^ 0x9e3779b9 ^ 67), 11); + ks[ 76] = rotl32_S ((ks[ 75] ^ ks[ 73] ^ ks[ 71] ^ ks[ 68] ^ 0x9e3779b9 ^ 68), 11); + ks[ 77] = rotl32_S ((ks[ 76] ^ ks[ 74] ^ ks[ 72] ^ ks[ 69] ^ 0x9e3779b9 ^ 69), 11); + ks[ 78] = rotl32_S ((ks[ 77] ^ ks[ 75] ^ ks[ 73] ^ ks[ 70] ^ 0x9e3779b9 ^ 70), 11); + ks[ 79] = rotl32_S ((ks[ 78] ^ ks[ 76] ^ ks[ 74] ^ ks[ 71] ^ 0x9e3779b9 ^ 71), 11); + ks[ 80] = rotl32_S ((ks[ 79] ^ ks[ 77] ^ ks[ 75] ^ ks[ 72] ^ 0x9e3779b9 ^ 72), 11); + ks[ 81] = rotl32_S ((ks[ 80] ^ ks[ 78] ^ ks[ 76] ^ ks[ 73] ^ 0x9e3779b9 ^ 73), 11); + ks[ 82] = rotl32_S ((ks[ 81] ^ ks[ 79] ^ ks[ 77] ^ ks[ 74] ^ 0x9e3779b9 ^ 74), 11); + ks[ 83] = rotl32_S ((ks[ 82] ^ ks[ 80] ^ ks[ 78] ^ ks[ 75] ^ 0x9e3779b9 ^ 75), 11); + ks[ 84] = rotl32_S ((ks[ 83] ^ ks[ 81] ^ ks[ 79] ^ ks[ 76] ^ 0x9e3779b9 ^ 76), 11); + ks[ 85] = rotl32_S ((ks[ 84] ^ ks[ 82] ^ ks[ 80] ^ ks[ 77] ^ 0x9e3779b9 ^ 77), 11); + ks[ 86] = rotl32_S ((ks[ 85] ^ ks[ 83] ^ ks[ 81] ^ ks[ 78] ^ 0x9e3779b9 ^ 78), 11); + ks[ 87] = rotl32_S ((ks[ 86] ^ ks[ 84] ^ ks[ 82] ^ ks[ 79] ^ 0x9e3779b9 ^ 79), 11); + ks[ 88] = rotl32_S ((ks[ 87] ^ ks[ 85] ^ ks[ 83] ^ ks[ 80] ^ 0x9e3779b9 ^ 80), 11); + ks[ 89] = rotl32_S ((ks[ 88] ^ ks[ 86] ^ ks[ 84] ^ ks[ 81] ^ 0x9e3779b9 ^ 81), 11); + ks[ 90] = rotl32_S ((ks[ 89] ^ ks[ 87] ^ ks[ 85] ^ ks[ 82] ^ 0x9e3779b9 ^ 82), 11); + ks[ 91] = rotl32_S ((ks[ 90] ^ ks[ 88] ^ ks[ 86] ^ ks[ 83] ^ 0x9e3779b9 ^ 83), 11); + ks[ 92] = rotl32_S ((ks[ 91] ^ ks[ 89] ^ ks[ 87] ^ ks[ 84] ^ 0x9e3779b9 ^ 84), 11); + ks[ 93] = rotl32_S ((ks[ 92] ^ ks[ 90] ^ ks[ 88] ^ ks[ 85] ^ 0x9e3779b9 ^ 85), 11); + ks[ 94] = rotl32_S ((ks[ 93] ^ ks[ 91] ^ ks[ 89] ^ ks[ 86] ^ 0x9e3779b9 ^ 86), 11); + ks[ 95] = rotl32_S ((ks[ 94] ^ ks[ 92] ^ ks[ 90] ^ ks[ 87] ^ 0x9e3779b9 ^ 87), 11); + ks[ 96] = rotl32_S ((ks[ 95] ^ ks[ 93] ^ ks[ 91] ^ ks[ 88] ^ 0x9e3779b9 ^ 88), 11); + ks[ 97] = rotl32_S ((ks[ 96] ^ ks[ 94] ^ ks[ 92] ^ ks[ 89] ^ 0x9e3779b9 ^ 89), 11); + ks[ 98] = rotl32_S ((ks[ 97] ^ ks[ 95] ^ ks[ 93] ^ ks[ 90] ^ 0x9e3779b9 ^ 90), 11); + ks[ 99] = rotl32_S ((ks[ 98] ^ ks[ 96] ^ ks[ 94] ^ ks[ 91] ^ 0x9e3779b9 ^ 91), 11); + ks[100] = rotl32_S ((ks[ 99] ^ ks[ 97] ^ ks[ 95] ^ ks[ 92] ^ 0x9e3779b9 ^ 92), 11); + ks[101] = rotl32_S ((ks[100] ^ ks[ 98] ^ ks[ 96] ^ ks[ 93] ^ 0x9e3779b9 ^ 93), 11); + ks[102] = rotl32_S ((ks[101] ^ ks[ 99] ^ ks[ 97] ^ ks[ 94] ^ 0x9e3779b9 ^ 94), 11); + ks[103] = rotl32_S ((ks[102] ^ ks[100] ^ ks[ 98] ^ ks[ 95] ^ 0x9e3779b9 ^ 95), 11); + ks[104] = rotl32_S ((ks[103] ^ ks[101] ^ ks[ 99] ^ ks[ 96] ^ 0x9e3779b9 ^ 96), 11); + ks[105] = rotl32_S ((ks[104] ^ ks[102] ^ ks[100] ^ ks[ 97] ^ 0x9e3779b9 ^ 97), 11); + ks[106] = rotl32_S ((ks[105] ^ ks[103] ^ ks[101] ^ ks[ 98] ^ 0x9e3779b9 ^ 98), 11); + ks[107] = rotl32_S ((ks[106] ^ ks[104] ^ ks[102] ^ ks[ 99] ^ 0x9e3779b9 ^ 99), 11); + ks[108] = rotl32_S ((ks[107] ^ ks[105] ^ ks[103] ^ ks[100] ^ 0x9e3779b9 ^ 100), 11); + ks[109] = rotl32_S ((ks[108] ^ ks[106] ^ ks[104] ^ ks[101] ^ 0x9e3779b9 ^ 101), 11); + ks[110] = rotl32_S ((ks[109] ^ ks[107] ^ ks[105] ^ ks[102] ^ 0x9e3779b9 ^ 102), 11); + ks[111] = rotl32_S ((ks[110] ^ ks[108] ^ ks[106] ^ ks[103] ^ 0x9e3779b9 ^ 103), 11); + ks[112] = rotl32_S ((ks[111] ^ ks[109] ^ ks[107] ^ ks[104] ^ 0x9e3779b9 ^ 104), 11); + ks[113] = rotl32_S ((ks[112] ^ ks[110] ^ ks[108] ^ ks[105] ^ 0x9e3779b9 ^ 105), 11); + ks[114] = rotl32_S ((ks[113] ^ ks[111] ^ ks[109] ^ ks[106] ^ 0x9e3779b9 ^ 106), 11); + ks[115] = rotl32_S ((ks[114] ^ ks[112] ^ ks[110] ^ ks[107] ^ 0x9e3779b9 ^ 107), 11); + ks[116] = rotl32_S ((ks[115] ^ ks[113] ^ ks[111] ^ ks[108] ^ 0x9e3779b9 ^ 108), 11); + ks[117] = rotl32_S ((ks[116] ^ ks[114] ^ ks[112] ^ ks[109] ^ 0x9e3779b9 ^ 109), 11); + ks[118] = rotl32_S ((ks[117] ^ ks[115] ^ ks[113] ^ ks[110] ^ 0x9e3779b9 ^ 110), 11); + ks[119] = rotl32_S ((ks[118] ^ ks[116] ^ ks[114] ^ ks[111] ^ 0x9e3779b9 ^ 111), 11); + ks[120] = rotl32_S ((ks[119] ^ ks[117] ^ ks[115] ^ ks[112] ^ 0x9e3779b9 ^ 112), 11); + ks[121] = rotl32_S ((ks[120] ^ ks[118] ^ ks[116] ^ ks[113] ^ 0x9e3779b9 ^ 113), 11); + ks[122] = rotl32_S ((ks[121] ^ ks[119] ^ ks[117] ^ ks[114] ^ 0x9e3779b9 ^ 114), 11); + ks[123] = rotl32_S ((ks[122] ^ ks[120] ^ ks[118] ^ ks[115] ^ 0x9e3779b9 ^ 115), 11); + ks[124] = rotl32_S ((ks[123] ^ ks[121] ^ ks[119] ^ ks[116] ^ 0x9e3779b9 ^ 116), 11); + ks[125] = rotl32_S ((ks[124] ^ ks[122] ^ ks[120] ^ ks[117] ^ 0x9e3779b9 ^ 117), 11); + ks[126] = rotl32_S ((ks[125] ^ ks[123] ^ ks[121] ^ ks[118] ^ 0x9e3779b9 ^ 118), 11); + ks[127] = rotl32_S ((ks[126] ^ ks[124] ^ ks[122] ^ ks[119] ^ 0x9e3779b9 ^ 119), 11); + ks[128] = rotl32_S ((ks[127] ^ ks[125] ^ ks[123] ^ ks[120] ^ 0x9e3779b9 ^ 120), 11); + ks[129] = rotl32_S ((ks[128] ^ ks[126] ^ ks[124] ^ ks[121] ^ 0x9e3779b9 ^ 121), 11); + ks[130] = rotl32_S ((ks[129] ^ ks[127] ^ ks[125] ^ ks[122] ^ 0x9e3779b9 ^ 122), 11); + ks[131] = rotl32_S ((ks[130] ^ ks[128] ^ ks[126] ^ ks[123] ^ 0x9e3779b9 ^ 123), 11); + ks[132] = rotl32_S ((ks[131] ^ ks[129] ^ ks[127] ^ ks[124] ^ 0x9e3779b9 ^ 124), 11); + ks[133] = rotl32_S ((ks[132] ^ ks[130] ^ ks[128] ^ ks[125] ^ 0x9e3779b9 ^ 125), 11); + ks[134] = rotl32_S ((ks[133] ^ ks[131] ^ ks[129] ^ ks[126] ^ 0x9e3779b9 ^ 126), 11); + ks[135] = rotl32_S ((ks[134] ^ ks[132] ^ ks[130] ^ ks[127] ^ 0x9e3779b9 ^ 127), 11); + ks[136] = rotl32_S ((ks[135] ^ ks[133] ^ ks[131] ^ ks[128] ^ 0x9e3779b9 ^ 128), 11); + ks[137] = rotl32_S ((ks[136] ^ ks[134] ^ ks[132] ^ ks[129] ^ 0x9e3779b9 ^ 129), 11); + ks[138] = rotl32_S ((ks[137] ^ ks[135] ^ ks[133] ^ ks[130] ^ 0x9e3779b9 ^ 130), 11); + ks[139] = rotl32_S ((ks[138] ^ ks[136] ^ ks[134] ^ ks[131] ^ 0x9e3779b9 ^ 131), 11); u32 a,b,c,d,e,f,g,h; u32 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; @@ -469,6 +585,7 @@ DECLSPEC void serpent128_set_key (u32 *ks, const u32 *ukey) k_set(32,a,b,c,d); sb3(a,b,c,d,e,f,g,h); k_get(32,e,f,g,h); } +DECLSPEC void serpent128_encrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void serpent128_encrypt (const u32 *ks, const u32 *in, u32 *out) { u32 a,b,c,d,e,f,g,h; @@ -519,6 +636,7 @@ DECLSPEC void serpent128_encrypt (const u32 *ks, const u32 *in, u32 *out) out[3] = d; } +DECLSPEC void serpent128_decrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void serpent128_decrypt (const u32 *ks, const u32 *in, u32 *out) { u32 a,b,c,d,e,f,g,h; @@ -571,23 +689,149 @@ DECLSPEC void serpent128_decrypt (const u32 *ks, const u32 *in, u32 *out) // 256 bit key +DECLSPEC void serpent256_set_key (u32 *ks, const u32 *ukey); DECLSPEC void serpent256_set_key (u32 *ks, const u32 *ukey) { - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 8; i++) - { - ks[i] = ukey[i]; - } - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 132; i++) - { - ks[i + 8] = rotl32_S (ks[i + 7] ^ ks[i + 5] ^ ks[i + 3] ^ ks[i + 0] ^ 0x9e3779b9 ^ i, 11); - } + ks[ 0] = ukey[0]; + ks[ 1] = ukey[1]; + ks[ 2] = ukey[2]; + ks[ 3] = ukey[3]; + ks[ 4] = ukey[4]; + ks[ 5] = ukey[5]; + ks[ 6] = ukey[6]; + ks[ 7] = ukey[7]; + ks[ 8] = rotl32_S ((ks[ 7] ^ ks[ 5] ^ ks[ 3] ^ ks[ 0] ^ 0x9e3779b9 ^ 0), 11); + ks[ 9] = rotl32_S ((ks[ 8] ^ ks[ 6] ^ ks[ 4] ^ ks[ 1] ^ 0x9e3779b9 ^ 1), 11); + ks[ 10] = rotl32_S ((ks[ 9] ^ ks[ 7] ^ ks[ 5] ^ ks[ 2] ^ 0x9e3779b9 ^ 2), 11); + ks[ 11] = rotl32_S ((ks[ 10] ^ ks[ 8] ^ ks[ 6] ^ ks[ 3] ^ 0x9e3779b9 ^ 3), 11); + ks[ 12] = rotl32_S ((ks[ 11] ^ ks[ 9] ^ ks[ 7] ^ ks[ 4] ^ 0x9e3779b9 ^ 4), 11); + ks[ 13] = rotl32_S ((ks[ 12] ^ ks[ 10] ^ ks[ 8] ^ ks[ 5] ^ 0x9e3779b9 ^ 5), 11); + ks[ 14] = rotl32_S ((ks[ 13] ^ ks[ 11] ^ ks[ 9] ^ ks[ 6] ^ 0x9e3779b9 ^ 6), 11); + ks[ 15] = rotl32_S ((ks[ 14] ^ ks[ 12] ^ ks[ 10] ^ ks[ 7] ^ 0x9e3779b9 ^ 7), 11); + ks[ 16] = rotl32_S ((ks[ 15] ^ ks[ 13] ^ ks[ 11] ^ ks[ 8] ^ 0x9e3779b9 ^ 8), 11); + ks[ 17] = rotl32_S ((ks[ 16] ^ ks[ 14] ^ ks[ 12] ^ ks[ 9] ^ 0x9e3779b9 ^ 9), 11); + ks[ 18] = rotl32_S ((ks[ 17] ^ ks[ 15] ^ ks[ 13] ^ ks[ 10] ^ 0x9e3779b9 ^ 10), 11); + ks[ 19] = rotl32_S ((ks[ 18] ^ ks[ 16] ^ ks[ 14] ^ ks[ 11] ^ 0x9e3779b9 ^ 11), 11); + ks[ 20] = rotl32_S ((ks[ 19] ^ ks[ 17] ^ ks[ 15] ^ ks[ 12] ^ 0x9e3779b9 ^ 12), 11); + ks[ 21] = rotl32_S ((ks[ 20] ^ ks[ 18] ^ ks[ 16] ^ ks[ 13] ^ 0x9e3779b9 ^ 13), 11); + ks[ 22] = rotl32_S ((ks[ 21] ^ ks[ 19] ^ ks[ 17] ^ ks[ 14] ^ 0x9e3779b9 ^ 14), 11); + ks[ 23] = rotl32_S ((ks[ 22] ^ ks[ 20] ^ ks[ 18] ^ ks[ 15] ^ 0x9e3779b9 ^ 15), 11); + ks[ 24] = rotl32_S ((ks[ 23] ^ ks[ 21] ^ ks[ 19] ^ ks[ 16] ^ 0x9e3779b9 ^ 16), 11); + ks[ 25] = rotl32_S ((ks[ 24] ^ ks[ 22] ^ ks[ 20] ^ ks[ 17] ^ 0x9e3779b9 ^ 17), 11); + ks[ 26] = rotl32_S ((ks[ 25] ^ ks[ 23] ^ ks[ 21] ^ ks[ 18] ^ 0x9e3779b9 ^ 18), 11); + ks[ 27] = rotl32_S ((ks[ 26] ^ ks[ 24] ^ ks[ 22] ^ ks[ 19] ^ 0x9e3779b9 ^ 19), 11); + ks[ 28] = rotl32_S ((ks[ 27] ^ ks[ 25] ^ ks[ 23] ^ ks[ 20] ^ 0x9e3779b9 ^ 20), 11); + ks[ 29] = rotl32_S ((ks[ 28] ^ ks[ 26] ^ ks[ 24] ^ ks[ 21] ^ 0x9e3779b9 ^ 21), 11); + ks[ 30] = rotl32_S ((ks[ 29] ^ ks[ 27] ^ ks[ 25] ^ ks[ 22] ^ 0x9e3779b9 ^ 22), 11); + ks[ 31] = rotl32_S ((ks[ 30] ^ ks[ 28] ^ ks[ 26] ^ ks[ 23] ^ 0x9e3779b9 ^ 23), 11); + ks[ 32] = rotl32_S ((ks[ 31] ^ ks[ 29] ^ ks[ 27] ^ ks[ 24] ^ 0x9e3779b9 ^ 24), 11); + ks[ 33] = rotl32_S ((ks[ 32] ^ ks[ 30] ^ ks[ 28] ^ ks[ 25] ^ 0x9e3779b9 ^ 25), 11); + ks[ 34] = rotl32_S ((ks[ 33] ^ ks[ 31] ^ ks[ 29] ^ ks[ 26] ^ 0x9e3779b9 ^ 26), 11); + ks[ 35] = rotl32_S ((ks[ 34] ^ ks[ 32] ^ ks[ 30] ^ ks[ 27] ^ 0x9e3779b9 ^ 27), 11); + ks[ 36] = rotl32_S ((ks[ 35] ^ ks[ 33] ^ ks[ 31] ^ ks[ 28] ^ 0x9e3779b9 ^ 28), 11); + ks[ 37] = rotl32_S ((ks[ 36] ^ ks[ 34] ^ ks[ 32] ^ ks[ 29] ^ 0x9e3779b9 ^ 29), 11); + ks[ 38] = rotl32_S ((ks[ 37] ^ ks[ 35] ^ ks[ 33] ^ ks[ 30] ^ 0x9e3779b9 ^ 30), 11); + ks[ 39] = rotl32_S ((ks[ 38] ^ ks[ 36] ^ ks[ 34] ^ ks[ 31] ^ 0x9e3779b9 ^ 31), 11); + ks[ 40] = rotl32_S ((ks[ 39] ^ ks[ 37] ^ ks[ 35] ^ ks[ 32] ^ 0x9e3779b9 ^ 32), 11); + ks[ 41] = rotl32_S ((ks[ 40] ^ ks[ 38] ^ ks[ 36] ^ ks[ 33] ^ 0x9e3779b9 ^ 33), 11); + ks[ 42] = rotl32_S ((ks[ 41] ^ ks[ 39] ^ ks[ 37] ^ ks[ 34] ^ 0x9e3779b9 ^ 34), 11); + ks[ 43] = rotl32_S ((ks[ 42] ^ ks[ 40] ^ ks[ 38] ^ ks[ 35] ^ 0x9e3779b9 ^ 35), 11); + ks[ 44] = rotl32_S ((ks[ 43] ^ ks[ 41] ^ ks[ 39] ^ ks[ 36] ^ 0x9e3779b9 ^ 36), 11); + ks[ 45] = rotl32_S ((ks[ 44] ^ ks[ 42] ^ ks[ 40] ^ ks[ 37] ^ 0x9e3779b9 ^ 37), 11); + ks[ 46] = rotl32_S ((ks[ 45] ^ ks[ 43] ^ ks[ 41] ^ ks[ 38] ^ 0x9e3779b9 ^ 38), 11); + ks[ 47] = rotl32_S ((ks[ 46] ^ ks[ 44] ^ ks[ 42] ^ ks[ 39] ^ 0x9e3779b9 ^ 39), 11); + ks[ 48] = rotl32_S ((ks[ 47] ^ ks[ 45] ^ ks[ 43] ^ ks[ 40] ^ 0x9e3779b9 ^ 40), 11); + ks[ 49] = rotl32_S ((ks[ 48] ^ ks[ 46] ^ ks[ 44] ^ ks[ 41] ^ 0x9e3779b9 ^ 41), 11); + ks[ 50] = rotl32_S ((ks[ 49] ^ ks[ 47] ^ ks[ 45] ^ ks[ 42] ^ 0x9e3779b9 ^ 42), 11); + ks[ 51] = rotl32_S ((ks[ 50] ^ ks[ 48] ^ ks[ 46] ^ ks[ 43] ^ 0x9e3779b9 ^ 43), 11); + ks[ 52] = rotl32_S ((ks[ 51] ^ ks[ 49] ^ ks[ 47] ^ ks[ 44] ^ 0x9e3779b9 ^ 44), 11); + ks[ 53] = rotl32_S ((ks[ 52] ^ ks[ 50] ^ ks[ 48] ^ ks[ 45] ^ 0x9e3779b9 ^ 45), 11); + ks[ 54] = rotl32_S ((ks[ 53] ^ ks[ 51] ^ ks[ 49] ^ ks[ 46] ^ 0x9e3779b9 ^ 46), 11); + ks[ 55] = rotl32_S ((ks[ 54] ^ ks[ 52] ^ ks[ 50] ^ ks[ 47] ^ 0x9e3779b9 ^ 47), 11); + ks[ 56] = rotl32_S ((ks[ 55] ^ ks[ 53] ^ ks[ 51] ^ ks[ 48] ^ 0x9e3779b9 ^ 48), 11); + ks[ 57] = rotl32_S ((ks[ 56] ^ ks[ 54] ^ ks[ 52] ^ ks[ 49] ^ 0x9e3779b9 ^ 49), 11); + ks[ 58] = rotl32_S ((ks[ 57] ^ ks[ 55] ^ ks[ 53] ^ ks[ 50] ^ 0x9e3779b9 ^ 50), 11); + ks[ 59] = rotl32_S ((ks[ 58] ^ ks[ 56] ^ ks[ 54] ^ ks[ 51] ^ 0x9e3779b9 ^ 51), 11); + ks[ 60] = rotl32_S ((ks[ 59] ^ ks[ 57] ^ ks[ 55] ^ ks[ 52] ^ 0x9e3779b9 ^ 52), 11); + ks[ 61] = rotl32_S ((ks[ 60] ^ ks[ 58] ^ ks[ 56] ^ ks[ 53] ^ 0x9e3779b9 ^ 53), 11); + ks[ 62] = rotl32_S ((ks[ 61] ^ ks[ 59] ^ ks[ 57] ^ ks[ 54] ^ 0x9e3779b9 ^ 54), 11); + ks[ 63] = rotl32_S ((ks[ 62] ^ ks[ 60] ^ ks[ 58] ^ ks[ 55] ^ 0x9e3779b9 ^ 55), 11); + ks[ 64] = rotl32_S ((ks[ 63] ^ ks[ 61] ^ ks[ 59] ^ ks[ 56] ^ 0x9e3779b9 ^ 56), 11); + ks[ 65] = rotl32_S ((ks[ 64] ^ ks[ 62] ^ ks[ 60] ^ ks[ 57] ^ 0x9e3779b9 ^ 57), 11); + ks[ 66] = rotl32_S ((ks[ 65] ^ ks[ 63] ^ ks[ 61] ^ ks[ 58] ^ 0x9e3779b9 ^ 58), 11); + ks[ 67] = rotl32_S ((ks[ 66] ^ ks[ 64] ^ ks[ 62] ^ ks[ 59] ^ 0x9e3779b9 ^ 59), 11); + ks[ 68] = rotl32_S ((ks[ 67] ^ ks[ 65] ^ ks[ 63] ^ ks[ 60] ^ 0x9e3779b9 ^ 60), 11); + ks[ 69] = rotl32_S ((ks[ 68] ^ ks[ 66] ^ ks[ 64] ^ ks[ 61] ^ 0x9e3779b9 ^ 61), 11); + ks[ 70] = rotl32_S ((ks[ 69] ^ ks[ 67] ^ ks[ 65] ^ ks[ 62] ^ 0x9e3779b9 ^ 62), 11); + ks[ 71] = rotl32_S ((ks[ 70] ^ ks[ 68] ^ ks[ 66] ^ ks[ 63] ^ 0x9e3779b9 ^ 63), 11); + ks[ 72] = rotl32_S ((ks[ 71] ^ ks[ 69] ^ ks[ 67] ^ ks[ 64] ^ 0x9e3779b9 ^ 64), 11); + ks[ 73] = rotl32_S ((ks[ 72] ^ ks[ 70] ^ ks[ 68] ^ ks[ 65] ^ 0x9e3779b9 ^ 65), 11); + ks[ 74] = rotl32_S ((ks[ 73] ^ ks[ 71] ^ ks[ 69] ^ ks[ 66] ^ 0x9e3779b9 ^ 66), 11); + ks[ 75] = rotl32_S ((ks[ 74] ^ ks[ 72] ^ ks[ 70] ^ ks[ 67] ^ 0x9e3779b9 ^ 67), 11); + ks[ 76] = rotl32_S ((ks[ 75] ^ ks[ 73] ^ ks[ 71] ^ ks[ 68] ^ 0x9e3779b9 ^ 68), 11); + ks[ 77] = rotl32_S ((ks[ 76] ^ ks[ 74] ^ ks[ 72] ^ ks[ 69] ^ 0x9e3779b9 ^ 69), 11); + ks[ 78] = rotl32_S ((ks[ 77] ^ ks[ 75] ^ ks[ 73] ^ ks[ 70] ^ 0x9e3779b9 ^ 70), 11); + ks[ 79] = rotl32_S ((ks[ 78] ^ ks[ 76] ^ ks[ 74] ^ ks[ 71] ^ 0x9e3779b9 ^ 71), 11); + ks[ 80] = rotl32_S ((ks[ 79] ^ ks[ 77] ^ ks[ 75] ^ ks[ 72] ^ 0x9e3779b9 ^ 72), 11); + ks[ 81] = rotl32_S ((ks[ 80] ^ ks[ 78] ^ ks[ 76] ^ ks[ 73] ^ 0x9e3779b9 ^ 73), 11); + ks[ 82] = rotl32_S ((ks[ 81] ^ ks[ 79] ^ ks[ 77] ^ ks[ 74] ^ 0x9e3779b9 ^ 74), 11); + ks[ 83] = rotl32_S ((ks[ 82] ^ ks[ 80] ^ ks[ 78] ^ ks[ 75] ^ 0x9e3779b9 ^ 75), 11); + ks[ 84] = rotl32_S ((ks[ 83] ^ ks[ 81] ^ ks[ 79] ^ ks[ 76] ^ 0x9e3779b9 ^ 76), 11); + ks[ 85] = rotl32_S ((ks[ 84] ^ ks[ 82] ^ ks[ 80] ^ ks[ 77] ^ 0x9e3779b9 ^ 77), 11); + ks[ 86] = rotl32_S ((ks[ 85] ^ ks[ 83] ^ ks[ 81] ^ ks[ 78] ^ 0x9e3779b9 ^ 78), 11); + ks[ 87] = rotl32_S ((ks[ 86] ^ ks[ 84] ^ ks[ 82] ^ ks[ 79] ^ 0x9e3779b9 ^ 79), 11); + ks[ 88] = rotl32_S ((ks[ 87] ^ ks[ 85] ^ ks[ 83] ^ ks[ 80] ^ 0x9e3779b9 ^ 80), 11); + ks[ 89] = rotl32_S ((ks[ 88] ^ ks[ 86] ^ ks[ 84] ^ ks[ 81] ^ 0x9e3779b9 ^ 81), 11); + ks[ 90] = rotl32_S ((ks[ 89] ^ ks[ 87] ^ ks[ 85] ^ ks[ 82] ^ 0x9e3779b9 ^ 82), 11); + ks[ 91] = rotl32_S ((ks[ 90] ^ ks[ 88] ^ ks[ 86] ^ ks[ 83] ^ 0x9e3779b9 ^ 83), 11); + ks[ 92] = rotl32_S ((ks[ 91] ^ ks[ 89] ^ ks[ 87] ^ ks[ 84] ^ 0x9e3779b9 ^ 84), 11); + ks[ 93] = rotl32_S ((ks[ 92] ^ ks[ 90] ^ ks[ 88] ^ ks[ 85] ^ 0x9e3779b9 ^ 85), 11); + ks[ 94] = rotl32_S ((ks[ 93] ^ ks[ 91] ^ ks[ 89] ^ ks[ 86] ^ 0x9e3779b9 ^ 86), 11); + ks[ 95] = rotl32_S ((ks[ 94] ^ ks[ 92] ^ ks[ 90] ^ ks[ 87] ^ 0x9e3779b9 ^ 87), 11); + ks[ 96] = rotl32_S ((ks[ 95] ^ ks[ 93] ^ ks[ 91] ^ ks[ 88] ^ 0x9e3779b9 ^ 88), 11); + ks[ 97] = rotl32_S ((ks[ 96] ^ ks[ 94] ^ ks[ 92] ^ ks[ 89] ^ 0x9e3779b9 ^ 89), 11); + ks[ 98] = rotl32_S ((ks[ 97] ^ ks[ 95] ^ ks[ 93] ^ ks[ 90] ^ 0x9e3779b9 ^ 90), 11); + ks[ 99] = rotl32_S ((ks[ 98] ^ ks[ 96] ^ ks[ 94] ^ ks[ 91] ^ 0x9e3779b9 ^ 91), 11); + ks[100] = rotl32_S ((ks[ 99] ^ ks[ 97] ^ ks[ 95] ^ ks[ 92] ^ 0x9e3779b9 ^ 92), 11); + ks[101] = rotl32_S ((ks[100] ^ ks[ 98] ^ ks[ 96] ^ ks[ 93] ^ 0x9e3779b9 ^ 93), 11); + ks[102] = rotl32_S ((ks[101] ^ ks[ 99] ^ ks[ 97] ^ ks[ 94] ^ 0x9e3779b9 ^ 94), 11); + ks[103] = rotl32_S ((ks[102] ^ ks[100] ^ ks[ 98] ^ ks[ 95] ^ 0x9e3779b9 ^ 95), 11); + ks[104] = rotl32_S ((ks[103] ^ ks[101] ^ ks[ 99] ^ ks[ 96] ^ 0x9e3779b9 ^ 96), 11); + ks[105] = rotl32_S ((ks[104] ^ ks[102] ^ ks[100] ^ ks[ 97] ^ 0x9e3779b9 ^ 97), 11); + ks[106] = rotl32_S ((ks[105] ^ ks[103] ^ ks[101] ^ ks[ 98] ^ 0x9e3779b9 ^ 98), 11); + ks[107] = rotl32_S ((ks[106] ^ ks[104] ^ ks[102] ^ ks[ 99] ^ 0x9e3779b9 ^ 99), 11); + ks[108] = rotl32_S ((ks[107] ^ ks[105] ^ ks[103] ^ ks[100] ^ 0x9e3779b9 ^ 100), 11); + ks[109] = rotl32_S ((ks[108] ^ ks[106] ^ ks[104] ^ ks[101] ^ 0x9e3779b9 ^ 101), 11); + ks[110] = rotl32_S ((ks[109] ^ ks[107] ^ ks[105] ^ ks[102] ^ 0x9e3779b9 ^ 102), 11); + ks[111] = rotl32_S ((ks[110] ^ ks[108] ^ ks[106] ^ ks[103] ^ 0x9e3779b9 ^ 103), 11); + ks[112] = rotl32_S ((ks[111] ^ ks[109] ^ ks[107] ^ ks[104] ^ 0x9e3779b9 ^ 104), 11); + ks[113] = rotl32_S ((ks[112] ^ ks[110] ^ ks[108] ^ ks[105] ^ 0x9e3779b9 ^ 105), 11); + ks[114] = rotl32_S ((ks[113] ^ ks[111] ^ ks[109] ^ ks[106] ^ 0x9e3779b9 ^ 106), 11); + ks[115] = rotl32_S ((ks[114] ^ ks[112] ^ ks[110] ^ ks[107] ^ 0x9e3779b9 ^ 107), 11); + ks[116] = rotl32_S ((ks[115] ^ ks[113] ^ ks[111] ^ ks[108] ^ 0x9e3779b9 ^ 108), 11); + ks[117] = rotl32_S ((ks[116] ^ ks[114] ^ ks[112] ^ ks[109] ^ 0x9e3779b9 ^ 109), 11); + ks[118] = rotl32_S ((ks[117] ^ ks[115] ^ ks[113] ^ ks[110] ^ 0x9e3779b9 ^ 110), 11); + ks[119] = rotl32_S ((ks[118] ^ ks[116] ^ ks[114] ^ ks[111] ^ 0x9e3779b9 ^ 111), 11); + ks[120] = rotl32_S ((ks[119] ^ ks[117] ^ ks[115] ^ ks[112] ^ 0x9e3779b9 ^ 112), 11); + ks[121] = rotl32_S ((ks[120] ^ ks[118] ^ ks[116] ^ ks[113] ^ 0x9e3779b9 ^ 113), 11); + ks[122] = rotl32_S ((ks[121] ^ ks[119] ^ ks[117] ^ ks[114] ^ 0x9e3779b9 ^ 114), 11); + ks[123] = rotl32_S ((ks[122] ^ ks[120] ^ ks[118] ^ ks[115] ^ 0x9e3779b9 ^ 115), 11); + ks[124] = rotl32_S ((ks[123] ^ ks[121] ^ ks[119] ^ ks[116] ^ 0x9e3779b9 ^ 116), 11); + ks[125] = rotl32_S ((ks[124] ^ ks[122] ^ ks[120] ^ ks[117] ^ 0x9e3779b9 ^ 117), 11); + ks[126] = rotl32_S ((ks[125] ^ ks[123] ^ ks[121] ^ ks[118] ^ 0x9e3779b9 ^ 118), 11); + ks[127] = rotl32_S ((ks[126] ^ ks[124] ^ ks[122] ^ ks[119] ^ 0x9e3779b9 ^ 119), 11); + ks[128] = rotl32_S ((ks[127] ^ ks[125] ^ ks[123] ^ ks[120] ^ 0x9e3779b9 ^ 120), 11); + ks[129] = rotl32_S ((ks[128] ^ ks[126] ^ ks[124] ^ ks[121] ^ 0x9e3779b9 ^ 121), 11); + ks[130] = rotl32_S ((ks[129] ^ ks[127] ^ ks[125] ^ ks[122] ^ 0x9e3779b9 ^ 122), 11); + ks[131] = rotl32_S ((ks[130] ^ ks[128] ^ ks[126] ^ ks[123] ^ 0x9e3779b9 ^ 123), 11); + ks[132] = rotl32_S ((ks[131] ^ ks[129] ^ ks[127] ^ ks[124] ^ 0x9e3779b9 ^ 124), 11); + ks[133] = rotl32_S ((ks[132] ^ ks[130] ^ ks[128] ^ ks[125] ^ 0x9e3779b9 ^ 125), 11); + ks[134] = rotl32_S ((ks[133] ^ ks[131] ^ ks[129] ^ ks[126] ^ 0x9e3779b9 ^ 126), 11); + ks[135] = rotl32_S ((ks[134] ^ ks[132] ^ ks[130] ^ ks[127] ^ 0x9e3779b9 ^ 127), 11); + ks[136] = rotl32_S ((ks[135] ^ ks[133] ^ ks[131] ^ ks[128] ^ 0x9e3779b9 ^ 128), 11); + ks[137] = rotl32_S ((ks[136] ^ ks[134] ^ ks[132] ^ ks[129] ^ 0x9e3779b9 ^ 129), 11); + ks[138] = rotl32_S ((ks[137] ^ ks[135] ^ ks[133] ^ ks[130] ^ 0x9e3779b9 ^ 130), 11); + ks[139] = rotl32_S ((ks[138] ^ ks[136] ^ ks[134] ^ ks[131] ^ 0x9e3779b9 ^ 131), 11); u32 a,b,c,d,e,f,g,h; u32 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; @@ -627,6 +871,7 @@ DECLSPEC void serpent256_set_key (u32 *ks, const u32 *ukey) k_set(32,a,b,c,d); sb3(a,b,c,d,e,f,g,h); k_get(32,e,f,g,h); } +DECLSPEC void serpent256_encrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void serpent256_encrypt (const u32 *ks, const u32 *in, u32 *out) { u32 a,b,c,d,e,f,g,h; @@ -677,6 +922,7 @@ DECLSPEC void serpent256_encrypt (const u32 *ks, const u32 *in, u32 *out) out[3] = d; } +DECLSPEC void serpent256_decrypt (const u32 *ks, const u32 *in, u32 *out); DECLSPEC void serpent256_decrypt (const u32 *ks, const u32 *in, u32 *out) { u32 a,b,c,d,e,f,g,h; diff --git a/OpenCL/inc_cipher_twofish.cl b/OpenCL/inc_cipher_twofish.cl index bda6e49fd..f5ca58b54 100644 --- a/OpenCL/inc_cipher_twofish.cl +++ b/OpenCL/inc_cipher_twofish.cl @@ -266,31 +266,35 @@ __constant u32a m_tab[4][256] = #define q42(x,k) q (1, q (0, q (0, q (0, x) ^ extract_byte (k[3], 2)) ^ extract_byte (k[2], 2)) ^ extract_byte (k[1], 2)) ^ extract_byte (k[0], 2) #define q43(x,k) q (1, q (1, q (0, q (1, x) ^ extract_byte (k[3], 3)) ^ extract_byte (k[2], 3)) ^ extract_byte (k[1], 3)) ^ extract_byte (k[0], 3) +DECLSPEC u32 mds_rem (u32 p0, u32 p1); DECLSPEC u32 mds_rem (u32 p0, u32 p1) { #define G_MOD 0x14d - for (int i = 0; i < 8; i++) - { - u32 t = p1 >> 24; - - p1 = (p1 << 8) | (p0 >> 24); - - p0 <<= 8; - - u32 u = (t << 1); - - if (t & 0x80) u ^= G_MOD; - - p1 ^= t ^ (u << 16); - - u ^= (t >> 1); - - if (t & 0x01) u ^= G_MOD >> 1; - - p1 ^= (u << 24) | (u << 8); + #define MDS_REM_ROUND() \ + { \ + u32 t = p1 >> 24; \ + p1 = (p1 << 8) | (p0 >> 24); \ + p0 <<= 8; \ + u32 u = (t << 1); \ + if (t & 0x80) u ^= G_MOD; \ + p1 ^= t ^ (u << 16); \ + u ^= (t >> 1); \ + if (t & 0x01) u ^= G_MOD >> 1; \ + p1 ^= (u << 24) | (u << 8); \ } + MDS_REM_ROUND(); + MDS_REM_ROUND(); + MDS_REM_ROUND(); + MDS_REM_ROUND(); + MDS_REM_ROUND(); + MDS_REM_ROUND(); + MDS_REM_ROUND(); + MDS_REM_ROUND(); + + #undef MDS_REM_ROUND + return p1; } @@ -332,6 +336,7 @@ DECLSPEC u32 mds_rem (u32 p0, u32 p1) data[1] = rotr32_S (data[1] ^ (t2 + 2 * t3 + lk[4 * (i) + 9]), 1); \ } +DECLSPEC u32 h_fun128 (u32 *sk, u32 *lk, const u32 x, const u32 *key); DECLSPEC u32 h_fun128 (u32 *sk, u32 *lk, const u32 x, const u32 *key) { u32 b0, b1, b2, b3; @@ -349,6 +354,7 @@ DECLSPEC u32 h_fun128 (u32 *sk, u32 *lk, const u32 x, const u32 *key) return mds (0, b0) ^ mds (1, b1) ^ mds (2, b2) ^ mds (3, b3); } +DECLSPEC void twofish128_set_key (u32 *sk, u32 *lk, const u32 *ukey); DECLSPEC void twofish128_set_key (u32 *sk, u32 *lk, const u32 *ukey) { u32 me_key[2]; @@ -379,6 +385,7 @@ DECLSPEC void twofish128_set_key (u32 *sk, u32 *lk, const u32 *ukey) } } +DECLSPEC void twofish128_encrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out); DECLSPEC void twofish128_encrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out) { u32 data[4]; @@ -403,6 +410,7 @@ DECLSPEC void twofish128_encrypt (const u32 *sk, const u32 *lk, const u32 *in, u out[3] = data[1] ^ lk[7]; } +DECLSPEC void twofish128_decrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out); DECLSPEC void twofish128_decrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out) { u32 data[4]; @@ -465,6 +473,7 @@ DECLSPEC void twofish128_decrypt (const u32 *sk, const u32 *lk, const u32 *in, u data[1] = rotr32_S (data[1] ^ (t2 + 2 * t3 + lk[4 * (i) + 9]), 1); \ } +DECLSPEC u32 h_fun256 (u32 *sk, u32 *lk, const u32 x, const u32 *key); DECLSPEC u32 h_fun256 (u32 *sk, u32 *lk, const u32 x, const u32 *key) { u32 b0, b1, b2, b3; @@ -492,6 +501,7 @@ DECLSPEC u32 h_fun256 (u32 *sk, u32 *lk, const u32 x, const u32 *key) return mds (0, b0) ^ mds (1, b1) ^ mds (2, b2) ^ mds (3, b3); } +DECLSPEC void twofish256_set_key (u32 *sk, u32 *lk, const u32 *ukey); DECLSPEC void twofish256_set_key (u32 *sk, u32 *lk, const u32 *ukey) { u32 me_key[4]; @@ -528,6 +538,7 @@ DECLSPEC void twofish256_set_key (u32 *sk, u32 *lk, const u32 *ukey) } } +DECLSPEC void twofish256_encrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out); DECLSPEC void twofish256_encrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out) { u32 data[4]; @@ -552,6 +563,7 @@ DECLSPEC void twofish256_encrypt (const u32 *sk, const u32 *lk, const u32 *in, u out[3] = data[1] ^ lk[7]; } +DECLSPEC void twofish256_decrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out); DECLSPEC void twofish256_decrypt (const u32 *sk, const u32 *lk, const u32 *in, u32 *out) { u32 data[4]; diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index 743eb4a86..bb03282fa 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -83,6 +83,7 @@ * pure scalar functions */ +DECLSPEC int ffz (const u32 v); DECLSPEC int ffz (const u32 v) { #ifdef _unroll @@ -98,6 +99,7 @@ DECLSPEC int ffz (const u32 v) return -1; } +DECLSPEC int hash_comp (const u32 *d1, __global const u32 *d2); DECLSPEC int hash_comp (const u32 *d1, __global const u32 *d2) { if (d1[3] > d2[DGST_R3]) return ( 1); @@ -112,6 +114,7 @@ DECLSPEC int hash_comp (const u32 *d1, __global const u32 *d2) return (0); } +DECLSPEC int find_hash (const u32 *digest, const u32 digests_cnt, __global const digest_t *digests_buf); DECLSPEC int find_hash (const u32 *digest, const u32 digests_cnt, __global const digest_t *digests_buf) { for (u32 l = 0, r = digests_cnt; r; r >>= 1) @@ -135,11 +138,13 @@ DECLSPEC int find_hash (const u32 *digest, const u32 digests_cnt, __global const return (-1); } +DECLSPEC u32 check_bitmap (__global const u32 *bitmap, const u32 bitmap_mask, const u32 bitmap_shift, const u32 digest); DECLSPEC u32 check_bitmap (__global const u32 *bitmap, const u32 bitmap_mask, const u32 bitmap_shift, const u32 digest) { return (bitmap[(digest >> bitmap_shift) & bitmap_mask] & (1 << (digest & 0x1f))); } +DECLSPEC u32 check (const u32 *digest, __global const u32 *bitmap_s1_a, __global const u32 *bitmap_s1_b, __global const u32 *bitmap_s1_c, __global const u32 *bitmap_s1_d, __global const u32 *bitmap_s2_a, __global const u32 *bitmap_s2_b, __global const u32 *bitmap_s2_c, __global const u32 *bitmap_s2_d, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2); DECLSPEC u32 check (const u32 *digest, __global const u32 *bitmap_s1_a, __global const u32 *bitmap_s1_b, __global const u32 *bitmap_s1_c, __global const u32 *bitmap_s1_d, __global const u32 *bitmap_s2_a, __global const u32 *bitmap_s2_b, __global const u32 *bitmap_s2_c, __global const u32 *bitmap_s2_d, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2) { if (check_bitmap (bitmap_s1_a, bitmap_mask, bitmap_shift1, digest[0]) == 0) return (0); @@ -155,7 +160,8 @@ DECLSPEC u32 check (const u32 *digest, __global const u32 *bitmap_s1_a, __global return (1); } -DECLSPEC void mark_hash (__global plain_t *plains_buf, __global u32 *d_result, const u32 salt_pos, const u32 digests_cnt, const u32 digest_pos, const u32 hash_pos, const u64 gid, const u32 il_pos) +DECLSPEC void mark_hash (__global plain_t *plains_buf, __global u32 *d_result, const u32 salt_pos, const u32 digests_cnt, const u32 digest_pos, const u32 hash_pos, const u64 gid, const u32 il_pos, const u32 extra1, const u32 extra2); +DECLSPEC void mark_hash (__global plain_t *plains_buf, __global u32 *d_result, const u32 salt_pos, const u32 digests_cnt, const u32 digest_pos, const u32 hash_pos, const u64 gid, const u32 il_pos, const u32 extra1, const u32 extra2) { const u32 idx = atomic_inc (d_result); @@ -169,13 +175,16 @@ DECLSPEC void mark_hash (__global plain_t *plains_buf, __global u32 *d_result, c return; } - plains_buf[idx].salt_pos = salt_pos; - plains_buf[idx].digest_pos = digest_pos; // relative - plains_buf[idx].hash_pos = hash_pos; // absolute - plains_buf[idx].gidvid = gid; - plains_buf[idx].il_pos = il_pos; + plains_buf[idx].salt_pos = salt_pos; + plains_buf[idx].digest_pos = digest_pos; // relative + plains_buf[idx].hash_pos = hash_pos; // absolute + plains_buf[idx].gidvid = gid; + plains_buf[idx].il_pos = il_pos; + plains_buf[idx].extra1 = extra1; // for example, used as veracrypt pim storage + plains_buf[idx].extra2 = extra2; // unused so far } +DECLSPEC int count_char (const u32 *buf, const int elems, const u32 c); DECLSPEC int count_char (const u32 *buf, const int elems, const u32 c) { int r = 0; @@ -193,6 +202,7 @@ DECLSPEC int count_char (const u32 *buf, const int elems, const u32 c) return r; } +DECLSPEC float get_entropy (const u32 *buf, const int elems); DECLSPEC float get_entropy (const u32 *buf, const int elems) { const int length = elems * 4; @@ -216,6 +226,7 @@ DECLSPEC float get_entropy (const u32 *buf, const int elems) return entropy; } +DECLSPEC int is_valid_hex_8 (const u8 v); DECLSPEC int is_valid_hex_8 (const u8 v) { // direct lookup table is slower thanks to CMOV @@ -226,6 +237,7 @@ DECLSPEC int is_valid_hex_8 (const u8 v) return 0; } +DECLSPEC int is_valid_hex_32 (const u32 v); DECLSPEC int is_valid_hex_32 (const u32 v) { if (is_valid_hex_8 ((u8) (v >> 0)) == 0) return 0; @@ -236,6 +248,7 @@ DECLSPEC int is_valid_hex_32 (const u32 v) return 1; } +DECLSPEC int is_valid_base58_8 (const u8 v); DECLSPEC int is_valid_base58_8 (const u8 v) { if (v > 'z') return 0; @@ -246,6 +259,7 @@ DECLSPEC int is_valid_base58_8 (const u8 v) return 1; } +DECLSPEC int is_valid_base58_32 (const u32 v); DECLSPEC int is_valid_base58_32 (const u32 v) { if (is_valid_base58_8 ((u8) (v >> 0)) == 0) return 0; @@ -256,6 +270,7 @@ DECLSPEC int is_valid_base58_32 (const u32 v) return 1; } +DECLSPEC int find_keyboard_layout_map (const u32 search, const int search_len, __local keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); DECLSPEC int find_keyboard_layout_map (const u32 search, const int search_len, __local keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt) { for (int idx = 0; idx < keyboard_layout_mapping_cnt; idx++) @@ -274,6 +289,7 @@ DECLSPEC int find_keyboard_layout_map (const u32 search, const int search_len, _ return -1; } +DECLSPEC int execute_keyboard_layout_mapping (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int pw_len, __local keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); DECLSPEC int execute_keyboard_layout_mapping (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int pw_len, __local keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt) { u32 out_buf[16] = { 0 }; @@ -404,6 +420,7 @@ DECLSPEC int execute_keyboard_layout_mapping (u32 w0[4], u32 w1[4], u32 w2[4], u * vector functions */ +DECLSPEC void make_utf16be (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16be (const u32x *in, u32x *out1, u32x *out2) { #if defined IS_NV @@ -442,6 +459,7 @@ DECLSPEC void make_utf16be (const u32x *in, u32x *out1, u32x *out2) #endif } +DECLSPEC void make_utf16beN (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16beN (const u32x *in, u32x *out1, u32x *out2) { #if defined IS_NV @@ -480,6 +498,7 @@ DECLSPEC void make_utf16beN (const u32x *in, u32x *out1, u32x *out2) #endif } +DECLSPEC void make_utf16le (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16le (const u32x *in, u32x *out1, u32x *out2) { #if defined IS_NV @@ -518,6 +537,7 @@ DECLSPEC void make_utf16le (const u32x *in, u32x *out1, u32x *out2) #endif } +DECLSPEC void make_utf16leN (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16leN (const u32x *in, u32x *out1, u32x *out2) { #if defined IS_NV @@ -556,6 +576,7 @@ DECLSPEC void make_utf16leN (const u32x *in, u32x *out1, u32x *out2) #endif } +DECLSPEC void undo_utf16be (const u32x *in1, const u32x *in2, u32x *out); DECLSPEC void undo_utf16be (const u32x *in1, const u32x *in2, u32x *out) { #if defined IS_NV @@ -586,6 +607,7 @@ DECLSPEC void undo_utf16be (const u32x *in1, const u32x *in2, u32x *out) #endif } +DECLSPEC void undo_utf16le (const u32x *in1, const u32x *in2, u32x *out); DECLSPEC void undo_utf16le (const u32x *in1, const u32x *in2, u32x *out) { #if defined IS_NV @@ -616,6 +638,7 @@ DECLSPEC void undo_utf16le (const u32x *in1, const u32x *in2, u32x *out) #endif } +DECLSPEC void set_mark_1x4 (u32 *v, const u32 offset); DECLSPEC void set_mark_1x4 (u32 *v, const u32 offset) { const u32 c = (offset & 15) / 4; @@ -627,6 +650,7 @@ DECLSPEC void set_mark_1x4 (u32 *v, const u32 offset) v[3] = (c == 3) ? r : 0; } +DECLSPEC void append_helper_1x4 (u32x *r, const u32 v, const u32 *m); DECLSPEC void append_helper_1x4 (u32x *r, const u32 v, const u32 *m) { r[0] |= v & m[0]; @@ -635,6 +659,7 @@ DECLSPEC void append_helper_1x4 (u32x *r, const u32 v, const u32 *m) r[3] |= v & m[3]; } +DECLSPEC void append_0x80_1x4 (u32x *w0, const u32 offset); DECLSPEC void append_0x80_1x4 (u32x *w0, const u32 offset) { u32 v[4]; @@ -644,6 +669,7 @@ DECLSPEC void append_0x80_1x4 (u32x *w0, const u32 offset) append_helper_1x4 (w0, 0x80808080, v); } +DECLSPEC void append_0x80_2x4 (u32x *w0, u32x *w1, const u32 offset); DECLSPEC void append_0x80_2x4 (u32x *w0, u32x *w1, const u32 offset) { u32 v[4]; @@ -656,6 +682,7 @@ DECLSPEC void append_0x80_2x4 (u32x *w0, u32x *w1, const u32 offset) append_helper_1x4 (w1, ((offset16 == 1) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_3x4 (u32x *w0, u32x *w1, u32x *w2, const u32 offset); DECLSPEC void append_0x80_3x4 (u32x *w0, u32x *w1, u32x *w2, const u32 offset) { u32 v[4]; @@ -669,6 +696,7 @@ DECLSPEC void append_0x80_3x4 (u32x *w0, u32x *w1, u32x *w2, const u32 offset) append_helper_1x4 (w2, ((offset16 == 2) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_4x4 (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 offset); DECLSPEC void append_0x80_4x4 (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 offset) { u32 v[4]; @@ -683,6 +711,7 @@ DECLSPEC void append_0x80_4x4 (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 append_helper_1x4 (w3, ((offset16 == 3) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_8x4 (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32 offset); DECLSPEC void append_0x80_8x4 (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32 offset) { u32 v[4]; @@ -701,6 +730,7 @@ DECLSPEC void append_0x80_8x4 (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, append_helper_1x4 (w7, ((offset16 == 7) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_1x16 (u32x *w, const u32 offset); DECLSPEC void append_0x80_1x16 (u32x *w, const u32 offset) { u32 v[4]; @@ -715,12 +745,9 @@ DECLSPEC void append_0x80_1x16 (u32x *w, const u32 offset) append_helper_1x4 (w + 12, ((offset16 == 3) ? 0x80808080 : 0), v); } +DECLSPEC void switch_buffer_by_offset_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 offset); DECLSPEC void switch_buffer_by_offset_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if (defined IS_AMD && HAS_VPERM == 0) || defined IS_GENERIC @@ -1050,6 +1077,10 @@ DECLSPEC void switch_buffer_by_offset_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3 #if (defined IS_AMD && HAS_VPERM == 1) || defined IS_NV + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + #if defined IS_NV const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; #endif @@ -1383,12 +1414,9 @@ DECLSPEC void switch_buffer_by_offset_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3 #endif } +DECLSPEC void switch_buffer_by_offset_carry_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *c0, u32x *c1, u32x *c2, u32x *c3, const u32 offset); DECLSPEC void switch_buffer_by_offset_carry_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *c0, u32x *c1, u32x *c2, u32x *c3, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if defined IS_AMD || defined IS_GENERIC @@ -1853,6 +1881,11 @@ DECLSPEC void switch_buffer_by_offset_carry_le (u32x *w0, u32x *w1, u32x *w2, u3 #endif #ifdef IS_NV + + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + // todo switch (offset_switch) { @@ -2651,6 +2684,7 @@ DECLSPEC void switch_buffer_by_offset_carry_le (u32x *w0, u32x *w1, u32x *w2, u3 #endif } +DECLSPEC void switch_buffer_by_offset_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 offset); DECLSPEC void switch_buffer_by_offset_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32 offset) { const int offset_switch = offset / 4; @@ -3315,6 +3349,7 @@ DECLSPEC void switch_buffer_by_offset_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3 #endif } +DECLSPEC void switch_buffer_by_offset_carry_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *c0, u32x *c1, u32x *c2, u32x *c3, const u32 offset); DECLSPEC void switch_buffer_by_offset_carry_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *c0, u32x *c1, u32x *c2, u32x *c3, const u32 offset) { const int offset_switch = offset / 4; @@ -4251,12 +4286,9 @@ DECLSPEC void switch_buffer_by_offset_carry_be (u32x *w0, u32x *w1, u32x *w2, u3 #endif } +DECLSPEC void switch_buffer_by_offset_8x4_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32 offset); DECLSPEC void switch_buffer_by_offset_8x4_le (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if (defined IS_AMD && HAS_VPERM == 0) || defined IS_GENERIC @@ -5418,6 +5450,10 @@ DECLSPEC void switch_buffer_by_offset_8x4_le (u32x *w0, u32x *w1, u32x *w2, u32x #if (defined IS_AMD && HAS_VPERM == 1) || defined IS_NV + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + #if defined IS_NV const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; #endif @@ -5991,6 +6027,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_le (u32x *w0, u32x *w1, u32x *w2, u32x #endif } +DECLSPEC void switch_buffer_by_offset_8x4_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32 offset); DECLSPEC void switch_buffer_by_offset_8x4_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32 offset) { const int offset_switch = offset / 4; @@ -8319,6 +8356,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_be (u32x *w0, u32x *w1, u32x *w2, u32x #endif } +DECLSPEC void switch_buffer_by_offset_8x4_carry_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u32x *c0, u32x *c1, u32x *c2, u32x *c3, u32x *c4, u32x *c5, u32x *c6, u32x *c7, const u32 offset); DECLSPEC void switch_buffer_by_offset_8x4_carry_be (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u32x *c0, u32x *c1, u32x *c2, u32x *c3, u32x *c4, u32x *c5, u32x *c6, u32x *c7, const u32 offset) { const int offset_switch = offset / 4; @@ -11703,12 +11741,9 @@ DECLSPEC void switch_buffer_by_offset_8x4_carry_be (u32x *w0, u32x *w1, u32x *w2 #endif } +DECLSPEC void switch_buffer_by_offset_1x64_le (u32x *w, const u32 offset); DECLSPEC void switch_buffer_by_offset_1x64_le (u32x *w, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if (defined IS_AMD && HAS_VPERM == 0) || defined IS_GENERIC @@ -16070,6 +16105,10 @@ DECLSPEC void switch_buffer_by_offset_1x64_le (u32x *w, const u32 offset) #if (defined IS_AMD && HAS_VPERM == 1) || defined IS_NV + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + #if defined IS_NV const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; #endif @@ -20435,6 +20474,7 @@ DECLSPEC void switch_buffer_by_offset_1x64_le (u32x *w, const u32 offset) #endif } +DECLSPEC void switch_buffer_by_offset_1x64_be (u32x *w, const u32 offset); DECLSPEC void switch_buffer_by_offset_1x64_be (u32x *w, const u32 offset) { const int offset_switch = offset / 4; @@ -29167,6 +29207,7 @@ DECLSPEC void switch_buffer_by_offset_1x64_be (u32x *w, const u32 offset) * vector functions as scalar (for outer loop usage) */ +DECLSPEC void truncate_block_4x4_le_S (u32 *w0, const u32 len); DECLSPEC void truncate_block_4x4_le_S (u32 *w0, const u32 len) { switch (len) @@ -29277,6 +29318,7 @@ DECLSPEC void truncate_block_4x4_le_S (u32 *w0, const u32 len) } } +DECLSPEC void truncate_block_4x4_be_S (u32 *w0, const u32 len); DECLSPEC void truncate_block_4x4_be_S (u32 *w0, const u32 len) { switch (len) @@ -29387,6 +29429,7 @@ DECLSPEC void truncate_block_4x4_be_S (u32 *w0, const u32 len) } } +DECLSPEC void truncate_block_16x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 len); DECLSPEC void truncate_block_16x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 len) { switch (len) @@ -30193,6 +30236,7 @@ DECLSPEC void truncate_block_16x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, cons } } +DECLSPEC void truncate_block_16x4_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 len); DECLSPEC void truncate_block_16x4_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 len) { switch (len) @@ -30999,6 +31043,7 @@ DECLSPEC void truncate_block_16x4_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, cons } } +DECLSPEC void set_mark_1x4_S (u32 *v, const u32 offset); DECLSPEC void set_mark_1x4_S (u32 *v, const u32 offset) { const u32 c = (offset & 15) / 4; @@ -31010,6 +31055,7 @@ DECLSPEC void set_mark_1x4_S (u32 *v, const u32 offset) v[3] = (c == 3) ? r : 0; } +DECLSPEC void append_helper_1x4_S (u32 *r, const u32 v, const u32 *m); DECLSPEC void append_helper_1x4_S (u32 *r, const u32 v, const u32 *m) { r[0] |= v & m[0]; @@ -31018,6 +31064,7 @@ DECLSPEC void append_helper_1x4_S (u32 *r, const u32 v, const u32 *m) r[3] |= v & m[3]; } +DECLSPEC void append_0x01_2x4_S (u32 *w0, u32 *w1, const u32 offset); DECLSPEC void append_0x01_2x4_S (u32 *w0, u32 *w1, const u32 offset) { u32 v[4]; @@ -31030,6 +31077,7 @@ DECLSPEC void append_0x01_2x4_S (u32 *w0, u32 *w1, const u32 offset) append_helper_1x4_S (w1, ((offset16 == 1) ? 0x01010101 : 0), v); } +DECLSPEC void append_0x06_2x4_S (u32 *w0, u32 *w1, const u32 offset); DECLSPEC void append_0x06_2x4_S (u32 *w0, u32 *w1, const u32 offset) { u32 v[4]; @@ -31042,6 +31090,7 @@ DECLSPEC void append_0x06_2x4_S (u32 *w0, u32 *w1, const u32 offset) append_helper_1x4_S (w1, ((offset16 == 1) ? 0x06060606 : 0), v); } +DECLSPEC void append_0x01_4x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset); DECLSPEC void append_0x01_4x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset) { u32 v[4]; @@ -31056,6 +31105,7 @@ DECLSPEC void append_0x01_4x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 o append_helper_1x4_S (w3, ((offset16 == 3) ? 0x01010101 : 0), v); } +DECLSPEC void append_0x80_1x4_S (u32 *w0, const u32 offset); DECLSPEC void append_0x80_1x4_S (u32 *w0, const u32 offset) { u32 v[4]; @@ -31065,6 +31115,7 @@ DECLSPEC void append_0x80_1x4_S (u32 *w0, const u32 offset) append_helper_1x4_S (w0, 0x80808080, v); } +DECLSPEC void append_0x80_2x4_S (u32 *w0, u32 *w1, const u32 offset); DECLSPEC void append_0x80_2x4_S (u32 *w0, u32 *w1, const u32 offset) { u32 v[4]; @@ -31077,6 +31128,7 @@ DECLSPEC void append_0x80_2x4_S (u32 *w0, u32 *w1, const u32 offset) append_helper_1x4_S (w1, ((offset16 == 1) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_3x4_S (u32 *w0, u32 *w1, u32 *w2, const u32 offset); DECLSPEC void append_0x80_3x4_S (u32 *w0, u32 *w1, u32 *w2, const u32 offset) { u32 v[4]; @@ -31090,6 +31142,7 @@ DECLSPEC void append_0x80_3x4_S (u32 *w0, u32 *w1, u32 *w2, const u32 offset) append_helper_1x4_S (w2, ((offset16 == 2) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_4x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset); DECLSPEC void append_0x80_4x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset) { u32 v[4]; @@ -31104,6 +31157,7 @@ DECLSPEC void append_0x80_4x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 o append_helper_1x4_S (w3, ((offset16 == 3) ? 0x80808080 : 0), v); } +DECLSPEC void append_0x80_8x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const u32 offset); DECLSPEC void append_0x80_8x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const u32 offset) { u32 v[4]; @@ -31122,6 +31176,7 @@ DECLSPEC void append_0x80_8x4_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u3 append_helper_1x4_S (w7, ((offset16 == 7) ? 0x80808080 : 0), v); } +DECLSPEC void make_utf16be_S (const u32 *in, u32 *out1, u32 *out2); DECLSPEC void make_utf16be_S (const u32 *in, u32 *out1, u32 *out2) { #if defined IS_NV @@ -31160,6 +31215,7 @@ DECLSPEC void make_utf16be_S (const u32 *in, u32 *out1, u32 *out2) #endif } +DECLSPEC void make_utf16le_S (const u32 *in, u32 *out1, u32 *out2); DECLSPEC void make_utf16le_S (const u32 *in, u32 *out1, u32 *out2) { #if defined IS_NV @@ -31198,6 +31254,7 @@ DECLSPEC void make_utf16le_S (const u32 *in, u32 *out1, u32 *out2) #endif } +DECLSPEC void undo_utf16be_S (const u32 *in1, const u32 *in2, u32 *out); DECLSPEC void undo_utf16be_S (const u32 *in1, const u32 *in2, u32 *out) { #if defined IS_NV @@ -31228,6 +31285,7 @@ DECLSPEC void undo_utf16be_S (const u32 *in1, const u32 *in2, u32 *out) #endif } +DECLSPEC void undo_utf16le_S (const u32 *in1, const u32 *in2, u32 *out); DECLSPEC void undo_utf16le_S (const u32 *in1, const u32 *in2, u32 *out) { #if defined IS_NV @@ -31258,12 +31316,9 @@ DECLSPEC void undo_utf16le_S (const u32 *in1, const u32 *in2, u32 *out) #endif } +DECLSPEC void switch_buffer_by_offset_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset); DECLSPEC void switch_buffer_by_offset_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if (defined IS_AMD && HAS_VPERM == 0) || defined IS_GENERIC @@ -31593,6 +31648,10 @@ DECLSPEC void switch_buffer_by_offset_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, #if (defined IS_AMD && HAS_VPERM == 1) || defined IS_NV + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + #if defined IS_NV const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; #endif @@ -31926,12 +31985,9 @@ DECLSPEC void switch_buffer_by_offset_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, #endif } +DECLSPEC void switch_buffer_by_offset_carry_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *c0, u32 *c1, u32 *c2, u32 *c3, const u32 offset); DECLSPEC void switch_buffer_by_offset_carry_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *c0, u32 *c1, u32 *c2, u32 *c3, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if defined IS_AMD || defined IS_GENERIC @@ -32396,6 +32452,11 @@ DECLSPEC void switch_buffer_by_offset_carry_le_S (u32 *w0, u32 *w1, u32 *w2, u32 #endif #ifdef IS_NV + + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + // todo switch (offset_switch) { @@ -33194,6 +33255,7 @@ DECLSPEC void switch_buffer_by_offset_carry_le_S (u32 *w0, u32 *w1, u32 *w2, u32 #endif } +DECLSPEC void switch_buffer_by_offset_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset); DECLSPEC void switch_buffer_by_offset_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 offset) { const int offset_switch = offset / 4; @@ -33858,6 +33920,7 @@ DECLSPEC void switch_buffer_by_offset_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, #endif } +DECLSPEC void switch_buffer_by_offset_carry_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *c0, u32 *c1, u32 *c2, u32 *c3, const u32 offset); DECLSPEC void switch_buffer_by_offset_carry_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *c0, u32 *c1, u32 *c2, u32 *c3, const u32 offset) { const int offset_switch = offset / 4; @@ -34794,12 +34857,9 @@ DECLSPEC void switch_buffer_by_offset_carry_be_S (u32 *w0, u32 *w1, u32 *w2, u32 #endif } +DECLSPEC void switch_buffer_by_offset_8x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const u32 offset); DECLSPEC void switch_buffer_by_offset_8x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if (defined IS_AMD && HAS_VPERM == 0) || defined IS_GENERIC @@ -35961,6 +36021,10 @@ DECLSPEC void switch_buffer_by_offset_8x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 * #if (defined IS_AMD && HAS_VPERM == 1) || defined IS_NV + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + #if defined IS_NV const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; #endif @@ -36534,6 +36598,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_le_S (u32 *w0, u32 *w1, u32 *w2, u32 * #endif } +DECLSPEC void switch_buffer_by_offset_8x4_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const u32 offset); DECLSPEC void switch_buffer_by_offset_8x4_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const u32 offset) { const int offset_switch = offset / 4; @@ -38862,6 +38927,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_be_S (u32 *w0, u32 *w1, u32 *w2, u32 * #endif } +DECLSPEC void switch_buffer_by_offset_8x4_carry_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, u32 *c0, u32 *c1, u32 *c2, u32 *c3, u32 *c4, u32 *c5, u32 *c6, u32 *c7, const u32 offset); DECLSPEC void switch_buffer_by_offset_8x4_carry_be_S (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, u32 *c0, u32 *c1, u32 *c2, u32 *c3, u32 *c4, u32 *c5, u32 *c6, u32 *c7, const u32 offset) { const int offset_switch = offset / 4; @@ -42246,12 +42312,9 @@ DECLSPEC void switch_buffer_by_offset_8x4_carry_be_S (u32 *w0, u32 *w1, u32 *w2, #endif } +DECLSPEC void switch_buffer_by_offset_1x64_le_S (u32 *w, const u32 offset); DECLSPEC void switch_buffer_by_offset_1x64_le_S (u32 *w, const u32 offset) { - const int offset_mod_4 = offset & 3; - - const int offset_minus_4 = 4 - offset_mod_4; - const int offset_switch = offset / 4; #if (defined IS_AMD && HAS_VPERM == 0) || defined IS_GENERIC @@ -46613,6 +46676,10 @@ DECLSPEC void switch_buffer_by_offset_1x64_le_S (u32 *w, const u32 offset) #if (defined IS_AMD && HAS_VPERM == 1) || defined IS_NV + const int offset_mod_4 = offset & 3; + + const int offset_minus_4 = 4 - offset_mod_4; + #if defined IS_NV const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; #endif @@ -50978,6 +51045,7 @@ DECLSPEC void switch_buffer_by_offset_1x64_le_S (u32 *w, const u32 offset) #endif } +DECLSPEC void switch_buffer_by_offset_1x64_be_S (u32 *w, const u32 offset); DECLSPEC void switch_buffer_by_offset_1x64_be_S (u32 *w, const u32 offset) { const int offset_switch = offset / 4; @@ -59770,6 +59838,7 @@ DECLSPEC void switch_buffer_by_offset_1x64_be_S (u32 *w, const u32 offset) PACKSV4 (s6, v6, e); \ PACKSV4 (s7, v7, e); +DECLSPEC void switch_buffer_by_offset_le_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset); DECLSPEC void switch_buffer_by_offset_le_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset) { #if VECT_SIZE == 1 @@ -59830,6 +59899,7 @@ DECLSPEC void switch_buffer_by_offset_le_VV (u32x *w0, u32x *w1, u32x *w2, u32x #endif } +DECLSPEC void switch_buffer_by_offset_8x4_le_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32x offset); DECLSPEC void switch_buffer_by_offset_8x4_le_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const u32x offset) { #if VECT_SIZE == 1 @@ -60010,6 +60080,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_le_VV (u32x *w0, u32x *w1, u32x *w2, u #endif } +DECLSPEC void append_0x01_2x4_VV (u32x *w0, u32x *w1, const u32x offset); DECLSPEC void append_0x01_2x4_VV (u32x *w0, u32x *w1, const u32x offset) { #if VECT_SIZE == 1 @@ -60068,6 +60139,7 @@ DECLSPEC void append_0x01_2x4_VV (u32x *w0, u32x *w1, const u32x offset) #endif } +DECLSPEC void append_0x01_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset); DECLSPEC void append_0x01_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset) { #if VECT_SIZE == 1 @@ -60128,6 +60200,7 @@ DECLSPEC void append_0x01_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const #endif } +DECLSPEC void append_0x06_2x4_VV (u32x *w0, u32x *w1, const u32x offset); DECLSPEC void append_0x06_2x4_VV (u32x *w0, u32x *w1, const u32x offset) { #if VECT_SIZE == 1 @@ -60186,6 +60259,7 @@ DECLSPEC void append_0x06_2x4_VV (u32x *w0, u32x *w1, const u32x offset) #endif } +DECLSPEC void append_0x80_2x4_VV (u32x *w0, u32x *w1, const u32x offset); DECLSPEC void append_0x80_2x4_VV (u32x *w0, u32x *w1, const u32x offset) { #if VECT_SIZE == 1 @@ -60244,6 +60318,7 @@ DECLSPEC void append_0x80_2x4_VV (u32x *w0, u32x *w1, const u32x offset) #endif } +DECLSPEC void append_0x80_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset); DECLSPEC void append_0x80_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset) { #if VECT_SIZE == 1 @@ -60304,6 +60379,7 @@ DECLSPEC void append_0x80_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const #endif } +DECLSPEC void gpu_decompress_entry (__global pw_idx_t *pws_idx, __global u32 *pws_comp, pw_t *pw, const u64 gid); DECLSPEC void gpu_decompress_entry (__global pw_idx_t *pws_idx, __global u32 *pws_comp, pw_t *pw, const u64 gid) { const u32 off = pws_idx[gid].off; diff --git a/OpenCL/inc_comp_multi.cl b/OpenCL/inc_comp_multi.cl index b10bfce00..5e6011237 100644 --- a/OpenCL/inc_comp_multi.cl +++ b/OpenCL/inc_comp_multi.cl @@ -26,7 +26,7 @@ if (check (digest_tp, if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/inc_comp_multi_bs.cl b/OpenCL/inc_comp_multi_bs.cl index 8534a0467..82a8c1e02 100644 --- a/OpenCL/inc_comp_multi_bs.cl +++ b/OpenCL/inc_comp_multi_bs.cl @@ -28,7 +28,7 @@ if (check (digest_tp, if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + slice); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + slice, 0, 0); } } } diff --git a/OpenCL/inc_comp_single.cl b/OpenCL/inc_comp_single.cl index 7895d50cc..2f931579e 100644 --- a/OpenCL/inc_comp_single.cl +++ b/OpenCL/inc_comp_single.cl @@ -7,6 +7,6 @@ if ((r0 == search[0]) if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos, 0, 0); } } diff --git a/OpenCL/inc_comp_single_bs.cl b/OpenCL/inc_comp_single_bs.cl index 02ff059eb..5fc4a84b4 100644 --- a/OpenCL/inc_comp_single_bs.cl +++ b/OpenCL/inc_comp_single_bs.cl @@ -5,6 +5,6 @@ if ((il_pos + slice) < il_cnt) if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + slice); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + slice, 0, 0); } } diff --git a/OpenCL/inc_hash_md4.cl b/OpenCL/inc_hash_md4.cl index cbce8c549..61e7f7e3a 100644 --- a/OpenCL/inc_hash_md4.cl +++ b/OpenCL/inc_hash_md4.cl @@ -17,6 +17,7 @@ typedef struct md4_ctx } md4_ctx_t; +DECLSPEC void md4_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void md4_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -81,6 +82,7 @@ DECLSPEC void md4_transform (const u32 *w0, const u32 *w1, const u32 *w2, const digest[3] += d; } +DECLSPEC void md4_init (md4_ctx_t *ctx); DECLSPEC void md4_init (md4_ctx_t *ctx) { ctx->h[0] = MD4M_A; @@ -108,6 +110,7 @@ DECLSPEC void md4_init (md4_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void md4_update_64 (md4_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void md4_update_64 (md4_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -182,6 +185,7 @@ DECLSPEC void md4_update_64 (md4_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, } } +DECLSPEC void md4_update (md4_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_update (md4_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -234,6 +238,7 @@ DECLSPEC void md4_update (md4_ctx_t *ctx, const u32 *w, const int len) md4_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md4_update_swap (md4_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_update_swap (md4_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -320,6 +325,7 @@ DECLSPEC void md4_update_swap (md4_ctx_t *ctx, const u32 *w, const int len) md4_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md4_update_utf16le (md4_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_update_utf16le (md4_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -362,6 +368,7 @@ DECLSPEC void md4_update_utf16le (md4_ctx_t *ctx, const u32 *w, const int len) md4_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md4_update_utf16le_swap (md4_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_update_utf16le_swap (md4_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -438,6 +445,7 @@ DECLSPEC void md4_update_utf16le_swap (md4_ctx_t *ctx, const u32 *w, const int l md4_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md4_update_global (md4_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_update_global (md4_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -490,6 +498,7 @@ DECLSPEC void md4_update_global (md4_ctx_t *ctx, const __global u32 *w, const in md4_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md4_update_global_swap (md4_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_update_global_swap (md4_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -576,6 +585,7 @@ DECLSPEC void md4_update_global_swap (md4_ctx_t *ctx, const __global u32 *w, con md4_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md4_update_global_utf16le (md4_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_update_global_utf16le (md4_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -618,6 +628,7 @@ DECLSPEC void md4_update_global_utf16le (md4_ctx_t *ctx, const __global u32 *w, md4_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md4_update_global_utf16le_swap (md4_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_update_global_utf16le_swap (md4_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -694,6 +705,7 @@ DECLSPEC void md4_update_global_utf16le_swap (md4_ctx_t *ctx, const __global u32 md4_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md4_final (md4_ctx_t *ctx); DECLSPEC void md4_final (md4_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -737,6 +749,7 @@ typedef struct md4_hmac_ctx } md4_hmac_ctx_t; +DECLSPEC void md4_hmac_init_64 (md4_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void md4_hmac_init_64 (md4_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u32 t0[4]; @@ -791,6 +804,7 @@ DECLSPEC void md4_hmac_init_64 (md4_hmac_ctx_t *ctx, const u32 *w0, const u32 *w md4_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void md4_hmac_init (md4_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_hmac_init (md4_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -848,6 +862,7 @@ DECLSPEC void md4_hmac_init (md4_hmac_ctx_t *ctx, const u32 *w, const int len) md4_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md4_hmac_init_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_hmac_init_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -905,6 +920,7 @@ DECLSPEC void md4_hmac_init_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int l md4_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md4_hmac_init_global (md4_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void md4_hmac_init_global (md4_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -962,6 +978,7 @@ DECLSPEC void md4_hmac_init_global (md4_hmac_ctx_t *ctx, __global const u32 *w, md4_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md4_hmac_init_global_swap (md4_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void md4_hmac_init_global_swap (md4_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1019,51 +1036,61 @@ DECLSPEC void md4_hmac_init_global_swap (md4_hmac_ctx_t *ctx, __global const u32 md4_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md4_hmac_update_64 (md4_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void md4_hmac_update_64 (md4_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { md4_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void md4_hmac_update (md4_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_hmac_update (md4_hmac_ctx_t *ctx, const u32 *w, const int len) { md4_update (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_hmac_update_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int len) { md4_update_swap (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_utf16le (md4_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_hmac_update_utf16le (md4_hmac_ctx_t *ctx, const u32 *w, const int len) { md4_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_utf16le_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md4_hmac_update_utf16le_swap (md4_hmac_ctx_t *ctx, const u32 *w, const int len) { md4_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_global (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_hmac_update_global (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md4_update_global (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_global_swap (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_hmac_update_global_swap (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md4_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_global_utf16le (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_hmac_update_global_utf16le (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md4_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_update_global_utf16le_swap (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md4_hmac_update_global_utf16le_swap (md4_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md4_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_final (md4_hmac_ctx_t *ctx); DECLSPEC void md4_hmac_final (md4_hmac_ctx_t *ctx) { md4_final (&ctx->ipad); @@ -1110,6 +1137,7 @@ typedef struct md4_ctx_vector } md4_ctx_vector_t; +DECLSPEC void md4_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest); DECLSPEC void md4_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest) { u32x a = digest[0]; @@ -1174,6 +1202,7 @@ DECLSPEC void md4_transform_vector (const u32x *w0, const u32x *w1, const u32x * digest[3] += d; } +DECLSPEC void md4_init_vector (md4_ctx_vector_t *ctx); DECLSPEC void md4_init_vector (md4_ctx_vector_t *ctx) { ctx->h[0] = MD4M_A; @@ -1201,6 +1230,7 @@ DECLSPEC void md4_init_vector (md4_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void md4_init_vector_from_scalar (md4_ctx_vector_t *ctx, md4_ctx_t *ctx0); DECLSPEC void md4_init_vector_from_scalar (md4_ctx_vector_t *ctx, md4_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -1228,6 +1258,7 @@ DECLSPEC void md4_init_vector_from_scalar (md4_ctx_vector_t *ctx, md4_ctx_t *ctx ctx->len = ctx0->len; } +DECLSPEC void md4_update_vector_64 (md4_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void md4_update_vector_64 (md4_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -1302,6 +1333,7 @@ DECLSPEC void md4_update_vector_64 (md4_ctx_vector_t *ctx, u32x *w0, u32x *w1, u } } +DECLSPEC void md4_update_vector (md4_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md4_update_vector (md4_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1354,6 +1386,7 @@ DECLSPEC void md4_update_vector (md4_ctx_vector_t *ctx, const u32x *w, const int md4_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md4_update_vector_swap (md4_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md4_update_vector_swap (md4_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1440,6 +1473,7 @@ DECLSPEC void md4_update_vector_swap (md4_ctx_vector_t *ctx, const u32x *w, cons md4_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md4_update_vector_utf16le (md4_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md4_update_vector_utf16le (md4_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1482,6 +1516,7 @@ DECLSPEC void md4_update_vector_utf16le (md4_ctx_vector_t *ctx, const u32x *w, c md4_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md4_update_vector_utf16le_swap (md4_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md4_update_vector_utf16le_swap (md4_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1558,6 +1593,7 @@ DECLSPEC void md4_update_vector_utf16le_swap (md4_ctx_vector_t *ctx, const u32x md4_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md4_final_vector (md4_ctx_vector_t *ctx); DECLSPEC void md4_final_vector (md4_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1601,6 +1637,7 @@ typedef struct md4_hmac_ctx_vector } md4_hmac_ctx_vector_t; +DECLSPEC void md4_hmac_init_vector_64 (md4_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void md4_hmac_init_vector_64 (md4_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u32x t0[4]; @@ -1655,6 +1692,7 @@ DECLSPEC void md4_hmac_init_vector_64 (md4_hmac_ctx_vector_t *ctx, const u32x *w md4_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void md4_hmac_init_vector (md4_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md4_hmac_init_vector (md4_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1712,16 +1750,19 @@ DECLSPEC void md4_hmac_init_vector (md4_hmac_ctx_vector_t *ctx, const u32x *w, c md4_hmac_init_vector_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md4_hmac_update_vector_64 (md4_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void md4_hmac_update_vector_64 (md4_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { md4_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void md4_hmac_update_vector (md4_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md4_hmac_update_vector (md4_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { md4_update_vector (&ctx->ipad, w, len); } +DECLSPEC void md4_hmac_final_vector (md4_hmac_ctx_vector_t *ctx); DECLSPEC void md4_hmac_final_vector (md4_hmac_ctx_vector_t *ctx) { md4_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_md5.cl b/OpenCL/inc_hash_md5.cl index 167c20951..cd5a5d321 100644 --- a/OpenCL/inc_hash_md5.cl +++ b/OpenCL/inc_hash_md5.cl @@ -17,6 +17,7 @@ typedef struct md5_ctx } md5_ctx_t; +DECLSPEC void md5_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void md5_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -117,6 +118,7 @@ DECLSPEC void md5_transform (const u32 *w0, const u32 *w1, const u32 *w2, const digest[3] += d; } +DECLSPEC void md5_init (md5_ctx_t *ctx); DECLSPEC void md5_init (md5_ctx_t *ctx) { ctx->h[0] = MD5M_A; @@ -144,6 +146,7 @@ DECLSPEC void md5_init (md5_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void md5_update_64 (md5_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void md5_update_64 (md5_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -218,6 +221,7 @@ DECLSPEC void md5_update_64 (md5_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, } } +DECLSPEC void md5_update (md5_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_update (md5_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -270,6 +274,7 @@ DECLSPEC void md5_update (md5_ctx_t *ctx, const u32 *w, const int len) md5_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_swap (md5_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_update_swap (md5_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -356,6 +361,7 @@ DECLSPEC void md5_update_swap (md5_ctx_t *ctx, const u32 *w, const int len) md5_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_utf16le (md5_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_update_utf16le (md5_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -398,6 +404,7 @@ DECLSPEC void md5_update_utf16le (md5_ctx_t *ctx, const u32 *w, const int len) md5_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md5_update_utf16le_swap (md5_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_update_utf16le_swap (md5_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -474,6 +481,7 @@ DECLSPEC void md5_update_utf16le_swap (md5_ctx_t *ctx, const u32 *w, const int l md5_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md5_update_global (md5_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_update_global (md5_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -526,6 +534,7 @@ DECLSPEC void md5_update_global (md5_ctx_t *ctx, const __global u32 *w, const in md5_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_global_swap (md5_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_update_global_swap (md5_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -612,6 +621,7 @@ DECLSPEC void md5_update_global_swap (md5_ctx_t *ctx, const __global u32 *w, con md5_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_global_utf16le (md5_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_update_global_utf16le (md5_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -654,6 +664,7 @@ DECLSPEC void md5_update_global_utf16le (md5_ctx_t *ctx, const __global u32 *w, md5_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md5_update_global_utf16le_swap (md5_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_update_global_utf16le_swap (md5_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -730,6 +741,7 @@ DECLSPEC void md5_update_global_utf16le_swap (md5_ctx_t *ctx, const __global u32 md5_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md5_final (md5_ctx_t *ctx); DECLSPEC void md5_final (md5_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -773,6 +785,7 @@ typedef struct md5_hmac_ctx } md5_hmac_ctx_t; +DECLSPEC void md5_hmac_init_64 (md5_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void md5_hmac_init_64 (md5_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u32 t0[4]; @@ -827,6 +840,7 @@ DECLSPEC void md5_hmac_init_64 (md5_hmac_ctx_t *ctx, const u32 *w0, const u32 *w md5_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void md5_hmac_init (md5_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_hmac_init (md5_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -884,6 +898,7 @@ DECLSPEC void md5_hmac_init (md5_hmac_ctx_t *ctx, const u32 *w, const int len) md5_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md5_hmac_init_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_hmac_init_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -941,6 +956,7 @@ DECLSPEC void md5_hmac_init_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int l md5_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md5_hmac_init_global (md5_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void md5_hmac_init_global (md5_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -998,6 +1014,7 @@ DECLSPEC void md5_hmac_init_global (md5_hmac_ctx_t *ctx, __global const u32 *w, md5_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md5_hmac_init_global_swap (md5_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void md5_hmac_init_global_swap (md5_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1055,51 +1072,61 @@ DECLSPEC void md5_hmac_init_global_swap (md5_hmac_ctx_t *ctx, __global const u32 md5_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md5_hmac_update_64 (md5_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void md5_hmac_update_64 (md5_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { md5_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void md5_hmac_update (md5_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_hmac_update (md5_hmac_ctx_t *ctx, const u32 *w, const int len) { md5_update (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_hmac_update_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int len) { md5_update_swap (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_utf16le (md5_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_hmac_update_utf16le (md5_hmac_ctx_t *ctx, const u32 *w, const int len) { md5_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_utf16le_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void md5_hmac_update_utf16le_swap (md5_hmac_ctx_t *ctx, const u32 *w, const int len) { md5_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_global (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_hmac_update_global (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md5_update_global (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_global_swap (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_hmac_update_global_swap (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md5_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_global_utf16le (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_hmac_update_global_utf16le (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md5_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_update_global_utf16le_swap (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void md5_hmac_update_global_utf16le_swap (md5_hmac_ctx_t *ctx, const __global u32 *w, const int len) { md5_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_final (md5_hmac_ctx_t *ctx); DECLSPEC void md5_hmac_final (md5_hmac_ctx_t *ctx) { md5_final (&ctx->ipad); @@ -1146,6 +1173,7 @@ typedef struct md5_ctx_vector } md5_ctx_vector_t; +DECLSPEC void md5_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest); DECLSPEC void md5_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest) { u32x a = digest[0]; @@ -1246,6 +1274,7 @@ DECLSPEC void md5_transform_vector (const u32x *w0, const u32x *w1, const u32x * digest[3] += d; } +DECLSPEC void md5_init_vector (md5_ctx_vector_t *ctx); DECLSPEC void md5_init_vector (md5_ctx_vector_t *ctx) { ctx->h[0] = MD5M_A; @@ -1273,6 +1302,7 @@ DECLSPEC void md5_init_vector (md5_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void md5_init_vector_from_scalar (md5_ctx_vector_t *ctx, md5_ctx_t *ctx0); DECLSPEC void md5_init_vector_from_scalar (md5_ctx_vector_t *ctx, md5_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -1300,6 +1330,7 @@ DECLSPEC void md5_init_vector_from_scalar (md5_ctx_vector_t *ctx, md5_ctx_t *ctx ctx->len = ctx0->len; } +DECLSPEC void md5_update_vector_64 (md5_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void md5_update_vector_64 (md5_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -1374,6 +1405,7 @@ DECLSPEC void md5_update_vector_64 (md5_ctx_vector_t *ctx, u32x *w0, u32x *w1, u } } +DECLSPEC void md5_update_vector (md5_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_update_vector (md5_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1426,6 +1458,7 @@ DECLSPEC void md5_update_vector (md5_ctx_vector_t *ctx, const u32x *w, const int md5_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_vector_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_update_vector_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1512,6 +1545,7 @@ DECLSPEC void md5_update_vector_swap (md5_ctx_vector_t *ctx, const u32x *w, cons md5_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void md5_update_vector_utf16le (md5_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_update_vector_utf16le (md5_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1554,6 +1588,7 @@ DECLSPEC void md5_update_vector_utf16le (md5_ctx_vector_t *ctx, const u32x *w, c md5_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md5_update_vector_utf16le_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_update_vector_utf16le_swap (md5_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1630,6 +1665,7 @@ DECLSPEC void md5_update_vector_utf16le_swap (md5_ctx_vector_t *ctx, const u32x md5_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void md5_final_vector (md5_ctx_vector_t *ctx); DECLSPEC void md5_final_vector (md5_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1673,6 +1709,7 @@ typedef struct md5_hmac_ctx_vector } md5_hmac_ctx_vector_t; +DECLSPEC void md5_hmac_init_vector_64 (md5_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void md5_hmac_init_vector_64 (md5_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u32x t0[4]; @@ -1727,6 +1764,7 @@ DECLSPEC void md5_hmac_init_vector_64 (md5_hmac_ctx_vector_t *ctx, const u32x *w md5_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void md5_hmac_init_vector (md5_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_hmac_init_vector (md5_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1784,16 +1822,19 @@ DECLSPEC void md5_hmac_init_vector (md5_hmac_ctx_vector_t *ctx, const u32x *w, c md5_hmac_init_vector_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void md5_hmac_update_vector_64 (md5_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void md5_hmac_update_vector_64 (md5_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { md5_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void md5_hmac_update_vector (md5_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void md5_hmac_update_vector (md5_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { md5_update_vector (&ctx->ipad, w, len); } +DECLSPEC void md5_hmac_final_vector (md5_hmac_ctx_vector_t *ctx); DECLSPEC void md5_hmac_final_vector (md5_hmac_ctx_vector_t *ctx) { md5_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_ripemd160.cl b/OpenCL/inc_hash_ripemd160.cl index b4c9cf907..1e66212fd 100644 --- a/OpenCL/inc_hash_ripemd160.cl +++ b/OpenCL/inc_hash_ripemd160.cl @@ -17,6 +17,7 @@ typedef struct ripemd160_ctx } ripemd160_ctx_t; +DECLSPEC void ripemd160_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void ripemd160_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a1 = digest[0]; @@ -214,6 +215,7 @@ DECLSPEC void ripemd160_transform (const u32 *w0, const u32 *w1, const u32 *w2, digest[4] = e; } +DECLSPEC void ripemd160_init (ripemd160_ctx_t *ctx); DECLSPEC void ripemd160_init (ripemd160_ctx_t *ctx) { ctx->h[0] = RIPEMD160M_A; @@ -242,6 +244,7 @@ DECLSPEC void ripemd160_init (ripemd160_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void ripemd160_update_64 (ripemd160_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void ripemd160_update_64 (ripemd160_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -316,6 +319,7 @@ DECLSPEC void ripemd160_update_64 (ripemd160_ctx_t *ctx, u32 *w0, u32 *w1, u32 * } } +DECLSPEC void ripemd160_update (ripemd160_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_update (ripemd160_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -368,6 +372,7 @@ DECLSPEC void ripemd160_update (ripemd160_ctx_t *ctx, const u32 *w, const int le ripemd160_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void ripemd160_update_swap (ripemd160_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_update_swap (ripemd160_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -454,6 +459,7 @@ DECLSPEC void ripemd160_update_swap (ripemd160_ctx_t *ctx, const u32 *w, const i ripemd160_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void ripemd160_update_utf16le (ripemd160_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_update_utf16le (ripemd160_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -496,6 +502,7 @@ DECLSPEC void ripemd160_update_utf16le (ripemd160_ctx_t *ctx, const u32 *w, cons ripemd160_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void ripemd160_update_utf16le_swap (ripemd160_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_update_utf16le_swap (ripemd160_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -572,6 +579,7 @@ DECLSPEC void ripemd160_update_utf16le_swap (ripemd160_ctx_t *ctx, const u32 *w, ripemd160_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void ripemd160_update_global (ripemd160_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_update_global (ripemd160_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -624,6 +632,7 @@ DECLSPEC void ripemd160_update_global (ripemd160_ctx_t *ctx, const __global u32 ripemd160_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void ripemd160_update_global_swap (ripemd160_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_update_global_swap (ripemd160_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -710,6 +719,7 @@ DECLSPEC void ripemd160_update_global_swap (ripemd160_ctx_t *ctx, const __global ripemd160_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void ripemd160_update_global_utf16le (ripemd160_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_update_global_utf16le (ripemd160_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -752,6 +762,7 @@ DECLSPEC void ripemd160_update_global_utf16le (ripemd160_ctx_t *ctx, const __glo ripemd160_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void ripemd160_update_global_utf16le_swap (ripemd160_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_update_global_utf16le_swap (ripemd160_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -828,6 +839,7 @@ DECLSPEC void ripemd160_update_global_utf16le_swap (ripemd160_ctx_t *ctx, const ripemd160_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void ripemd160_final (ripemd160_ctx_t *ctx); DECLSPEC void ripemd160_final (ripemd160_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -871,6 +883,7 @@ typedef struct ripemd160_hmac_ctx } ripemd160_hmac_ctx_t; +DECLSPEC void ripemd160_hmac_init_64 (ripemd160_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void ripemd160_hmac_init_64 (ripemd160_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u32 t0[4]; @@ -925,6 +938,7 @@ DECLSPEC void ripemd160_hmac_init_64 (ripemd160_hmac_ctx_t *ctx, const u32 *w0, ripemd160_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void ripemd160_hmac_init (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_hmac_init (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -982,6 +996,7 @@ DECLSPEC void ripemd160_hmac_init (ripemd160_hmac_ctx_t *ctx, const u32 *w, cons ripemd160_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void ripemd160_hmac_init_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_hmac_init_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1039,6 +1054,7 @@ DECLSPEC void ripemd160_hmac_init_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, ripemd160_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void ripemd160_hmac_init_global (ripemd160_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void ripemd160_hmac_init_global (ripemd160_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1096,6 +1112,7 @@ DECLSPEC void ripemd160_hmac_init_global (ripemd160_hmac_ctx_t *ctx, __global co ripemd160_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void ripemd160_hmac_init_global_swap (ripemd160_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void ripemd160_hmac_init_global_swap (ripemd160_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1153,51 +1170,61 @@ DECLSPEC void ripemd160_hmac_init_global_swap (ripemd160_hmac_ctx_t *ctx, __glob ripemd160_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void ripemd160_hmac_update_64 (ripemd160_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void ripemd160_hmac_update_64 (ripemd160_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { ripemd160_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void ripemd160_hmac_update (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_hmac_update (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) { ripemd160_update (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) { ripemd160_update_swap (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_utf16le (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_utf16le (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) { ripemd160_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_utf16le_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_utf16le_swap (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) { ripemd160_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_global (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_global (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len) { ripemd160_update_global (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_global_swap (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_global_swap (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len) { ripemd160_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_global_utf16le (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_global_utf16le (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len) { ripemd160_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_update_global_utf16le_swap (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void ripemd160_hmac_update_global_utf16le_swap (ripemd160_hmac_ctx_t *ctx, const __global u32 *w, const int len) { ripemd160_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_final (ripemd160_hmac_ctx_t *ctx); DECLSPEC void ripemd160_hmac_final (ripemd160_hmac_ctx_t *ctx) { ripemd160_final (&ctx->ipad); @@ -1244,6 +1271,7 @@ typedef struct ripemd160_ctx_vector } ripemd160_ctx_vector_t; +DECLSPEC void ripemd160_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest); DECLSPEC void ripemd160_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest) { u32x a1 = digest[0]; @@ -1441,6 +1469,7 @@ DECLSPEC void ripemd160_transform_vector (const u32x *w0, const u32x *w1, const digest[4] = e; } +DECLSPEC void ripemd160_init_vector (ripemd160_ctx_vector_t *ctx); DECLSPEC void ripemd160_init_vector (ripemd160_ctx_vector_t *ctx) { ctx->h[0] = RIPEMD160M_A; @@ -1469,6 +1498,7 @@ DECLSPEC void ripemd160_init_vector (ripemd160_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void ripemd160_init_vector_from_scalar (ripemd160_ctx_vector_t *ctx, ripemd160_ctx_t *ctx0); DECLSPEC void ripemd160_init_vector_from_scalar (ripemd160_ctx_vector_t *ctx, ripemd160_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -1497,6 +1527,7 @@ DECLSPEC void ripemd160_init_vector_from_scalar (ripemd160_ctx_vector_t *ctx, ri ctx->len = ctx0->len; } +DECLSPEC void ripemd160_update_vector_64 (ripemd160_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void ripemd160_update_vector_64 (ripemd160_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -1571,6 +1602,7 @@ DECLSPEC void ripemd160_update_vector_64 (ripemd160_ctx_vector_t *ctx, u32x *w0, } } +DECLSPEC void ripemd160_update_vector (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void ripemd160_update_vector (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1623,6 +1655,7 @@ DECLSPEC void ripemd160_update_vector (ripemd160_ctx_vector_t *ctx, const u32x * ripemd160_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void ripemd160_update_vector_swap (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void ripemd160_update_vector_swap (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1709,6 +1742,7 @@ DECLSPEC void ripemd160_update_vector_swap (ripemd160_ctx_vector_t *ctx, const u ripemd160_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void ripemd160_update_vector_utf16le (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void ripemd160_update_vector_utf16le (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1751,6 +1785,7 @@ DECLSPEC void ripemd160_update_vector_utf16le (ripemd160_ctx_vector_t *ctx, cons ripemd160_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void ripemd160_update_vector_utf16le_swap (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void ripemd160_update_vector_utf16le_swap (ripemd160_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1827,6 +1862,7 @@ DECLSPEC void ripemd160_update_vector_utf16le_swap (ripemd160_ctx_vector_t *ctx, ripemd160_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void ripemd160_final_vector (ripemd160_ctx_vector_t *ctx); DECLSPEC void ripemd160_final_vector (ripemd160_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1870,6 +1906,7 @@ typedef struct ripemd160_hmac_ctx_vector } ripemd160_hmac_ctx_vector_t; +DECLSPEC void ripemd160_hmac_init_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void ripemd160_hmac_init_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u32x t0[4]; @@ -1924,6 +1961,7 @@ DECLSPEC void ripemd160_hmac_init_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, c ripemd160_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void ripemd160_hmac_init_vector (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void ripemd160_hmac_init_vector (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1981,16 +2019,19 @@ DECLSPEC void ripemd160_hmac_init_vector (ripemd160_hmac_ctx_vector_t *ctx, cons ripemd160_hmac_init_vector_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void ripemd160_hmac_update_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void ripemd160_hmac_update_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { ripemd160_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void ripemd160_hmac_update_vector (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void ripemd160_hmac_update_vector (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { ripemd160_update_vector (&ctx->ipad, w, len); } +DECLSPEC void ripemd160_hmac_final_vector (ripemd160_hmac_ctx_vector_t *ctx); DECLSPEC void ripemd160_hmac_final_vector (ripemd160_hmac_ctx_vector_t *ctx) { ripemd160_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_sha1.cl b/OpenCL/inc_hash_sha1.cl index c2664c80f..4c45c7c1e 100644 --- a/OpenCL/inc_hash_sha1.cl +++ b/OpenCL/inc_hash_sha1.cl @@ -17,6 +17,7 @@ typedef struct sha1_ctx } sha1_ctx_t; +DECLSPEC void sha1_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void sha1_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -146,6 +147,7 @@ DECLSPEC void sha1_transform (const u32 *w0, const u32 *w1, const u32 *w2, const digest[4] += e; } +DECLSPEC void sha1_init (sha1_ctx_t *ctx); DECLSPEC void sha1_init (sha1_ctx_t *ctx) { ctx->h[0] = SHA1M_A; @@ -174,6 +176,7 @@ DECLSPEC void sha1_init (sha1_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void sha1_update_64 (sha1_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void sha1_update_64 (sha1_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -248,6 +251,7 @@ DECLSPEC void sha1_update_64 (sha1_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w } } +DECLSPEC void sha1_update (sha1_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_update (sha1_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -300,6 +304,7 @@ DECLSPEC void sha1_update (sha1_ctx_t *ctx, const u32 *w, const int len) sha1_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha1_update_swap (sha1_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_update_swap (sha1_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -386,6 +391,7 @@ DECLSPEC void sha1_update_swap (sha1_ctx_t *ctx, const u32 *w, const int len) sha1_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha1_update_utf16le (sha1_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_update_utf16le (sha1_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -428,6 +434,7 @@ DECLSPEC void sha1_update_utf16le (sha1_ctx_t *ctx, const u32 *w, const int len) sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_utf16le_swap (sha1_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_update_utf16le_swap (sha1_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -504,6 +511,7 @@ DECLSPEC void sha1_update_utf16le_swap (sha1_ctx_t *ctx, const u32 *w, const int sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_utf16be (sha1_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_update_utf16be (sha1_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -546,6 +554,7 @@ DECLSPEC void sha1_update_utf16be (sha1_ctx_t *ctx, const u32 *w, const int len) sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_utf16be_swap (sha1_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_update_utf16be_swap (sha1_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -622,6 +631,7 @@ DECLSPEC void sha1_update_utf16be_swap (sha1_ctx_t *ctx, const u32 *w, const int sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_global (sha1_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_update_global (sha1_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -674,6 +684,7 @@ DECLSPEC void sha1_update_global (sha1_ctx_t *ctx, const __global u32 *w, const sha1_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha1_update_global_swap (sha1_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_update_global_swap (sha1_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -760,6 +771,7 @@ DECLSPEC void sha1_update_global_swap (sha1_ctx_t *ctx, const __global u32 *w, c sha1_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha1_update_global_utf16le (sha1_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_update_global_utf16le (sha1_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -802,6 +814,7 @@ DECLSPEC void sha1_update_global_utf16le (sha1_ctx_t *ctx, const __global u32 *w sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_global_utf16le_swap (sha1_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_update_global_utf16le_swap (sha1_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -878,6 +891,7 @@ DECLSPEC void sha1_update_global_utf16le_swap (sha1_ctx_t *ctx, const __global u sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_global_utf16be (sha1_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_update_global_utf16be (sha1_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -920,6 +934,7 @@ DECLSPEC void sha1_update_global_utf16be (sha1_ctx_t *ctx, const __global u32 *w sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_global_utf16be_swap (sha1_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_update_global_utf16be_swap (sha1_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -996,6 +1011,7 @@ DECLSPEC void sha1_update_global_utf16be_swap (sha1_ctx_t *ctx, const __global u sha1_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_final (sha1_ctx_t *ctx); DECLSPEC void sha1_final (sha1_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -1039,6 +1055,7 @@ typedef struct sha1_hmac_ctx } sha1_hmac_ctx_t; +DECLSPEC void sha1_hmac_init_64 (sha1_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void sha1_hmac_init_64 (sha1_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u32 t0[4]; @@ -1093,6 +1110,7 @@ DECLSPEC void sha1_hmac_init_64 (sha1_hmac_ctx_t *ctx, const u32 *w0, const u32 sha1_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void sha1_hmac_init (sha1_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_hmac_init (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1150,6 +1168,7 @@ DECLSPEC void sha1_hmac_init (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) sha1_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha1_hmac_init_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_hmac_init_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1207,6 +1226,7 @@ DECLSPEC void sha1_hmac_init_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int sha1_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha1_hmac_init_global (sha1_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha1_hmac_init_global (sha1_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1264,6 +1284,7 @@ DECLSPEC void sha1_hmac_init_global (sha1_hmac_ctx_t *ctx, __global const u32 *w sha1_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha1_hmac_init_global_swap (sha1_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha1_hmac_init_global_swap (sha1_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1321,51 +1342,61 @@ DECLSPEC void sha1_hmac_init_global_swap (sha1_hmac_ctx_t *ctx, __global const u sha1_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha1_hmac_update_64 (sha1_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void sha1_hmac_update_64 (sha1_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { sha1_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void sha1_hmac_update (sha1_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_hmac_update (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) { sha1_update (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_hmac_update_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) { sha1_update_swap (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_utf16le (sha1_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_hmac_update_utf16le (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) { sha1_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_utf16le_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha1_hmac_update_utf16le_swap (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) { sha1_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_global (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_hmac_update_global (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha1_update_global (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_global_swap (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_hmac_update_global_swap (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha1_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_global_utf16le (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_hmac_update_global_utf16le (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha1_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_update_global_utf16le_swap (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha1_hmac_update_global_utf16le_swap (sha1_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha1_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_final (sha1_hmac_ctx_t *ctx); DECLSPEC void sha1_hmac_final (sha1_hmac_ctx_t *ctx) { sha1_final (&ctx->ipad); @@ -1412,6 +1443,7 @@ typedef struct sha1_ctx_vector } sha1_ctx_vector_t; +DECLSPEC void sha1_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest); DECLSPEC void sha1_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest) { u32x a = digest[0]; @@ -1541,6 +1573,7 @@ DECLSPEC void sha1_transform_vector (const u32x *w0, const u32x *w1, const u32x digest[4] += e; } +DECLSPEC void sha1_init_vector (sha1_ctx_vector_t *ctx); DECLSPEC void sha1_init_vector (sha1_ctx_vector_t *ctx) { ctx->h[0] = SHA1M_A; @@ -1569,6 +1602,7 @@ DECLSPEC void sha1_init_vector (sha1_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void sha1_init_vector_from_scalar (sha1_ctx_vector_t *ctx, sha1_ctx_t *ctx0); DECLSPEC void sha1_init_vector_from_scalar (sha1_ctx_vector_t *ctx, sha1_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -1597,6 +1631,7 @@ DECLSPEC void sha1_init_vector_from_scalar (sha1_ctx_vector_t *ctx, sha1_ctx_t * ctx->len = ctx0->len; } +DECLSPEC void sha1_update_vector_64 (sha1_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void sha1_update_vector_64 (sha1_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -1671,6 +1706,7 @@ DECLSPEC void sha1_update_vector_64 (sha1_ctx_vector_t *ctx, u32x *w0, u32x *w1, } } +DECLSPEC void sha1_update_vector (sha1_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_update_vector (sha1_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1723,6 +1759,7 @@ DECLSPEC void sha1_update_vector (sha1_ctx_vector_t *ctx, const u32x *w, const i sha1_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha1_update_vector_swap (sha1_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_update_vector_swap (sha1_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1809,6 +1846,7 @@ DECLSPEC void sha1_update_vector_swap (sha1_ctx_vector_t *ctx, const u32x *w, co sha1_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha1_update_vector_utf16le (sha1_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_update_vector_utf16le (sha1_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1851,6 +1889,7 @@ DECLSPEC void sha1_update_vector_utf16le (sha1_ctx_vector_t *ctx, const u32x *w, sha1_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_vector_utf16le_swap (sha1_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_update_vector_utf16le_swap (sha1_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1927,6 +1966,7 @@ DECLSPEC void sha1_update_vector_utf16le_swap (sha1_ctx_vector_t *ctx, const u32 sha1_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_vector_utf16leN (sha1_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_update_vector_utf16leN (sha1_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1969,6 +2009,7 @@ DECLSPEC void sha1_update_vector_utf16leN (sha1_ctx_vector_t *ctx, const u32x *w sha1_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_update_vector_utf16beN (sha1_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_update_vector_utf16beN (sha1_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2011,6 +2052,7 @@ DECLSPEC void sha1_update_vector_utf16beN (sha1_ctx_vector_t *ctx, const u32x *w sha1_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha1_final_vector (sha1_ctx_vector_t *ctx); DECLSPEC void sha1_final_vector (sha1_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -2054,6 +2096,7 @@ typedef struct sha1_hmac_ctx_vector } sha1_hmac_ctx_vector_t; +DECLSPEC void sha1_hmac_init_vector_64 (sha1_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void sha1_hmac_init_vector_64 (sha1_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u32x t0[4]; @@ -2108,6 +2151,7 @@ DECLSPEC void sha1_hmac_init_vector_64 (sha1_hmac_ctx_vector_t *ctx, const u32x sha1_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void sha1_hmac_init_vector (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_hmac_init_vector (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2165,16 +2209,19 @@ DECLSPEC void sha1_hmac_init_vector (sha1_hmac_ctx_vector_t *ctx, const u32x *w, sha1_hmac_init_vector_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha1_hmac_update_vector_64 (sha1_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void sha1_hmac_update_vector_64 (sha1_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { sha1_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void sha1_hmac_update_vector (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha1_hmac_update_vector (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { sha1_update_vector (&ctx->ipad, w, len); } +DECLSPEC void sha1_hmac_final_vector (sha1_hmac_ctx_vector_t *ctx); DECLSPEC void sha1_hmac_final_vector (sha1_hmac_ctx_vector_t *ctx) { sha1_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_sha224.cl b/OpenCL/inc_hash_sha224.cl index da88059b9..82a5cbb3a 100644 --- a/OpenCL/inc_hash_sha224.cl +++ b/OpenCL/inc_hash_sha224.cl @@ -37,6 +37,7 @@ typedef struct sha224_ctx } sha224_ctx_t; +DECLSPEC void sha224_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void sha224_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -128,6 +129,7 @@ DECLSPEC void sha224_transform (const u32 *w0, const u32 *w1, const u32 *w2, con digest[7] += h; } +DECLSPEC void sha224_init (sha224_ctx_t *ctx); DECLSPEC void sha224_init (sha224_ctx_t *ctx) { ctx->h[0] = SHA224M_A; @@ -159,6 +161,7 @@ DECLSPEC void sha224_init (sha224_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void sha224_update_64 (sha224_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void sha224_update_64 (sha224_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -233,6 +236,7 @@ DECLSPEC void sha224_update_64 (sha224_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u3 } } +DECLSPEC void sha224_update (sha224_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_update (sha224_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -285,6 +289,7 @@ DECLSPEC void sha224_update (sha224_ctx_t *ctx, const u32 *w, const int len) sha224_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha224_update_swap (sha224_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_update_swap (sha224_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -371,6 +376,7 @@ DECLSPEC void sha224_update_swap (sha224_ctx_t *ctx, const u32 *w, const int len sha224_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha224_update_utf16le (sha224_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_update_utf16le (sha224_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -413,6 +419,7 @@ DECLSPEC void sha224_update_utf16le (sha224_ctx_t *ctx, const u32 *w, const int sha224_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_update_utf16le_swap (sha224_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_update_utf16le_swap (sha224_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -489,6 +496,7 @@ DECLSPEC void sha224_update_utf16le_swap (sha224_ctx_t *ctx, const u32 *w, const sha224_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_update_global (sha224_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_update_global (sha224_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -541,6 +549,7 @@ DECLSPEC void sha224_update_global (sha224_ctx_t *ctx, const __global u32 *w, co sha224_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha224_update_global_swap (sha224_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_update_global_swap (sha224_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -627,6 +636,7 @@ DECLSPEC void sha224_update_global_swap (sha224_ctx_t *ctx, const __global u32 * sha224_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha224_update_global_utf16le (sha224_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_update_global_utf16le (sha224_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -669,6 +679,7 @@ DECLSPEC void sha224_update_global_utf16le (sha224_ctx_t *ctx, const __global u3 sha224_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_update_global_utf16le_swap (sha224_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_update_global_utf16le_swap (sha224_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -745,6 +756,7 @@ DECLSPEC void sha224_update_global_utf16le_swap (sha224_ctx_t *ctx, const __glob sha224_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_final (sha224_ctx_t *ctx); DECLSPEC void sha224_final (sha224_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -788,6 +800,7 @@ typedef struct sha224_hmac_ctx } sha224_hmac_ctx_t; +DECLSPEC void sha224_hmac_init_64 (sha224_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void sha224_hmac_init_64 (sha224_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u32 t0[4]; @@ -842,6 +855,7 @@ DECLSPEC void sha224_hmac_init_64 (sha224_hmac_ctx_t *ctx, const u32 *w0, const sha224_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void sha224_hmac_init (sha224_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_hmac_init (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -899,6 +913,7 @@ DECLSPEC void sha224_hmac_init (sha224_hmac_ctx_t *ctx, const u32 *w, const int sha224_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha224_hmac_init_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_hmac_init_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -956,6 +971,7 @@ DECLSPEC void sha224_hmac_init_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const sha224_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha224_hmac_init_global (sha224_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha224_hmac_init_global (sha224_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1013,6 +1029,7 @@ DECLSPEC void sha224_hmac_init_global (sha224_hmac_ctx_t *ctx, __global const u3 sha224_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha224_hmac_init_global_swap (sha224_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha224_hmac_init_global_swap (sha224_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1070,51 +1087,61 @@ DECLSPEC void sha224_hmac_init_global_swap (sha224_hmac_ctx_t *ctx, __global con sha224_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha224_hmac_update_64 (sha224_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void sha224_hmac_update_64 (sha224_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { sha224_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void sha224_hmac_update (sha224_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_hmac_update (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) { sha224_update (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_hmac_update_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) { sha224_update_swap (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_utf16le (sha224_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_hmac_update_utf16le (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) { sha224_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_utf16le_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha224_hmac_update_utf16le_swap (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) { sha224_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_global (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_hmac_update_global (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha224_update_global (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_global_swap (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_hmac_update_global_swap (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha224_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_global_utf16le (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_hmac_update_global_utf16le (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha224_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_update_global_utf16le_swap (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha224_hmac_update_global_utf16le_swap (sha224_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha224_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_final (sha224_hmac_ctx_t *ctx); DECLSPEC void sha224_hmac_final (sha224_hmac_ctx_t *ctx) { sha224_final (&ctx->ipad); @@ -1161,6 +1188,7 @@ typedef struct sha224_ctx_vector } sha224_ctx_vector_t; +DECLSPEC void sha224_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest); DECLSPEC void sha224_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest) { u32x a = digest[0]; @@ -1252,6 +1280,7 @@ DECLSPEC void sha224_transform_vector (const u32x *w0, const u32x *w1, const u32 digest[7] += h; } +DECLSPEC void sha224_init_vector (sha224_ctx_vector_t *ctx); DECLSPEC void sha224_init_vector (sha224_ctx_vector_t *ctx) { ctx->h[0] = SHA224M_A; @@ -1283,6 +1312,7 @@ DECLSPEC void sha224_init_vector (sha224_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void sha224_init_vector_from_scalar (sha224_ctx_vector_t *ctx, sha224_ctx_t *ctx0); DECLSPEC void sha224_init_vector_from_scalar (sha224_ctx_vector_t *ctx, sha224_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -1314,6 +1344,7 @@ DECLSPEC void sha224_init_vector_from_scalar (sha224_ctx_vector_t *ctx, sha224_c ctx->len = ctx0->len; } +DECLSPEC void sha224_update_vector_64 (sha224_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void sha224_update_vector_64 (sha224_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -1388,6 +1419,7 @@ DECLSPEC void sha224_update_vector_64 (sha224_ctx_vector_t *ctx, u32x *w0, u32x } } +DECLSPEC void sha224_update_vector (sha224_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_update_vector (sha224_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1440,6 +1472,7 @@ DECLSPEC void sha224_update_vector (sha224_ctx_vector_t *ctx, const u32x *w, con sha224_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha224_update_vector_swap (sha224_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_update_vector_swap (sha224_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1526,6 +1559,7 @@ DECLSPEC void sha224_update_vector_swap (sha224_ctx_vector_t *ctx, const u32x *w sha224_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha224_update_vector_utf16le (sha224_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_update_vector_utf16le (sha224_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1568,6 +1602,7 @@ DECLSPEC void sha224_update_vector_utf16le (sha224_ctx_vector_t *ctx, const u32x sha224_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_update_vector_utf16le_swap (sha224_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_update_vector_utf16le_swap (sha224_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1644,6 +1679,7 @@ DECLSPEC void sha224_update_vector_utf16le_swap (sha224_ctx_vector_t *ctx, const sha224_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_update_vector_utf16beN (sha224_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_update_vector_utf16beN (sha224_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1686,6 +1722,7 @@ DECLSPEC void sha224_update_vector_utf16beN (sha224_ctx_vector_t *ctx, const u32 sha224_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha224_final_vector (sha224_ctx_vector_t *ctx); DECLSPEC void sha224_final_vector (sha224_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1729,6 +1766,7 @@ typedef struct sha224_hmac_ctx_vector } sha224_hmac_ctx_vector_t; +DECLSPEC void sha224_hmac_init_vector_64 (sha224_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void sha224_hmac_init_vector_64 (sha224_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u32x t0[4]; @@ -1783,6 +1821,7 @@ DECLSPEC void sha224_hmac_init_vector_64 (sha224_hmac_ctx_vector_t *ctx, const u sha224_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void sha224_hmac_init_vector (sha224_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_hmac_init_vector (sha224_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1840,16 +1879,19 @@ DECLSPEC void sha224_hmac_init_vector (sha224_hmac_ctx_vector_t *ctx, const u32x sha224_hmac_init_vector_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha224_hmac_update_vector_64 (sha224_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void sha224_hmac_update_vector_64 (sha224_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { sha224_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void sha224_hmac_update_vector (sha224_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha224_hmac_update_vector (sha224_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { sha224_update_vector (&ctx->ipad, w, len); } +DECLSPEC void sha224_hmac_final_vector (sha224_hmac_ctx_vector_t *ctx); DECLSPEC void sha224_hmac_final_vector (sha224_hmac_ctx_vector_t *ctx) { sha224_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_sha256.cl b/OpenCL/inc_hash_sha256.cl index 756ae7c22..5563e95f8 100644 --- a/OpenCL/inc_hash_sha256.cl +++ b/OpenCL/inc_hash_sha256.cl @@ -37,6 +37,7 @@ typedef struct sha256_ctx } sha256_ctx_t; +DECLSPEC void sha256_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void sha256_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -128,6 +129,7 @@ DECLSPEC void sha256_transform (const u32 *w0, const u32 *w1, const u32 *w2, con digest[7] += h; } +DECLSPEC void sha256_init (sha256_ctx_t *ctx); DECLSPEC void sha256_init (sha256_ctx_t *ctx) { ctx->h[0] = SHA256M_A; @@ -159,6 +161,7 @@ DECLSPEC void sha256_init (sha256_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void sha256_update_64 (sha256_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void sha256_update_64 (sha256_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -233,6 +236,7 @@ DECLSPEC void sha256_update_64 (sha256_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u3 } } +DECLSPEC void sha256_update (sha256_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_update (sha256_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -285,6 +289,7 @@ DECLSPEC void sha256_update (sha256_ctx_t *ctx, const u32 *w, const int len) sha256_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha256_update_swap (sha256_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_update_swap (sha256_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -371,6 +376,7 @@ DECLSPEC void sha256_update_swap (sha256_ctx_t *ctx, const u32 *w, const int len sha256_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha256_update_utf16le (sha256_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_update_utf16le (sha256_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -413,6 +419,7 @@ DECLSPEC void sha256_update_utf16le (sha256_ctx_t *ctx, const u32 *w, const int sha256_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_update_utf16le_swap (sha256_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_update_utf16le_swap (sha256_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -489,6 +496,7 @@ DECLSPEC void sha256_update_utf16le_swap (sha256_ctx_t *ctx, const u32 *w, const sha256_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_update_global (sha256_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_update_global (sha256_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -541,6 +549,7 @@ DECLSPEC void sha256_update_global (sha256_ctx_t *ctx, const __global u32 *w, co sha256_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha256_update_global_swap (sha256_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_update_global_swap (sha256_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -627,6 +636,7 @@ DECLSPEC void sha256_update_global_swap (sha256_ctx_t *ctx, const __global u32 * sha256_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha256_update_global_utf16le (sha256_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_update_global_utf16le (sha256_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -669,6 +679,7 @@ DECLSPEC void sha256_update_global_utf16le (sha256_ctx_t *ctx, const __global u3 sha256_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_update_global_utf16le_swap (sha256_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_update_global_utf16le_swap (sha256_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -745,6 +756,7 @@ DECLSPEC void sha256_update_global_utf16le_swap (sha256_ctx_t *ctx, const __glob sha256_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_final (sha256_ctx_t *ctx); DECLSPEC void sha256_final (sha256_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -788,6 +800,7 @@ typedef struct sha256_hmac_ctx } sha256_hmac_ctx_t; +DECLSPEC void sha256_hmac_init_64 (sha256_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void sha256_hmac_init_64 (sha256_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u32 t0[4]; @@ -842,6 +855,7 @@ DECLSPEC void sha256_hmac_init_64 (sha256_hmac_ctx_t *ctx, const u32 *w0, const sha256_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void sha256_hmac_init (sha256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_hmac_init (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -899,6 +913,7 @@ DECLSPEC void sha256_hmac_init (sha256_hmac_ctx_t *ctx, const u32 *w, const int sha256_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha256_hmac_init_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_hmac_init_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -956,6 +971,7 @@ DECLSPEC void sha256_hmac_init_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const sha256_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha256_hmac_init_global (sha256_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha256_hmac_init_global (sha256_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1013,6 +1029,7 @@ DECLSPEC void sha256_hmac_init_global (sha256_hmac_ctx_t *ctx, __global const u3 sha256_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha256_hmac_init_global_swap (sha256_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha256_hmac_init_global_swap (sha256_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1070,51 +1087,61 @@ DECLSPEC void sha256_hmac_init_global_swap (sha256_hmac_ctx_t *ctx, __global con sha256_hmac_init_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha256_hmac_update_64 (sha256_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void sha256_hmac_update_64 (sha256_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { sha256_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void sha256_hmac_update (sha256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_hmac_update (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) { sha256_update (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_hmac_update_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) { sha256_update_swap (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_utf16le (sha256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_hmac_update_utf16le (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) { sha256_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_utf16le_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha256_hmac_update_utf16le_swap (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) { sha256_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_global (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_hmac_update_global (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha256_update_global (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_global_swap (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_hmac_update_global_swap (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha256_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_global_utf16le (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_hmac_update_global_utf16le (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha256_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_update_global_utf16le_swap (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha256_hmac_update_global_utf16le_swap (sha256_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha256_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_final (sha256_hmac_ctx_t *ctx); DECLSPEC void sha256_hmac_final (sha256_hmac_ctx_t *ctx) { sha256_final (&ctx->ipad); @@ -1161,6 +1188,7 @@ typedef struct sha256_ctx_vector } sha256_ctx_vector_t; +DECLSPEC void sha256_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest); DECLSPEC void sha256_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest) { u32x a = digest[0]; @@ -1252,6 +1280,7 @@ DECLSPEC void sha256_transform_vector (const u32x *w0, const u32x *w1, const u32 digest[7] += h; } +DECLSPEC void sha256_init_vector (sha256_ctx_vector_t *ctx); DECLSPEC void sha256_init_vector (sha256_ctx_vector_t *ctx) { ctx->h[0] = SHA256M_A; @@ -1283,6 +1312,7 @@ DECLSPEC void sha256_init_vector (sha256_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void sha256_init_vector_from_scalar (sha256_ctx_vector_t *ctx, sha256_ctx_t *ctx0); DECLSPEC void sha256_init_vector_from_scalar (sha256_ctx_vector_t *ctx, sha256_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -1314,6 +1344,7 @@ DECLSPEC void sha256_init_vector_from_scalar (sha256_ctx_vector_t *ctx, sha256_c ctx->len = ctx0->len; } +DECLSPEC void sha256_update_vector_64 (sha256_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void sha256_update_vector_64 (sha256_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -1388,6 +1419,7 @@ DECLSPEC void sha256_update_vector_64 (sha256_ctx_vector_t *ctx, u32x *w0, u32x } } +DECLSPEC void sha256_update_vector (sha256_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_update_vector (sha256_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1440,6 +1472,7 @@ DECLSPEC void sha256_update_vector (sha256_ctx_vector_t *ctx, const u32x *w, con sha256_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha256_update_vector_swap (sha256_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_update_vector_swap (sha256_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1526,6 +1559,7 @@ DECLSPEC void sha256_update_vector_swap (sha256_ctx_vector_t *ctx, const u32x *w sha256_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void sha256_update_vector_utf16le (sha256_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_update_vector_utf16le (sha256_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1568,6 +1602,7 @@ DECLSPEC void sha256_update_vector_utf16le (sha256_ctx_vector_t *ctx, const u32x sha256_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_update_vector_utf16le_swap (sha256_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_update_vector_utf16le_swap (sha256_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1644,6 +1679,7 @@ DECLSPEC void sha256_update_vector_utf16le_swap (sha256_ctx_vector_t *ctx, const sha256_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_update_vector_utf16beN (sha256_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_update_vector_utf16beN (sha256_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1686,6 +1722,7 @@ DECLSPEC void sha256_update_vector_utf16beN (sha256_ctx_vector_t *ctx, const u32 sha256_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void sha256_final_vector (sha256_ctx_vector_t *ctx); DECLSPEC void sha256_final_vector (sha256_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1729,6 +1766,7 @@ typedef struct sha256_hmac_ctx_vector } sha256_hmac_ctx_vector_t; +DECLSPEC void sha256_hmac_init_vector_64 (sha256_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void sha256_hmac_init_vector_64 (sha256_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u32x t0[4]; @@ -1783,6 +1821,7 @@ DECLSPEC void sha256_hmac_init_vector_64 (sha256_hmac_ctx_vector_t *ctx, const u sha256_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void sha256_hmac_init_vector (sha256_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_hmac_init_vector (sha256_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -1840,16 +1879,19 @@ DECLSPEC void sha256_hmac_init_vector (sha256_hmac_ctx_vector_t *ctx, const u32x sha256_hmac_init_vector_64 (ctx, w0, w1, w2, w3); } +DECLSPEC void sha256_hmac_update_vector_64 (sha256_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void sha256_hmac_update_vector_64 (sha256_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { sha256_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void sha256_hmac_update_vector (sha256_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha256_hmac_update_vector (sha256_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { sha256_update_vector (&ctx->ipad, w, len); } +DECLSPEC void sha256_hmac_final_vector (sha256_hmac_ctx_vector_t *ctx); DECLSPEC void sha256_hmac_final_vector (sha256_hmac_ctx_vector_t *ctx) { sha256_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_sha384.cl b/OpenCL/inc_hash_sha384.cl index c9ef4da53..e21cbdf44 100644 --- a/OpenCL/inc_hash_sha384.cl +++ b/OpenCL/inc_hash_sha384.cl @@ -45,6 +45,7 @@ typedef struct sha384_ctx } sha384_ctx_t; +DECLSPEC void sha384_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7, u64 *digest); DECLSPEC void sha384_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7, u64 *digest) { u64 a = digest[0]; @@ -136,6 +137,7 @@ DECLSPEC void sha384_transform (const u32 *w0, const u32 *w1, const u32 *w2, con digest[7] += h; } +DECLSPEC void sha384_init (sha384_ctx_t *ctx); DECLSPEC void sha384_init (sha384_ctx_t *ctx) { ctx->h[0] = SHA384M_A; @@ -183,6 +185,7 @@ DECLSPEC void sha384_init (sha384_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void sha384_update_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len); DECLSPEC void sha384_update_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len) { const int pos = ctx->len & 127; @@ -309,6 +312,7 @@ DECLSPEC void sha384_update_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u } } +DECLSPEC void sha384_update (sha384_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_update (sha384_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -397,6 +401,7 @@ DECLSPEC void sha384_update (sha384_ctx_t *ctx, const u32 *w, const int len) sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha384_update_swap (sha384_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_update_swap (sha384_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -551,6 +556,7 @@ DECLSPEC void sha384_update_swap (sha384_ctx_t *ctx, const u32 *w, const int len sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha384_update_utf16le (sha384_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_update_utf16le (sha384_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -617,6 +623,7 @@ DECLSPEC void sha384_update_utf16le (sha384_ctx_t *ctx, const u32 *w, const int sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_update_utf16le_swap (sha384_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_update_utf16le_swap (sha384_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -749,6 +756,7 @@ DECLSPEC void sha384_update_utf16le_swap (sha384_ctx_t *ctx, const u32 *w, const sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_update_global (sha384_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_update_global (sha384_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -837,6 +845,7 @@ DECLSPEC void sha384_update_global (sha384_ctx_t *ctx, const __global u32 *w, co sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha384_update_global_swap (sha384_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_update_global_swap (sha384_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -991,6 +1000,7 @@ DECLSPEC void sha384_update_global_swap (sha384_ctx_t *ctx, const __global u32 * sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha384_update_global_utf16le (sha384_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_update_global_utf16le (sha384_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1057,6 +1067,7 @@ DECLSPEC void sha384_update_global_utf16le (sha384_ctx_t *ctx, const __global u3 sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_update_global_utf16le_swap (sha384_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_update_global_utf16le_swap (sha384_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1189,6 +1200,7 @@ DECLSPEC void sha384_update_global_utf16le_swap (sha384_ctx_t *ctx, const __glob sha384_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_final (sha384_ctx_t *ctx); DECLSPEC void sha384_final (sha384_ctx_t *ctx) { const int pos = ctx->len & 127; @@ -1248,6 +1260,7 @@ typedef struct sha384_hmac_ctx } sha384_hmac_ctx_t; +DECLSPEC void sha384_hmac_init_128 (sha384_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7); DECLSPEC void sha384_hmac_init_128 (sha384_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7) { u32 t0[4]; @@ -1338,6 +1351,7 @@ DECLSPEC void sha384_hmac_init_128 (sha384_hmac_ctx_t *ctx, const u32 *w0, const sha384_update_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } +DECLSPEC void sha384_hmac_init (sha384_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_hmac_init (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1431,6 +1445,7 @@ DECLSPEC void sha384_hmac_init (sha384_hmac_ctx_t *ctx, const u32 *w, const int sha384_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha384_hmac_init_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_hmac_init_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1524,6 +1539,7 @@ DECLSPEC void sha384_hmac_init_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const sha384_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha384_hmac_init_global (sha384_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha384_hmac_init_global (sha384_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1617,6 +1633,7 @@ DECLSPEC void sha384_hmac_init_global (sha384_hmac_ctx_t *ctx, __global const u3 sha384_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha384_hmac_init_global_swap (sha384_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha384_hmac_init_global_swap (sha384_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1710,51 +1727,61 @@ DECLSPEC void sha384_hmac_init_global_swap (sha384_hmac_ctx_t *ctx, __global con sha384_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha384_hmac_update_128 (sha384_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len); DECLSPEC void sha384_hmac_update_128 (sha384_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len) { sha384_update_128 (&ctx->ipad, w0, w1, w2, w3, w4, w5, w6, w7, len); } +DECLSPEC void sha384_hmac_update (sha384_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_hmac_update (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) { sha384_update (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_hmac_update_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) { sha384_update_swap (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_utf16le (sha384_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_hmac_update_utf16le (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) { sha384_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_utf16le_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha384_hmac_update_utf16le_swap (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) { sha384_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_global (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_hmac_update_global (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha384_update_global (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_global_swap (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_hmac_update_global_swap (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha384_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_global_utf16le (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_hmac_update_global_utf16le (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha384_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_update_global_utf16le_swap (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha384_hmac_update_global_utf16le_swap (sha384_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha384_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_final (sha384_hmac_ctx_t *ctx); DECLSPEC void sha384_hmac_final (sha384_hmac_ctx_t *ctx) { sha384_final (&ctx->ipad); @@ -1825,6 +1852,7 @@ typedef struct sha384_ctx_vector } sha384_ctx_vector_t; +DECLSPEC void sha384_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7, u64x *digest); DECLSPEC void sha384_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7, u64x *digest) { u64x a = digest[0]; @@ -1916,6 +1944,7 @@ DECLSPEC void sha384_transform_vector (const u32x *w0, const u32x *w1, const u32 digest[7] += h; } +DECLSPEC void sha384_init_vector (sha384_ctx_vector_t *ctx); DECLSPEC void sha384_init_vector (sha384_ctx_vector_t *ctx) { ctx->h[0] = SHA384M_A; @@ -1963,6 +1992,7 @@ DECLSPEC void sha384_init_vector (sha384_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void sha384_init_vector_from_scalar (sha384_ctx_vector_t *ctx, sha384_ctx_t *ctx0); DECLSPEC void sha384_init_vector_from_scalar (sha384_ctx_vector_t *ctx, sha384_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -2010,6 +2040,7 @@ DECLSPEC void sha384_init_vector_from_scalar (sha384_ctx_vector_t *ctx, sha384_c ctx->len = ctx0->len; } +DECLSPEC void sha384_update_vector_128 (sha384_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len); DECLSPEC void sha384_update_vector_128 (sha384_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len) { const int pos = ctx->len & 127; @@ -2136,6 +2167,7 @@ DECLSPEC void sha384_update_vector_128 (sha384_ctx_vector_t *ctx, u32x *w0, u32x } } +DECLSPEC void sha384_update_vector (sha384_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_update_vector (sha384_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2224,6 +2256,7 @@ DECLSPEC void sha384_update_vector (sha384_ctx_vector_t *ctx, const u32x *w, con sha384_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha384_update_vector_swap (sha384_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_update_vector_swap (sha384_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2378,6 +2411,7 @@ DECLSPEC void sha384_update_vector_swap (sha384_ctx_vector_t *ctx, const u32x *w sha384_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha384_update_vector_utf16le (sha384_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_update_vector_utf16le (sha384_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2444,6 +2478,7 @@ DECLSPEC void sha384_update_vector_utf16le (sha384_ctx_vector_t *ctx, const u32x sha384_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_update_vector_utf16le_swap (sha384_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_update_vector_utf16le_swap (sha384_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2576,6 +2611,7 @@ DECLSPEC void sha384_update_vector_utf16le_swap (sha384_ctx_vector_t *ctx, const sha384_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_update_vector_utf16beN (sha384_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_update_vector_utf16beN (sha384_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2642,6 +2678,7 @@ DECLSPEC void sha384_update_vector_utf16beN (sha384_ctx_vector_t *ctx, const u32 sha384_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha384_final_vector (sha384_ctx_vector_t *ctx); DECLSPEC void sha384_final_vector (sha384_ctx_vector_t *ctx) { const int pos = ctx->len & 127; @@ -2701,6 +2738,7 @@ typedef struct sha384_hmac_ctx_vector } sha384_hmac_ctx_vector_t; +DECLSPEC void sha384_hmac_init_vector_128 (sha384_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7); DECLSPEC void sha384_hmac_init_vector_128 (sha384_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7) { u32x t0[4]; @@ -2791,6 +2829,7 @@ DECLSPEC void sha384_hmac_init_vector_128 (sha384_hmac_ctx_vector_t *ctx, const sha384_update_vector_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } +DECLSPEC void sha384_hmac_init_vector (sha384_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_hmac_init_vector (sha384_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2884,16 +2923,19 @@ DECLSPEC void sha384_hmac_init_vector (sha384_hmac_ctx_vector_t *ctx, const u32x sha384_hmac_init_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha384_hmac_update_vector_128 (sha384_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len); DECLSPEC void sha384_hmac_update_vector_128 (sha384_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len) { sha384_update_vector_128 (&ctx->ipad, w0, w1, w2, w3, w4, w5, w6, w7, len); } +DECLSPEC void sha384_hmac_update_vector (sha384_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha384_hmac_update_vector (sha384_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { sha384_update_vector (&ctx->ipad, w, len); } +DECLSPEC void sha384_hmac_final_vector (sha384_hmac_ctx_vector_t *ctx); DECLSPEC void sha384_hmac_final_vector (sha384_hmac_ctx_vector_t *ctx) { sha384_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_sha512.cl b/OpenCL/inc_hash_sha512.cl index aa3586498..6adb062b2 100644 --- a/OpenCL/inc_hash_sha512.cl +++ b/OpenCL/inc_hash_sha512.cl @@ -45,6 +45,7 @@ typedef struct sha512_ctx } sha512_ctx_t; +DECLSPEC void sha512_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7, u64 *digest); DECLSPEC void sha512_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7, u64 *digest) { u64 a = digest[0]; @@ -136,6 +137,7 @@ DECLSPEC void sha512_transform (const u32 *w0, const u32 *w1, const u32 *w2, con digest[7] += h; } +DECLSPEC void sha512_init (sha512_ctx_t *ctx); DECLSPEC void sha512_init (sha512_ctx_t *ctx) { ctx->h[0] = SHA512M_A; @@ -183,6 +185,7 @@ DECLSPEC void sha512_init (sha512_ctx_t *ctx) ctx->len = 0; } +DECLSPEC void sha512_update_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len); DECLSPEC void sha512_update_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len) { const int pos = ctx->len & 127; @@ -309,6 +312,7 @@ DECLSPEC void sha512_update_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u } } +DECLSPEC void sha512_update (sha512_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_update (sha512_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -397,6 +401,7 @@ DECLSPEC void sha512_update (sha512_ctx_t *ctx, const u32 *w, const int len) sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha512_update_swap (sha512_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_update_swap (sha512_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -551,6 +556,7 @@ DECLSPEC void sha512_update_swap (sha512_ctx_t *ctx, const u32 *w, const int len sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha512_update_utf16le (sha512_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_update_utf16le (sha512_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -617,6 +623,7 @@ DECLSPEC void sha512_update_utf16le (sha512_ctx_t *ctx, const u32 *w, const int sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_update_utf16le_swap (sha512_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_update_utf16le_swap (sha512_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -749,6 +756,7 @@ DECLSPEC void sha512_update_utf16le_swap (sha512_ctx_t *ctx, const u32 *w, const sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_update_global (sha512_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_update_global (sha512_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -837,6 +845,7 @@ DECLSPEC void sha512_update_global (sha512_ctx_t *ctx, const __global u32 *w, co sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha512_update_global_swap (sha512_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_update_global_swap (sha512_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -991,6 +1000,7 @@ DECLSPEC void sha512_update_global_swap (sha512_ctx_t *ctx, const __global u32 * sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha512_update_global_utf16le (sha512_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_update_global_utf16le (sha512_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1057,6 +1067,7 @@ DECLSPEC void sha512_update_global_utf16le (sha512_ctx_t *ctx, const __global u3 sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_update_global_utf16le_swap (sha512_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_update_global_utf16le_swap (sha512_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1189,6 +1200,7 @@ DECLSPEC void sha512_update_global_utf16le_swap (sha512_ctx_t *ctx, const __glob sha512_update_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_final (sha512_ctx_t *ctx); DECLSPEC void sha512_final (sha512_ctx_t *ctx) { const int pos = ctx->len & 127; @@ -1248,6 +1260,7 @@ typedef struct sha512_hmac_ctx } sha512_hmac_ctx_t; +DECLSPEC void sha512_hmac_init_128 (sha512_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7); DECLSPEC void sha512_hmac_init_128 (sha512_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, const u32 *w4, const u32 *w5, const u32 *w6, const u32 *w7) { u32 t0[4]; @@ -1338,6 +1351,7 @@ DECLSPEC void sha512_hmac_init_128 (sha512_hmac_ctx_t *ctx, const u32 *w0, const sha512_update_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } +DECLSPEC void sha512_hmac_init (sha512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_hmac_init (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1431,6 +1445,7 @@ DECLSPEC void sha512_hmac_init (sha512_hmac_ctx_t *ctx, const u32 *w, const int sha512_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha512_hmac_init_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_hmac_init_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1524,6 +1539,7 @@ DECLSPEC void sha512_hmac_init_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const sha512_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha512_hmac_init_global (sha512_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha512_hmac_init_global (sha512_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1617,6 +1633,7 @@ DECLSPEC void sha512_hmac_init_global (sha512_hmac_ctx_t *ctx, __global const u3 sha512_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha512_hmac_init_global_swap (sha512_hmac_ctx_t *ctx, __global const u32 *w, const int len); DECLSPEC void sha512_hmac_init_global_swap (sha512_hmac_ctx_t *ctx, __global const u32 *w, const int len) { u32 w0[4]; @@ -1710,51 +1727,61 @@ DECLSPEC void sha512_hmac_init_global_swap (sha512_hmac_ctx_t *ctx, __global con sha512_hmac_init_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha512_hmac_update_128 (sha512_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len); DECLSPEC void sha512_hmac_update_128 (sha512_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len) { sha512_update_128 (&ctx->ipad, w0, w1, w2, w3, w4, w5, w6, w7, len); } +DECLSPEC void sha512_hmac_update (sha512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_hmac_update (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) { sha512_update (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_hmac_update_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) { sha512_update_swap (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_utf16le (sha512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_hmac_update_utf16le (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) { sha512_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_utf16le_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void sha512_hmac_update_utf16le_swap (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) { sha512_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_global (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_hmac_update_global (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha512_update_global (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_global_swap (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_hmac_update_global_swap (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha512_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_global_utf16le (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_hmac_update_global_utf16le (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha512_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_update_global_utf16le_swap (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void sha512_hmac_update_global_utf16le_swap (sha512_hmac_ctx_t *ctx, const __global u32 *w, const int len) { sha512_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_final (sha512_hmac_ctx_t *ctx); DECLSPEC void sha512_hmac_final (sha512_hmac_ctx_t *ctx) { sha512_final (&ctx->ipad); @@ -1825,6 +1852,7 @@ typedef struct sha512_ctx_vector } sha512_ctx_vector_t; +DECLSPEC void sha512_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7, u64x *digest); DECLSPEC void sha512_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7, u64x *digest) { u64x a = digest[0]; @@ -1916,6 +1944,7 @@ DECLSPEC void sha512_transform_vector (const u32x *w0, const u32x *w1, const u32 digest[7] += h; } +DECLSPEC void sha512_init_vector (sha512_ctx_vector_t *ctx); DECLSPEC void sha512_init_vector (sha512_ctx_vector_t *ctx) { ctx->h[0] = SHA512M_A; @@ -1963,6 +1992,7 @@ DECLSPEC void sha512_init_vector (sha512_ctx_vector_t *ctx) ctx->len = 0; } +DECLSPEC void sha512_init_vector_from_scalar (sha512_ctx_vector_t *ctx, sha512_ctx_t *ctx0); DECLSPEC void sha512_init_vector_from_scalar (sha512_ctx_vector_t *ctx, sha512_ctx_t *ctx0) { ctx->h[0] = ctx0->h[0]; @@ -2010,6 +2040,7 @@ DECLSPEC void sha512_init_vector_from_scalar (sha512_ctx_vector_t *ctx, sha512_c ctx->len = ctx0->len; } +DECLSPEC void sha512_update_vector_128 (sha512_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len); DECLSPEC void sha512_update_vector_128 (sha512_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len) { const int pos = ctx->len & 127; @@ -2136,6 +2167,7 @@ DECLSPEC void sha512_update_vector_128 (sha512_ctx_vector_t *ctx, u32x *w0, u32x } } +DECLSPEC void sha512_update_vector (sha512_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_update_vector (sha512_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2224,6 +2256,7 @@ DECLSPEC void sha512_update_vector (sha512_ctx_vector_t *ctx, const u32x *w, con sha512_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha512_update_vector_swap (sha512_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_update_vector_swap (sha512_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2378,6 +2411,7 @@ DECLSPEC void sha512_update_vector_swap (sha512_ctx_vector_t *ctx, const u32x *w sha512_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1); } +DECLSPEC void sha512_update_vector_utf16le (sha512_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_update_vector_utf16le (sha512_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2444,6 +2478,7 @@ DECLSPEC void sha512_update_vector_utf16le (sha512_ctx_vector_t *ctx, const u32x sha512_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_update_vector_utf16le_swap (sha512_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_update_vector_utf16le_swap (sha512_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2576,6 +2611,7 @@ DECLSPEC void sha512_update_vector_utf16le_swap (sha512_ctx_vector_t *ctx, const sha512_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_update_vector_utf16beN (sha512_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_update_vector_utf16beN (sha512_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2642,6 +2678,7 @@ DECLSPEC void sha512_update_vector_utf16beN (sha512_ctx_vector_t *ctx, const u32 sha512_update_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, (len - pos1) * 2); } +DECLSPEC void sha512_final_vector (sha512_ctx_vector_t *ctx); DECLSPEC void sha512_final_vector (sha512_ctx_vector_t *ctx) { const int pos = ctx->len & 127; @@ -2701,6 +2738,7 @@ typedef struct sha512_hmac_ctx_vector } sha512_hmac_ctx_vector_t; +DECLSPEC void sha512_hmac_init_vector_128 (sha512_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7); DECLSPEC void sha512_hmac_init_vector_128 (sha512_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x *w4, const u32x *w5, const u32x *w6, const u32x *w7) { u32x t0[4]; @@ -2791,6 +2829,7 @@ DECLSPEC void sha512_hmac_init_vector_128 (sha512_hmac_ctx_vector_t *ctx, const sha512_update_vector_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } +DECLSPEC void sha512_hmac_init_vector (sha512_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_hmac_init_vector (sha512_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2884,16 +2923,19 @@ DECLSPEC void sha512_hmac_init_vector (sha512_hmac_ctx_vector_t *ctx, const u32x sha512_hmac_init_vector_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7); } +DECLSPEC void sha512_hmac_update_vector_128 (sha512_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len); DECLSPEC void sha512_hmac_update_vector_128 (sha512_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, const int len) { sha512_update_vector_128 (&ctx->ipad, w0, w1, w2, w3, w4, w5, w6, w7, len); } +DECLSPEC void sha512_hmac_update_vector (sha512_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void sha512_hmac_update_vector (sha512_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { sha512_update_vector (&ctx->ipad, w, len); } +DECLSPEC void sha512_hmac_final_vector (sha512_hmac_ctx_vector_t *ctx); DECLSPEC void sha512_hmac_final_vector (sha512_hmac_ctx_vector_t *ctx) { sha512_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_streebog256.cl b/OpenCL/inc_hash_streebog256.cl index f58be0b09..69196eba1 100644 --- a/OpenCL/inc_hash_streebog256.cl +++ b/OpenCL/inc_hash_streebog256.cl @@ -634,6 +634,7 @@ typedef struct streebog256_ctx } streebog256_ctx_t; +DECLSPEC void streebog256_init (streebog256_ctx_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_init (streebog256_ctx_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]) { ctx->h[0] = 0x0101010101010101; @@ -688,6 +689,7 @@ DECLSPEC void streebog256_init (streebog256_ctx_t *ctx, SHM_TYPE u64a (*s_sbob_s ctx->s_sbob_sl64 = s_sbob_sl64; } +DECLSPEC void streebog256_add (u64 *x, const u64 *y); DECLSPEC void streebog256_add (u64 *x, const u64 *y) { u64 carry = 0; @@ -707,6 +709,7 @@ DECLSPEC void streebog256_add (u64 *x, const u64 *y) } } +DECLSPEC void streebog256_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u64 k[8]; @@ -775,6 +778,7 @@ DECLSPEC void streebog256_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a ( } } +DECLSPEC void streebog256_transform (streebog256_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void streebog256_transform (streebog256_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u64 m[8]; @@ -797,6 +801,7 @@ DECLSPEC void streebog256_transform (streebog256_ctx_t *ctx, const u32 *w0, cons streebog256_add (ctx->s, m); } +DECLSPEC void streebog256_update_64 (streebog256_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void streebog256_update_64 (streebog256_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len; @@ -873,6 +878,7 @@ DECLSPEC void streebog256_update_64 (streebog256_ctx_t *ctx, u32 *w0, u32 *w1, u } } +DECLSPEC void streebog256_update (streebog256_ctx_t *ctx, const u32 *w, int len); DECLSPEC void streebog256_update (streebog256_ctx_t *ctx, const u32 *w, int len) { u32 w0[4]; @@ -930,6 +936,7 @@ DECLSPEC void streebog256_update (streebog256_ctx_t *ctx, const u32 *w, int len) } } +DECLSPEC void streebog256_update_swap (streebog256_ctx_t *ctx, const u32 *w, int len); DECLSPEC void streebog256_update_swap (streebog256_ctx_t *ctx, const u32 *w, int len) { u32 w0[4]; @@ -987,6 +994,7 @@ DECLSPEC void streebog256_update_swap (streebog256_ctx_t *ctx, const u32 *w, int } } +DECLSPEC void streebog256_update_global_swap (streebog256_ctx_t *ctx, const __global u32 *w, int len); DECLSPEC void streebog256_update_global_swap (streebog256_ctx_t *ctx, const __global u32 *w, int len) { u32 w0[4]; @@ -1044,6 +1052,7 @@ DECLSPEC void streebog256_update_global_swap (streebog256_ctx_t *ctx, const __gl } } +DECLSPEC void streebog256_final (streebog256_ctx_t *ctx); DECLSPEC void streebog256_final (streebog256_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -1084,6 +1093,7 @@ typedef struct streebog256_hmac_ctx } streebog256_hmac_ctx_t; +DECLSPEC void streebog256_hmac_init_64 (streebog256_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_hmac_init_64 (streebog256_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32 t0[4]; @@ -1138,6 +1148,7 @@ DECLSPEC void streebog256_hmac_init_64 (streebog256_hmac_ctx_t *ctx, const u32 * streebog256_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void streebog256_hmac_init (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_hmac_init (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32 w0[4]; @@ -1195,6 +1206,7 @@ DECLSPEC void streebog256_hmac_init (streebog256_hmac_ctx_t *ctx, const u32 *w, streebog256_hmac_init_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog256_hmac_init_swap (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_hmac_init_swap (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32 w0[4]; @@ -1252,26 +1264,31 @@ DECLSPEC void streebog256_hmac_init_swap (streebog256_hmac_ctx_t *ctx, const u32 streebog256_hmac_init_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog256_hmac_update_64 (streebog256_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void streebog256_hmac_update_64 (streebog256_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { streebog256_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void streebog256_hmac_update (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void streebog256_hmac_update (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len) { streebog256_update (&ctx->ipad, w, len); } +DECLSPEC void streebog256_hmac_update_swap (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void streebog256_hmac_update_swap (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len) { streebog256_update_swap (&ctx->ipad, w, len); } +DECLSPEC void streebog256_hmac_update_global_swap (streebog256_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void streebog256_hmac_update_global_swap (streebog256_hmac_ctx_t *ctx, const __global u32 *w, const int len) { streebog256_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void streebog256_hmac_final (streebog256_hmac_ctx_t *ctx); DECLSPEC void streebog256_hmac_final (streebog256_hmac_ctx_t *ctx) { streebog256_final (&ctx->ipad); @@ -1322,6 +1339,7 @@ typedef struct streebog256_ctx_vector } streebog256_ctx_vector_t; +DECLSPEC void streebog256_init_vector (streebog256_ctx_vector_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_init_vector (streebog256_ctx_vector_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]) { ctx->h[0] = 0x0101010101010101; @@ -1376,6 +1394,7 @@ DECLSPEC void streebog256_init_vector (streebog256_ctx_vector_t *ctx, SHM_TYPE u ctx->s_sbob_sl64 = s_sbob_sl64; } +DECLSPEC void streebog256_add_vector (u64x *x, const u64x *y); DECLSPEC void streebog256_add_vector (u64x *x, const u64x *y) { u64x carry = 0; @@ -1395,6 +1414,7 @@ DECLSPEC void streebog256_add_vector (u64x *x, const u64x *y) } } +DECLSPEC void streebog256_g_vector (u64x *h, const u64x *n, const u64x *m, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_g_vector (u64x *h, const u64x *n, const u64x *m, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u64x k[8]; @@ -1463,6 +1483,7 @@ DECLSPEC void streebog256_g_vector (u64x *h, const u64x *n, const u64x *m, SHM_T } } +DECLSPEC void streebog256_transform_vector (streebog256_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void streebog256_transform_vector (streebog256_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u64x m[8]; @@ -1485,6 +1506,7 @@ DECLSPEC void streebog256_transform_vector (streebog256_ctx_vector_t *ctx, const streebog256_add_vector (ctx->s, m); } +DECLSPEC void streebog256_update_vector_64 (streebog256_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void streebog256_update_vector_64 (streebog256_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len; @@ -1561,6 +1583,7 @@ DECLSPEC void streebog256_update_vector_64 (streebog256_ctx_vector_t *ctx, u32x } } +DECLSPEC void streebog256_update_vector (streebog256_ctx_vector_t *ctx, const u32x *w, int len); DECLSPEC void streebog256_update_vector (streebog256_ctx_vector_t *ctx, const u32x *w, int len) { u32x w0[4]; @@ -1618,6 +1641,7 @@ DECLSPEC void streebog256_update_vector (streebog256_ctx_vector_t *ctx, const u3 } } +DECLSPEC void streebog256_update_vector_swap (streebog256_ctx_vector_t *ctx, const u32x *w, int len); DECLSPEC void streebog256_update_vector_swap (streebog256_ctx_vector_t *ctx, const u32x *w, int len) { u32x w0[4]; @@ -1675,6 +1699,7 @@ DECLSPEC void streebog256_update_vector_swap (streebog256_ctx_vector_t *ctx, con } } +DECLSPEC void streebog256_final_vector (streebog256_ctx_vector_t *ctx); DECLSPEC void streebog256_final_vector (streebog256_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1715,6 +1740,7 @@ typedef struct streebog256_hmac_ctx_vector } streebog256_hmac_ctx_vector_t; +DECLSPEC void streebog256_hmac_init_vector_64 (streebog256_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_hmac_init_vector_64 (streebog256_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32x t0[4]; @@ -1769,6 +1795,7 @@ DECLSPEC void streebog256_hmac_init_vector_64 (streebog256_hmac_ctx_vector_t *ct streebog256_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void streebog256_hmac_init_vector (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_hmac_init_vector (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32x w0[4]; @@ -1826,6 +1853,7 @@ DECLSPEC void streebog256_hmac_init_vector (streebog256_hmac_ctx_vector_t *ctx, streebog256_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog256_hmac_init_vector_swap (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog256_hmac_init_vector_swap (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32x w0[4]; @@ -1883,16 +1911,19 @@ DECLSPEC void streebog256_hmac_init_vector_swap (streebog256_hmac_ctx_vector_t * streebog256_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog256_hmac_update_vector (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void streebog256_hmac_update_vector (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { streebog256_update_vector (&ctx->ipad, w, len); } +DECLSPEC void streebog256_hmac_update_vector_swap (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void streebog256_hmac_update_vector_swap (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { streebog256_update_vector_swap (&ctx->ipad, w, len); } +DECLSPEC void streebog256_hmac_final_vector (streebog256_hmac_ctx_vector_t *ctx); DECLSPEC void streebog256_hmac_final_vector (streebog256_hmac_ctx_vector_t *ctx) { streebog256_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_streebog512.cl b/OpenCL/inc_hash_streebog512.cl index 940706d0e..b4ef00eaf 100644 --- a/OpenCL/inc_hash_streebog512.cl +++ b/OpenCL/inc_hash_streebog512.cl @@ -634,6 +634,7 @@ typedef struct streebog512_ctx } streebog512_ctx_t; +DECLSPEC void streebog512_init (streebog512_ctx_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_init (streebog512_ctx_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]) { ctx->h[0] = 0; @@ -688,6 +689,7 @@ DECLSPEC void streebog512_init (streebog512_ctx_t *ctx, SHM_TYPE u64a (*s_sbob_s ctx->s_sbob_sl64 = s_sbob_sl64; } +DECLSPEC void streebog512_add (u64 *x, const u64 *y); DECLSPEC void streebog512_add (u64 *x, const u64 *y) { u64 carry = 0; @@ -707,6 +709,7 @@ DECLSPEC void streebog512_add (u64 *x, const u64 *y) } } +DECLSPEC void streebog512_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u64 k[8]; @@ -775,6 +778,7 @@ DECLSPEC void streebog512_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a ( } } +DECLSPEC void streebog512_transform (streebog512_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3); DECLSPEC void streebog512_transform (streebog512_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3) { u64 m[8]; @@ -797,6 +801,7 @@ DECLSPEC void streebog512_transform (streebog512_ctx_t *ctx, const u32 *w0, cons streebog512_add (ctx->s, m); } +DECLSPEC void streebog512_update_64 (streebog512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void streebog512_update_64 (streebog512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len; @@ -873,6 +878,7 @@ DECLSPEC void streebog512_update_64 (streebog512_ctx_t *ctx, u32 *w0, u32 *w1, u } } +DECLSPEC void streebog512_update (streebog512_ctx_t *ctx, const u32 *w, int len); DECLSPEC void streebog512_update (streebog512_ctx_t *ctx, const u32 *w, int len) { u32 w0[4]; @@ -930,6 +936,7 @@ DECLSPEC void streebog512_update (streebog512_ctx_t *ctx, const u32 *w, int len) } } +DECLSPEC void streebog512_update_swap (streebog512_ctx_t *ctx, const u32 *w, int len); DECLSPEC void streebog512_update_swap (streebog512_ctx_t *ctx, const u32 *w, int len) { u32 w0[4]; @@ -987,6 +994,7 @@ DECLSPEC void streebog512_update_swap (streebog512_ctx_t *ctx, const u32 *w, int } } +DECLSPEC void streebog512_update_global_swap (streebog512_ctx_t *ctx, const __global u32 *w, int len); DECLSPEC void streebog512_update_global_swap (streebog512_ctx_t *ctx, const __global u32 *w, int len) { u32 w0[4]; @@ -1044,6 +1052,7 @@ DECLSPEC void streebog512_update_global_swap (streebog512_ctx_t *ctx, const __gl } } +DECLSPEC void streebog512_final (streebog512_ctx_t *ctx); DECLSPEC void streebog512_final (streebog512_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -1084,6 +1093,7 @@ typedef struct streebog512_hmac_ctx } streebog512_hmac_ctx_t; +DECLSPEC void streebog512_hmac_init_64 (streebog512_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_hmac_init_64 (streebog512_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32 t0[4]; @@ -1138,6 +1148,7 @@ DECLSPEC void streebog512_hmac_init_64 (streebog512_hmac_ctx_t *ctx, const u32 * streebog512_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void streebog512_hmac_init (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_hmac_init (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32 w0[4]; @@ -1195,6 +1206,7 @@ DECLSPEC void streebog512_hmac_init (streebog512_hmac_ctx_t *ctx, const u32 *w, streebog512_hmac_init_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog512_hmac_init_swap (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_hmac_init_swap (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32 w0[4]; @@ -1252,26 +1264,31 @@ DECLSPEC void streebog512_hmac_init_swap (streebog512_hmac_ctx_t *ctx, const u32 streebog512_hmac_init_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog512_hmac_update_64 (streebog512_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void streebog512_hmac_update_64 (streebog512_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { streebog512_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void streebog512_hmac_update (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void streebog512_hmac_update (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len) { streebog512_update (&ctx->ipad, w, len); } +DECLSPEC void streebog512_hmac_update_swap (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void streebog512_hmac_update_swap (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len) { streebog512_update_swap (&ctx->ipad, w, len); } +DECLSPEC void streebog512_hmac_update_global_swap (streebog512_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void streebog512_hmac_update_global_swap (streebog512_hmac_ctx_t *ctx, const __global u32 *w, const int len) { streebog512_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void streebog512_hmac_final (streebog512_hmac_ctx_t *ctx); DECLSPEC void streebog512_hmac_final (streebog512_hmac_ctx_t *ctx) { streebog512_final (&ctx->ipad); @@ -1322,6 +1339,7 @@ typedef struct streebog512_ctx_vector } streebog512_ctx_vector_t; +DECLSPEC void streebog512_init_vector (streebog512_ctx_vector_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_init_vector (streebog512_ctx_vector_t *ctx, SHM_TYPE u64a (*s_sbob_sl64)[256]) { ctx->h[0] = 0; @@ -1376,6 +1394,7 @@ DECLSPEC void streebog512_init_vector (streebog512_ctx_vector_t *ctx, SHM_TYPE u ctx->s_sbob_sl64 = s_sbob_sl64; } +DECLSPEC void streebog512_add_vector (u64x *x, const u64x *y); DECLSPEC void streebog512_add_vector (u64x *x, const u64x *y) { u64x carry = 0; @@ -1395,6 +1414,7 @@ DECLSPEC void streebog512_add_vector (u64x *x, const u64x *y) } } +DECLSPEC void streebog512_g_vector (u64x *h, const u64x *n, const u64x *m, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_g_vector (u64x *h, const u64x *n, const u64x *m, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u64x k[8]; @@ -1463,6 +1483,7 @@ DECLSPEC void streebog512_g_vector (u64x *h, const u64x *n, const u64x *m, SHM_T } } +DECLSPEC void streebog512_transform_vector (streebog512_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3); DECLSPEC void streebog512_transform_vector (streebog512_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3) { u64x m[8]; @@ -1485,6 +1506,7 @@ DECLSPEC void streebog512_transform_vector (streebog512_ctx_vector_t *ctx, const streebog512_add_vector (ctx->s, m); } +DECLSPEC void streebog512_update_vector_64 (streebog512_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void streebog512_update_vector_64 (streebog512_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len; @@ -1561,6 +1583,7 @@ DECLSPEC void streebog512_update_vector_64 (streebog512_ctx_vector_t *ctx, u32x } } +DECLSPEC void streebog512_update_vector (streebog512_ctx_vector_t *ctx, const u32x *w, int len); DECLSPEC void streebog512_update_vector (streebog512_ctx_vector_t *ctx, const u32x *w, int len) { u32x w0[4]; @@ -1618,6 +1641,7 @@ DECLSPEC void streebog512_update_vector (streebog512_ctx_vector_t *ctx, const u3 } } +DECLSPEC void streebog512_update_vector_swap (streebog512_ctx_vector_t *ctx, const u32x *w, int len); DECLSPEC void streebog512_update_vector_swap (streebog512_ctx_vector_t *ctx, const u32x *w, int len) { u32x w0[4]; @@ -1675,6 +1699,7 @@ DECLSPEC void streebog512_update_vector_swap (streebog512_ctx_vector_t *ctx, con } } +DECLSPEC void streebog512_final_vector (streebog512_ctx_vector_t *ctx); DECLSPEC void streebog512_final_vector (streebog512_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -1715,6 +1740,7 @@ typedef struct streebog512_hmac_ctx_vector } streebog512_hmac_ctx_vector_t; +DECLSPEC void streebog512_hmac_init_vector_64 (streebog512_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_hmac_init_vector_64 (streebog512_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32x t0[4]; @@ -1769,6 +1795,7 @@ DECLSPEC void streebog512_hmac_init_vector_64 (streebog512_hmac_ctx_vector_t *ct streebog512_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } +DECLSPEC void streebog512_hmac_init_vector (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_hmac_init_vector (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32x w0[4]; @@ -1826,6 +1853,7 @@ DECLSPEC void streebog512_hmac_init_vector (streebog512_hmac_ctx_vector_t *ctx, streebog512_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog512_hmac_init_vector_swap (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]); DECLSPEC void streebog512_hmac_init_vector_swap (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) { u32x w0[4]; @@ -1883,16 +1911,19 @@ DECLSPEC void streebog512_hmac_init_vector_swap (streebog512_hmac_ctx_vector_t * streebog512_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_sbob_sl64); } +DECLSPEC void streebog512_hmac_update_vector (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void streebog512_hmac_update_vector (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { streebog512_update_vector (&ctx->ipad, w, len); } +DECLSPEC void streebog512_hmac_update_vector_swap (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void streebog512_hmac_update_vector_swap (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { streebog512_update_vector_swap (&ctx->ipad, w, len); } +DECLSPEC void streebog512_hmac_final_vector (streebog512_hmac_ctx_vector_t *ctx); DECLSPEC void streebog512_hmac_final_vector (streebog512_hmac_ctx_vector_t *ctx) { streebog512_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_hash_whirlpool.cl b/OpenCL/inc_hash_whirlpool.cl index 7a44a3e71..dd63df9f3 100644 --- a/OpenCL/inc_hash_whirlpool.cl +++ b/OpenCL/inc_hash_whirlpool.cl @@ -1125,12 +1125,13 @@ typedef struct whirlpool_ctx int len; - __local u32 (*s_Ch)[256]; - __local u32 (*s_Cl)[256]; + SHM_TYPE u32 (*s_Ch)[256]; + SHM_TYPE u32 (*s_Cl)[256]; } whirlpool_ctx_t; -DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32 Kh[8]; u32 Kl[8]; @@ -1300,7 +1301,8 @@ DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, digest[15] ^= statel[7] ^ w3[3]; } -DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { ctx->h[ 0] = 0; ctx->h[ 1] = 0; @@ -1342,6 +1344,7 @@ DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, __local u32 (*s_Ch)[256], __ ctx->s_Cl = s_Cl; } +DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { const int pos = ctx->len & 63; @@ -1416,6 +1419,7 @@ DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 * } } +DECLSPEC void whirlpool_update (whirlpool_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_update (whirlpool_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1468,6 +1472,7 @@ DECLSPEC void whirlpool_update (whirlpool_ctx_t *ctx, const u32 *w, const int le whirlpool_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void whirlpool_update_swap (whirlpool_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_update_swap (whirlpool_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1554,6 +1559,7 @@ DECLSPEC void whirlpool_update_swap (whirlpool_ctx_t *ctx, const u32 *w, const i whirlpool_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void whirlpool_update_utf16le (whirlpool_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_update_utf16le (whirlpool_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1596,6 +1602,7 @@ DECLSPEC void whirlpool_update_utf16le (whirlpool_ctx_t *ctx, const u32 *w, cons whirlpool_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void whirlpool_update_utf16le_swap (whirlpool_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_update_utf16le_swap (whirlpool_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; @@ -1672,6 +1679,7 @@ DECLSPEC void whirlpool_update_utf16le_swap (whirlpool_ctx_t *ctx, const u32 *w, whirlpool_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void whirlpool_update_global (whirlpool_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_update_global (whirlpool_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1724,6 +1732,7 @@ DECLSPEC void whirlpool_update_global (whirlpool_ctx_t *ctx, const __global u32 whirlpool_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void whirlpool_update_global_swap (whirlpool_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_update_global_swap (whirlpool_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1810,6 +1819,7 @@ DECLSPEC void whirlpool_update_global_swap (whirlpool_ctx_t *ctx, const __global whirlpool_update_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void whirlpool_update_global_utf16le (whirlpool_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_update_global_utf16le (whirlpool_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1852,6 +1862,7 @@ DECLSPEC void whirlpool_update_global_utf16le (whirlpool_ctx_t *ctx, const __glo whirlpool_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void whirlpool_update_global_utf16le_swap (whirlpool_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_update_global_utf16le_swap (whirlpool_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; @@ -1928,6 +1939,7 @@ DECLSPEC void whirlpool_update_global_utf16le_swap (whirlpool_ctx_t *ctx, const whirlpool_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void whirlpool_final (whirlpool_ctx_t *ctx); DECLSPEC void whirlpool_final (whirlpool_ctx_t *ctx) { const int pos = ctx->len & 63; @@ -1971,7 +1983,8 @@ typedef struct whirlpool_hmac_ctx } whirlpool_hmac_ctx_t; -DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32 t0[4]; u32 t1[4]; @@ -2025,7 +2038,8 @@ DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, whirlpool_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } -DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32 w0[4]; u32 w1[4]; @@ -2082,7 +2096,8 @@ DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, cons whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); } -DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32 w0[4]; u32 w1[4]; @@ -2139,7 +2154,8 @@ DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); } -DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, __global const u32 *w, const int len, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, __global const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, __global const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32 w0[4]; u32 w1[4]; @@ -2196,7 +2212,8 @@ DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, __global co whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); } -DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, __global const u32 *w, const int len, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, __global const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, __global const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32 w0[4]; u32 w1[4]; @@ -2253,51 +2270,61 @@ DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, __glob whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); } +DECLSPEC void whirlpool_hmac_update_64 (whirlpool_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void whirlpool_hmac_update_64 (whirlpool_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) { whirlpool_update_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void whirlpool_hmac_update (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_hmac_update (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len) { whirlpool_update (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len) { whirlpool_update_swap (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_utf16le (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_utf16le (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len) { whirlpool_update_utf16le (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_utf16le_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_utf16le_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len) { whirlpool_update_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_global (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_global (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len) { whirlpool_update_global (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_global_swap (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_global_swap (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len) { whirlpool_update_global_swap (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_global_utf16le (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_global_utf16le (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len) { whirlpool_update_global_utf16le (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_update_global_utf16le_swap (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_global_utf16le_swap (whirlpool_hmac_ctx_t *ctx, const __global u32 *w, const int len) { whirlpool_update_global_utf16le_swap (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_final (whirlpool_hmac_ctx_t *ctx); DECLSPEC void whirlpool_hmac_final (whirlpool_hmac_ctx_t *ctx) { whirlpool_final (&ctx->ipad); @@ -2342,12 +2369,13 @@ typedef struct whirlpool_ctx_vector int len; - __local u32 (*s_Ch)[256]; - __local u32 (*s_Cl)[256]; + SHM_TYPE u32 (*s_Ch)[256]; + SHM_TYPE u32 (*s_Cl)[256]; } whirlpool_ctx_vector_t; -DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32x Kh[8]; u32x Kl[8]; @@ -2517,7 +2545,8 @@ DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const digest[15] ^= statel[7] ^ w3[3]; } -DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { ctx->h[ 0] = 0; ctx->h[ 1] = 0; @@ -2559,6 +2588,7 @@ DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, __local u32 (* ctx->s_Cl = s_Cl; } +DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, whirlpool_ctx_t *ctx0); DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, whirlpool_ctx_t *ctx0) { ctx->h[ 0] = ctx0->h[ 0]; @@ -2601,6 +2631,7 @@ DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, wh ctx->s_Cl = ctx0->s_Cl; } +DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { const int pos = ctx->len & 63; @@ -2675,6 +2706,7 @@ DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, } } +DECLSPEC void whirlpool_update_vector (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_update_vector (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2727,6 +2759,7 @@ DECLSPEC void whirlpool_update_vector (whirlpool_ctx_vector_t *ctx, const u32x * whirlpool_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void whirlpool_update_vector_swap (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_update_vector_swap (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2813,6 +2846,7 @@ DECLSPEC void whirlpool_update_vector_swap (whirlpool_ctx_vector_t *ctx, const u whirlpool_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } +DECLSPEC void whirlpool_update_vector_utf16le (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_update_vector_utf16le (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2855,6 +2889,7 @@ DECLSPEC void whirlpool_update_vector_utf16le (whirlpool_ctx_vector_t *ctx, cons whirlpool_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void whirlpool_update_vector_utf16le_swap (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_update_vector_utf16le_swap (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; @@ -2931,6 +2966,7 @@ DECLSPEC void whirlpool_update_vector_utf16le_swap (whirlpool_ctx_vector_t *ctx, whirlpool_update_vector_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } +DECLSPEC void whirlpool_final_vector (whirlpool_ctx_vector_t *ctx); DECLSPEC void whirlpool_final_vector (whirlpool_ctx_vector_t *ctx) { const int pos = ctx->len & 63; @@ -2974,7 +3010,8 @@ typedef struct whirlpool_hmac_ctx_vector } whirlpool_hmac_ctx_vector_t; -DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32x t0[4]; u32x t1[4]; @@ -3028,7 +3065,8 @@ DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, c whirlpool_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } -DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { u32x w0[4]; u32x w1[4]; @@ -3085,16 +3123,19 @@ DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, cons whirlpool_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); } +DECLSPEC void whirlpool_hmac_update_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void whirlpool_hmac_update_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) { whirlpool_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); } +DECLSPEC void whirlpool_hmac_update_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_hmac_update_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len) { whirlpool_update_vector (&ctx->ipad, w, len); } +DECLSPEC void whirlpool_hmac_final_vector (whirlpool_hmac_ctx_vector_t *ctx); DECLSPEC void whirlpool_hmac_final_vector (whirlpool_hmac_ctx_vector_t *ctx) { whirlpool_final_vector (&ctx->ipad); diff --git a/OpenCL/inc_luks_aes.cl b/OpenCL/inc_luks_aes.cl index d47a9492a..29929b5b7 100644 --- a/OpenCL/inc_luks_aes.cl +++ b/OpenCL/inc_luks_aes.cl @@ -1,6 +1,7 @@ // cbc-essiv +DECLSPEC void aes128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { aes128_decrypt (ks1, in, out, s_td0, s_td1, s_td2, s_td3, s_td4); @@ -16,6 +17,7 @@ DECLSPEC void aes128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 * essiv[3] = in[3]; } +DECLSPEC void aes256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { aes256_decrypt (ks1, in, out, s_td0, s_td1, s_td2, s_td3, s_td4); @@ -31,6 +33,7 @@ DECLSPEC void aes256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 * essiv[3] = in[3]; } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -65,6 +68,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128 (__global const u32 *in, u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -102,6 +106,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha1 (__global const u32 * } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -162,6 +167,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha1_final (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -199,6 +205,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha256 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -259,6 +266,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha256_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -296,6 +304,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha512 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -356,6 +365,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_sha512_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -393,6 +403,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_ripemd160 (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -453,6 +464,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv128_mk_ripemd160_final (__global } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -487,6 +499,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256 (__global const u32 *in, u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -524,6 +537,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha1 (__global const u32 * } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -584,6 +598,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha1_final (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -621,6 +636,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha256 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -681,6 +697,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha256_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -718,6 +735,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha512 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -778,6 +796,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_sha512_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -815,6 +834,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_ripemd160 (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -877,6 +897,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_essiv256_mk_ripemd160_final (__global // cbc-plain +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -907,6 +928,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128 (__global const u32 *in, u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -940,6 +962,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha1 (__global const u32 * } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -996,6 +1019,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha1_final (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1029,6 +1053,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha256 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1085,6 +1110,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha256_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1118,6 +1144,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha512 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1174,6 +1201,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_sha512_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1207,6 +1235,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_ripemd160 (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1263,6 +1292,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain128_mk_ripemd160_final (__global } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1293,6 +1323,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256 (__global const u32 *in, u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1326,6 +1357,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha1 (__global const u32 * } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1382,6 +1414,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha1_final (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1415,6 +1448,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha256 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1471,6 +1505,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha256_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1504,6 +1539,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha512 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1560,6 +1596,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_sha512_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1593,6 +1630,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_ripemd160 (__global const } } +DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1651,6 +1689,7 @@ DECLSPEC void luks_decrypt_sector_aes_cbc_plain256_mk_ripemd160_final (__global // xts-plain +DECLSPEC void aes128_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes128_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { out[0] = in[0]; @@ -1673,6 +1712,7 @@ DECLSPEC void aes128_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 * xts_mul2 (T, T); } +DECLSPEC void aes256_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { out[0] = in[0]; @@ -1695,6 +1735,7 @@ DECLSPEC void aes256_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 * xts_mul2 (T, T); } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1729,6 +1770,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256 (__global const u32 *in, u32 } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1766,6 +1808,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha1 (__global const u32 * } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1826,6 +1869,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha1_final (__global const } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1863,6 +1907,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha256 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1923,6 +1968,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha256_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1960,6 +2006,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha512 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2020,6 +2067,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_sha512_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2057,6 +2105,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_ripemd160 (__global const } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2117,6 +2166,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain256_mk_ripemd160_final (__global } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2151,6 +2201,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512 (__global const u32 *in, u32 } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2188,6 +2239,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha1 (__global const u32 * } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2248,6 +2300,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha1_final (__global const } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2285,6 +2338,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha256 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2345,6 +2399,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha256_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2382,6 +2437,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha512 (__global const u32 } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2442,6 +2498,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_sha512_final (__global con } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2479,6 +2536,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_ripemd160 (__global const } } +DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2541,6 +2599,7 @@ DECLSPEC void luks_decrypt_sector_aes_xts_plain512_mk_ripemd160_final (__global // luks helper +DECLSPEC void luks_af_sha1_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_af_sha1_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { const u32 key_size = luks_bufs->key_size; @@ -2932,6 +2991,7 @@ DECLSPEC void luks_af_sha1_then_aes_decrypt (__global const luks_t *luks_bufs, _ } } +DECLSPEC void luks_af_sha256_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_af_sha256_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { const u32 key_size = luks_bufs->key_size; @@ -3291,6 +3351,7 @@ DECLSPEC void luks_af_sha256_then_aes_decrypt (__global const luks_t *luks_bufs, } } +DECLSPEC void luks_af_sha512_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_af_sha512_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { const u32 key_size = luks_bufs->key_size; @@ -3669,6 +3730,7 @@ DECLSPEC void luks_af_sha512_then_aes_decrypt (__global const luks_t *luks_bufs, } } +DECLSPEC void luks_af_ripemd160_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void luks_af_ripemd160_then_aes_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { const u32 key_size = luks_bufs->key_size; diff --git a/OpenCL/inc_luks_af.cl b/OpenCL/inc_luks_af.cl index 441fa2811..d43017c69 100644 --- a/OpenCL/inc_luks_af.cl +++ b/OpenCL/inc_luks_af.cl @@ -45,6 +45,7 @@ __constant u64a AF_k_sha512[80] = SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f, }; +DECLSPEC void AF_sha1_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void AF_sha1_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 A = digest[0]; @@ -173,6 +174,7 @@ DECLSPEC void AF_sha1_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, digest[4] += E; } +DECLSPEC void AF_sha256_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void AF_sha256_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -261,6 +263,7 @@ DECLSPEC void AF_sha256_transform_S (const u32 *w0, const u32 *w1, const u32 *w2 digest[7] += h; } +DECLSPEC void AF_sha512_transform_S (const u64 *w0, const u64 *w1, const u64 *w2, const u64 *w3, u64 *digest); DECLSPEC void AF_sha512_transform_S (const u64 *w0, const u64 *w1, const u64 *w2, const u64 *w3, u64 *digest) { u64 a = digest[0]; @@ -349,6 +352,7 @@ DECLSPEC void AF_sha512_transform_S (const u64 *w0, const u64 *w1, const u64 *w2 digest[7] += h; } +DECLSPEC void AF_ripemd160_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void AF_ripemd160_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 w0_t = w0[0]; @@ -565,6 +569,7 @@ DECLSPEC void AF_ripemd160_transform_S (const u32 *w0, const u32 *w1, const u32 // diffuse functions +DECLSPEC void AF_sha1_diffuse16 (u32 *out); DECLSPEC void AF_sha1_diffuse16 (u32 *out) { u32 w0[4]; @@ -607,6 +612,7 @@ DECLSPEC void AF_sha1_diffuse16 (u32 *out) out[3] = swap32_S (digest[3]); } +DECLSPEC void AF_sha1_diffuse32 (u32 *out); DECLSPEC void AF_sha1_diffuse32 (u32 *out) { u32 w0[4]; @@ -681,6 +687,7 @@ DECLSPEC void AF_sha1_diffuse32 (u32 *out) out[7] = swap32_S (digest[2]); } +DECLSPEC void AF_sha1_diffuse64 (u32 *out); DECLSPEC void AF_sha1_diffuse64 (u32 *out) { u32 w0[4]; @@ -819,6 +826,7 @@ DECLSPEC void AF_sha1_diffuse64 (u32 *out) out[15] = swap32_S (digest[0]); } +DECLSPEC void AF_sha256_diffuse16 (u32 *out); DECLSPEC void AF_sha256_diffuse16 (u32 *out) { u32 w0[4]; @@ -864,6 +872,7 @@ DECLSPEC void AF_sha256_diffuse16 (u32 *out) out[3] = swap32_S (digest[3]); } +DECLSPEC void AF_sha256_diffuse32 (u32 *out); DECLSPEC void AF_sha256_diffuse32 (u32 *out) { u32 w0[4]; @@ -913,6 +922,7 @@ DECLSPEC void AF_sha256_diffuse32 (u32 *out) out[7] = swap32_S (digest[7]); } +DECLSPEC void AF_sha256_diffuse64 (u32 *out); DECLSPEC void AF_sha256_diffuse64 (u32 *out) { u32 w0[4]; @@ -1001,6 +1011,7 @@ DECLSPEC void AF_sha256_diffuse64 (u32 *out) out[15] = swap32_S (digest[7]); } +DECLSPEC void AF_sha512_diffuse16 (u32 *out); DECLSPEC void AF_sha512_diffuse16 (u32 *out) { u64 w0[4]; @@ -1046,6 +1057,7 @@ DECLSPEC void AF_sha512_diffuse16 (u32 *out) out[3] = swap32_S (l32_from_64_S (digest[1])); } +DECLSPEC void AF_sha512_diffuse32 (u32 *out); DECLSPEC void AF_sha512_diffuse32 (u32 *out) { u64 w0[4]; @@ -1095,6 +1107,7 @@ DECLSPEC void AF_sha512_diffuse32 (u32 *out) out[7] = swap32_S (l32_from_64_S (digest[3])); } +DECLSPEC void AF_sha512_diffuse64 (u32 *out); DECLSPEC void AF_sha512_diffuse64 (u32 *out) { u64 w0[4]; @@ -1152,6 +1165,7 @@ DECLSPEC void AF_sha512_diffuse64 (u32 *out) out[15] = swap32_S (l32_from_64_S (digest[7])); } +DECLSPEC void AF_ripemd160_diffuse16 (u32 *out); DECLSPEC void AF_ripemd160_diffuse16 (u32 *out) { u32 w0[4]; @@ -1194,6 +1208,7 @@ DECLSPEC void AF_ripemd160_diffuse16 (u32 *out) out[3] = digest[3]; } +DECLSPEC void AF_ripemd160_diffuse32 (u32 *out); DECLSPEC void AF_ripemd160_diffuse32 (u32 *out) { u32 w0[4]; @@ -1268,6 +1283,7 @@ DECLSPEC void AF_ripemd160_diffuse32 (u32 *out) out[7] = digest[2]; } +DECLSPEC void AF_ripemd160_diffuse64 (u32 *out); DECLSPEC void AF_ripemd160_diffuse64 (u32 *out) { u32 w0[4]; diff --git a/OpenCL/inc_luks_essiv.cl b/OpenCL/inc_luks_essiv.cl index dd08d28a5..2acd7d99a 100644 --- a/OpenCL/inc_luks_essiv.cl +++ b/OpenCL/inc_luks_essiv.cl @@ -19,6 +19,7 @@ __constant u32a ESSIV_k_sha256[64] = }; // basically a normal sha256_transform() but with a different name to avoid collisions with function nameing +DECLSPEC void ESSIV_sha256_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest); DECLSPEC void ESSIV_sha256_transform_S (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; @@ -107,6 +108,7 @@ DECLSPEC void ESSIV_sha256_transform_S (const u32 *w0, const u32 *w1, const u32 digest[7] += h; } +DECLSPEC void ESSIV_sha256_init128 (u32 *key, u32 *essivhash); DECLSPEC void ESSIV_sha256_init128 (u32 *key, u32 *essivhash) { essivhash[0] = SHA256M_A; @@ -152,6 +154,7 @@ DECLSPEC void ESSIV_sha256_init128 (u32 *key, u32 *essivhash) essivhash[7] = swap32_S (essivhash[7]); } +DECLSPEC void ESSIV_sha256_init256 (u32 *key, u32 *essivhash); DECLSPEC void ESSIV_sha256_init256 (u32 *key, u32 *essivhash) { essivhash[0] = SHA256M_A; diff --git a/OpenCL/inc_luks_serpent.cl b/OpenCL/inc_luks_serpent.cl index f2bc56502..03430492d 100644 --- a/OpenCL/inc_luks_serpent.cl +++ b/OpenCL/inc_luks_serpent.cl @@ -1,6 +1,7 @@ // cbc-essiv +DECLSPEC void serpent128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv); DECLSPEC void serpent128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv) { serpent128_decrypt (ks1, in, out); @@ -16,6 +17,7 @@ DECLSPEC void serpent128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u essiv[3] = in[3]; } +DECLSPEC void serpent256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv); DECLSPEC void serpent256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv) { serpent256_decrypt (ks1, in, out); @@ -31,6 +33,7 @@ DECLSPEC void serpent256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u essiv[3] = in[3]; } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -65,6 +68,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -102,6 +106,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -162,6 +167,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -199,6 +205,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -259,6 +266,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -296,6 +304,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -356,6 +365,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -393,6 +403,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -453,6 +464,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv128_mk_ripemd160_final (__glo } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -487,6 +499,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -524,6 +537,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -584,6 +598,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -621,6 +636,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -681,6 +697,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -718,6 +735,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -778,6 +796,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -815,6 +834,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -877,6 +897,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_essiv256_mk_ripemd160_final (__glo // cbc-plain +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -907,6 +928,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -940,6 +962,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -996,6 +1019,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1029,6 +1053,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1085,6 +1110,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1118,6 +1144,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1174,6 +1201,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1207,6 +1235,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1263,6 +1292,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain128_mk_ripemd160_final (__glo } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1293,6 +1323,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1326,6 +1357,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1382,6 +1414,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1415,6 +1448,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1471,6 +1505,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1504,6 +1539,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1560,6 +1596,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1593,6 +1630,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1651,6 +1689,7 @@ DECLSPEC void luks_decrypt_sector_serpent_cbc_plain256_mk_ripemd160_final (__glo // xts-plain +DECLSPEC void serpent128_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T); DECLSPEC void serpent128_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T) { out[0] = in[0]; @@ -1673,6 +1712,7 @@ DECLSPEC void serpent128_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u xts_mul2 (T, T); } +DECLSPEC void serpent256_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T); DECLSPEC void serpent256_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u32 *T) { out[0] = in[0]; @@ -1695,6 +1735,7 @@ DECLSPEC void serpent256_decrypt_xts (const u32 *ks1, const u32 *in, u32 *out, u xts_mul2 (T, T); } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1729,6 +1770,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1766,6 +1808,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1826,6 +1869,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1863,6 +1907,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1923,6 +1968,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1960,6 +2006,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2020,6 +2067,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2057,6 +2105,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2117,6 +2166,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain256_mk_ripemd160_final (__glo } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512 (__global const u32 *in, u32 *out, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2151,6 +2201,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2188,6 +2239,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2248,6 +2300,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2285,6 +2338,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2345,6 +2399,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2382,6 +2437,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2442,6 +2498,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2479,6 +2536,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector); DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *ks1, const u32 *ks2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2541,6 +2599,7 @@ DECLSPEC void luks_decrypt_sector_serpent_xts_plain512_mk_ripemd160_final (__glo // luks helper +DECLSPEC void luks_af_sha1_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_sha1_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; @@ -2900,6 +2959,7 @@ DECLSPEC void luks_af_sha1_then_serpent_decrypt (__global const luks_t *luks_buf } } +DECLSPEC void luks_af_sha256_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_sha256_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; @@ -3259,6 +3319,7 @@ DECLSPEC void luks_af_sha256_then_serpent_decrypt (__global const luks_t *luks_b } } +DECLSPEC void luks_af_sha512_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_sha512_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; @@ -3637,6 +3698,7 @@ DECLSPEC void luks_af_sha512_then_serpent_decrypt (__global const luks_t *luks_b } } +DECLSPEC void luks_af_ripemd160_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_ripemd160_then_serpent_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; diff --git a/OpenCL/inc_luks_twofish.cl b/OpenCL/inc_luks_twofish.cl index e8349c87e..e17e0897c 100644 --- a/OpenCL/inc_luks_twofish.cl +++ b/OpenCL/inc_luks_twofish.cl @@ -1,6 +1,7 @@ // cbc-essiv +DECLSPEC void twofish128_decrypt_cbc (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *essiv); DECLSPEC void twofish128_decrypt_cbc (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *essiv) { twofish128_decrypt (sk1, lk1, in, out); @@ -16,6 +17,7 @@ DECLSPEC void twofish128_decrypt_cbc (const u32 *sk1, const u32 *lk1, const u32 essiv[3] = in[3]; } +DECLSPEC void twofish256_decrypt_cbc (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *essiv); DECLSPEC void twofish256_decrypt_cbc (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *essiv) { twofish256_decrypt (sk1, lk1, in, out); @@ -31,6 +33,7 @@ DECLSPEC void twofish256_decrypt_cbc (const u32 *sk1, const u32 *lk1, const u32 essiv[3] = in[3]; } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -65,6 +68,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -102,6 +106,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -162,6 +167,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -199,6 +205,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -259,6 +266,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -296,6 +304,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -356,6 +365,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -393,6 +403,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -453,6 +464,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv128_mk_ripemd160_final (__glo } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -487,6 +499,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -524,6 +537,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -584,6 +598,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -621,6 +636,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -681,6 +697,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -718,6 +735,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -778,6 +796,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -815,6 +834,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -877,6 +897,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_essiv256_mk_ripemd160_final (__glo // cbc-plain +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -907,6 +928,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -940,6 +962,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -996,6 +1019,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1029,6 +1053,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1085,6 +1110,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1118,6 +1144,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1174,6 +1201,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1207,6 +1235,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1263,6 +1292,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain128_mk_ripemd160_final (__glo } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1293,6 +1323,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1326,6 +1357,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1382,6 +1414,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1415,6 +1448,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1471,6 +1505,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1504,6 +1539,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1560,6 +1596,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1593,6 +1630,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1651,6 +1689,7 @@ DECLSPEC void luks_decrypt_sector_twofish_cbc_plain256_mk_ripemd160_final (__glo // xts-plain +DECLSPEC void twofish128_decrypt_xts (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *T); DECLSPEC void twofish128_decrypt_xts (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *T) { out[0] = in[0]; @@ -1673,6 +1712,7 @@ DECLSPEC void twofish128_decrypt_xts (const u32 *sk1, const u32 *lk1, const u32 xts_mul2 (T, T); } +DECLSPEC void twofish256_decrypt_xts (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *T); DECLSPEC void twofish256_decrypt_xts (const u32 *sk1, const u32 *lk1, const u32 *in, u32 *out, u32 *T) { out[0] = in[0]; @@ -1695,6 +1735,7 @@ DECLSPEC void twofish256_decrypt_xts (const u32 *sk1, const u32 *lk1, const u32 xts_mul2 (T, T); } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1729,6 +1770,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1766,6 +1808,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1826,6 +1869,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1863,6 +1907,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1923,6 +1968,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -1960,6 +2006,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2020,6 +2067,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2057,6 +2105,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2117,6 +2166,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain256_mk_ripemd160_final (__glo } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512 (__global const u32 *in, u32 *out, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2151,6 +2201,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512 (__global const u32 *in, } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha1 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2188,6 +2239,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha1 (__global const u } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha1_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2248,6 +2300,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha1_final (__global c } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha256 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2285,6 +2338,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha256 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha256_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2345,6 +2399,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha256_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha512 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2382,6 +2437,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha512 (__global const } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha512_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2442,6 +2498,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_sha512_final (__global } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_ripemd160 (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2479,6 +2536,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_ripemd160 (__global co } } +DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector); DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_ripemd160_final (__global const u32 *in, u32 *mk, const u32 *sk1, const u32 *lk1, const u32 *sk2, const u32 *lk2, const u32 sector) { u32 S[4] = { sector, 0, 0, 0 }; @@ -2541,6 +2599,7 @@ DECLSPEC void luks_decrypt_sector_twofish_xts_plain512_mk_ripemd160_final (__glo // luks helper +DECLSPEC void luks_af_sha1_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_sha1_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; @@ -2900,6 +2959,7 @@ DECLSPEC void luks_af_sha1_then_twofish_decrypt (__global const luks_t *luks_buf } } +DECLSPEC void luks_af_sha256_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_sha256_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; @@ -3259,6 +3319,7 @@ DECLSPEC void luks_af_sha256_then_twofish_decrypt (__global const luks_t *luks_b } } +DECLSPEC void luks_af_sha512_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_sha512_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; @@ -3637,6 +3698,7 @@ DECLSPEC void luks_af_sha512_then_twofish_decrypt (__global const luks_t *luks_b } } +DECLSPEC void luks_af_ripemd160_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf); DECLSPEC void luks_af_ripemd160_then_twofish_decrypt (__global const luks_t *luks_bufs, __global luks_tmp_t *tmps, u32 *pt_buf) { const u32 key_size = luks_bufs->key_size; diff --git a/OpenCL/inc_luks_xts.cl b/OpenCL/inc_luks_xts.cl index c2a36937e..cdec6818d 100644 --- a/OpenCL/inc_luks_xts.cl +++ b/OpenCL/inc_luks_xts.cl @@ -1,3 +1,4 @@ +DECLSPEC void xts_mul2 (u32 *in, u32 *out); DECLSPEC void xts_mul2 (u32 *in, u32 *out) { const u32 c = in[3] >> 31; diff --git a/OpenCL/inc_rp.cl b/OpenCL/inc_rp.cl index 23064b5ee..c45a7c591 100644 --- a/OpenCL/inc_rp.cl +++ b/OpenCL/inc_rp.cl @@ -3,8 +3,11 @@ * License.....: MIT */ +#ifndef MAYBE_UNUSED #define MAYBE_UNUSED +#endif +u32 generate_cmask (const u32 value); u32 generate_cmask (const u32 value) { const u32 rmask = ((value & 0x40404040u) >> 1u) @@ -16,6 +19,7 @@ u32 generate_cmask (const u32 value) return rmask & ~hmask & lmask; } +void append_four_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst); void append_four_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst) { const int sd = off_src / 4; @@ -39,6 +43,7 @@ void append_four_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, cons buf_dst[dd + 1] |= t1; } +void append_three_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst); void append_three_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst) { const int sd = off_src / 4; @@ -62,6 +67,7 @@ void append_three_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, con buf_dst[dd + 1] |= t1; } +void append_two_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst); void append_two_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst) { const int sd = off_src / 4; @@ -85,6 +91,7 @@ void append_two_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const buf_dst[dd + 1] |= t1; } +void append_one_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst); void append_one_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst) { const int sd = off_src / 4; @@ -104,6 +111,7 @@ void append_one_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const buf_dst[dd] |= t; } +void append_block (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst, const int len); void append_block (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst, const int len) { int i; @@ -123,6 +131,7 @@ void append_block (const u32 *buf_src, const int off_src, u32 *buf_dst, const in } } +void exchange_byte (u32 *buf, const int off_src, const int off_dst); void exchange_byte (u32 *buf, const int off_src, const int off_dst) { u8 *ptr = (u8 *) buf; @@ -162,6 +171,7 @@ void exchange_byte (u32 *buf, const int off_src, const int off_dst) */ } +int mangle_lrest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_lrest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int i = 0, idx = 0; i < len; i += 4, idx += 1) @@ -174,6 +184,7 @@ int mangle_lrest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, return (len); } +int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int i = 0, idx = 0; i < len; i += 4, idx += 1) @@ -190,6 +201,7 @@ int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 return (len); } +int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int i = 0, idx = 0; i < len; i += 4, idx += 1) @@ -202,6 +214,7 @@ int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, return (len); } +int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int i = 0, idx = 0; i < len; i += 4, idx += 1) @@ -218,6 +231,7 @@ int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 return (len); } +int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int i = 0, idx = 0; i < len; i += 4, idx += 1) @@ -230,6 +244,7 @@ int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, return (len); } +int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { if (p0 >= len) return (len); @@ -246,6 +261,7 @@ int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *b return (len); } +int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int l = 0; l < len / 2; l++) @@ -258,6 +274,7 @@ int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf return (len); } +int mangle_dupeword (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_dupeword (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { const int out_len = len * 2; @@ -269,6 +286,7 @@ int mangle_dupeword (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *bu return (out_len); } +int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { const int out_len = (len * p0) + len; @@ -282,6 +300,7 @@ int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u return (out_len); } +int mangle_reflect (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_reflect (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { const int out_len = len * 2; @@ -300,6 +319,7 @@ int mangle_reflect (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf return out_len; } +int mangle_append (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_append (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { const int out_len = len + 1; @@ -311,6 +331,7 @@ int mangle_append (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, return (out_len); } +int mangle_prepend (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_prepend (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { const int out_len = len + 1; @@ -327,6 +348,7 @@ int mangle_prepend (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, return (out_len); } +int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int l = 0, r = len - 1; r > l; r--) @@ -337,6 +359,7 @@ int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 return (len); } +int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { for (int l = 0, r = len - 1; l < r; l++) @@ -347,6 +370,7 @@ int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 return (len); } +int mangle_delete_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_delete_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -361,11 +385,13 @@ int mangle_delete_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *bu return (len - 1); } +int mangle_delete_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_delete_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { return mangle_delete_at (0, p1, buf, len); } +int mangle_delete_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_delete_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (len == 0) return 0; @@ -373,6 +399,7 @@ int mangle_delete_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 * return mangle_delete_at (len - 1, p1, buf, len); } +int mangle_extract (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_extract (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -392,6 +419,7 @@ int mangle_extract (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, return (p1); } +int mangle_omit (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_omit (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -411,6 +439,7 @@ int mangle_omit (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, co return (len - p1); } +int mangle_insert (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_insert (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len + 1) return (len); @@ -429,6 +458,7 @@ int mangle_insert (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, return (out_len); } +int mangle_overstrike (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_overstrike (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -438,6 +468,7 @@ int mangle_overstrike (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *b return (len); } +int mangle_truncate_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_truncate_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -450,6 +481,7 @@ int mangle_truncate_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 * return (p0); } +int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { for (int pos = 0; pos < len; pos++) @@ -462,6 +494,7 @@ int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, return (len); } +int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { int out_len = 0; @@ -483,6 +516,7 @@ int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *bu return (out_len); } +int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { const int out_len = len + p0; @@ -499,6 +533,7 @@ int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u return (out_len); } +int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { const int out_len = len + p0; @@ -516,6 +551,7 @@ int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 return (out_len); } +int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { const int out_len = len + len; @@ -534,6 +570,7 @@ int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 return (out_len); } +int mangle_switch_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_switch_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { if (len < 2) return (len); @@ -543,6 +580,7 @@ int mangle_switch_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 return (len); } +int mangle_switch_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_switch_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { if (len < 2) return (len); @@ -552,6 +590,7 @@ int mangle_switch_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 return (len); } +int mangle_switch_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_switch_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { if (p0 >= len) return (len); @@ -562,6 +601,7 @@ int mangle_switch_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *b return (len); } +int mangle_chr_shiftl (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_chr_shiftl (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -571,6 +611,7 @@ int mangle_chr_shiftl (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *b return (len); } +int mangle_chr_shiftr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_chr_shiftr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -580,6 +621,7 @@ int mangle_chr_shiftr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *b return (len); } +int mangle_chr_incr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_chr_incr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -589,6 +631,7 @@ int mangle_chr_incr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf return (len); } +int mangle_chr_decr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_chr_decr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -598,6 +641,7 @@ int mangle_chr_decr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf return (len); } +int mangle_replace_np1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_replace_np1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if ((p0 + 1) >= len) return (len); @@ -607,6 +651,7 @@ int mangle_replace_np1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 * return (len); } +int mangle_replace_nm1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_replace_nm1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 == 0) return (len); @@ -618,6 +663,7 @@ int mangle_replace_nm1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 * return (len); } +int mangle_dupeblock_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_dupeblock_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -636,6 +682,7 @@ int mangle_dupeblock_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, return (out_len); } +int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len); int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len) { if (p0 >= len) return (len); @@ -654,6 +701,7 @@ int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u return (out_len); } +int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len); int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { if ((len + 4) >= RP_PASSWORD_SIZE) return (len); // cheap way to not need to check for overflow of i + 1 @@ -679,6 +727,7 @@ int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *b return (len); } +int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int in_len); int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int in_len) { int out_len = in_len; @@ -730,6 +779,7 @@ int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 return out_len; } +int apply_rules (__constant const u32 *cmds, u32 *buf, const int in_len); int apply_rules (__constant const u32 *cmds, u32 *buf, const int in_len) { int out_len = in_len; diff --git a/OpenCL/inc_rp_optimized.cl b/OpenCL/inc_rp_optimized.cl index a097836f5..03b9039e7 100644 --- a/OpenCL/inc_rp_optimized.cl +++ b/OpenCL/inc_rp_optimized.cl @@ -3,8 +3,11 @@ * License.....: MIT */ +#ifndef MAYBE_UNUSED #define MAYBE_UNUSED +#endif +u32 generate_cmask (const u32 value); u32 generate_cmask (const u32 value) { const u32 rmask = ((value & 0x40404040u) >> 1u) @@ -16,6 +19,7 @@ u32 generate_cmask (const u32 value) return rmask & ~hmask & lmask; } +void truncate_right (u32 *buf0, u32 *buf1, const u32 offset); void truncate_right (u32 *buf0, u32 *buf1, const u32 offset) { const u32 tmp = (1u << ((offset & 3u) * 8u)) - 1u; @@ -75,6 +79,7 @@ void truncate_right (u32 *buf0, u32 *buf1, const u32 offset) } } +void truncate_left (u32 *buf0, u32 *buf1, const u32 offset); void truncate_left (u32 *buf0, u32 *buf1, const u32 offset) { const u32 tmp = ~((1u << ((offset & 3u) * 8u)) - 1u); @@ -134,6 +139,7 @@ void truncate_left (u32 *buf0, u32 *buf1, const u32 offset) } } +void lshift_block (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1); void lshift_block (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1) { out0[0] = hc_bytealign_S (in0[1], in0[0], 1); @@ -146,6 +152,7 @@ void lshift_block (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1) out1[3] = hc_bytealign_S ( 0, in1[3], 1); } +void rshift_block (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1); void rshift_block (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1) { out1[3] = hc_bytealign_S (in1[3], in1[2], 3); @@ -158,6 +165,7 @@ void rshift_block (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1) out0[0] = hc_bytealign_S (in0[0], 0, 3); } +void lshift_block_N (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1, const u32 num); void lshift_block_N (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1, const u32 num) { switch (num) @@ -453,6 +461,7 @@ void lshift_block_N (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1, const } } +void rshift_block_N (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1, const u32 num); void rshift_block_N (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1, const u32 num) { switch (num) @@ -748,6 +757,7 @@ void rshift_block_N (const u32 *in0, const u32 *in1, u32 *out0, u32 *out1, const } } +void append_block1 (const u32 offset, u32 *buf0, u32 *buf1, const u32 src_r0); void append_block1 (const u32 offset, u32 *buf0, u32 *buf1, const u32 src_r0) { // this version works with 1 byte append only @@ -769,6 +779,7 @@ void append_block1 (const u32 offset, u32 *buf0, u32 *buf1, const u32 src_r0) } +void append_block8 (const u32 offset, u32 *buf0, u32 *buf1, const u32 *src_l0, const u32 *src_l1, const u32 *src_r0, const u32 *src_r1); void append_block8 (const u32 offset, u32 *buf0, u32 *buf1, const u32 *src_l0, const u32 *src_l1, const u32 *src_r0, const u32 *src_r1) { u32 s0 = 0; @@ -1024,6 +1035,7 @@ void append_block8 (const u32 offset, u32 *buf0, u32 *buf1, const u32 *src_l0, c buf1[3] = src_l1[3] | s7; } +void reverse_block (u32 *in0, u32 *in1, u32 *out0, u32 *out1, const u32 len); void reverse_block (u32 *in0, u32 *in1, u32 *out0, u32 *out1, const u32 len) { rshift_block_N (in0, in1, out0, out1, 32 - len); @@ -1050,6 +1062,7 @@ void reverse_block (u32 *in0, u32 *in1, u32 *out0, u32 *out1, const u32 len) out1[3] = swap32_S (tib41[3]); } +void exchange_byte (u32 *buf, const int off_src, const int off_dst); void exchange_byte (u32 *buf, const int off_src, const int off_dst) { u8 *ptr = (u8 *) buf; @@ -1060,6 +1073,7 @@ void exchange_byte (u32 *buf, const int off_src, const int off_dst) ptr[off_dst] = tmp; } +u32 rule_op_mangle_lrest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_lrest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { u32 t; @@ -1076,6 +1090,7 @@ u32 rule_op_mangle_lrest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, return in_len; } +u32 rule_op_mangle_urest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_urest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { u32 t; @@ -1092,6 +1107,7 @@ u32 rule_op_mangle_urest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, return in_len; } +u32 rule_op_mangle_lrest_ufirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_lrest_ufirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { u32 t; @@ -1110,6 +1126,7 @@ u32 rule_op_mangle_lrest_ufirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u return in_len; } +u32 rule_op_mangle_urest_lfirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_urest_lfirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { u32 t; @@ -1128,6 +1145,7 @@ u32 rule_op_mangle_urest_lfirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u return in_len; } +u32 rule_op_mangle_trest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_trest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { u32 t; @@ -1144,6 +1162,7 @@ u32 rule_op_mangle_trest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, return in_len; } +u32 rule_op_mangle_toggle_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_toggle_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1177,6 +1196,7 @@ u32 rule_op_mangle_toggle_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return (in_len); } +u32 rule_op_mangle_reverse (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_reverse (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { reverse_block (buf0, buf1, buf0, buf1, in_len); @@ -1184,6 +1204,7 @@ u32 rule_op_mangle_reverse (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1 return in_len; } +u32 rule_op_mangle_dupeword (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupeword (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ((in_len + in_len) >= 32) return in_len; @@ -1197,6 +1218,7 @@ u32 rule_op_mangle_dupeword (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p return out_len; } +u32 rule_op_mangle_dupeword_times (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupeword_times (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (((in_len * p0) + in_len) >= 32) return in_len; @@ -1225,6 +1247,7 @@ u32 rule_op_mangle_dupeword_times (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const return out_len; } +u32 rule_op_mangle_reflect (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_reflect (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ((in_len + in_len) >= 32) return in_len; @@ -1243,6 +1266,7 @@ u32 rule_op_mangle_reflect (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1 return out_len; } +u32 rule_op_mangle_append (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_append (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ((in_len + 1) >= 32) return in_len; @@ -1256,6 +1280,7 @@ u32 rule_op_mangle_append (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, return out_len; } +u32 rule_op_mangle_prepend (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_prepend (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ((in_len + 1) >= 32) return in_len; @@ -1271,6 +1296,7 @@ u32 rule_op_mangle_prepend (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1 return out_len; } +u32 rule_op_mangle_rotate_left (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_rotate_left (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len == 0) return in_len; @@ -1286,6 +1312,7 @@ u32 rule_op_mangle_rotate_left (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u3 return in_len; } +u32 rule_op_mangle_rotate_right (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_rotate_right (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len == 0) return in_len; @@ -1328,6 +1355,7 @@ u32 rule_op_mangle_rotate_right (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u return in_len; } +u32 rule_op_mangle_delete_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_delete_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len == 0) return in_len; @@ -1339,6 +1367,7 @@ u32 rule_op_mangle_delete_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u return in_len1; } +u32 rule_op_mangle_delete_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_delete_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len == 0) return in_len; @@ -1359,6 +1388,7 @@ u32 rule_op_mangle_delete_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u3 return in_len1; } +u32 rule_op_mangle_delete_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_delete_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1440,6 +1470,7 @@ u32 rule_op_mangle_delete_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return out_len; } +u32 rule_op_mangle_extract (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_extract (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1455,6 +1486,7 @@ u32 rule_op_mangle_extract (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1 return out_len; } +u32 rule_op_mangle_omit (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_omit (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1547,6 +1579,7 @@ u32 rule_op_mangle_omit (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, M return out_len; } +u32 rule_op_mangle_insert (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_insert (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 > in_len) return in_len; @@ -1625,6 +1658,7 @@ u32 rule_op_mangle_insert (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, return out_len; } +u32 rule_op_mangle_overstrike (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_overstrike (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1660,6 +1694,7 @@ u32 rule_op_mangle_overstrike (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return in_len; } +u32 rule_op_mangle_truncate_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_truncate_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1669,6 +1704,7 @@ u32 rule_op_mangle_truncate_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u3 return p0; } +u32 search_on_register (const u32 in, const u32 p0); u32 search_on_register (const u32 in, const u32 p0) { u32 r = 0; @@ -1681,6 +1717,7 @@ u32 search_on_register (const u32 in, const u32 p0) return r; } +u32 replace_on_register (const u32 in, const u32 r, const u32 p1); u32 replace_on_register (const u32 in, const u32 r, const u32 p1) { u32 out = in; @@ -1693,6 +1730,7 @@ u32 replace_on_register (const u32 in, const u32 r, const u32 p1) return out; } +u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { const u32 r0 = search_on_register (buf0[0], p0); @@ -1720,6 +1758,7 @@ u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1 return in_len; } +u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { const u32 r0 = search_on_register (buf0[0], p0); @@ -1774,6 +1813,7 @@ u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return out_len; } +u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ( in_len == 0) return in_len; @@ -1809,6 +1849,7 @@ u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const return out_len; } +u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ( in_len == 0) return in_len; @@ -1855,6 +1896,7 @@ u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const return out_len; } +u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ( in_len == 0) return in_len; @@ -1888,6 +1930,7 @@ u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u return out_len; } +u32 rule_op_mangle_switch_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_switch_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len < 2) return in_len; @@ -1897,6 +1940,7 @@ u32 rule_op_mangle_switch_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u return in_len; } +u32 rule_op_mangle_switch_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_switch_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len < 2) return in_len; @@ -1926,6 +1970,7 @@ u32 rule_op_mangle_switch_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u3 return in_len; } +u32 rule_op_mangle_switch_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_switch_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1956,6 +2001,7 @@ u32 rule_op_mangle_switch_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return in_len; } +u32 rule_op_mangle_chr_shiftl (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_chr_shiftl (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -1990,6 +2036,7 @@ u32 rule_op_mangle_chr_shiftl (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return in_len; } +u32 rule_op_mangle_chr_shiftr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_chr_shiftr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -2024,6 +2071,7 @@ u32 rule_op_mangle_chr_shiftr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return in_len; } +u32 rule_op_mangle_chr_incr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_chr_incr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -2060,6 +2108,7 @@ u32 rule_op_mangle_chr_incr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p return in_len; } +u32 rule_op_mangle_chr_decr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_chr_decr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 >= in_len) return in_len; @@ -2096,6 +2145,7 @@ u32 rule_op_mangle_chr_decr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p return in_len; } +u32 rule_op_mangle_replace_np1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_replace_np1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if ((p0 + 1) >= in_len) return in_len; @@ -2136,6 +2186,7 @@ u32 rule_op_mangle_replace_np1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u3 return in_len; } +u32 rule_op_mangle_replace_nm1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_replace_nm1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 == 0) return in_len; @@ -2178,6 +2229,7 @@ u32 rule_op_mangle_replace_nm1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u3 return in_len; } +u32 rule_op_mangle_dupeblock_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupeblock_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 > in_len) return in_len; @@ -2216,6 +2268,7 @@ u32 rule_op_mangle_dupeblock_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED cons return out_len; } +u32 rule_op_mangle_dupeblock_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_dupeblock_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (p0 > in_len) return in_len; @@ -2245,6 +2298,7 @@ u32 rule_op_mangle_dupeblock_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const return out_len; } +u32 toggle_on_register (const u32 in, const u32 r); u32 toggle_on_register (const u32 in, const u32 r) { u32 out = in; @@ -2259,6 +2313,7 @@ u32 toggle_on_register (const u32 in, const u32 r) return out; } +u32 rule_op_mangle_title_sep (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len); u32 rule_op_mangle_title_sep (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 *buf0, MAYBE_UNUSED u32 *buf1, const u32 in_len) { if (in_len == 0) return in_len; @@ -2299,6 +2354,7 @@ u32 rule_op_mangle_title_sep (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 return in_len; } +u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 *buf0, u32 *buf1, const u32 in_len); u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 *buf0, u32 *buf1, const u32 in_len) { u32 out_len = in_len; @@ -2351,6 +2407,7 @@ u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 *buf0, u32 *buf1 return out_len; } +u32 apply_rules (__constant const u32 *cmds, u32 *buf0, u32 *buf1, const u32 len); u32 apply_rules (__constant const u32 *cmds, u32 *buf0, u32 *buf1, const u32 len) { u32 out_len = len; @@ -2369,6 +2426,7 @@ u32 apply_rules (__constant const u32 *cmds, u32 *buf0, u32 *buf1, const u32 len return out_len; } +u32x apply_rules_vect (const u32 *pw_buf0, const u32 *pw_buf1, const u32 pw_len, __constant const kernel_rule_t *rules_buf, const u32 il_pos, u32x *buf0, u32x *buf1); u32x apply_rules_vect (const u32 *pw_buf0, const u32 *pw_buf1, const u32 pw_len, __constant const kernel_rule_t *rules_buf, const u32 il_pos, u32x *buf0, u32x *buf1) { #if VECT_SIZE == 1 diff --git a/OpenCL/inc_scalar.cl b/OpenCL/inc_scalar.cl index bc29b2322..49983b10a 100644 --- a/OpenCL/inc_scalar.cl +++ b/OpenCL/inc_scalar.cl @@ -11,7 +11,7 @@ \ if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos, 0, 0); \ } \ } \ } @@ -35,7 +35,7 @@ \ if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); \ } \ } \ } \ diff --git a/OpenCL/inc_simd.cl b/OpenCL/inc_simd.cl index 2b3c02274..bcd1434d7 100644 --- a/OpenCL/inc_simd.cl +++ b/OpenCL/inc_simd.cl @@ -18,7 +18,7 @@ \ if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos, 0, 0); \ } \ } \ } @@ -42,7 +42,7 @@ \ if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); \ } \ } \ } \ @@ -67,7 +67,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ \ @@ -77,7 +77,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ } @@ -102,7 +102,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ } \ @@ -122,7 +122,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ } \ @@ -145,7 +145,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ \ @@ -155,7 +155,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ \ @@ -165,7 +165,7 @@ \ if (vector_accessible (il_pos, il_cnt, 2) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 2); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 2, 0, 0); \ } \ } \ \ @@ -175,7 +175,7 @@ \ if (vector_accessible (il_pos, il_cnt, 3) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 3); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 3, 0, 0); \ } \ } \ } @@ -202,7 +202,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ } \ @@ -222,7 +222,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ } \ @@ -242,7 +242,7 @@ \ if (vector_accessible (il_pos, il_cnt, 2) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 2); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 2, 0, 0); \ } \ } \ } \ @@ -262,7 +262,7 @@ \ if (vector_accessible (il_pos, il_cnt, 3) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 3); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 3, 0, 0); \ } \ } \ } \ @@ -285,7 +285,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ \ @@ -295,7 +295,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ \ @@ -305,7 +305,7 @@ \ if (vector_accessible (il_pos, il_cnt, 2) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 2); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 2, 0, 0); \ } \ } \ \ @@ -315,7 +315,7 @@ \ if (vector_accessible (il_pos, il_cnt, 3) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 3); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 3, 0, 0); \ } \ } \ if (((h0).s4 == search[0]) && ((h1).s4 == search[1]) && ((h2).s4 == search[2]) && ((h3).s4 == search[3])) \ @@ -324,7 +324,7 @@ \ if (vector_accessible (il_pos, il_cnt, 4) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 4); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 4, 0, 0); \ } \ } \ \ @@ -334,7 +334,7 @@ \ if (vector_accessible (il_pos, il_cnt, 5) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 5); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 5, 0, 0); \ } \ } \ \ @@ -344,7 +344,7 @@ \ if (vector_accessible (il_pos, il_cnt, 6) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 6); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 6, 0, 0); \ } \ } \ \ @@ -354,7 +354,7 @@ \ if (vector_accessible (il_pos, il_cnt, 7) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 7); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 7, 0, 0); \ } \ } \ } @@ -385,7 +385,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ } \ @@ -405,7 +405,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ } \ @@ -425,7 +425,7 @@ \ if (vector_accessible (il_pos, il_cnt, 2) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 2); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 2, 0, 0); \ } \ } \ } \ @@ -445,7 +445,7 @@ \ if (vector_accessible (il_pos, il_cnt, 3) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 3); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 3, 0, 0); \ } \ } \ } \ @@ -464,7 +464,7 @@ \ if (vector_accessible (il_pos, il_cnt, 4) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 4); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 4, 0, 0); \ } \ } \ } \ @@ -484,7 +484,7 @@ \ if (vector_accessible (il_pos, il_cnt, 5) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 5); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 5, 0, 0); \ } \ } \ } \ @@ -504,7 +504,7 @@ \ if (vector_accessible (il_pos, il_cnt, 6) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 6); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 6, 0, 0); \ } \ } \ } \ @@ -524,7 +524,7 @@ \ if (vector_accessible (il_pos, il_cnt, 7) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 7); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 7, 0, 0); \ } \ } \ } \ @@ -547,7 +547,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ \ @@ -557,7 +557,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ \ @@ -567,7 +567,7 @@ \ if (vector_accessible (il_pos, il_cnt, 2) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 2); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 2, 0, 0); \ } \ } \ \ @@ -577,7 +577,7 @@ \ if (vector_accessible (il_pos, il_cnt, 3) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 3); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 3, 0, 0); \ } \ } \ if (((h0).s4 == search[0]) && ((h1).s4 == search[1]) && ((h2).s4 == search[2]) && ((h3).s4 == search[3])) \ @@ -586,7 +586,7 @@ \ if (vector_accessible (il_pos, il_cnt, 4) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 4); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 4, 0, 0); \ } \ } \ \ @@ -596,7 +596,7 @@ \ if (vector_accessible (il_pos, il_cnt, 5) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 5); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 5, 0, 0); \ } \ } \ \ @@ -606,7 +606,7 @@ \ if (vector_accessible (il_pos, il_cnt, 6) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 6); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 6, 0, 0); \ } \ } \ \ @@ -616,7 +616,7 @@ \ if (vector_accessible (il_pos, il_cnt, 7) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 7); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 7, 0, 0); \ } \ } \ \ @@ -626,7 +626,7 @@ \ if (vector_accessible (il_pos, il_cnt, 8) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 8); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 8, 0, 0); \ } \ } \ \ @@ -636,7 +636,7 @@ \ if (vector_accessible (il_pos, il_cnt, 9) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 9); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 9, 0, 0); \ } \ } \ \ @@ -646,7 +646,7 @@ \ if (vector_accessible (il_pos, il_cnt, 10) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 10); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 10, 0, 0); \ } \ } \ \ @@ -656,7 +656,7 @@ \ if (vector_accessible (il_pos, il_cnt, 11) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 11); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 11, 0, 0); \ } \ } \ \ @@ -666,7 +666,7 @@ \ if (vector_accessible (il_pos, il_cnt, 12) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 12); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 12, 0, 0); \ } \ } \ \ @@ -676,7 +676,7 @@ \ if (vector_accessible (il_pos, il_cnt, 13) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 13); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 13, 0, 0); \ } \ } \ \ @@ -686,7 +686,7 @@ \ if (vector_accessible (il_pos, il_cnt, 14) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 14); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 14, 0, 0); \ } \ } \ \ @@ -696,7 +696,7 @@ \ if (vector_accessible (il_pos, il_cnt, 15) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 15); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, final_hash_pos, gid, il_pos + 15, 0, 0); \ } \ } \ } @@ -735,7 +735,7 @@ \ if (vector_accessible (il_pos, il_cnt, 0) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 0, 0, 0); \ } \ } \ } \ @@ -755,7 +755,7 @@ \ if (vector_accessible (il_pos, il_cnt, 1) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 1, 0, 0); \ } \ } \ } \ @@ -775,7 +775,7 @@ \ if (vector_accessible (il_pos, il_cnt, 2) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 2); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 2, 0, 0); \ } \ } \ } \ @@ -795,7 +795,7 @@ \ if (vector_accessible (il_pos, il_cnt, 3) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 3); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 3, 0, 0); \ } \ } \ } \ @@ -815,7 +815,7 @@ \ if (vector_accessible (il_pos, il_cnt, 4) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 4); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 4, 0, 0); \ } \ } \ } \ @@ -835,7 +835,7 @@ \ if (vector_accessible (il_pos, il_cnt, 5) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 5); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 5, 0, 0); \ } \ } \ } \ @@ -855,7 +855,7 @@ \ if (vector_accessible (il_pos, il_cnt, 6) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 6); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 6, 0, 0); \ } \ } \ } \ @@ -875,7 +875,7 @@ \ if (vector_accessible (il_pos, il_cnt, 7) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 7); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 7, 0, 0); \ } \ } \ } \ @@ -895,7 +895,7 @@ \ if (vector_accessible (il_pos, il_cnt, 8) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 8); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 8, 0, 0); \ } \ } \ } \ @@ -915,7 +915,7 @@ \ if (vector_accessible (il_pos, il_cnt, 9) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 9); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 9, 0, 0); \ } \ } \ } \ @@ -935,7 +935,7 @@ \ if (vector_accessible (il_pos, il_cnt, 10) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 10); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 10, 0, 0); \ } \ } \ } \ @@ -955,7 +955,7 @@ \ if (vector_accessible (il_pos, il_cnt, 11) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 11); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 11, 0, 0); \ } \ } \ } \ @@ -975,7 +975,7 @@ \ if (vector_accessible (il_pos, il_cnt, 12) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 12); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 12, 0, 0); \ } \ } \ } \ @@ -995,7 +995,7 @@ \ if (vector_accessible (il_pos, il_cnt, 13) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 13); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 13, 0, 0); \ } \ } \ } \ @@ -1015,7 +1015,7 @@ \ if (vector_accessible (il_pos, il_cnt, 14) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 14); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 14, 0, 0); \ } \ } \ } \ @@ -1035,7 +1035,7 @@ \ if (vector_accessible (il_pos, il_cnt, 15) && (atomic_inc (&hashes_shown[final_hash_pos]) == 0)) \ { \ - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 15); \ + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos + 15, 0, 0); \ } \ } \ } \ @@ -1048,6 +1048,7 @@ // attack-mode 0 +DECLSPEC u32x ix_create_bft (__global const bf_t *bfs_buf, const u32 il_pos); DECLSPEC u32x ix_create_bft (__global const bf_t *bfs_buf, const u32 il_pos) { #if VECT_SIZE == 1 @@ -1067,6 +1068,7 @@ DECLSPEC u32x ix_create_bft (__global const bf_t *bfs_buf, const u32 il_pos) // attack-mode 1 +DECLSPEC u32x pwlenx_create_combt (__global const pw_t *combs_buf, const u32 il_pos); DECLSPEC u32x pwlenx_create_combt (__global const pw_t *combs_buf, const u32 il_pos) { #if VECT_SIZE == 1 @@ -1084,6 +1086,7 @@ DECLSPEC u32x pwlenx_create_combt (__global const pw_t *combs_buf, const u32 il_ return pw_lenx; } +DECLSPEC u32x ix_create_combt (__global const pw_t *combs_buf, const u32 il_pos, const int idx); DECLSPEC u32x ix_create_combt (__global const pw_t *combs_buf, const u32 il_pos, const int idx) { #if VECT_SIZE == 1 diff --git a/OpenCL/inc_truecrypt_crc32.cl b/OpenCL/inc_truecrypt_crc32.cl index ccec03d16..eb6dea338 100644 --- a/OpenCL/inc_truecrypt_crc32.cl +++ b/OpenCL/inc_truecrypt_crc32.cl @@ -66,6 +66,7 @@ __constant u32a crc32tab[0x100] = 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; +DECLSPEC u32 round_crc32 (u32 a, const u32 v); DECLSPEC u32 round_crc32 (u32 a, const u32 v) { const u32 k = (a ^ v) & 0xff; @@ -79,6 +80,7 @@ DECLSPEC u32 round_crc32 (u32 a, const u32 v) return a; } +DECLSPEC u32 round_crc32_4 (const u32 w, const u32 iv); DECLSPEC u32 round_crc32_4 (const u32 w, const u32 iv) { u32 a = iv; diff --git a/OpenCL/inc_truecrypt_keyfile.cl b/OpenCL/inc_truecrypt_keyfile.cl index 803bbed9d..56cbd2673 100644 --- a/OpenCL/inc_truecrypt_keyfile.cl +++ b/OpenCL/inc_truecrypt_keyfile.cl @@ -1,3 +1,4 @@ +DECLSPEC u32 u8add (const u32 a, const u32 b); DECLSPEC u32 u8add (const u32 a, const u32 b) { const u32 a1 = (a >> 0) & 0xff; diff --git a/OpenCL/inc_truecrypt_xts.cl b/OpenCL/inc_truecrypt_xts.cl index bc6f319d0..a0b08cb30 100644 --- a/OpenCL/inc_truecrypt_xts.cl +++ b/OpenCL/inc_truecrypt_xts.cl @@ -1,3 +1,4 @@ +DECLSPEC void xts_mul2 (u32 *in, u32 *out); DECLSPEC void xts_mul2 (u32 *in, u32 *out) { const u32 c = in[3] >> 31; @@ -10,6 +11,7 @@ DECLSPEC void xts_mul2 (u32 *in, u32 *out) out[0] ^= c * 0x87; } +DECLSPEC void aes256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { out[0] = in[0]; @@ -34,6 +36,7 @@ DECLSPEC void aes256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, cons out[3] ^= T[3]; } +DECLSPEC void aes256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); DECLSPEC void aes256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { out[0] = in[0]; @@ -56,6 +59,7 @@ DECLSPEC void aes256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks, out[3] ^= T[3]; } +DECLSPEC void serpent256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks); DECLSPEC void serpent256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks) { out[0] = in[0]; @@ -80,6 +84,7 @@ DECLSPEC void serpent256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, out[3] ^= T[3]; } +DECLSPEC void serpent256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks); DECLSPEC void serpent256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks) { out[0] = in[0]; @@ -102,6 +107,7 @@ DECLSPEC void serpent256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 out[3] ^= T[3]; } +DECLSPEC void twofish256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *sk, u32 *lk); DECLSPEC void twofish256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *sk, u32 *lk) { out[0] = in[0]; @@ -126,6 +132,7 @@ DECLSPEC void twofish256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, out[3] ^= T[3]; } +DECLSPEC void twofish256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *sk, u32 *lk); DECLSPEC void twofish256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *sk, u32 *lk) { out[0] = in[0]; @@ -150,7 +157,8 @@ DECLSPEC void twofish256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 // 512 bit -DECLSPEC int verify_header_aes (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +DECLSPEC int verify_header_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); +DECLSPEC int verify_header_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ks_aes[60]; @@ -160,17 +168,15 @@ DECLSPEC int verify_header_aes (__global const tc_t *esalt_bufs, const u32 *ukey u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; aes256_decrypt_xts_first (ukey1, ukey2, data, tmp, S, T_aes, ks_aes, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -188,10 +194,10 @@ DECLSPEC int verify_header_aes (__global const tc_t *esalt_bufs, const u32 *ukey for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; aes256_decrypt_xts_next (data, tmp, T_aes, ks_aes, s_td0, s_td1, s_td2, s_td3, s_td4); @@ -206,7 +212,8 @@ DECLSPEC int verify_header_aes (__global const tc_t *esalt_bufs, const u32 *ukey return 1; } -DECLSPEC int verify_header_serpent (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2) +DECLSPEC int verify_header_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2); +DECLSPEC int verify_header_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2) { u32 ks_serpent[140]; @@ -216,17 +223,15 @@ DECLSPEC int verify_header_serpent (__global const tc_t *esalt_bufs, const u32 * u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; serpent256_decrypt_xts_first (ukey1, ukey2, data, tmp, S, T_serpent, ks_serpent); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -244,10 +249,10 @@ DECLSPEC int verify_header_serpent (__global const tc_t *esalt_bufs, const u32 * for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; serpent256_decrypt_xts_next (data, tmp, T_serpent, ks_serpent); @@ -262,7 +267,8 @@ DECLSPEC int verify_header_serpent (__global const tc_t *esalt_bufs, const u32 * return 1; } -DECLSPEC int verify_header_twofish (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2) +DECLSPEC int verify_header_twofish (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2); +DECLSPEC int verify_header_twofish (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2) { u32 sk_twofish[4]; u32 lk_twofish[40]; @@ -273,17 +279,15 @@ DECLSPEC int verify_header_twofish (__global const tc_t *esalt_bufs, const u32 * u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; twofish256_decrypt_xts_first (ukey1, ukey2, data, tmp, S, T_twofish, sk_twofish, lk_twofish); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -301,10 +305,10 @@ DECLSPEC int verify_header_twofish (__global const tc_t *esalt_bufs, const u32 * for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; twofish256_decrypt_xts_next (data, tmp, T_twofish, sk_twofish, lk_twofish); @@ -321,7 +325,8 @@ DECLSPEC int verify_header_twofish (__global const tc_t *esalt_bufs, const u32 * // 1024 bit -DECLSPEC int verify_header_aes_twofish (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +DECLSPEC int verify_header_aes_twofish (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); +DECLSPEC int verify_header_aes_twofish (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ks_aes[60]; @@ -335,18 +340,16 @@ DECLSPEC int verify_header_aes_twofish (__global const tc_t *esalt_bufs, const u u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; aes256_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_aes, ks_aes, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); twofish256_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_twofish, sk_twofish, lk_twofish); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -365,10 +368,10 @@ DECLSPEC int verify_header_aes_twofish (__global const tc_t *esalt_bufs, const u for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; aes256_decrypt_xts_next (data, tmp, T_aes, ks_aes, s_td0, s_td1, s_td2, s_td3, s_td4); twofish256_decrypt_xts_next (tmp, tmp, T_twofish, sk_twofish, lk_twofish); @@ -384,7 +387,8 @@ DECLSPEC int verify_header_aes_twofish (__global const tc_t *esalt_bufs, const u return 1; } -DECLSPEC int verify_header_serpent_aes (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +DECLSPEC int verify_header_serpent_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); +DECLSPEC int verify_header_serpent_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ks_serpent[140]; u32 ks_aes[60]; @@ -396,18 +400,16 @@ DECLSPEC int verify_header_serpent_aes (__global const tc_t *esalt_bufs, const u u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; serpent256_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_serpent, ks_serpent); aes256_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_aes, ks_aes, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -426,10 +428,10 @@ DECLSPEC int verify_header_serpent_aes (__global const tc_t *esalt_bufs, const u for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; serpent256_decrypt_xts_next (data, tmp, T_serpent, ks_serpent); aes256_decrypt_xts_next (tmp, tmp, T_aes, ks_aes, s_td0, s_td1, s_td2, s_td3, s_td4); @@ -445,7 +447,8 @@ DECLSPEC int verify_header_serpent_aes (__global const tc_t *esalt_bufs, const u return 1; } -DECLSPEC int verify_header_twofish_serpent (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) +DECLSPEC int verify_header_twofish_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4); +DECLSPEC int verify_header_twofish_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) { u32 sk_twofish[4]; u32 lk_twofish[40]; @@ -459,18 +462,16 @@ DECLSPEC int verify_header_twofish_serpent (__global const tc_t *esalt_bufs, con u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; twofish256_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_twofish, sk_twofish, lk_twofish); serpent256_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_serpent, ks_serpent); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -489,10 +490,10 @@ DECLSPEC int verify_header_twofish_serpent (__global const tc_t *esalt_bufs, con for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; twofish256_decrypt_xts_next (data, tmp, T_twofish, sk_twofish, lk_twofish); serpent256_decrypt_xts_next (tmp, tmp, T_serpent, ks_serpent); @@ -510,7 +511,8 @@ DECLSPEC int verify_header_twofish_serpent (__global const tc_t *esalt_bufs, con // 1536 bit -DECLSPEC int verify_header_aes_twofish_serpent (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +DECLSPEC int verify_header_aes_twofish_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); +DECLSPEC int verify_header_aes_twofish_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ks_aes[60]; @@ -527,10 +529,10 @@ DECLSPEC int verify_header_aes_twofish_serpent (__global const tc_t *esalt_bufs, u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; @@ -538,8 +540,6 @@ DECLSPEC int verify_header_aes_twofish_serpent (__global const tc_t *esalt_bufs, twofish256_decrypt_xts_first (ukey2, ukey5, tmp, tmp, S, T_twofish, sk_twofish, lk_twofish); serpent256_decrypt_xts_first (ukey1, ukey4, tmp, tmp, S, T_serpent, ks_serpent); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -559,10 +559,10 @@ DECLSPEC int verify_header_aes_twofish_serpent (__global const tc_t *esalt_bufs, for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; aes256_decrypt_xts_next (data, tmp, T_aes, ks_aes, s_td0, s_td1, s_td2, s_td3, s_td4); twofish256_decrypt_xts_next (tmp, tmp, T_twofish, sk_twofish, lk_twofish); @@ -579,7 +579,8 @@ DECLSPEC int verify_header_aes_twofish_serpent (__global const tc_t *esalt_bufs, return 1; } -DECLSPEC int verify_header_serpent_twofish_aes (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +DECLSPEC int verify_header_serpent_twofish_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); +DECLSPEC int verify_header_serpent_twofish_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ks_serpent[140]; @@ -596,10 +597,10 @@ DECLSPEC int verify_header_serpent_twofish_aes (__global const tc_t *esalt_bufs, u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; @@ -607,8 +608,6 @@ DECLSPEC int verify_header_serpent_twofish_aes (__global const tc_t *esalt_bufs, twofish256_decrypt_xts_first (ukey2, ukey5, tmp, tmp, S, T_twofish, sk_twofish, lk_twofish); aes256_decrypt_xts_first (ukey1, ukey4, tmp, tmp, S, T_aes, ks_aes, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -628,10 +627,10 @@ DECLSPEC int verify_header_serpent_twofish_aes (__global const tc_t *esalt_bufs, for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; serpent256_decrypt_xts_next (data, tmp, T_serpent, ks_serpent); twofish256_decrypt_xts_next (tmp, tmp, T_twofish, sk_twofish, lk_twofish); diff --git a/OpenCL/inc_types.cl b/OpenCL/inc_types.cl index dda8b416b..50c789aa5 100644 --- a/OpenCL/inc_types.cl +++ b/OpenCL/inc_types.cl @@ -8,10 +8,16 @@ typedef ushort u16; typedef uint u32; typedef ulong u64; -typedef u8 u8a __attribute__ ((aligned (8))); -typedef u16 u16a __attribute__ ((aligned (8))); -typedef u32 u32a __attribute__ ((aligned (8))); -typedef u64 u64a __attribute__ ((aligned (8))); +//testwise disabled +//typedef u8 u8a __attribute__ ((aligned (8))); +//typedef u16 u16a __attribute__ ((aligned (8))); +//typedef u32 u32a __attribute__ ((aligned (8))); +//typedef u64 u64a __attribute__ ((aligned (8))); + +typedef u8 u8a; +typedef u16 u16a; +typedef u32 u32a; +typedef u64 u64a; #ifndef NEW_SIMD_CODE #undef VECT_SIZE @@ -33,6 +39,7 @@ typedef VTYPE(uint, VECT_SIZE) u32x; typedef VTYPE(ulong, VECT_SIZE) u64x; #endif +DECLSPEC u32 l32_from_64_S (u64 a); DECLSPEC u32 l32_from_64_S (u64 a) { const u32 r = (u32) (a); @@ -40,6 +47,7 @@ DECLSPEC u32 l32_from_64_S (u64 a) return r; } +DECLSPEC u32 h32_from_64_S (u64 a); DECLSPEC u32 h32_from_64_S (u64 a) { a >>= 32; @@ -49,11 +57,13 @@ DECLSPEC u32 h32_from_64_S (u64 a) return r; } +DECLSPEC u64 hl32_to_64_S (const u32 a, const u32 b); DECLSPEC u64 hl32_to_64_S (const u32 a, const u32 b) { return as_ulong ((uint2) (b, a)); } +DECLSPEC u32x l32_from_64 (u64x a); DECLSPEC u32x l32_from_64 (u64x a) { u32x r; @@ -93,6 +103,7 @@ DECLSPEC u32x l32_from_64 (u64x a) return r; } +DECLSPEC u32x h32_from_64 (u64x a); DECLSPEC u32x h32_from_64 (u64x a) { a >>= 32; @@ -134,6 +145,7 @@ DECLSPEC u32x h32_from_64 (u64x a) return r; } +DECLSPEC u64x hl32_to_64 (const u32x a, const u32x b); DECLSPEC u64x hl32_to_64 (const u32x a, const u32x b) { u64x r; @@ -176,6 +188,7 @@ DECLSPEC u64x hl32_to_64 (const u32x a, const u32x b) #ifdef IS_AMD #if HAS_VPERM +DECLSPEC u32 swap32_S (const u32 v); DECLSPEC u32 swap32_S (const u32 v) { u32 r; @@ -185,6 +198,7 @@ DECLSPEC u32 swap32_S (const u32 v) return r; } +DECLSPEC u64 swap64_S (const u64 v); DECLSPEC u64 swap64_S (const u64 v) { const u32 v0 = h32_from_64_S (v); @@ -201,27 +215,32 @@ DECLSPEC u64 swap64_S (const u64 v) return r; } #else +DECLSPEC u32 swap32_S (const u32 v); DECLSPEC u32 swap32_S (const u32 v) { return as_uint (as_uchar4 (v).s3210); } +DECLSPEC u64 swap64_S (const u64 v); DECLSPEC u64 swap64_S (const u64 v) { return (as_ulong (as_uchar8 (v).s76543210)); } #endif +DECLSPEC u32 rotr32_S (const u32 a, const u32 n); DECLSPEC u32 rotr32_S (const u32 a, const u32 n) { return rotate (a, (32 - n)); } +DECLSPEC u32 rotl32_S (const u32 a, const u32 n); DECLSPEC u32 rotl32_S (const u32 a, const u32 n) { return rotate (a, n); } +DECLSPEC u64 rotr64_S (const u64 a, const u32 n); DECLSPEC u64 rotr64_S (const u64 a, const u32 n) { const u32 a0 = h32_from_64_S (a); @@ -235,17 +254,20 @@ DECLSPEC u64 rotr64_S (const u64 a, const u32 n) return r; } +DECLSPEC u64 rotl64_S (const u64 a, const u32 n); DECLSPEC u64 rotl64_S (const u64 a, const u32 n) { return rotr64_S (a, 64 - n); } #if HAS_VPERM +DECLSPEC u32x swap32 (const u32x v); DECLSPEC u32x swap32 (const u32x v) { return bitselect (rotate (v, 24u), rotate (v, 8u), 0x00ff00ffu); } +DECLSPEC u64x swap64 (const u64x v); DECLSPEC u64x swap64 (const u64x v) { const u32x a0 = h32_from_64 (v); @@ -308,11 +330,13 @@ DECLSPEC u64x swap64 (const u64x v) return r; } #else +DECLSPEC u32x swap32 (const u32x v); DECLSPEC u32x swap32 (const u32x v) { return bitselect (rotate (v, 24u), rotate (v, 8u), 0x00ff00ffu); } +DECLSPEC u64x swap64 (const u64x v); DECLSPEC u64x swap64 (const u64x v) { return bitselect (bitselect (rotate (v, 24ul), @@ -323,16 +347,19 @@ DECLSPEC u64x swap64 (const u64x v) } #endif +DECLSPEC u32x rotr32 (const u32x a, const u32 n); DECLSPEC u32x rotr32 (const u32x a, const u32 n) { return rotate (a, (32 - n)); } +DECLSPEC u32x rotl32 (const u32x a, const u32 n); DECLSPEC u32x rotl32 (const u32x a, const u32 n) { return rotate (a, n); } +DECLSPEC u64x rotr64 (const u64x a, const u32 n); DECLSPEC u64x rotr64 (const u64x a, const u32 n) { const u32x a0 = h32_from_64 (a); @@ -346,11 +373,13 @@ DECLSPEC u64x rotr64 (const u64x a, const u32 n) return r; } +DECLSPEC u64x rotl64 (const u64x a, const u32 n); DECLSPEC u64x rotl64 (const u64x a, const u32 n) { return rotr64 (a, 64 - n); } +DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c) { #define BIT(x) ((u32x) (1u) << (x)) @@ -364,6 +393,7 @@ DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c) #undef BFE } +DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c) { #define BIT(x) (1u << (x)) @@ -377,6 +407,7 @@ DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c) #undef BFE } +DECLSPEC u32x hc_bytealign_be (const u32x a, const u32x b, const u32 c); DECLSPEC u32x hc_bytealign_be (const u32x a, const u32x b, const u32 c) { u32x r; @@ -392,6 +423,7 @@ DECLSPEC u32x hc_bytealign_be (const u32x a, const u32x b, const u32 c) return r; } +DECLSPEC u32 hc_bytealign_be_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bytealign_be_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -407,6 +439,7 @@ DECLSPEC u32 hc_bytealign_be_S (const u32 a, const u32 b, const u32 c) return r; } +DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32 c); DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32 c) { u32x r; @@ -422,6 +455,7 @@ DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32 c) return r; } +DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -438,6 +472,7 @@ DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c) } #if HAS_VPERM +DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const u32x c) { u32x r; @@ -491,6 +526,7 @@ DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const u32x c) return r; } +DECLSPEC u32 hc_byte_perm_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_byte_perm_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -502,6 +538,7 @@ DECLSPEC u32 hc_byte_perm_S (const u32 a, const u32 b, const u32 c) #endif #if HAS_VADD3 +DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) { u32x r; @@ -555,6 +592,7 @@ DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) return r; } +DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -564,22 +602,26 @@ DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c) return r; } #else +DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) { return a + b + c; } +DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c) { return a + b + c; } #endif +DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c) { return a ^ b ^ c; } +DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c) { return a ^ b ^ c; @@ -588,6 +630,7 @@ DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c) #endif #ifdef IS_NV +DECLSPEC u32 swap32_S (const u32 v); DECLSPEC u32 swap32_S (const u32 v) { u32 r; @@ -597,6 +640,7 @@ DECLSPEC u32 swap32_S (const u32 v) return r; } +DECLSPEC u64 swap64_S (const u64 v); DECLSPEC u64 swap64_S (const u64 v) { u32 il; @@ -617,26 +661,31 @@ DECLSPEC u64 swap64_S (const u64 v) return r; } +DECLSPEC u32 rotr32_S (const u32 a, const u32 n); DECLSPEC u32 rotr32_S (const u32 a, const u32 n) { return rotate (a, (32 - n)); } +DECLSPEC u32 rotl32_S (const u32 a, const u32 n); DECLSPEC u32 rotl32_S (const u32 a, const u32 n) { return rotate (a, n); } +DECLSPEC u64 rotr64_S (const u64 a, const u32 n); DECLSPEC u64 rotr64_S (const u64 a, const u32 n) { return rotate (a, (u64) (64 - n)); } +DECLSPEC u64 rotl64_S (const u64 a, const u32 n); DECLSPEC u64 rotl64_S (const u64 a, const u32 n) { return rotate (a, (u64) n); } +DECLSPEC u32x swap32 (const u32x v); DECLSPEC u32x swap32 (const u32x v) { u32x r; @@ -676,6 +725,7 @@ DECLSPEC u32x swap32 (const u32x v) return r; } +DECLSPEC u64x swap64 (const u64x v); DECLSPEC u64x swap64 (const u64x v) { u32x il; @@ -802,26 +852,31 @@ DECLSPEC u64x swap64 (const u64x v) return r; } +DECLSPEC u32x rotr32 (const u32x a, const u32 n); DECLSPEC u32x rotr32 (const u32x a, const u32 n) { return rotate (a, (32 - n)); } +DECLSPEC u32x rotl32 (const u32x a, const u32 n); DECLSPEC u32x rotl32 (const u32x a, const u32 n) { return rotate (a, n); } +DECLSPEC u64x rotr64 (const u64x a, const u32 n); DECLSPEC u64x rotr64 (const u64x a, const u32 n) { return rotate (a, (u64x) (64 - n)); } +DECLSPEC u64x rotl64 (const u64x a, const u32 n); DECLSPEC u64x rotl64 (const u64x a, const u32 n) { return rotate (a, (u64x) n); } +DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const u32x c) { u32x r; @@ -861,6 +916,7 @@ DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const u32x c) return r; } +DECLSPEC u32 hc_byte_perm_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_byte_perm_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -870,6 +926,7 @@ DECLSPEC u32 hc_byte_perm_S (const u32 a, const u32 b, const u32 c) return r; } +DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c) { u32x r; @@ -909,6 +966,7 @@ DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c) return r; } +DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -918,6 +976,7 @@ DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c) return r; } +DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32x c) { u32x r; @@ -965,6 +1024,7 @@ DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32x c) return r; } +DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -982,16 +1042,19 @@ DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c) return r; } +DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) { return a + b + c; } +DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c) { return a + b + c; } +DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c) { u32x r; @@ -1039,6 +1102,7 @@ DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c) return r; } +DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -1059,36 +1123,43 @@ DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c) #endif #ifdef IS_GENERIC +DECLSPEC u32 swap32_S (const u32 v); DECLSPEC u32 swap32_S (const u32 v) { return (as_uint (as_uchar4 (v).s3210)); } +DECLSPEC u64 swap64_S (const u64 v); DECLSPEC u64 swap64_S (const u64 v) { return (as_ulong (as_uchar8 (v).s76543210)); } +DECLSPEC u32 rotr32_S (const u32 a, const u32 n); DECLSPEC u32 rotr32_S (const u32 a, const u32 n) { return rotate (a, (32 - n)); } +DECLSPEC u32 rotl32_S (const u32 a, const u32 n); DECLSPEC u32 rotl32_S (const u32 a, const u32 n) { return rotate (a, n); } +DECLSPEC u64 rotr64_S (const u64 a, const u32 n); DECLSPEC u64 rotr64_S (const u64 a, const u32 n) { return rotate (a, (u64) (64 - n)); } +DECLSPEC u64 rotl64_S (const u64 a, const u32 n); DECLSPEC u64 rotl64_S (const u64 a, const u32 n) { return rotate (a, (u64) n); } +DECLSPEC u32x swap32 (const u32x v); DECLSPEC u32x swap32 (const u32x v) { return ((v >> 24) & 0x000000ff) @@ -1097,6 +1168,7 @@ DECLSPEC u32x swap32 (const u32x v) | ((v << 24) & 0xff000000); } +DECLSPEC u64x swap64 (const u64x v); DECLSPEC u64x swap64 (const u64x v) { return ((v >> 56) & 0x00000000000000ff) @@ -1109,26 +1181,31 @@ DECLSPEC u64x swap64 (const u64x v) | ((v << 56) & 0xff00000000000000); } +DECLSPEC u32x rotr32 (const u32x a, const u32 n); DECLSPEC u32x rotr32 (const u32x a, const u32 n) { return rotate (a, (32 - n)); } +DECLSPEC u32x rotl32 (const u32x a, const u32 n); DECLSPEC u32x rotl32 (const u32x a, const u32 n) { return rotate (a, n); } +DECLSPEC u64x rotr64 (const u64x a, const u32 n); DECLSPEC u64x rotr64 (const u64x a, const u32 n) { return rotate (a, (u64x) (64 - n)); } +DECLSPEC u64x rotl64 (const u64x a, const u32 n); DECLSPEC u64x rotl64 (const u64x a, const u32 n) { return rotate (a, (u64x) n); } +DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c) { #define BIT(x) ((u32x) (1u) << (x)) @@ -1142,6 +1219,7 @@ DECLSPEC u32x hc_bfe (const u32x a, const u32x b, const u32x c) #undef BFE } +DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c) { #define BIT(x) (1u << (x)) @@ -1155,6 +1233,7 @@ DECLSPEC u32 hc_bfe_S (const u32 a, const u32 b, const u32 c) #undef BFE } +DECLSPEC u32x hc_bytealign_be (const u32x a, const u32x b, const u32 c); DECLSPEC u32x hc_bytealign_be (const u32x a, const u32x b, const u32 c) { u32x r; @@ -1170,6 +1249,7 @@ DECLSPEC u32x hc_bytealign_be (const u32x a, const u32x b, const u32 c) return r; } +DECLSPEC u32 hc_bytealign_be_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bytealign_be_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -1185,6 +1265,7 @@ DECLSPEC u32 hc_bytealign_be_S (const u32 a, const u32 b, const u32 c) return r; } +DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32 c); DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32 c) { u32x r; @@ -1200,6 +1281,7 @@ DECLSPEC u32x hc_bytealign (const u32x a, const u32x b, const u32 c) return r; } +DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c) { u32 r; @@ -1215,21 +1297,25 @@ DECLSPEC u32 hc_bytealign_S (const u32 a, const u32 b, const u32 c) return r; } +DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) { return a + b + c; } +DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_add3_S (const u32 a, const u32 b, const u32 c) { return a + b + c; } +DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c); DECLSPEC u32x hc_lop_0x96 (const u32x a, const u32x b, const u32x c) { return a ^ b ^ c; } +DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c); DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c) { return a ^ b ^ c; @@ -1237,6 +1323,13 @@ DECLSPEC u32 hc_lop_0x96_S (const u32 a, const u32 b, const u32 c) #endif +typedef enum combinator_mode +{ + COMBINATOR_MODE_BASE_LEFT = 10001, + COMBINATOR_MODE_BASE_RIGHT = 10002 + +} combinator_mode_t; + typedef struct digest { u32 digest_buf[DGST_ELEM]; @@ -1265,940 +1358,6 @@ typedef struct salt } salt_t; -#define LUKS_STRIPES 4000 - -typedef enum hc_luks_hash_type -{ - HC_LUKS_HASH_TYPE_SHA1 = 1, - HC_LUKS_HASH_TYPE_SHA256 = 2, - HC_LUKS_HASH_TYPE_SHA512 = 3, - HC_LUKS_HASH_TYPE_RIPEMD160 = 4, - HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, - -} hc_luks_hash_type_t; - -typedef enum hc_luks_key_size -{ - HC_LUKS_KEY_SIZE_128 = 128, - HC_LUKS_KEY_SIZE_256 = 256, - HC_LUKS_KEY_SIZE_512 = 512, - -} hc_luks_key_size_t; - -typedef enum hc_luks_cipher_type -{ - HC_LUKS_CIPHER_TYPE_AES = 1, - HC_LUKS_CIPHER_TYPE_SERPENT = 2, - HC_LUKS_CIPHER_TYPE_TWOFISH = 3, - -} hc_luks_cipher_type_t; - -typedef enum hc_luks_cipher_mode -{ - HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, - HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, - HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, - -} hc_luks_cipher_mode_t; - -typedef struct luks -{ - int hash_type; // hc_luks_hash_type_t - int key_size; // hc_luks_key_size_t - int cipher_type; // hc_luks_cipher_type_t - int cipher_mode; // hc_luks_cipher_mode_t - - u32 ct_buf[128]; - - u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; - -} luks_t; - -typedef struct itunes_backup -{ - u32 wpky[10]; - u32 dpsl[5]; - -} itunes_backup_t; - -typedef struct blake2 -{ - u64 h[8]; - u64 t[2]; - u64 f[2]; - u32 buflen; - u32 outlen; - -} blake2_t; - -typedef struct chacha20 -{ - u32 iv[2]; - u32 plain[2]; - u32 position[2]; - u32 offset; - -} chacha20_t; - -typedef struct pdf -{ - int V; - int R; - int P; - - int enc_md; - - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; - - int id_len; - int o_len; - int u_len; - - u32 rc4key[2]; - u32 rc4data[2]; - -} pdf_t; - -typedef struct wpa_eapol -{ - u32 pke[32]; - u32 eapol[64 + 16]; - u16 eapol_len; - u8 message_pair; - int message_pair_chgd; - u8 keyver; - u8 orig_mac_ap[6]; - u8 orig_mac_sta[6]; - u8 orig_nonce_ap[32]; - u8 orig_nonce_sta[32]; - u8 essid_len; - u8 essid[32]; - u32 keymic[4]; - u32 hash[4]; - int nonce_compare; - int nonce_error_corrections; - int detected_le; - int detected_be; - -} wpa_eapol_t; - -typedef struct wpa_pmkid -{ - u32 pmkid[4]; - u32 pmkid_data[16]; - u8 orig_mac_ap[6]; - u8 orig_mac_sta[6]; - u8 essid_len; - u32 essid_buf[16]; - -} wpa_pmkid_t; - -typedef struct bitcoin_wallet -{ - u32 cry_master_buf[64]; - u32 cry_master_len; - -} bitcoin_wallet_t; - -typedef struct sip -{ - u32 salt_buf[32]; - u32 salt_len; - - u32 esalt_buf[256]; - u32 esalt_len; - -} sip_t; - -typedef struct androidfde -{ - u32 data[384]; - -} androidfde_t; - -typedef struct ikepsk -{ - u32 nr_buf[16]; - u32 nr_len; - - u32 msg_buf[128]; - u32 msg_len[6]; - -} ikepsk_t; - -typedef struct netntlm -{ - u32 user_len; - u32 domain_len; - u32 srvchall_len; - u32 clichall_len; - - u32 userdomain_buf[64]; - u32 chall_buf[256]; - -} netntlm_t; - -typedef struct krb5pa -{ - u32 user[16]; - u32 realm[16]; - u32 salt[32]; - u32 timestamp[16]; - u32 checksum[4]; - -} krb5pa_t; - -typedef struct krb5tgs -{ - u32 account_info[512]; - u32 checksum[4]; - u32 edata2[5120]; - u32 edata2_len; - -} krb5tgs_t; - -typedef struct krb5asrep -{ - u32 account_info[512]; - u32 checksum[4]; - u32 edata2[5120]; - u32 edata2_len; - -} krb5asrep_t; - -typedef struct keyboard_layout_mapping -{ - u32 src_char; - int src_len; - u32 dst_char; - int dst_len; - -} keyboard_layout_mapping_t; - -typedef struct tc -{ - u32 salt_buf[32]; - u32 data_buf[112]; - u32 keyfile_buf[16]; - u32 signature; - - keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; - int keyboard_layout_mapping_cnt; - -} tc_t; - -typedef struct pbkdf2_md5 -{ - u32 salt_buf[64]; - -} pbkdf2_md5_t; - -typedef struct pbkdf2_sha1 -{ - u32 salt_buf[64]; - -} pbkdf2_sha1_t; - -typedef struct pbkdf2_sha256 -{ - u32 salt_buf[64]; - -} pbkdf2_sha256_t; - -typedef struct pbkdf2_sha512 -{ - u32 salt_buf[64]; - -} pbkdf2_sha512_t; - -typedef struct rakp -{ - u32 salt_buf[128]; - u32 salt_len; - -} rakp_t; - -typedef struct cloudkey -{ - u32 data_len; - u32 data_buf[512]; - -} cloudkey_t; - -typedef struct office2007 -{ - u32 encryptedVerifier[4]; - u32 encryptedVerifierHash[5]; - - u32 keySize; - -} office2007_t; - -typedef struct office2010 -{ - u32 encryptedVerifier[4]; - u32 encryptedVerifierHash[8]; - -} office2010_t; - -typedef struct office2013 -{ - u32 encryptedVerifier[4]; - u32 encryptedVerifierHash[8]; - -} office2013_t; - -typedef struct oldoffice01 -{ - u32 version; - u32 encryptedVerifier[4]; - u32 encryptedVerifierHash[4]; - u32 rc4key[2]; - -} oldoffice01_t; - -typedef struct oldoffice34 -{ - u32 version; - u32 encryptedVerifier[4]; - u32 encryptedVerifierHash[5]; - u32 rc4key[2]; - -} oldoffice34_t; - -typedef struct odf11_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[5]; - u32 out[5]; - -} odf11_tmp_t; - -typedef struct odf11 -{ - u32 iterations; - u32 iv[2]; - u32 checksum[5]; - u32 encrypted_data[256]; - -} odf11_t; - -typedef struct odf12_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[10]; - u32 out[10]; - -} odf12_tmp_t; - -typedef struct odf12 -{ - u32 iterations; - u32 iv[4]; - u32 checksum[8]; - u32 encrypted_data[256]; - -} odf12_t; - -typedef struct pstoken -{ - u32 salt_buf[128]; - u32 salt_len; - - u32 pc_digest[5]; - u32 pc_offset; - -} pstoken_t; - -typedef struct zip2 -{ - u32 type; - u32 mode; - u32 magic; - u32 salt_len; - u32 salt_buf[4]; - u32 verify_bytes; - u32 compress_length; - u32 data_len; - u32 data_buf[2048]; - u32 auth_len; - u32 auth_buf[4]; - -} zip2_t; - -typedef struct win8phone -{ - u32 salt_buf[32]; - -} win8phone_t; - -typedef struct keepass -{ - u32 version; - u32 algorithm; - - /* key-file handling */ - u32 keyfile_len; - u32 keyfile[8]; - - u32 final_random_seed[8]; - u32 transf_random_seed[8]; - u32 enc_iv[4]; - u32 contents_hash[8]; - - /* specific to version 1 */ - u32 contents_len; - u32 contents[75000]; - - /* specific to version 2 */ - u32 expected_bytes[8]; - -} keepass_t; - -typedef struct dpapimk -{ - u32 context; - - u32 SID[32]; - u32 SID_len; - u32 SID_offset; - - /* here only for possible - forward compatibiliy - */ - // u8 cipher_algo[16]; - // u8 hash_algo[16]; - - u32 iv[4]; - u32 contents_len; - u32 contents[128]; - -} dpapimk_t; - -typedef struct jks_sha1 -{ - u32 checksum[5]; - u32 iv[5]; - u32 enc_key_buf[4096]; - u32 enc_key_len; - u32 der[5]; - u32 alias[16]; - -} jks_sha1_t; - -typedef struct ethereum_pbkdf2 -{ - u32 salt_buf[16]; - u32 ciphertext[8]; - -} ethereum_pbkdf2_t; - -typedef struct ethereum_scrypt -{ - u32 salt_buf[16]; - u32 ciphertext[8]; - -} ethereum_scrypt_t; - -typedef struct ethereum_presale -{ - u32 iv[4]; - u32 enc_seed[152]; - u32 enc_seed_len; - -} ethereum_presale_t; - -typedef struct tacacs_plus -{ - u32 session_buf[16]; - - u32 ct_data_buf[64]; - u32 ct_data_len; - - u32 sequence_buf[16]; - -} tacacs_plus_t; - -typedef struct apple_secure_notes -{ - u32 Z_PK; - u32 ZCRYPTOITERATIONCOUNT; - u32 ZCRYPTOSALT[16]; - u32 ZCRYPTOWRAPPEDKEY[16]; - -} apple_secure_notes_t; - -typedef struct jwt -{ - u32 salt_buf[1024]; - u32 salt_len; - - u32 signature_len; - -} jwt_t; - -typedef struct electrum_wallet -{ - u32 salt_type; - u32 iv[4]; - u32 encrypted[4]; - -} electrum_wallet_t; - -typedef struct ansible_vault -{ - u32 cipher; - u32 version; - u32 ct_data_buf[4096]; - u32 ct_data_len; -} ansible_vault_t; - -typedef struct pdf14_tmp -{ - u32 digest[4]; - u32 out[4]; - -} pdf14_tmp_t; - -typedef struct luks_tmp -{ - u32 ipad32[8]; - u64 ipad64[8]; - - u32 opad32[8]; - u64 opad64[8]; - - u32 dgst32[32]; - u64 dgst64[16]; - - u32 out32[32]; - u64 out64[16]; - -} luks_tmp_t; - -typedef struct pdf17l8_tmp -{ - union - { - u32 dgst32[16]; - u64 dgst64[8]; - }; - - u32 dgst_len; - u32 W_len; - -} pdf17l8_tmp_t; - -typedef struct phpass_tmp -{ - u32 digest_buf[4]; - -} phpass_tmp_t; - -typedef struct md5crypt_tmp -{ - u32 digest_buf[4]; - -} md5crypt_tmp_t; - -typedef struct sha256crypt_tmp -{ - // pure version - - u32 alt_result[8]; - u32 p_bytes[64]; - u32 s_bytes[64]; - -} sha256crypt_tmp_t; - -typedef struct sha512crypt_tmp -{ - u64 l_alt_result[8]; - u64 l_p_bytes[2]; - u64 l_s_bytes[2]; - - // pure version - - u32 alt_result[16]; - u32 p_bytes[64]; - u32 s_bytes[64]; - -} sha512crypt_tmp_t; - -typedef struct wpa_pbkdf2_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[10]; - u32 out[10]; - -} wpa_pbkdf2_tmp_t; - -typedef struct wpa_pmk_tmp -{ - u32 out[8]; - -} wpa_pmk_tmp_t; - -typedef struct bitcoin_wallet_tmp -{ - u64 dgst[8]; - -} bitcoin_wallet_tmp_t; - -typedef struct dcc2_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[5]; - u32 out[4]; - -} dcc2_tmp_t; - -typedef struct bcrypt_tmp -{ - u32 E[18]; - - u32 P[18]; - - u32 S0[256]; - u32 S1[256]; - u32 S2[256]; - u32 S3[256]; - -} bcrypt_tmp_t; - -typedef struct pwsafe2_tmp -{ - u32 digest[2]; - - u32 P[18]; - - u32 S0[256]; - u32 S1[256]; - u32 S2[256]; - u32 S3[256]; - -} pwsafe2_tmp_t; - -typedef struct pwsafe3_tmp -{ - u32 digest_buf[8]; - -} pwsafe3_tmp_t; - -typedef struct androidpin_tmp -{ - u32 digest_buf[5]; - -} androidpin_tmp_t; - -typedef struct androidfde_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[10]; - u32 out[10]; - -} androidfde_tmp_t; - -typedef struct tc_tmp -{ - u32 ipad[16]; - u32 opad[16]; - - u32 dgst[64]; - u32 out[64]; - -} tc_tmp_t; - -typedef struct tc64_tmp -{ - u64 ipad[8]; - u64 opad[8]; - - u64 dgst[32]; - u64 out[32]; - -} tc64_tmp_t; - -typedef struct vc64_sbog_tmp -{ - u64 ipad_raw[8]; - u64 opad_raw[8]; - - u64 ipad_hash[8]; - u64 opad_hash[8]; - - u64 dgst[32]; - u64 out[32]; - -} vc64_sbog_tmp_t; - -typedef struct pbkdf1_sha1_tmp -{ - // pbkdf1-sha1 is limited to 160 bits - - u32 ipad[5]; - u32 opad[5]; - - u32 out[5]; - -} pbkdf1_sha1_tmp_t; - -typedef struct pbkdf2_md5_tmp -{ - u32 ipad[4]; - u32 opad[4]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_md5_tmp_t; - -typedef struct pbkdf2_sha1_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha1_tmp_t; - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; - -typedef struct pbkdf2_sha512_tmp -{ - u64 ipad[8]; - u64 opad[8]; - - u64 dgst[16]; - u64 out[16]; - -} pbkdf2_sha512_tmp_t; - -typedef struct ecryptfs_tmp -{ - u64 out[8]; - -} ecryptfs_tmp_t; - -typedef struct oraclet_tmp -{ - u64 ipad[8]; - u64 opad[8]; - - u64 dgst[16]; - u64 out[16]; - -} oraclet_tmp_t; - -typedef struct agilekey_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[5]; - u32 out[5]; - -} agilekey_tmp_t; - -typedef struct mywallet_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[10]; - u32 out[10]; - -} mywallet_tmp_t; - -typedef struct sha1aix_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[5]; - u32 out[5]; - -} sha1aix_tmp_t; - -typedef struct sha256aix_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[8]; - u32 out[8]; - -} sha256aix_tmp_t; - -typedef struct sha512aix_tmp -{ - u64 ipad[8]; - u64 opad[8]; - - u64 dgst[8]; - u64 out[8]; - -} sha512aix_tmp_t; - -typedef struct lastpass_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[8]; - u32 out[8]; - -} lastpass_tmp_t; - -typedef struct drupal7_tmp -{ - u64 digest_buf[8]; - -} drupal7_tmp_t; - -typedef struct lotus8_tmp -{ - u32 ipad[5]; - u32 opad[5]; - - u32 dgst[5]; - u32 out[5]; - -} lotus8_tmp_t; - -typedef struct office2007_tmp -{ - u32 out[5]; - -} office2007_tmp_t; - -typedef struct office2010_tmp -{ - u32 out[5]; - -} office2010_tmp_t; - -typedef struct office2013_tmp -{ - u64 out[8]; - -} office2013_tmp_t; - -typedef struct saph_sha1_tmp -{ - u32 digest_buf[5]; - -} saph_sha1_tmp_t; - -typedef struct seven_zip_tmp -{ - u32 h[8]; - - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - - int len; - -} seven_zip_tmp_t; - -typedef struct axcrypt_tmp -{ - u32 KEK[4]; - u32 lsb[4]; - u32 cipher[4]; - -} axcrypt_tmp_t; - -typedef struct keepass_tmp -{ - u32 tmp_digest[8]; - -} keepass_tmp_t; - -typedef struct dpapimk_tmp_v1 -{ - u32 ipad[5]; - u32 opad[5]; - u32 dgst[10]; - u32 out[10]; - - u32 userKey[5]; - -} dpapimk_tmp_v1_t; - -typedef struct dpapimk_tmp_v2 -{ - u64 ipad64[8]; - u64 opad64[8]; - u64 dgst64[16]; - u64 out64[16]; - - u32 userKey[8]; - -} dpapimk_tmp_v2_t; - -typedef struct apple_secure_notes_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[8]; - u32 out[8]; - -} apple_secure_notes_tmp_t; - -typedef struct bsdicrypt_tmp -{ - u32 Kc[16]; - u32 Kd[16]; - - u32 iv[2]; - -} bsdicrypt_tmp_t; - -typedef struct rar3_tmp -{ - u32 dgst[17][5]; - -} rar3_tmp_t; - -typedef struct -{ - u32 ukey[8]; - - u32 hook_success; - -} seven_zip_hook_t; - -typedef struct cram_md5 -{ - u32 user[16]; - -} cram_md5_t; - typedef struct { u32 key; @@ -2254,22 +1413,16 @@ typedef struct plain u32 salt_pos; u32 digest_pos; u32 hash_pos; + u32 extra1; + u32 extra2; } plain_t; -typedef struct +typedef struct keyboard_layout_mapping { - #ifndef SCRYPT_TMP_ELEM - #define SCRYPT_TMP_ELEM 1 - #endif + u32 src_char; + int src_len; + u32 dst_char; + int dst_len; - uint4 P[SCRYPT_TMP_ELEM]; - -} scrypt_tmp_t; - -typedef enum combinator_mode -{ - COMBINATOR_MODE_BASE_LEFT = 10001, - COMBINATOR_MODE_BASE_RIGHT = 10002 - -} combinator_mode_t; +} keyboard_layout_mapping_t; diff --git a/OpenCL/inc_vendor.cl b/OpenCL/inc_vendor.cl index e28fa0a20..8fc58a19f 100644 --- a/OpenCL/inc_vendor.cl +++ b/OpenCL/inc_vendor.cl @@ -100,97 +100,3 @@ #ifdef NO_UNROLL #undef _unroll #endif - -#if KERN_TYPE == 1420 -#undef _unroll -#endif -#if KERN_TYPE == 1450 -#undef _unroll -#endif -#if KERN_TYPE == 1460 -#undef _unroll -#endif -#if KERN_TYPE == 1720 -#undef _unroll -#endif -#if KERN_TYPE == 1750 -#undef _unroll -#endif -#if KERN_TYPE == 1760 -#undef _unroll -#endif -#if KERN_TYPE == 1800 -#undef _unroll -#endif -#if KERN_TYPE == 6221 -#undef _unroll -#endif -#if KERN_TYPE == 6222 -#undef _unroll -#endif -#if KERN_TYPE == 6223 -#undef _unroll -#endif -#if KERN_TYPE == 6400 -#undef _unroll -#endif -#if KERN_TYPE == 6500 -#undef _unroll -#endif -#if KERN_TYPE == 7100 -#undef _unroll -#endif -#if KERN_TYPE == 7400 -#undef _unroll -#endif -#if KERN_TYPE == 7900 -#undef _unroll -#endif -#if KERN_TYPE == 8900 -#undef _unroll -#endif -#if KERN_TYPE == 10700 -#undef _unroll -#endif -#if KERN_TYPE == 13721 -#undef _unroll -#endif -#if KERN_TYPE == 13722 -#undef _unroll -#endif -#if KERN_TYPE == 13723 -#undef _unroll -#endif -#if KERN_TYPE == 13751 -#undef _unroll -#endif -#if KERN_TYPE == 13752 -#undef _unroll -#endif -#if KERN_TYPE == 13753 -#undef _unroll -#endif -#if KERN_TYPE == 13800 -#undef _unroll -#endif -#if KERN_TYPE == 15700 -#undef _unroll -#endif - -// nvidia specific - -#ifdef IS_NV -#ifdef IS_GPU - -#endif -#endif - -// apple specific - -#ifdef IS_APPLE - -#if KERN_TYPE == 5000 -#undef _unroll -#endif - -#endif diff --git a/OpenCL/inc_veracrypt_xts.cl b/OpenCL/inc_veracrypt_xts.cl index d6310d274..a7c598360 100644 --- a/OpenCL/inc_veracrypt_xts.cl +++ b/OpenCL/inc_veracrypt_xts.cl @@ -1,3 +1,4 @@ +DECLSPEC void camellia256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks); DECLSPEC void camellia256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks) { out[0] = in[0]; @@ -22,6 +23,7 @@ DECLSPEC void camellia256_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, out[3] ^= T[3]; } +DECLSPEC void camellia256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks); DECLSPEC void camellia256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks) { out[0] = in[0]; @@ -44,6 +46,7 @@ DECLSPEC void camellia256_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 out[3] ^= T[3]; } +DECLSPEC void kuznyechik_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks); DECLSPEC void kuznyechik_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, const u32 *in, u32 *out, u32 *S, u32 *T, u32 *ks) { out[0] = in[0]; @@ -68,6 +71,7 @@ DECLSPEC void kuznyechik_decrypt_xts_first (const u32 *ukey1, const u32 *ukey2, out[3] ^= T[3]; } +DECLSPEC void kuznyechik_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks); DECLSPEC void kuznyechik_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 *ks) { out[0] = in[0]; @@ -92,7 +96,8 @@ DECLSPEC void kuznyechik_decrypt_xts_next (const u32 *in, u32 *out, u32 *T, u32 // 512 bit -DECLSPEC int verify_header_camellia (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2) +DECLSPEC int verify_header_camellia (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2); +DECLSPEC int verify_header_camellia (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2) { u32 ks_camellia[68]; @@ -102,17 +107,15 @@ DECLSPEC int verify_header_camellia (__global const tc_t *esalt_bufs, const u32 u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; camellia256_decrypt_xts_first (ukey1, ukey2, data, tmp, S, T_camellia, ks_camellia); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -130,10 +133,10 @@ DECLSPEC int verify_header_camellia (__global const tc_t *esalt_bufs, const u32 for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; camellia256_decrypt_xts_next (data, tmp, T_camellia, ks_camellia); @@ -148,7 +151,8 @@ DECLSPEC int verify_header_camellia (__global const tc_t *esalt_bufs, const u32 return 1; } -DECLSPEC int verify_header_kuznyechik (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2) +DECLSPEC int verify_header_kuznyechik (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2); +DECLSPEC int verify_header_kuznyechik (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2) { u32 ks_kuznyechik[40]; @@ -158,17 +162,15 @@ DECLSPEC int verify_header_kuznyechik (__global const tc_t *esalt_bufs, const u3 u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; kuznyechik_decrypt_xts_first (ukey1, ukey2, data, tmp, S, T_kuznyechik, ks_kuznyechik); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -186,10 +188,10 @@ DECLSPEC int verify_header_kuznyechik (__global const tc_t *esalt_bufs, const u3 for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; kuznyechik_decrypt_xts_next (data, tmp, T_kuznyechik, ks_kuznyechik); @@ -206,7 +208,8 @@ DECLSPEC int verify_header_kuznyechik (__global const tc_t *esalt_bufs, const u3 // 1024 bit -DECLSPEC int verify_header_camellia_kuznyechik (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) +DECLSPEC int verify_header_camellia_kuznyechik (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4); +DECLSPEC int verify_header_camellia_kuznyechik (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) { u32 ks_camellia[68]; u32 ks_kuznyechik[40]; @@ -218,18 +221,16 @@ DECLSPEC int verify_header_camellia_kuznyechik (__global const tc_t *esalt_bufs, u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; camellia256_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_camellia, ks_camellia); kuznyechik_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_kuznyechik, ks_kuznyechik); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -248,10 +249,10 @@ DECLSPEC int verify_header_camellia_kuznyechik (__global const tc_t *esalt_bufs, for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; camellia256_decrypt_xts_next (data, tmp, T_camellia, ks_camellia); kuznyechik_decrypt_xts_next (tmp, tmp, T_kuznyechik, ks_kuznyechik); @@ -267,7 +268,8 @@ DECLSPEC int verify_header_camellia_kuznyechik (__global const tc_t *esalt_bufs, return 1; } -DECLSPEC int verify_header_camellia_serpent (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) +DECLSPEC int verify_header_camellia_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4); +DECLSPEC int verify_header_camellia_serpent (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) { u32 ks_camellia[68]; u32 ks_serpent[140]; @@ -279,18 +281,16 @@ DECLSPEC int verify_header_camellia_serpent (__global const tc_t *esalt_bufs, co u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; camellia256_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_camellia, ks_camellia); serpent256_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_serpent, ks_serpent); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -309,10 +309,10 @@ DECLSPEC int verify_header_camellia_serpent (__global const tc_t *esalt_bufs, co for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; camellia256_decrypt_xts_next (data, tmp, T_camellia, ks_camellia); serpent256_decrypt_xts_next (tmp, tmp, T_serpent, ks_serpent); @@ -328,7 +328,8 @@ DECLSPEC int verify_header_camellia_serpent (__global const tc_t *esalt_bufs, co return 1; } -DECLSPEC int verify_header_kuznyechik_aes (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +DECLSPEC int verify_header_kuznyechik_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4); +DECLSPEC int verify_header_kuznyechik_aes (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) { u32 ks_kuznyechik[40]; u32 ks_aes[60]; @@ -340,18 +341,16 @@ DECLSPEC int verify_header_kuznyechik_aes (__global const tc_t *esalt_bufs, cons u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; kuznyechik_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_kuznyechik, ks_kuznyechik); aes256_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_aes, ks_aes, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -370,10 +369,10 @@ DECLSPEC int verify_header_kuznyechik_aes (__global const tc_t *esalt_bufs, cons for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; kuznyechik_decrypt_xts_next (data, tmp, T_kuznyechik, ks_kuznyechik); aes256_decrypt_xts_next (tmp, tmp, T_aes, ks_aes, s_td0, s_td1, s_td2, s_td3, s_td4); @@ -389,7 +388,8 @@ DECLSPEC int verify_header_kuznyechik_aes (__global const tc_t *esalt_bufs, cons return 1; } -DECLSPEC int verify_header_kuznyechik_twofish (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) +DECLSPEC int verify_header_kuznyechik_twofish (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4); +DECLSPEC int verify_header_kuznyechik_twofish (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4) { u32 ks_kuznyechik[40]; @@ -403,18 +403,16 @@ DECLSPEC int verify_header_kuznyechik_twofish (__global const tc_t *esalt_bufs, u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; kuznyechik_decrypt_xts_first (ukey2, ukey4, data, tmp, S, T_kuznyechik, ks_kuznyechik); twofish256_decrypt_xts_first (ukey1, ukey3, tmp, tmp, S, T_twofish, sk_twofish, lk_twofish); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -433,10 +431,10 @@ DECLSPEC int verify_header_kuznyechik_twofish (__global const tc_t *esalt_bufs, for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; kuznyechik_decrypt_xts_next (data, tmp, T_kuznyechik, ks_kuznyechik); twofish256_decrypt_xts_next (tmp, tmp, T_twofish, sk_twofish, lk_twofish); @@ -454,7 +452,8 @@ DECLSPEC int verify_header_kuznyechik_twofish (__global const tc_t *esalt_bufs, // 1536 bit -DECLSPEC int verify_header_kuznyechik_serpent_camellia (__global const tc_t *esalt_bufs, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6) +DECLSPEC int verify_header_kuznyechik_serpent_camellia (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6); +DECLSPEC int verify_header_kuznyechik_serpent_camellia (__global const u32 *data_buf, const u32 signature, const u32 *ukey1, const u32 *ukey2, const u32 *ukey3, const u32 *ukey4, const u32 *ukey5, const u32 *ukey6) { u32 ks_kuznyechik[40]; u32 ks_serpent[140]; @@ -468,10 +467,10 @@ DECLSPEC int verify_header_kuznyechik_serpent_camellia (__global const tc_t *esa u32 data[4]; - data[0] = esalt_bufs[0].data_buf[0]; - data[1] = esalt_bufs[0].data_buf[1]; - data[2] = esalt_bufs[0].data_buf[2]; - data[3] = esalt_bufs[0].data_buf[3]; + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; u32 tmp[4]; @@ -479,8 +478,6 @@ DECLSPEC int verify_header_kuznyechik_serpent_camellia (__global const tc_t *esa serpent256_decrypt_xts_first (ukey2, ukey5, tmp, tmp, S, T_serpent, ks_serpent); camellia256_decrypt_xts_first (ukey1, ukey4, tmp, tmp, S, T_camellia, ks_camellia); - const u32 signature = esalt_bufs[0].signature; - if (tmp[0] != signature) return 0; const u32 crc32_save = swap32_S (~tmp[2]); @@ -500,10 +497,10 @@ DECLSPEC int verify_header_kuznyechik_serpent_camellia (__global const tc_t *esa for (int i = 64 - 16; i < 128 - 16; i += 4) { - data[0] = esalt_bufs[0].data_buf[i + 0]; - data[1] = esalt_bufs[0].data_buf[i + 1]; - data[2] = esalt_bufs[0].data_buf[i + 2]; - data[3] = esalt_bufs[0].data_buf[i + 3]; + data[0] = data_buf[i + 0]; + data[1] = data_buf[i + 1]; + data[2] = data_buf[i + 2]; + data[3] = data_buf[i + 3]; kuznyechik_decrypt_xts_next (data, tmp, T_kuznyechik, ks_kuznyechik); serpent256_decrypt_xts_next (tmp, tmp, T_serpent, ks_serpent); diff --git a/OpenCL/m00400-optimized.cl b/OpenCL/m00400-optimized.cl index ffb51984b..62970e2b1 100644 --- a/OpenCL/m00400-optimized.cl +++ b/OpenCL/m00400-optimized.cl @@ -16,6 +16,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct phpass_tmp +{ + u32 digest_buf[4]; + +} phpass_tmp_t; + __kernel void m00400_init (KERN_ATTR_TMPS (phpass_tmp_t)) { /** diff --git a/OpenCL/m00400-pure.cl b/OpenCL/m00400-pure.cl index 65430e0bd..c945ae3c3 100644 --- a/OpenCL/m00400-pure.cl +++ b/OpenCL/m00400-pure.cl @@ -16,6 +16,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct phpass_tmp +{ + u32 digest_buf[4]; + +} phpass_tmp_t; + __kernel void m00400_init (KERN_ATTR_TMPS (phpass_tmp_t)) { /** diff --git a/OpenCL/m00500-optimized.cl b/OpenCL/m00500-optimized.cl index e2a39b401..eddc33a0a 100644 --- a/OpenCL/m00500-optimized.cl +++ b/OpenCL/m00500-optimized.cl @@ -15,6 +15,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct md5crypt_tmp +{ + u32 digest_buf[4]; + +} md5crypt_tmp_t; + #define md5crypt_magic 0x00243124u DECLSPEC void memcat16 (u32 *block0, u32 *block1, u32 *block2, u32 *block3, const u32 offset, const u32 *append) diff --git a/OpenCL/m00500-pure.cl b/OpenCL/m00500-pure.cl index bc4816999..f4ea85e76 100644 --- a/OpenCL/m00500-pure.cl +++ b/OpenCL/m00500-pure.cl @@ -15,6 +15,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct md5crypt_tmp +{ + u32 digest_buf[4]; + +} md5crypt_tmp_t; + #define md5crypt_magic 0x00243124u __kernel void m00500_init (KERN_ATTR_TMPS (md5crypt_tmp_t)) diff --git a/OpenCL/m00600_a0-optimized.cl b/OpenCL/m00600_a0-optimized.cl index f5991d1b2..8a64b977b 100644 --- a/OpenCL/m00600_a0-optimized.cl +++ b/OpenCL/m00600_a0-optimized.cl @@ -14,6 +14,16 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct blake2 +{ + u64 h[8]; + u64 t[2]; + u64 f[2]; + u32 buflen; + u32 outlen; + +} blake2_t; + #define BLAKE2B_FINAL 1 #define BLAKE2B_UPDATE 0 diff --git a/OpenCL/m00600_a1-optimized.cl b/OpenCL/m00600_a1-optimized.cl index be4658f9b..7d4d837bb 100644 --- a/OpenCL/m00600_a1-optimized.cl +++ b/OpenCL/m00600_a1-optimized.cl @@ -14,6 +14,16 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct blake2 +{ + u64 h[8]; + u64 t[2]; + u64 f[2]; + u32 buflen; + u32 outlen; + +} blake2_t; + #define BLAKE2B_FINAL 1 #define BLAKE2B_UPDATE 0 diff --git a/OpenCL/m00600_a3-optimized.cl b/OpenCL/m00600_a3-optimized.cl index d95f8a5c4..bb3796ade 100644 --- a/OpenCL/m00600_a3-optimized.cl +++ b/OpenCL/m00600_a3-optimized.cl @@ -12,6 +12,16 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct blake2 +{ + u64 h[8]; + u64 t[2]; + u64 f[2]; + u32 buflen; + u32 outlen; + +} blake2_t; + #define BLAKE2B_FINAL 1 #define BLAKE2B_UPDATE 0 diff --git a/OpenCL/m01600-optimized.cl b/OpenCL/m01600-optimized.cl index e5a09c5b3..0281c8b87 100644 --- a/OpenCL/m01600-optimized.cl +++ b/OpenCL/m01600-optimized.cl @@ -13,6 +13,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct md5crypt_tmp +{ + u32 digest_buf[4]; + +} md5crypt_tmp_t; + #define md5apr1_magic0 0x72706124u #define md5apr1_magic1 0x00002431u diff --git a/OpenCL/m01600-pure.cl b/OpenCL/m01600-pure.cl index 0337b1ad1..741a35022 100644 --- a/OpenCL/m01600-pure.cl +++ b/OpenCL/m01600-pure.cl @@ -18,6 +18,12 @@ #define PUTCHAR_LE(a,p,c) ((u8 *)(a))[(p)] = (u8) (c) #define GETCHAR_LE(a,p) ((u8 *)(a))[(p)] +typedef struct md5crypt_tmp +{ + u32 digest_buf[4]; + +} md5crypt_tmp_t; + #define md5apr1_magic0 0x72706124u #define md5apr1_magic1 0x00002431u diff --git a/OpenCL/m01800-optimized.cl b/OpenCL/m01800-optimized.cl index 15a9d6fd9..087c64ef0 100644 --- a/OpenCL/m01800-optimized.cl +++ b/OpenCL/m01800-optimized.cl @@ -16,6 +16,20 @@ #define PUTCHAR64_BE(a,p,c) ((u8 *)(a))[(p) ^ 7] = (u8) (c) #define GETCHAR64_BE(a,p) ((u8 *)(a))[(p) ^ 7] +typedef struct sha512crypt_tmp +{ + u64 l_alt_result[8]; + u64 l_p_bytes[2]; + u64 l_s_bytes[2]; + + // pure version + + u32 alt_result[16]; + u32 p_bytes[64]; + u32 s_bytes[64]; + +} sha512crypt_tmp_t; + typedef struct { u64 state[8]; diff --git a/OpenCL/m01800-pure.cl b/OpenCL/m01800-pure.cl index c31be393f..0884f84a3 100644 --- a/OpenCL/m01800-pure.cl +++ b/OpenCL/m01800-pure.cl @@ -13,6 +13,20 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct sha512crypt_tmp +{ + u64 l_alt_result[8]; + u64 l_p_bytes[2]; + u64 l_s_bytes[2]; + + // pure version + + u32 alt_result[16]; + u32 p_bytes[64]; + u32 s_bytes[64]; + +} sha512crypt_tmp_t; + __kernel void m01800_init (KERN_ATTR_TMPS (sha512crypt_tmp_t)) { /** diff --git a/OpenCL/m02100-pure.cl b/OpenCL/m02100-pure.cl index ecaa9b75b..6060a4a7e 100644 --- a/OpenCL/m02100-pure.cl +++ b/OpenCL/m02100-pure.cl @@ -17,6 +17,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct dcc2_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[5]; + u32 out[4]; + +} dcc2_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m02500-pure.cl b/OpenCL/m02500-pure.cl index 907e1566f..fbad337d6 100644 --- a/OpenCL/m02500-pure.cl +++ b/OpenCL/m02500-pure.cl @@ -19,6 +19,39 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct wpa_eapol +{ + u32 pke[32]; + u32 eapol[64 + 16]; + u16 eapol_len; + u8 message_pair; + int message_pair_chgd; + u8 keyver; + u8 orig_mac_ap[6]; + u8 orig_mac_sta[6]; + u8 orig_nonce_ap[32]; + u8 orig_nonce_sta[32]; + u8 essid_len; + u8 essid[32]; + u32 keymic[4]; + u32 hash[4]; + int nonce_compare; + int nonce_error_corrections; + int detected_le; + int detected_be; + +} wpa_eapol_t; + +typedef struct wpa_pbkdf2_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[10]; + u32 out[10]; + +} wpa_pbkdf2_tmp_t; + DECLSPEC void make_kn (u32 *k) { u32 kl[4]; @@ -431,7 +464,7 @@ __kernel void m02500_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -551,7 +584,7 @@ __kernel void m02500_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -742,7 +775,7 @@ __kernel void m02500_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -862,7 +895,7 @@ __kernel void m02500_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -1136,7 +1169,7 @@ __kernel void m02500_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -1287,7 +1320,7 @@ __kernel void m02500_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } diff --git a/OpenCL/m02501-pure.cl b/OpenCL/m02501-pure.cl index 13d66301c..2b9c19c3f 100644 --- a/OpenCL/m02501-pure.cl +++ b/OpenCL/m02501-pure.cl @@ -19,6 +19,35 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct wpa_pmk_tmp +{ + u32 out[8]; + +} wpa_pmk_tmp_t; + +typedef struct wpa_eapol +{ + u32 pke[32]; + u32 eapol[64 + 16]; + u16 eapol_len; + u8 message_pair; + int message_pair_chgd; + u8 keyver; + u8 orig_mac_ap[6]; + u8 orig_mac_sta[6]; + u8 orig_nonce_ap[32]; + u8 orig_nonce_sta[32]; + u8 essid_len; + u8 essid[32]; + u32 keymic[4]; + u32 hash[4]; + int nonce_compare; + int nonce_error_corrections; + int detected_le; + int detected_be; + +} wpa_eapol_t; + DECLSPEC u8 hex_convert (const u8 c) { return (c & 15) + (c >> 6) * 9; @@ -306,7 +335,7 @@ __kernel void m02501_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -426,7 +455,7 @@ __kernel void m02501_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -617,7 +646,7 @@ __kernel void m02501_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -737,7 +766,7 @@ __kernel void m02501_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -1011,7 +1040,7 @@ __kernel void m02501_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } @@ -1162,7 +1191,7 @@ __kernel void m02501_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t)) { if (atomic_inc (&hashes_shown[digest_cur]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); } } } diff --git a/OpenCL/m03100_a0-optimized.cl b/OpenCL/m03100_a0-optimized.cl index 045537d13..4de52c967 100644 --- a/OpenCL/m03100_a0-optimized.cl +++ b/OpenCL/m03100_a0-optimized.cl @@ -14,478 +14,7 @@ #include "inc_rp_optimized.h" #include "inc_rp_optimized.cl" #include "inc_simd.cl" - -#define PERM_OP(a,b,tt,n,m) \ -{ \ - tt = a >> n; \ - tt = tt ^ b; \ - tt = tt & m; \ - b = b ^ tt; \ - tt = tt << n; \ - a = a ^ tt; \ -} - -#define HPERM_OP(a,tt,n,m) \ -{ \ - tt = a << (16 + n); \ - tt = tt ^ a; \ - tt = tt & m; \ - a = a ^ tt; \ - tt = tt >> (16 + n); \ - a = a ^ tt; \ -} - -#define IP(l,r,tt) \ -{ \ - PERM_OP (r, l, tt, 4, 0x0f0f0f0f); \ - PERM_OP (l, r, tt, 16, 0x0000ffff); \ - PERM_OP (r, l, tt, 2, 0x33333333); \ - PERM_OP (l, r, tt, 8, 0x00ff00ff); \ - PERM_OP (r, l, tt, 1, 0x55555555); \ -} - -#define FP(l,r,tt) \ -{ \ - PERM_OP (l, r, tt, 1, 0x55555555); \ - PERM_OP (r, l, tt, 8, 0x00ff00ff); \ - PERM_OP (l, r, tt, 2, 0x33333333); \ - PERM_OP (r, l, tt, 16, 0x0000ffff); \ - PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \ -} - -__constant u32a c_SPtrans[8][64] = -{ - { - 0x02080800, 0x00080000, 0x02000002, 0x02080802, - 0x02000000, 0x00080802, 0x00080002, 0x02000002, - 0x00080802, 0x02080800, 0x02080000, 0x00000802, - 0x02000802, 0x02000000, 0x00000000, 0x00080002, - 0x00080000, 0x00000002, 0x02000800, 0x00080800, - 0x02080802, 0x02080000, 0x00000802, 0x02000800, - 0x00000002, 0x00000800, 0x00080800, 0x02080002, - 0x00000800, 0x02000802, 0x02080002, 0x00000000, - 0x00000000, 0x02080802, 0x02000800, 0x00080002, - 0x02080800, 0x00080000, 0x00000802, 0x02000800, - 0x02080002, 0x00000800, 0x00080800, 0x02000002, - 0x00080802, 0x00000002, 0x02000002, 0x02080000, - 0x02080802, 0x00080800, 0x02080000, 0x02000802, - 0x02000000, 0x00000802, 0x00080002, 0x00000000, - 0x00080000, 0x02000000, 0x02000802, 0x02080800, - 0x00000002, 0x02080002, 0x00000800, 0x00080802, - }, - { - 0x40108010, 0x00000000, 0x00108000, 0x40100000, - 0x40000010, 0x00008010, 0x40008000, 0x00108000, - 0x00008000, 0x40100010, 0x00000010, 0x40008000, - 0x00100010, 0x40108000, 0x40100000, 0x00000010, - 0x00100000, 0x40008010, 0x40100010, 0x00008000, - 0x00108010, 0x40000000, 0x00000000, 0x00100010, - 0x40008010, 0x00108010, 0x40108000, 0x40000010, - 0x40000000, 0x00100000, 0x00008010, 0x40108010, - 0x00100010, 0x40108000, 0x40008000, 0x00108010, - 0x40108010, 0x00100010, 0x40000010, 0x00000000, - 0x40000000, 0x00008010, 0x00100000, 0x40100010, - 0x00008000, 0x40000000, 0x00108010, 0x40008010, - 0x40108000, 0x00008000, 0x00000000, 0x40000010, - 0x00000010, 0x40108010, 0x00108000, 0x40100000, - 0x40100010, 0x00100000, 0x00008010, 0x40008000, - 0x40008010, 0x00000010, 0x40100000, 0x00108000, - }, - { - 0x04000001, 0x04040100, 0x00000100, 0x04000101, - 0x00040001, 0x04000000, 0x04000101, 0x00040100, - 0x04000100, 0x00040000, 0x04040000, 0x00000001, - 0x04040101, 0x00000101, 0x00000001, 0x04040001, - 0x00000000, 0x00040001, 0x04040100, 0x00000100, - 0x00000101, 0x04040101, 0x00040000, 0x04000001, - 0x04040001, 0x04000100, 0x00040101, 0x04040000, - 0x00040100, 0x00000000, 0x04000000, 0x00040101, - 0x04040100, 0x00000100, 0x00000001, 0x00040000, - 0x00000101, 0x00040001, 0x04040000, 0x04000101, - 0x00000000, 0x04040100, 0x00040100, 0x04040001, - 0x00040001, 0x04000000, 0x04040101, 0x00000001, - 0x00040101, 0x04000001, 0x04000000, 0x04040101, - 0x00040000, 0x04000100, 0x04000101, 0x00040100, - 0x04000100, 0x00000000, 0x04040001, 0x00000101, - 0x04000001, 0x00040101, 0x00000100, 0x04040000, - }, - { - 0x00401008, 0x10001000, 0x00000008, 0x10401008, - 0x00000000, 0x10400000, 0x10001008, 0x00400008, - 0x10401000, 0x10000008, 0x10000000, 0x00001008, - 0x10000008, 0x00401008, 0x00400000, 0x10000000, - 0x10400008, 0x00401000, 0x00001000, 0x00000008, - 0x00401000, 0x10001008, 0x10400000, 0x00001000, - 0x00001008, 0x00000000, 0x00400008, 0x10401000, - 0x10001000, 0x10400008, 0x10401008, 0x00400000, - 0x10400008, 0x00001008, 0x00400000, 0x10000008, - 0x00401000, 0x10001000, 0x00000008, 0x10400000, - 0x10001008, 0x00000000, 0x00001000, 0x00400008, - 0x00000000, 0x10400008, 0x10401000, 0x00001000, - 0x10000000, 0x10401008, 0x00401008, 0x00400000, - 0x10401008, 0x00000008, 0x10001000, 0x00401008, - 0x00400008, 0x00401000, 0x10400000, 0x10001008, - 0x00001008, 0x10000000, 0x10000008, 0x10401000, - }, - { - 0x08000000, 0x00010000, 0x00000400, 0x08010420, - 0x08010020, 0x08000400, 0x00010420, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x00010400, - 0x08000420, 0x08010020, 0x08010400, 0x00000000, - 0x00010400, 0x08000000, 0x00010020, 0x00000420, - 0x08000400, 0x00010420, 0x00000000, 0x08000020, - 0x00000020, 0x08000420, 0x08010420, 0x00010020, - 0x08010000, 0x00000400, 0x00000420, 0x08010400, - 0x08010400, 0x08000420, 0x00010020, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x08000400, - 0x08000000, 0x00010400, 0x08010420, 0x00000000, - 0x00010420, 0x08000000, 0x00000400, 0x00010020, - 0x08000420, 0x00000400, 0x00000000, 0x08010420, - 0x08010020, 0x08010400, 0x00000420, 0x00010000, - 0x00010400, 0x08010020, 0x08000400, 0x00000420, - 0x00000020, 0x00010420, 0x08010000, 0x08000020, - }, - { - 0x80000040, 0x00200040, 0x00000000, 0x80202000, - 0x00200040, 0x00002000, 0x80002040, 0x00200000, - 0x00002040, 0x80202040, 0x00202000, 0x80000000, - 0x80002000, 0x80000040, 0x80200000, 0x00202040, - 0x00200000, 0x80002040, 0x80200040, 0x00000000, - 0x00002000, 0x00000040, 0x80202000, 0x80200040, - 0x80202040, 0x80200000, 0x80000000, 0x00002040, - 0x00000040, 0x00202000, 0x00202040, 0x80002000, - 0x00002040, 0x80000000, 0x80002000, 0x00202040, - 0x80202000, 0x00200040, 0x00000000, 0x80002000, - 0x80000000, 0x00002000, 0x80200040, 0x00200000, - 0x00200040, 0x80202040, 0x00202000, 0x00000040, - 0x80202040, 0x00202000, 0x00200000, 0x80002040, - 0x80000040, 0x80200000, 0x00202040, 0x00000000, - 0x00002000, 0x80000040, 0x80002040, 0x80202000, - 0x80200000, 0x00002040, 0x00000040, 0x80200040, - }, - { - 0x00004000, 0x00000200, 0x01000200, 0x01000004, - 0x01004204, 0x00004004, 0x00004200, 0x00000000, - 0x01000000, 0x01000204, 0x00000204, 0x01004000, - 0x00000004, 0x01004200, 0x01004000, 0x00000204, - 0x01000204, 0x00004000, 0x00004004, 0x01004204, - 0x00000000, 0x01000200, 0x01000004, 0x00004200, - 0x01004004, 0x00004204, 0x01004200, 0x00000004, - 0x00004204, 0x01004004, 0x00000200, 0x01000000, - 0x00004204, 0x01004000, 0x01004004, 0x00000204, - 0x00004000, 0x00000200, 0x01000000, 0x01004004, - 0x01000204, 0x00004204, 0x00004200, 0x00000000, - 0x00000200, 0x01000004, 0x00000004, 0x01000200, - 0x00000000, 0x01000204, 0x01000200, 0x00004200, - 0x00000204, 0x00004000, 0x01004204, 0x01000000, - 0x01004200, 0x00000004, 0x00004004, 0x01004204, - 0x01000004, 0x01004200, 0x01004000, 0x00004004, - }, - { - 0x20800080, 0x20820000, 0x00020080, 0x00000000, - 0x20020000, 0x00800080, 0x20800000, 0x20820080, - 0x00000080, 0x20000000, 0x00820000, 0x00020080, - 0x00820080, 0x20020080, 0x20000080, 0x20800000, - 0x00020000, 0x00820080, 0x00800080, 0x20020000, - 0x20820080, 0x20000080, 0x00000000, 0x00820000, - 0x20000000, 0x00800000, 0x20020080, 0x20800080, - 0x00800000, 0x00020000, 0x20820000, 0x00000080, - 0x00800000, 0x00020000, 0x20000080, 0x20820080, - 0x00020080, 0x20000000, 0x00000000, 0x00820000, - 0x20800080, 0x20020080, 0x20020000, 0x00800080, - 0x20820000, 0x00000080, 0x00800080, 0x20020000, - 0x20820080, 0x00800000, 0x20800000, 0x20000080, - 0x00820000, 0x00020080, 0x20020080, 0x20800000, - 0x00000080, 0x20820000, 0x00820080, 0x00000000, - 0x20000000, 0x20800080, 0x00020000, 0x00820080, - } -}; - -__constant u32a c_skb[8][64] = -{ - { - 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00010000, 0x00010010, 0x20010000, 0x20010010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00010800, 0x00010810, 0x20010800, 0x20010810, - 0x00000020, 0x00000030, 0x20000020, 0x20000030, - 0x00010020, 0x00010030, 0x20010020, 0x20010030, - 0x00000820, 0x00000830, 0x20000820, 0x20000830, - 0x00010820, 0x00010830, 0x20010820, 0x20010830, - 0x00080000, 0x00080010, 0x20080000, 0x20080010, - 0x00090000, 0x00090010, 0x20090000, 0x20090010, - 0x00080800, 0x00080810, 0x20080800, 0x20080810, - 0x00090800, 0x00090810, 0x20090800, 0x20090810, - 0x00080020, 0x00080030, 0x20080020, 0x20080030, - 0x00090020, 0x00090030, 0x20090020, 0x20090030, - 0x00080820, 0x00080830, 0x20080820, 0x20080830, - 0x00090820, 0x00090830, 0x20090820, 0x20090830, - }, - { - 0x00000000, 0x02000000, 0x00002000, 0x02002000, - 0x00200000, 0x02200000, 0x00202000, 0x02202000, - 0x00000004, 0x02000004, 0x00002004, 0x02002004, - 0x00200004, 0x02200004, 0x00202004, 0x02202004, - 0x00000400, 0x02000400, 0x00002400, 0x02002400, - 0x00200400, 0x02200400, 0x00202400, 0x02202400, - 0x00000404, 0x02000404, 0x00002404, 0x02002404, - 0x00200404, 0x02200404, 0x00202404, 0x02202404, - 0x10000000, 0x12000000, 0x10002000, 0x12002000, - 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, - 0x10200004, 0x12200004, 0x10202004, 0x12202004, - 0x10000400, 0x12000400, 0x10002400, 0x12002400, - 0x10200400, 0x12200400, 0x10202400, 0x12202400, - 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404, - }, - { - 0x00000000, 0x00000001, 0x00040000, 0x00040001, - 0x01000000, 0x01000001, 0x01040000, 0x01040001, - 0x00000002, 0x00000003, 0x00040002, 0x00040003, - 0x01000002, 0x01000003, 0x01040002, 0x01040003, - 0x00000200, 0x00000201, 0x00040200, 0x00040201, - 0x01000200, 0x01000201, 0x01040200, 0x01040201, - 0x00000202, 0x00000203, 0x00040202, 0x00040203, - 0x01000202, 0x01000203, 0x01040202, 0x01040203, - 0x08000000, 0x08000001, 0x08040000, 0x08040001, - 0x09000000, 0x09000001, 0x09040000, 0x09040001, - 0x08000002, 0x08000003, 0x08040002, 0x08040003, - 0x09000002, 0x09000003, 0x09040002, 0x09040003, - 0x08000200, 0x08000201, 0x08040200, 0x08040201, - 0x09000200, 0x09000201, 0x09040200, 0x09040201, - 0x08000202, 0x08000203, 0x08040202, 0x08040203, - 0x09000202, 0x09000203, 0x09040202, 0x09040203, - }, - { - 0x00000000, 0x00100000, 0x00000100, 0x00100100, - 0x00000008, 0x00100008, 0x00000108, 0x00100108, - 0x00001000, 0x00101000, 0x00001100, 0x00101100, - 0x00001008, 0x00101008, 0x00001108, 0x00101108, - 0x04000000, 0x04100000, 0x04000100, 0x04100100, - 0x04000008, 0x04100008, 0x04000108, 0x04100108, - 0x04001000, 0x04101000, 0x04001100, 0x04101100, - 0x04001008, 0x04101008, 0x04001108, 0x04101108, - 0x00020000, 0x00120000, 0x00020100, 0x00120100, - 0x00020008, 0x00120008, 0x00020108, 0x00120108, - 0x00021000, 0x00121000, 0x00021100, 0x00121100, - 0x00021008, 0x00121008, 0x00021108, 0x00121108, - 0x04020000, 0x04120000, 0x04020100, 0x04120100, - 0x04020008, 0x04120008, 0x04020108, 0x04120108, - 0x04021000, 0x04121000, 0x04021100, 0x04121100, - 0x04021008, 0x04121008, 0x04021108, 0x04121108, - }, - { - 0x00000000, 0x10000000, 0x00010000, 0x10010000, - 0x00000004, 0x10000004, 0x00010004, 0x10010004, - 0x20000000, 0x30000000, 0x20010000, 0x30010000, - 0x20000004, 0x30000004, 0x20010004, 0x30010004, - 0x00100000, 0x10100000, 0x00110000, 0x10110000, - 0x00100004, 0x10100004, 0x00110004, 0x10110004, - 0x20100000, 0x30100000, 0x20110000, 0x30110000, - 0x20100004, 0x30100004, 0x20110004, 0x30110004, - 0x00001000, 0x10001000, 0x00011000, 0x10011000, - 0x00001004, 0x10001004, 0x00011004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, - 0x20001004, 0x30001004, 0x20011004, 0x30011004, - 0x00101000, 0x10101000, 0x00111000, 0x10111000, - 0x00101004, 0x10101004, 0x00111004, 0x10111004, - 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004, - }, - { - 0x00000000, 0x08000000, 0x00000008, 0x08000008, - 0x00000400, 0x08000400, 0x00000408, 0x08000408, - 0x00020000, 0x08020000, 0x00020008, 0x08020008, - 0x00020400, 0x08020400, 0x00020408, 0x08020408, - 0x00000001, 0x08000001, 0x00000009, 0x08000009, - 0x00000401, 0x08000401, 0x00000409, 0x08000409, - 0x00020001, 0x08020001, 0x00020009, 0x08020009, - 0x00020401, 0x08020401, 0x00020409, 0x08020409, - 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, - 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, - 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, - 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, - 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, - 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, - 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, - 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, - }, - { - 0x00000000, 0x00000100, 0x00080000, 0x00080100, - 0x01000000, 0x01000100, 0x01080000, 0x01080100, - 0x00000010, 0x00000110, 0x00080010, 0x00080110, - 0x01000010, 0x01000110, 0x01080010, 0x01080110, - 0x00200000, 0x00200100, 0x00280000, 0x00280100, - 0x01200000, 0x01200100, 0x01280000, 0x01280100, - 0x00200010, 0x00200110, 0x00280010, 0x00280110, - 0x01200010, 0x01200110, 0x01280010, 0x01280110, - 0x00000200, 0x00000300, 0x00080200, 0x00080300, - 0x01000200, 0x01000300, 0x01080200, 0x01080300, - 0x00000210, 0x00000310, 0x00080210, 0x00080310, - 0x01000210, 0x01000310, 0x01080210, 0x01080310, - 0x00200200, 0x00200300, 0x00280200, 0x00280300, - 0x01200200, 0x01200300, 0x01280200, 0x01280300, - 0x00200210, 0x00200310, 0x00280210, 0x00280310, - 0x01200210, 0x01200310, 0x01280210, 0x01280310, - }, - { - 0x00000000, 0x04000000, 0x00040000, 0x04040000, - 0x00000002, 0x04000002, 0x00040002, 0x04040002, - 0x00002000, 0x04002000, 0x00042000, 0x04042000, - 0x00002002, 0x04002002, 0x00042002, 0x04042002, - 0x00000020, 0x04000020, 0x00040020, 0x04040020, - 0x00000022, 0x04000022, 0x00040022, 0x04040022, - 0x00002020, 0x04002020, 0x00042020, 0x04042020, - 0x00002022, 0x04002022, 0x00042022, 0x04042022, - 0x00000800, 0x04000800, 0x00040800, 0x04040800, - 0x00000802, 0x04000802, 0x00040802, 0x04040802, - 0x00002800, 0x04002800, 0x00042800, 0x04042800, - 0x00002802, 0x04002802, 0x00042802, 0x04042802, - 0x00000820, 0x04000820, 0x00040820, 0x04040820, - 0x00000822, 0x04000822, 0x00040822, 0x04040822, - 0x00002820, 0x04002820, 0x00042820, 0x04042820, - 0x00002822, 0x04002822, 0x00042822, 0x04042822 - } -}; - -#if VECT_SIZE == 1 -#define BOX(i,n,S) (S)[(n)][(i)] -#elif VECT_SIZE == 2 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1]) -#elif VECT_SIZE == 4 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3]) -#elif VECT_SIZE == 8 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) -#elif VECT_SIZE == 16 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) -#endif - -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, __local u32 (*s_SPtrans)[64]) -{ - u32x tt; - - u32x r = data[0]; - u32x l = data[1]; - - IP (r, l, tt); - - r = rotl32 (r, 3u); - l = rotl32 (l, 3u); - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i += 2) - { - u32x u; - u32x t; - - u = Kc[i + 0] ^ r; - t = Kd[i + 0] ^ rotl32 (r, 28u); - - l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - - u = Kc[i + 1] ^ l; - t = Kd[i + 1] ^ rotl32 (l, 28u); - - r ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - } - - l = rotl32 (l, 29u); - r = rotl32 (r, 29u); - - FP (r, l, tt); - - iv[0] = l; - iv[1] = r; -} - -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, __local u32 (*s_skb)[64]) -{ - u32x tt; - - PERM_OP (d, c, tt, 4, 0x0f0f0f0f); - HPERM_OP (c, tt, 2, 0xcccc0000); - HPERM_OP (d, tt, 2, 0xcccc0000); - PERM_OP (d, c, tt, 1, 0x55555555); - PERM_OP (c, d, tt, 8, 0x00ff00ff); - PERM_OP (d, c, tt, 1, 0x55555555); - - d = ((d & 0x000000ff) << 16) - | ((d & 0x0000ff00) << 0) - | ((d & 0x00ff0000) >> 16) - | ((c & 0xf0000000) >> 4); - - c = c & 0x0fffffff; - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i++) - { - if ((i < 2) || (i == 8) || (i == 15)) - { - c = ((c >> 1) | (c << 27)); - d = ((d >> 1) | (d << 27)); - } - else - { - c = ((c >> 2) | (c << 26)); - d = ((d >> 2) | (d << 26)); - } - - c = c & 0x0fffffff; - d = d & 0x0fffffff; - - const u32x c00 = (c >> 0) & 0x0000003f; - const u32x c06 = (c >> 6) & 0x00383003; - const u32x c07 = (c >> 7) & 0x0000003c; - const u32x c13 = (c >> 13) & 0x0000060f; - const u32x c20 = (c >> 20) & 0x00000001; - - u32x s = BOX (((c00 >> 0) & 0xff), 0, s_skb) - | BOX (((c06 >> 0) & 0xff) - |((c07 >> 0) & 0xff), 1, s_skb) - | BOX (((c13 >> 0) & 0xff) - |((c06 >> 8) & 0xff), 2, s_skb) - | BOX (((c20 >> 0) & 0xff) - |((c13 >> 8) & 0xff) - |((c06 >> 16) & 0xff), 3, s_skb); - - const u32x d00 = (d >> 0) & 0x00003c3f; - const u32x d07 = (d >> 7) & 0x00003f03; - const u32x d21 = (d >> 21) & 0x0000000f; - const u32x d22 = (d >> 22) & 0x00000030; - - u32x t = BOX (((d00 >> 0) & 0xff), 4, s_skb) - | BOX (((d07 >> 0) & 0xff) - |((d00 >> 8) & 0xff), 5, s_skb) - | BOX (((d07 >> 8) & 0xff), 6, s_skb) - | BOX (((d21 >> 0) & 0xff) - |((d22 >> 0) & 0xff), 7, s_skb); - - Kc[i] = ((t << 16) | (s & 0x0000ffff)); - Kd[i] = ((s >> 16) | (t & 0xffff0000)); - - Kc[i] = rotl32 (Kc[i], 2u); - Kd[i] = rotl32 (Kd[i], 2u); - } -} +#include "inc_cipher_des.cl" __kernel void m03100_m04 (KERN_ATTR_RULES ()) { @@ -498,9 +27,11 @@ __kernel void m03100_m04 (KERN_ATTR_RULES ()) const u64 lsz = get_local_size (0); /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -527,6 +58,13 @@ __kernel void m03100_m04 (KERN_ATTR_RULES ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -721,9 +259,11 @@ __kernel void m03100_s04 (KERN_ATTR_RULES ()) const u64 lsz = get_local_size (0); /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -750,6 +290,13 @@ __kernel void m03100_s04 (KERN_ATTR_RULES ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m03100_a1-optimized.cl b/OpenCL/m03100_a1-optimized.cl index 88a0d2233..198de12c6 100644 --- a/OpenCL/m03100_a1-optimized.cl +++ b/OpenCL/m03100_a1-optimized.cl @@ -12,478 +12,7 @@ #include "inc_types.cl" #include "inc_common.cl" #include "inc_simd.cl" - -#define PERM_OP(a,b,tt,n,m) \ -{ \ - tt = a >> n; \ - tt = tt ^ b; \ - tt = tt & m; \ - b = b ^ tt; \ - tt = tt << n; \ - a = a ^ tt; \ -} - -#define HPERM_OP(a,tt,n,m) \ -{ \ - tt = a << (16 + n); \ - tt = tt ^ a; \ - tt = tt & m; \ - a = a ^ tt; \ - tt = tt >> (16 + n); \ - a = a ^ tt; \ -} - -#define IP(l,r,tt) \ -{ \ - PERM_OP (r, l, tt, 4, 0x0f0f0f0f); \ - PERM_OP (l, r, tt, 16, 0x0000ffff); \ - PERM_OP (r, l, tt, 2, 0x33333333); \ - PERM_OP (l, r, tt, 8, 0x00ff00ff); \ - PERM_OP (r, l, tt, 1, 0x55555555); \ -} - -#define FP(l,r,tt) \ -{ \ - PERM_OP (l, r, tt, 1, 0x55555555); \ - PERM_OP (r, l, tt, 8, 0x00ff00ff); \ - PERM_OP (l, r, tt, 2, 0x33333333); \ - PERM_OP (r, l, tt, 16, 0x0000ffff); \ - PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \ -} - -__constant u32a c_SPtrans[8][64] = -{ - { - 0x02080800, 0x00080000, 0x02000002, 0x02080802, - 0x02000000, 0x00080802, 0x00080002, 0x02000002, - 0x00080802, 0x02080800, 0x02080000, 0x00000802, - 0x02000802, 0x02000000, 0x00000000, 0x00080002, - 0x00080000, 0x00000002, 0x02000800, 0x00080800, - 0x02080802, 0x02080000, 0x00000802, 0x02000800, - 0x00000002, 0x00000800, 0x00080800, 0x02080002, - 0x00000800, 0x02000802, 0x02080002, 0x00000000, - 0x00000000, 0x02080802, 0x02000800, 0x00080002, - 0x02080800, 0x00080000, 0x00000802, 0x02000800, - 0x02080002, 0x00000800, 0x00080800, 0x02000002, - 0x00080802, 0x00000002, 0x02000002, 0x02080000, - 0x02080802, 0x00080800, 0x02080000, 0x02000802, - 0x02000000, 0x00000802, 0x00080002, 0x00000000, - 0x00080000, 0x02000000, 0x02000802, 0x02080800, - 0x00000002, 0x02080002, 0x00000800, 0x00080802, - }, - { - 0x40108010, 0x00000000, 0x00108000, 0x40100000, - 0x40000010, 0x00008010, 0x40008000, 0x00108000, - 0x00008000, 0x40100010, 0x00000010, 0x40008000, - 0x00100010, 0x40108000, 0x40100000, 0x00000010, - 0x00100000, 0x40008010, 0x40100010, 0x00008000, - 0x00108010, 0x40000000, 0x00000000, 0x00100010, - 0x40008010, 0x00108010, 0x40108000, 0x40000010, - 0x40000000, 0x00100000, 0x00008010, 0x40108010, - 0x00100010, 0x40108000, 0x40008000, 0x00108010, - 0x40108010, 0x00100010, 0x40000010, 0x00000000, - 0x40000000, 0x00008010, 0x00100000, 0x40100010, - 0x00008000, 0x40000000, 0x00108010, 0x40008010, - 0x40108000, 0x00008000, 0x00000000, 0x40000010, - 0x00000010, 0x40108010, 0x00108000, 0x40100000, - 0x40100010, 0x00100000, 0x00008010, 0x40008000, - 0x40008010, 0x00000010, 0x40100000, 0x00108000, - }, - { - 0x04000001, 0x04040100, 0x00000100, 0x04000101, - 0x00040001, 0x04000000, 0x04000101, 0x00040100, - 0x04000100, 0x00040000, 0x04040000, 0x00000001, - 0x04040101, 0x00000101, 0x00000001, 0x04040001, - 0x00000000, 0x00040001, 0x04040100, 0x00000100, - 0x00000101, 0x04040101, 0x00040000, 0x04000001, - 0x04040001, 0x04000100, 0x00040101, 0x04040000, - 0x00040100, 0x00000000, 0x04000000, 0x00040101, - 0x04040100, 0x00000100, 0x00000001, 0x00040000, - 0x00000101, 0x00040001, 0x04040000, 0x04000101, - 0x00000000, 0x04040100, 0x00040100, 0x04040001, - 0x00040001, 0x04000000, 0x04040101, 0x00000001, - 0x00040101, 0x04000001, 0x04000000, 0x04040101, - 0x00040000, 0x04000100, 0x04000101, 0x00040100, - 0x04000100, 0x00000000, 0x04040001, 0x00000101, - 0x04000001, 0x00040101, 0x00000100, 0x04040000, - }, - { - 0x00401008, 0x10001000, 0x00000008, 0x10401008, - 0x00000000, 0x10400000, 0x10001008, 0x00400008, - 0x10401000, 0x10000008, 0x10000000, 0x00001008, - 0x10000008, 0x00401008, 0x00400000, 0x10000000, - 0x10400008, 0x00401000, 0x00001000, 0x00000008, - 0x00401000, 0x10001008, 0x10400000, 0x00001000, - 0x00001008, 0x00000000, 0x00400008, 0x10401000, - 0x10001000, 0x10400008, 0x10401008, 0x00400000, - 0x10400008, 0x00001008, 0x00400000, 0x10000008, - 0x00401000, 0x10001000, 0x00000008, 0x10400000, - 0x10001008, 0x00000000, 0x00001000, 0x00400008, - 0x00000000, 0x10400008, 0x10401000, 0x00001000, - 0x10000000, 0x10401008, 0x00401008, 0x00400000, - 0x10401008, 0x00000008, 0x10001000, 0x00401008, - 0x00400008, 0x00401000, 0x10400000, 0x10001008, - 0x00001008, 0x10000000, 0x10000008, 0x10401000, - }, - { - 0x08000000, 0x00010000, 0x00000400, 0x08010420, - 0x08010020, 0x08000400, 0x00010420, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x00010400, - 0x08000420, 0x08010020, 0x08010400, 0x00000000, - 0x00010400, 0x08000000, 0x00010020, 0x00000420, - 0x08000400, 0x00010420, 0x00000000, 0x08000020, - 0x00000020, 0x08000420, 0x08010420, 0x00010020, - 0x08010000, 0x00000400, 0x00000420, 0x08010400, - 0x08010400, 0x08000420, 0x00010020, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x08000400, - 0x08000000, 0x00010400, 0x08010420, 0x00000000, - 0x00010420, 0x08000000, 0x00000400, 0x00010020, - 0x08000420, 0x00000400, 0x00000000, 0x08010420, - 0x08010020, 0x08010400, 0x00000420, 0x00010000, - 0x00010400, 0x08010020, 0x08000400, 0x00000420, - 0x00000020, 0x00010420, 0x08010000, 0x08000020, - }, - { - 0x80000040, 0x00200040, 0x00000000, 0x80202000, - 0x00200040, 0x00002000, 0x80002040, 0x00200000, - 0x00002040, 0x80202040, 0x00202000, 0x80000000, - 0x80002000, 0x80000040, 0x80200000, 0x00202040, - 0x00200000, 0x80002040, 0x80200040, 0x00000000, - 0x00002000, 0x00000040, 0x80202000, 0x80200040, - 0x80202040, 0x80200000, 0x80000000, 0x00002040, - 0x00000040, 0x00202000, 0x00202040, 0x80002000, - 0x00002040, 0x80000000, 0x80002000, 0x00202040, - 0x80202000, 0x00200040, 0x00000000, 0x80002000, - 0x80000000, 0x00002000, 0x80200040, 0x00200000, - 0x00200040, 0x80202040, 0x00202000, 0x00000040, - 0x80202040, 0x00202000, 0x00200000, 0x80002040, - 0x80000040, 0x80200000, 0x00202040, 0x00000000, - 0x00002000, 0x80000040, 0x80002040, 0x80202000, - 0x80200000, 0x00002040, 0x00000040, 0x80200040, - }, - { - 0x00004000, 0x00000200, 0x01000200, 0x01000004, - 0x01004204, 0x00004004, 0x00004200, 0x00000000, - 0x01000000, 0x01000204, 0x00000204, 0x01004000, - 0x00000004, 0x01004200, 0x01004000, 0x00000204, - 0x01000204, 0x00004000, 0x00004004, 0x01004204, - 0x00000000, 0x01000200, 0x01000004, 0x00004200, - 0x01004004, 0x00004204, 0x01004200, 0x00000004, - 0x00004204, 0x01004004, 0x00000200, 0x01000000, - 0x00004204, 0x01004000, 0x01004004, 0x00000204, - 0x00004000, 0x00000200, 0x01000000, 0x01004004, - 0x01000204, 0x00004204, 0x00004200, 0x00000000, - 0x00000200, 0x01000004, 0x00000004, 0x01000200, - 0x00000000, 0x01000204, 0x01000200, 0x00004200, - 0x00000204, 0x00004000, 0x01004204, 0x01000000, - 0x01004200, 0x00000004, 0x00004004, 0x01004204, - 0x01000004, 0x01004200, 0x01004000, 0x00004004, - }, - { - 0x20800080, 0x20820000, 0x00020080, 0x00000000, - 0x20020000, 0x00800080, 0x20800000, 0x20820080, - 0x00000080, 0x20000000, 0x00820000, 0x00020080, - 0x00820080, 0x20020080, 0x20000080, 0x20800000, - 0x00020000, 0x00820080, 0x00800080, 0x20020000, - 0x20820080, 0x20000080, 0x00000000, 0x00820000, - 0x20000000, 0x00800000, 0x20020080, 0x20800080, - 0x00800000, 0x00020000, 0x20820000, 0x00000080, - 0x00800000, 0x00020000, 0x20000080, 0x20820080, - 0x00020080, 0x20000000, 0x00000000, 0x00820000, - 0x20800080, 0x20020080, 0x20020000, 0x00800080, - 0x20820000, 0x00000080, 0x00800080, 0x20020000, - 0x20820080, 0x00800000, 0x20800000, 0x20000080, - 0x00820000, 0x00020080, 0x20020080, 0x20800000, - 0x00000080, 0x20820000, 0x00820080, 0x00000000, - 0x20000000, 0x20800080, 0x00020000, 0x00820080, - } -}; - -__constant u32a c_skb[8][64] = -{ - { - 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00010000, 0x00010010, 0x20010000, 0x20010010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00010800, 0x00010810, 0x20010800, 0x20010810, - 0x00000020, 0x00000030, 0x20000020, 0x20000030, - 0x00010020, 0x00010030, 0x20010020, 0x20010030, - 0x00000820, 0x00000830, 0x20000820, 0x20000830, - 0x00010820, 0x00010830, 0x20010820, 0x20010830, - 0x00080000, 0x00080010, 0x20080000, 0x20080010, - 0x00090000, 0x00090010, 0x20090000, 0x20090010, - 0x00080800, 0x00080810, 0x20080800, 0x20080810, - 0x00090800, 0x00090810, 0x20090800, 0x20090810, - 0x00080020, 0x00080030, 0x20080020, 0x20080030, - 0x00090020, 0x00090030, 0x20090020, 0x20090030, - 0x00080820, 0x00080830, 0x20080820, 0x20080830, - 0x00090820, 0x00090830, 0x20090820, 0x20090830, - }, - { - 0x00000000, 0x02000000, 0x00002000, 0x02002000, - 0x00200000, 0x02200000, 0x00202000, 0x02202000, - 0x00000004, 0x02000004, 0x00002004, 0x02002004, - 0x00200004, 0x02200004, 0x00202004, 0x02202004, - 0x00000400, 0x02000400, 0x00002400, 0x02002400, - 0x00200400, 0x02200400, 0x00202400, 0x02202400, - 0x00000404, 0x02000404, 0x00002404, 0x02002404, - 0x00200404, 0x02200404, 0x00202404, 0x02202404, - 0x10000000, 0x12000000, 0x10002000, 0x12002000, - 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, - 0x10200004, 0x12200004, 0x10202004, 0x12202004, - 0x10000400, 0x12000400, 0x10002400, 0x12002400, - 0x10200400, 0x12200400, 0x10202400, 0x12202400, - 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404, - }, - { - 0x00000000, 0x00000001, 0x00040000, 0x00040001, - 0x01000000, 0x01000001, 0x01040000, 0x01040001, - 0x00000002, 0x00000003, 0x00040002, 0x00040003, - 0x01000002, 0x01000003, 0x01040002, 0x01040003, - 0x00000200, 0x00000201, 0x00040200, 0x00040201, - 0x01000200, 0x01000201, 0x01040200, 0x01040201, - 0x00000202, 0x00000203, 0x00040202, 0x00040203, - 0x01000202, 0x01000203, 0x01040202, 0x01040203, - 0x08000000, 0x08000001, 0x08040000, 0x08040001, - 0x09000000, 0x09000001, 0x09040000, 0x09040001, - 0x08000002, 0x08000003, 0x08040002, 0x08040003, - 0x09000002, 0x09000003, 0x09040002, 0x09040003, - 0x08000200, 0x08000201, 0x08040200, 0x08040201, - 0x09000200, 0x09000201, 0x09040200, 0x09040201, - 0x08000202, 0x08000203, 0x08040202, 0x08040203, - 0x09000202, 0x09000203, 0x09040202, 0x09040203, - }, - { - 0x00000000, 0x00100000, 0x00000100, 0x00100100, - 0x00000008, 0x00100008, 0x00000108, 0x00100108, - 0x00001000, 0x00101000, 0x00001100, 0x00101100, - 0x00001008, 0x00101008, 0x00001108, 0x00101108, - 0x04000000, 0x04100000, 0x04000100, 0x04100100, - 0x04000008, 0x04100008, 0x04000108, 0x04100108, - 0x04001000, 0x04101000, 0x04001100, 0x04101100, - 0x04001008, 0x04101008, 0x04001108, 0x04101108, - 0x00020000, 0x00120000, 0x00020100, 0x00120100, - 0x00020008, 0x00120008, 0x00020108, 0x00120108, - 0x00021000, 0x00121000, 0x00021100, 0x00121100, - 0x00021008, 0x00121008, 0x00021108, 0x00121108, - 0x04020000, 0x04120000, 0x04020100, 0x04120100, - 0x04020008, 0x04120008, 0x04020108, 0x04120108, - 0x04021000, 0x04121000, 0x04021100, 0x04121100, - 0x04021008, 0x04121008, 0x04021108, 0x04121108, - }, - { - 0x00000000, 0x10000000, 0x00010000, 0x10010000, - 0x00000004, 0x10000004, 0x00010004, 0x10010004, - 0x20000000, 0x30000000, 0x20010000, 0x30010000, - 0x20000004, 0x30000004, 0x20010004, 0x30010004, - 0x00100000, 0x10100000, 0x00110000, 0x10110000, - 0x00100004, 0x10100004, 0x00110004, 0x10110004, - 0x20100000, 0x30100000, 0x20110000, 0x30110000, - 0x20100004, 0x30100004, 0x20110004, 0x30110004, - 0x00001000, 0x10001000, 0x00011000, 0x10011000, - 0x00001004, 0x10001004, 0x00011004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, - 0x20001004, 0x30001004, 0x20011004, 0x30011004, - 0x00101000, 0x10101000, 0x00111000, 0x10111000, - 0x00101004, 0x10101004, 0x00111004, 0x10111004, - 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004, - }, - { - 0x00000000, 0x08000000, 0x00000008, 0x08000008, - 0x00000400, 0x08000400, 0x00000408, 0x08000408, - 0x00020000, 0x08020000, 0x00020008, 0x08020008, - 0x00020400, 0x08020400, 0x00020408, 0x08020408, - 0x00000001, 0x08000001, 0x00000009, 0x08000009, - 0x00000401, 0x08000401, 0x00000409, 0x08000409, - 0x00020001, 0x08020001, 0x00020009, 0x08020009, - 0x00020401, 0x08020401, 0x00020409, 0x08020409, - 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, - 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, - 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, - 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, - 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, - 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, - 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, - 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, - }, - { - 0x00000000, 0x00000100, 0x00080000, 0x00080100, - 0x01000000, 0x01000100, 0x01080000, 0x01080100, - 0x00000010, 0x00000110, 0x00080010, 0x00080110, - 0x01000010, 0x01000110, 0x01080010, 0x01080110, - 0x00200000, 0x00200100, 0x00280000, 0x00280100, - 0x01200000, 0x01200100, 0x01280000, 0x01280100, - 0x00200010, 0x00200110, 0x00280010, 0x00280110, - 0x01200010, 0x01200110, 0x01280010, 0x01280110, - 0x00000200, 0x00000300, 0x00080200, 0x00080300, - 0x01000200, 0x01000300, 0x01080200, 0x01080300, - 0x00000210, 0x00000310, 0x00080210, 0x00080310, - 0x01000210, 0x01000310, 0x01080210, 0x01080310, - 0x00200200, 0x00200300, 0x00280200, 0x00280300, - 0x01200200, 0x01200300, 0x01280200, 0x01280300, - 0x00200210, 0x00200310, 0x00280210, 0x00280310, - 0x01200210, 0x01200310, 0x01280210, 0x01280310, - }, - { - 0x00000000, 0x04000000, 0x00040000, 0x04040000, - 0x00000002, 0x04000002, 0x00040002, 0x04040002, - 0x00002000, 0x04002000, 0x00042000, 0x04042000, - 0x00002002, 0x04002002, 0x00042002, 0x04042002, - 0x00000020, 0x04000020, 0x00040020, 0x04040020, - 0x00000022, 0x04000022, 0x00040022, 0x04040022, - 0x00002020, 0x04002020, 0x00042020, 0x04042020, - 0x00002022, 0x04002022, 0x00042022, 0x04042022, - 0x00000800, 0x04000800, 0x00040800, 0x04040800, - 0x00000802, 0x04000802, 0x00040802, 0x04040802, - 0x00002800, 0x04002800, 0x00042800, 0x04042800, - 0x00002802, 0x04002802, 0x00042802, 0x04042802, - 0x00000820, 0x04000820, 0x00040820, 0x04040820, - 0x00000822, 0x04000822, 0x00040822, 0x04040822, - 0x00002820, 0x04002820, 0x00042820, 0x04042820, - 0x00002822, 0x04002822, 0x00042822, 0x04042822 - } -}; - -#if VECT_SIZE == 1 -#define BOX(i,n,S) (S)[(n)][(i)] -#elif VECT_SIZE == 2 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1]) -#elif VECT_SIZE == 4 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3]) -#elif VECT_SIZE == 8 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) -#elif VECT_SIZE == 16 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) -#endif - -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, __local u32 (*s_SPtrans)[64]) -{ - u32x tt; - - u32x r = data[0]; - u32x l = data[1]; - - IP (r, l, tt); - - r = rotl32 (r, 3u); - l = rotl32 (l, 3u); - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i += 2) - { - u32x u; - u32x t; - - u = Kc[i + 0] ^ r; - t = Kd[i + 0] ^ rotl32 (r, 28u); - - l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - - u = Kc[i + 1] ^ l; - t = Kd[i + 1] ^ rotl32 (l, 28u); - - r ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - } - - l = rotl32 (l, 29u); - r = rotl32 (r, 29u); - - FP (r, l, tt); - - iv[0] = l; - iv[1] = r; -} - -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, __local u32 (*s_skb)[64]) -{ - u32x tt; - - PERM_OP (d, c, tt, 4, 0x0f0f0f0f); - HPERM_OP (c, tt, 2, 0xcccc0000); - HPERM_OP (d, tt, 2, 0xcccc0000); - PERM_OP (d, c, tt, 1, 0x55555555); - PERM_OP (c, d, tt, 8, 0x00ff00ff); - PERM_OP (d, c, tt, 1, 0x55555555); - - d = ((d & 0x000000ff) << 16) - | ((d & 0x0000ff00) << 0) - | ((d & 0x00ff0000) >> 16) - | ((c & 0xf0000000) >> 4); - - c = c & 0x0fffffff; - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i++) - { - if ((i < 2) || (i == 8) || (i == 15)) - { - c = ((c >> 1) | (c << 27)); - d = ((d >> 1) | (d << 27)); - } - else - { - c = ((c >> 2) | (c << 26)); - d = ((d >> 2) | (d << 26)); - } - - c = c & 0x0fffffff; - d = d & 0x0fffffff; - - const u32x c00 = (c >> 0) & 0x0000003f; - const u32x c06 = (c >> 6) & 0x00383003; - const u32x c07 = (c >> 7) & 0x0000003c; - const u32x c13 = (c >> 13) & 0x0000060f; - const u32x c20 = (c >> 20) & 0x00000001; - - u32x s = BOX (((c00 >> 0) & 0xff), 0, s_skb) - | BOX (((c06 >> 0) & 0xff) - |((c07 >> 0) & 0xff), 1, s_skb) - | BOX (((c13 >> 0) & 0xff) - |((c06 >> 8) & 0xff), 2, s_skb) - | BOX (((c20 >> 0) & 0xff) - |((c13 >> 8) & 0xff) - |((c06 >> 16) & 0xff), 3, s_skb); - - const u32x d00 = (d >> 0) & 0x00003c3f; - const u32x d07 = (d >> 7) & 0x00003f03; - const u32x d21 = (d >> 21) & 0x0000000f; - const u32x d22 = (d >> 22) & 0x00000030; - - u32x t = BOX (((d00 >> 0) & 0xff), 4, s_skb) - | BOX (((d07 >> 0) & 0xff) - |((d00 >> 8) & 0xff), 5, s_skb) - | BOX (((d07 >> 8) & 0xff), 6, s_skb) - | BOX (((d21 >> 0) & 0xff) - |((d22 >> 0) & 0xff), 7, s_skb); - - Kc[i] = ((t << 16) | (s & 0x0000ffff)); - Kd[i] = ((s >> 16) | (t & 0xffff0000)); - - Kc[i] = rotl32 (Kc[i], 2u); - Kd[i] = rotl32 (Kd[i], 2u); - } -} +#include "inc_cipher_des.cl" __kernel void m03100_m04 (KERN_ATTR_BASIC ()) { @@ -496,9 +25,11 @@ __kernel void m03100_m04 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -525,6 +56,13 @@ __kernel void m03100_m04 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -779,9 +317,11 @@ __kernel void m03100_s04 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -808,6 +348,13 @@ __kernel void m03100_s04 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m03100_a3-optimized.cl b/OpenCL/m03100_a3-optimized.cl index 31087ad4c..f375ca0dc 100644 --- a/OpenCL/m03100_a3-optimized.cl +++ b/OpenCL/m03100_a3-optimized.cl @@ -11,480 +11,9 @@ #include "inc_types.cl" #include "inc_common.cl" #include "inc_simd.cl" +#include "inc_cipher_des.cl" -#define PERM_OP(a,b,tt,n,m) \ -{ \ - tt = a >> n; \ - tt = tt ^ b; \ - tt = tt & m; \ - b = b ^ tt; \ - tt = tt << n; \ - a = a ^ tt; \ -} - -#define HPERM_OP(a,tt,n,m) \ -{ \ - tt = a << (16 + n); \ - tt = tt ^ a; \ - tt = tt & m; \ - a = a ^ tt; \ - tt = tt >> (16 + n); \ - a = a ^ tt; \ -} - -#define IP(l,r,tt) \ -{ \ - PERM_OP (r, l, tt, 4, 0x0f0f0f0f); \ - PERM_OP (l, r, tt, 16, 0x0000ffff); \ - PERM_OP (r, l, tt, 2, 0x33333333); \ - PERM_OP (l, r, tt, 8, 0x00ff00ff); \ - PERM_OP (r, l, tt, 1, 0x55555555); \ -} - -#define FP(l,r,tt) \ -{ \ - PERM_OP (l, r, tt, 1, 0x55555555); \ - PERM_OP (r, l, tt, 8, 0x00ff00ff); \ - PERM_OP (l, r, tt, 2, 0x33333333); \ - PERM_OP (r, l, tt, 16, 0x0000ffff); \ - PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \ -} - -__constant u32a c_SPtrans[8][64] = -{ - { - 0x02080800, 0x00080000, 0x02000002, 0x02080802, - 0x02000000, 0x00080802, 0x00080002, 0x02000002, - 0x00080802, 0x02080800, 0x02080000, 0x00000802, - 0x02000802, 0x02000000, 0x00000000, 0x00080002, - 0x00080000, 0x00000002, 0x02000800, 0x00080800, - 0x02080802, 0x02080000, 0x00000802, 0x02000800, - 0x00000002, 0x00000800, 0x00080800, 0x02080002, - 0x00000800, 0x02000802, 0x02080002, 0x00000000, - 0x00000000, 0x02080802, 0x02000800, 0x00080002, - 0x02080800, 0x00080000, 0x00000802, 0x02000800, - 0x02080002, 0x00000800, 0x00080800, 0x02000002, - 0x00080802, 0x00000002, 0x02000002, 0x02080000, - 0x02080802, 0x00080800, 0x02080000, 0x02000802, - 0x02000000, 0x00000802, 0x00080002, 0x00000000, - 0x00080000, 0x02000000, 0x02000802, 0x02080800, - 0x00000002, 0x02080002, 0x00000800, 0x00080802, - }, - { - 0x40108010, 0x00000000, 0x00108000, 0x40100000, - 0x40000010, 0x00008010, 0x40008000, 0x00108000, - 0x00008000, 0x40100010, 0x00000010, 0x40008000, - 0x00100010, 0x40108000, 0x40100000, 0x00000010, - 0x00100000, 0x40008010, 0x40100010, 0x00008000, - 0x00108010, 0x40000000, 0x00000000, 0x00100010, - 0x40008010, 0x00108010, 0x40108000, 0x40000010, - 0x40000000, 0x00100000, 0x00008010, 0x40108010, - 0x00100010, 0x40108000, 0x40008000, 0x00108010, - 0x40108010, 0x00100010, 0x40000010, 0x00000000, - 0x40000000, 0x00008010, 0x00100000, 0x40100010, - 0x00008000, 0x40000000, 0x00108010, 0x40008010, - 0x40108000, 0x00008000, 0x00000000, 0x40000010, - 0x00000010, 0x40108010, 0x00108000, 0x40100000, - 0x40100010, 0x00100000, 0x00008010, 0x40008000, - 0x40008010, 0x00000010, 0x40100000, 0x00108000, - }, - { - 0x04000001, 0x04040100, 0x00000100, 0x04000101, - 0x00040001, 0x04000000, 0x04000101, 0x00040100, - 0x04000100, 0x00040000, 0x04040000, 0x00000001, - 0x04040101, 0x00000101, 0x00000001, 0x04040001, - 0x00000000, 0x00040001, 0x04040100, 0x00000100, - 0x00000101, 0x04040101, 0x00040000, 0x04000001, - 0x04040001, 0x04000100, 0x00040101, 0x04040000, - 0x00040100, 0x00000000, 0x04000000, 0x00040101, - 0x04040100, 0x00000100, 0x00000001, 0x00040000, - 0x00000101, 0x00040001, 0x04040000, 0x04000101, - 0x00000000, 0x04040100, 0x00040100, 0x04040001, - 0x00040001, 0x04000000, 0x04040101, 0x00000001, - 0x00040101, 0x04000001, 0x04000000, 0x04040101, - 0x00040000, 0x04000100, 0x04000101, 0x00040100, - 0x04000100, 0x00000000, 0x04040001, 0x00000101, - 0x04000001, 0x00040101, 0x00000100, 0x04040000, - }, - { - 0x00401008, 0x10001000, 0x00000008, 0x10401008, - 0x00000000, 0x10400000, 0x10001008, 0x00400008, - 0x10401000, 0x10000008, 0x10000000, 0x00001008, - 0x10000008, 0x00401008, 0x00400000, 0x10000000, - 0x10400008, 0x00401000, 0x00001000, 0x00000008, - 0x00401000, 0x10001008, 0x10400000, 0x00001000, - 0x00001008, 0x00000000, 0x00400008, 0x10401000, - 0x10001000, 0x10400008, 0x10401008, 0x00400000, - 0x10400008, 0x00001008, 0x00400000, 0x10000008, - 0x00401000, 0x10001000, 0x00000008, 0x10400000, - 0x10001008, 0x00000000, 0x00001000, 0x00400008, - 0x00000000, 0x10400008, 0x10401000, 0x00001000, - 0x10000000, 0x10401008, 0x00401008, 0x00400000, - 0x10401008, 0x00000008, 0x10001000, 0x00401008, - 0x00400008, 0x00401000, 0x10400000, 0x10001008, - 0x00001008, 0x10000000, 0x10000008, 0x10401000, - }, - { - 0x08000000, 0x00010000, 0x00000400, 0x08010420, - 0x08010020, 0x08000400, 0x00010420, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x00010400, - 0x08000420, 0x08010020, 0x08010400, 0x00000000, - 0x00010400, 0x08000000, 0x00010020, 0x00000420, - 0x08000400, 0x00010420, 0x00000000, 0x08000020, - 0x00000020, 0x08000420, 0x08010420, 0x00010020, - 0x08010000, 0x00000400, 0x00000420, 0x08010400, - 0x08010400, 0x08000420, 0x00010020, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x08000400, - 0x08000000, 0x00010400, 0x08010420, 0x00000000, - 0x00010420, 0x08000000, 0x00000400, 0x00010020, - 0x08000420, 0x00000400, 0x00000000, 0x08010420, - 0x08010020, 0x08010400, 0x00000420, 0x00010000, - 0x00010400, 0x08010020, 0x08000400, 0x00000420, - 0x00000020, 0x00010420, 0x08010000, 0x08000020, - }, - { - 0x80000040, 0x00200040, 0x00000000, 0x80202000, - 0x00200040, 0x00002000, 0x80002040, 0x00200000, - 0x00002040, 0x80202040, 0x00202000, 0x80000000, - 0x80002000, 0x80000040, 0x80200000, 0x00202040, - 0x00200000, 0x80002040, 0x80200040, 0x00000000, - 0x00002000, 0x00000040, 0x80202000, 0x80200040, - 0x80202040, 0x80200000, 0x80000000, 0x00002040, - 0x00000040, 0x00202000, 0x00202040, 0x80002000, - 0x00002040, 0x80000000, 0x80002000, 0x00202040, - 0x80202000, 0x00200040, 0x00000000, 0x80002000, - 0x80000000, 0x00002000, 0x80200040, 0x00200000, - 0x00200040, 0x80202040, 0x00202000, 0x00000040, - 0x80202040, 0x00202000, 0x00200000, 0x80002040, - 0x80000040, 0x80200000, 0x00202040, 0x00000000, - 0x00002000, 0x80000040, 0x80002040, 0x80202000, - 0x80200000, 0x00002040, 0x00000040, 0x80200040, - }, - { - 0x00004000, 0x00000200, 0x01000200, 0x01000004, - 0x01004204, 0x00004004, 0x00004200, 0x00000000, - 0x01000000, 0x01000204, 0x00000204, 0x01004000, - 0x00000004, 0x01004200, 0x01004000, 0x00000204, - 0x01000204, 0x00004000, 0x00004004, 0x01004204, - 0x00000000, 0x01000200, 0x01000004, 0x00004200, - 0x01004004, 0x00004204, 0x01004200, 0x00000004, - 0x00004204, 0x01004004, 0x00000200, 0x01000000, - 0x00004204, 0x01004000, 0x01004004, 0x00000204, - 0x00004000, 0x00000200, 0x01000000, 0x01004004, - 0x01000204, 0x00004204, 0x00004200, 0x00000000, - 0x00000200, 0x01000004, 0x00000004, 0x01000200, - 0x00000000, 0x01000204, 0x01000200, 0x00004200, - 0x00000204, 0x00004000, 0x01004204, 0x01000000, - 0x01004200, 0x00000004, 0x00004004, 0x01004204, - 0x01000004, 0x01004200, 0x01004000, 0x00004004, - }, - { - 0x20800080, 0x20820000, 0x00020080, 0x00000000, - 0x20020000, 0x00800080, 0x20800000, 0x20820080, - 0x00000080, 0x20000000, 0x00820000, 0x00020080, - 0x00820080, 0x20020080, 0x20000080, 0x20800000, - 0x00020000, 0x00820080, 0x00800080, 0x20020000, - 0x20820080, 0x20000080, 0x00000000, 0x00820000, - 0x20000000, 0x00800000, 0x20020080, 0x20800080, - 0x00800000, 0x00020000, 0x20820000, 0x00000080, - 0x00800000, 0x00020000, 0x20000080, 0x20820080, - 0x00020080, 0x20000000, 0x00000000, 0x00820000, - 0x20800080, 0x20020080, 0x20020000, 0x00800080, - 0x20820000, 0x00000080, 0x00800080, 0x20020000, - 0x20820080, 0x00800000, 0x20800000, 0x20000080, - 0x00820000, 0x00020080, 0x20020080, 0x20800000, - 0x00000080, 0x20820000, 0x00820080, 0x00000000, - 0x20000000, 0x20800080, 0x00020000, 0x00820080, - } -}; - -__constant u32a c_skb[8][64] = -{ - { - 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00010000, 0x00010010, 0x20010000, 0x20010010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00010800, 0x00010810, 0x20010800, 0x20010810, - 0x00000020, 0x00000030, 0x20000020, 0x20000030, - 0x00010020, 0x00010030, 0x20010020, 0x20010030, - 0x00000820, 0x00000830, 0x20000820, 0x20000830, - 0x00010820, 0x00010830, 0x20010820, 0x20010830, - 0x00080000, 0x00080010, 0x20080000, 0x20080010, - 0x00090000, 0x00090010, 0x20090000, 0x20090010, - 0x00080800, 0x00080810, 0x20080800, 0x20080810, - 0x00090800, 0x00090810, 0x20090800, 0x20090810, - 0x00080020, 0x00080030, 0x20080020, 0x20080030, - 0x00090020, 0x00090030, 0x20090020, 0x20090030, - 0x00080820, 0x00080830, 0x20080820, 0x20080830, - 0x00090820, 0x00090830, 0x20090820, 0x20090830, - }, - { - 0x00000000, 0x02000000, 0x00002000, 0x02002000, - 0x00200000, 0x02200000, 0x00202000, 0x02202000, - 0x00000004, 0x02000004, 0x00002004, 0x02002004, - 0x00200004, 0x02200004, 0x00202004, 0x02202004, - 0x00000400, 0x02000400, 0x00002400, 0x02002400, - 0x00200400, 0x02200400, 0x00202400, 0x02202400, - 0x00000404, 0x02000404, 0x00002404, 0x02002404, - 0x00200404, 0x02200404, 0x00202404, 0x02202404, - 0x10000000, 0x12000000, 0x10002000, 0x12002000, - 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, - 0x10200004, 0x12200004, 0x10202004, 0x12202004, - 0x10000400, 0x12000400, 0x10002400, 0x12002400, - 0x10200400, 0x12200400, 0x10202400, 0x12202400, - 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404, - }, - { - 0x00000000, 0x00000001, 0x00040000, 0x00040001, - 0x01000000, 0x01000001, 0x01040000, 0x01040001, - 0x00000002, 0x00000003, 0x00040002, 0x00040003, - 0x01000002, 0x01000003, 0x01040002, 0x01040003, - 0x00000200, 0x00000201, 0x00040200, 0x00040201, - 0x01000200, 0x01000201, 0x01040200, 0x01040201, - 0x00000202, 0x00000203, 0x00040202, 0x00040203, - 0x01000202, 0x01000203, 0x01040202, 0x01040203, - 0x08000000, 0x08000001, 0x08040000, 0x08040001, - 0x09000000, 0x09000001, 0x09040000, 0x09040001, - 0x08000002, 0x08000003, 0x08040002, 0x08040003, - 0x09000002, 0x09000003, 0x09040002, 0x09040003, - 0x08000200, 0x08000201, 0x08040200, 0x08040201, - 0x09000200, 0x09000201, 0x09040200, 0x09040201, - 0x08000202, 0x08000203, 0x08040202, 0x08040203, - 0x09000202, 0x09000203, 0x09040202, 0x09040203, - }, - { - 0x00000000, 0x00100000, 0x00000100, 0x00100100, - 0x00000008, 0x00100008, 0x00000108, 0x00100108, - 0x00001000, 0x00101000, 0x00001100, 0x00101100, - 0x00001008, 0x00101008, 0x00001108, 0x00101108, - 0x04000000, 0x04100000, 0x04000100, 0x04100100, - 0x04000008, 0x04100008, 0x04000108, 0x04100108, - 0x04001000, 0x04101000, 0x04001100, 0x04101100, - 0x04001008, 0x04101008, 0x04001108, 0x04101108, - 0x00020000, 0x00120000, 0x00020100, 0x00120100, - 0x00020008, 0x00120008, 0x00020108, 0x00120108, - 0x00021000, 0x00121000, 0x00021100, 0x00121100, - 0x00021008, 0x00121008, 0x00021108, 0x00121108, - 0x04020000, 0x04120000, 0x04020100, 0x04120100, - 0x04020008, 0x04120008, 0x04020108, 0x04120108, - 0x04021000, 0x04121000, 0x04021100, 0x04121100, - 0x04021008, 0x04121008, 0x04021108, 0x04121108, - }, - { - 0x00000000, 0x10000000, 0x00010000, 0x10010000, - 0x00000004, 0x10000004, 0x00010004, 0x10010004, - 0x20000000, 0x30000000, 0x20010000, 0x30010000, - 0x20000004, 0x30000004, 0x20010004, 0x30010004, - 0x00100000, 0x10100000, 0x00110000, 0x10110000, - 0x00100004, 0x10100004, 0x00110004, 0x10110004, - 0x20100000, 0x30100000, 0x20110000, 0x30110000, - 0x20100004, 0x30100004, 0x20110004, 0x30110004, - 0x00001000, 0x10001000, 0x00011000, 0x10011000, - 0x00001004, 0x10001004, 0x00011004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, - 0x20001004, 0x30001004, 0x20011004, 0x30011004, - 0x00101000, 0x10101000, 0x00111000, 0x10111000, - 0x00101004, 0x10101004, 0x00111004, 0x10111004, - 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004, - }, - { - 0x00000000, 0x08000000, 0x00000008, 0x08000008, - 0x00000400, 0x08000400, 0x00000408, 0x08000408, - 0x00020000, 0x08020000, 0x00020008, 0x08020008, - 0x00020400, 0x08020400, 0x00020408, 0x08020408, - 0x00000001, 0x08000001, 0x00000009, 0x08000009, - 0x00000401, 0x08000401, 0x00000409, 0x08000409, - 0x00020001, 0x08020001, 0x00020009, 0x08020009, - 0x00020401, 0x08020401, 0x00020409, 0x08020409, - 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, - 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, - 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, - 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, - 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, - 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, - 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, - 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, - }, - { - 0x00000000, 0x00000100, 0x00080000, 0x00080100, - 0x01000000, 0x01000100, 0x01080000, 0x01080100, - 0x00000010, 0x00000110, 0x00080010, 0x00080110, - 0x01000010, 0x01000110, 0x01080010, 0x01080110, - 0x00200000, 0x00200100, 0x00280000, 0x00280100, - 0x01200000, 0x01200100, 0x01280000, 0x01280100, - 0x00200010, 0x00200110, 0x00280010, 0x00280110, - 0x01200010, 0x01200110, 0x01280010, 0x01280110, - 0x00000200, 0x00000300, 0x00080200, 0x00080300, - 0x01000200, 0x01000300, 0x01080200, 0x01080300, - 0x00000210, 0x00000310, 0x00080210, 0x00080310, - 0x01000210, 0x01000310, 0x01080210, 0x01080310, - 0x00200200, 0x00200300, 0x00280200, 0x00280300, - 0x01200200, 0x01200300, 0x01280200, 0x01280300, - 0x00200210, 0x00200310, 0x00280210, 0x00280310, - 0x01200210, 0x01200310, 0x01280210, 0x01280310, - }, - { - 0x00000000, 0x04000000, 0x00040000, 0x04040000, - 0x00000002, 0x04000002, 0x00040002, 0x04040002, - 0x00002000, 0x04002000, 0x00042000, 0x04042000, - 0x00002002, 0x04002002, 0x00042002, 0x04042002, - 0x00000020, 0x04000020, 0x00040020, 0x04040020, - 0x00000022, 0x04000022, 0x00040022, 0x04040022, - 0x00002020, 0x04002020, 0x00042020, 0x04042020, - 0x00002022, 0x04002022, 0x00042022, 0x04042022, - 0x00000800, 0x04000800, 0x00040800, 0x04040800, - 0x00000802, 0x04000802, 0x00040802, 0x04040802, - 0x00002800, 0x04002800, 0x00042800, 0x04042800, - 0x00002802, 0x04002802, 0x00042802, 0x04042802, - 0x00000820, 0x04000820, 0x00040820, 0x04040820, - 0x00000822, 0x04000822, 0x00040822, 0x04040822, - 0x00002820, 0x04002820, 0x00042820, 0x04042820, - 0x00002822, 0x04002822, 0x00042822, 0x04042822 - } -}; - -#if VECT_SIZE == 1 -#define BOX(i,n,S) (S)[(n)][(i)] -#elif VECT_SIZE == 2 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1]) -#elif VECT_SIZE == 4 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3]) -#elif VECT_SIZE == 8 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) -#elif VECT_SIZE == 16 -#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) -#endif - -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, __local u32 (*s_SPtrans)[64]) -{ - u32x tt; - - u32x r = data[0]; - u32x l = data[1]; - - IP (r, l, tt); - - r = rotl32 (r, 3u); - l = rotl32 (l, 3u); - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i += 2) - { - u32x u; - u32x t; - - u = Kc[i + 0] ^ r; - t = Kd[i + 0] ^ rotl32 (r, 28u); - - l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - - u = Kc[i + 1] ^ l; - t = Kd[i + 1] ^ rotl32 (l, 28u); - - r ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - } - - l = rotl32 (l, 29u); - r = rotl32 (r, 29u); - - FP (r, l, tt); - - iv[0] = l; - iv[1] = r; -} - -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, __local u32 (*s_skb)[64]) -{ - u32x tt; - - PERM_OP (d, c, tt, 4, 0x0f0f0f0f); - HPERM_OP (c, tt, 2, 0xcccc0000); - HPERM_OP (d, tt, 2, 0xcccc0000); - PERM_OP (d, c, tt, 1, 0x55555555); - PERM_OP (c, d, tt, 8, 0x00ff00ff); - PERM_OP (d, c, tt, 1, 0x55555555); - - d = ((d & 0x000000ff) << 16) - | ((d & 0x0000ff00) << 0) - | ((d & 0x00ff0000) >> 16) - | ((c & 0xf0000000) >> 4); - - c = c & 0x0fffffff; - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i++) - { - if ((i < 2) || (i == 8) || (i == 15)) - { - c = ((c >> 1) | (c << 27)); - d = ((d >> 1) | (d << 27)); - } - else - { - c = ((c >> 2) | (c << 26)); - d = ((d >> 2) | (d << 26)); - } - - c = c & 0x0fffffff; - d = d & 0x0fffffff; - - const u32x c00 = (c >> 0) & 0x0000003f; - const u32x c06 = (c >> 6) & 0x00383003; - const u32x c07 = (c >> 7) & 0x0000003c; - const u32x c13 = (c >> 13) & 0x0000060f; - const u32x c20 = (c >> 20) & 0x00000001; - - u32x s = BOX (((c00 >> 0) & 0xff), 0, s_skb) - | BOX (((c06 >> 0) & 0xff) - |((c07 >> 0) & 0xff), 1, s_skb) - | BOX (((c13 >> 0) & 0xff) - |((c06 >> 8) & 0xff), 2, s_skb) - | BOX (((c20 >> 0) & 0xff) - |((c13 >> 8) & 0xff) - |((c06 >> 16) & 0xff), 3, s_skb); - - const u32x d00 = (d >> 0) & 0x00003c3f; - const u32x d07 = (d >> 7) & 0x00003f03; - const u32x d21 = (d >> 21) & 0x0000000f; - const u32x d22 = (d >> 22) & 0x00000030; - - u32x t = BOX (((d00 >> 0) & 0xff), 4, s_skb) - | BOX (((d07 >> 0) & 0xff) - |((d00 >> 8) & 0xff), 5, s_skb) - | BOX (((d07 >> 8) & 0xff), 6, s_skb) - | BOX (((d21 >> 0) & 0xff) - |((d22 >> 0) & 0xff), 7, s_skb); - - Kc[i] = ((t << 16) | (s & 0x0000ffff)); - Kd[i] = ((s >> 16) | (t & 0xffff0000)); - - Kc[i] = rotl32 (Kc[i], 2u); - Kd[i] = rotl32 (Kd[i], 2u); - } -} - -DECLSPEC void m03100m (__local u32 (*s_SPtrans)[64], __local u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) +DECLSPEC void m03100m (SHM_TYPE u32 (*s_SPtrans)[64], SHM_TYPE u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) { /** * modifier @@ -665,7 +194,7 @@ DECLSPEC void m03100m (__local u32 (*s_SPtrans)[64], __local u32 (*s_skb)[64], u } } -DECLSPEC void m03100s (__local u32 (*s_SPtrans)[64], __local u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) +DECLSPEC void m03100s (SHM_TYPE u32 (*s_SPtrans)[64], SHM_TYPE u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) { /** * modifier @@ -894,9 +423,11 @@ __kernel void m03100_m04 (KERN_ATTR_VECTOR ()) const u32 pw_len = pws[gid].pw_len & 63; /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -923,6 +454,13 @@ __kernel void m03100_m04 (KERN_ATTR_VECTOR ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -968,9 +506,11 @@ __kernel void m03100_m08 (KERN_ATTR_VECTOR ()) const u32 pw_len = pws[gid].pw_len & 63; /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -997,6 +537,13 @@ __kernel void m03100_m08 (KERN_ATTR_VECTOR ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -1046,9 +593,11 @@ __kernel void m03100_s04 (KERN_ATTR_VECTOR ()) const u32 pw_len = pws[gid].pw_len & 63; /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -1075,6 +624,13 @@ __kernel void m03100_s04 (KERN_ATTR_VECTOR ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -1120,9 +676,11 @@ __kernel void m03100_s08 (KERN_ATTR_VECTOR ()) const u32 pw_len = pws[gid].pw_len & 63; /** - * sbox, kbox + * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -1149,6 +707,13 @@ __kernel void m03100_s08 (KERN_ATTR_VECTOR ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m03200-pure.cl b/OpenCL/m03200-pure.cl index 92b2dabfb..b950da688 100644 --- a/OpenCL/m03200-pure.cl +++ b/OpenCL/m03200-pure.cl @@ -12,6 +12,19 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct bcrypt_tmp +{ + u32 E[18]; + + u32 P[18]; + + u32 S0[256]; + u32 S1[256]; + u32 S2[256]; + u32 S3[256]; + +} bcrypt_tmp_t; + // http://www.schneier.com/code/constants.txt __constant u32a c_sbox0[256] = @@ -286,16 +299,21 @@ __constant u32a c_sbox3[256] = 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 }; -#define BF_ROUND(L,R,N) \ -{ \ - u32 tmp; \ - \ - tmp = S0[hc_bfe_S ((L), 24, 8)]; \ - tmp += S1[hc_bfe_S ((L), 16, 8)]; \ - tmp ^= S2[hc_bfe_S ((L), 8, 8)]; \ - tmp += S3[hc_bfe_S ((L), 0, 8)]; \ - \ - (R) ^= tmp ^ P[(N)]; \ +#define BF_ROUND(L,R,N) \ +{ \ + u32 tmp; \ + \ + const u32 r0 = hc_bfe_S ((L), 24, 8); \ + const u32 r1 = hc_bfe_S ((L), 16, 8); \ + const u32 r2 = hc_bfe_S ((L), 8, 8); \ + const u32 r3 = hc_bfe_S ((L), 0, 8); \ + \ + tmp = S0[r0]; \ + tmp += S1[r1]; \ + tmp ^= S2[r2]; \ + tmp += S3[r3]; \ + \ + (R) ^= tmp ^ P[(N)]; \ } #define BF_ENCRYPT(L,R) \ @@ -348,7 +366,7 @@ DECLSPEC void expand_key (u32 *E, u32 *W, const int len) } } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_init (KERN_ATTR_TMPS (bcrypt_tmp_t)) +__kernel void __attribute__((reqd_work_group_size(FIXED_LOCAL_SIZE, 1, 1))) m03200_init (KERN_ATTR_TMPS (bcrypt_tmp_t)) { /** * base @@ -425,10 +443,10 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_init (KERN_A * do the key setup */ - __local u32 S0_all[8][256]; - __local u32 S1_all[8][256]; - __local u32 S2_all[8][256]; - __local u32 S3_all[8][256]; + __local u32 S0_all[FIXED_LOCAL_SIZE][256]; + __local u32 S1_all[FIXED_LOCAL_SIZE][256]; + __local u32 S2_all[FIXED_LOCAL_SIZE][256]; + __local u32 S3_all[FIXED_LOCAL_SIZE][256]; __local u32 *S0 = S0_all[lid]; __local u32 *S1 = S1_all[lid]; @@ -567,7 +585,7 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_init (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_loop (KERN_ATTR_TMPS (bcrypt_tmp_t)) +__kernel void __attribute__((reqd_work_group_size(FIXED_LOCAL_SIZE, 1, 1))) m03200_loop (KERN_ATTR_TMPS (bcrypt_tmp_t)) { /** * base @@ -594,10 +612,10 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_loop (KERN_A P[i] = tmps[gid].P[i]; } - __local u32 S0_all[8][256]; - __local u32 S1_all[8][256]; - __local u32 S2_all[8][256]; - __local u32 S3_all[8][256]; + __local u32 S0_all[FIXED_LOCAL_SIZE][256]; + __local u32 S1_all[FIXED_LOCAL_SIZE][256]; + __local u32 S2_all[FIXED_LOCAL_SIZE][256]; + __local u32 S3_all[FIXED_LOCAL_SIZE][256]; __local u32 *S0 = S0_all[lid]; __local u32 *S1 = S1_all[lid]; @@ -765,7 +783,7 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_loop (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_comp (KERN_ATTR_TMPS (bcrypt_tmp_t)) +__kernel void __attribute__((reqd_work_group_size(FIXED_LOCAL_SIZE, 1, 1))) m03200_comp (KERN_ATTR_TMPS (bcrypt_tmp_t)) { /** * base @@ -785,10 +803,10 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m03200_comp (KERN_A P[i] = tmps[gid].P[i]; } - __local u32 S0_all[8][256]; - __local u32 S1_all[8][256]; - __local u32 S2_all[8][256]; - __local u32 S3_all[8][256]; + __local u32 S0_all[FIXED_LOCAL_SIZE][256]; + __local u32 S1_all[FIXED_LOCAL_SIZE][256]; + __local u32 S2_all[FIXED_LOCAL_SIZE][256]; + __local u32 S3_all[FIXED_LOCAL_SIZE][256]; __local u32 *S0 = S0_all[lid]; __local u32 *S1 = S1_all[lid]; diff --git a/OpenCL/m05200-pure.cl b/OpenCL/m05200-pure.cl index c659110cf..23a2d0d0a 100644 --- a/OpenCL/m05200-pure.cl +++ b/OpenCL/m05200-pure.cl @@ -16,6 +16,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pwsafe3_tmp +{ + u32 digest_buf[8]; + +} pwsafe3_tmp_t; + __kernel void m05200_init (KERN_ATTR_TMPS (pwsafe3_tmp_t)) { /** diff --git a/OpenCL/m05300_a0-optimized.cl b/OpenCL/m05300_a0-optimized.cl index 3e8aed4b4..17ebfe988 100644 --- a/OpenCL/m05300_a0-optimized.cl +++ b/OpenCL/m05300_a0-optimized.cl @@ -15,6 +15,16 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + DECLSPEC void hmac_md5_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05300_a0-pure.cl b/OpenCL/m05300_a0-pure.cl index 51e56415a..86e2ffc8b 100644 --- a/OpenCL/m05300_a0-pure.cl +++ b/OpenCL/m05300_a0-pure.cl @@ -15,6 +15,16 @@ #include "inc_scalar.cl" #include "inc_hash_md5.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + __kernel void m05300_mxx (KERN_ATTR_RULES_ESALT (ikepsk_t)) { /** diff --git a/OpenCL/m05300_a1-optimized.cl b/OpenCL/m05300_a1-optimized.cl index db4bf40d7..ac717373f 100644 --- a/OpenCL/m05300_a1-optimized.cl +++ b/OpenCL/m05300_a1-optimized.cl @@ -13,6 +13,16 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + DECLSPEC void hmac_md5_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05300_a1-pure.cl b/OpenCL/m05300_a1-pure.cl index 39d8019e2..3b6d61142 100644 --- a/OpenCL/m05300_a1-pure.cl +++ b/OpenCL/m05300_a1-pure.cl @@ -13,6 +13,16 @@ #include "inc_scalar.cl" #include "inc_hash_md5.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + __kernel void m05300_mxx (KERN_ATTR_ESALT (ikepsk_t)) { /** diff --git a/OpenCL/m05300_a3-optimized.cl b/OpenCL/m05300_a3-optimized.cl index 50f35935a..fe953a59e 100644 --- a/OpenCL/m05300_a3-optimized.cl +++ b/OpenCL/m05300_a3-optimized.cl @@ -13,6 +13,16 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + DECLSPEC void hmac_md5_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05300_a3-pure.cl b/OpenCL/m05300_a3-pure.cl index f9b4b3bca..aa387c52c 100644 --- a/OpenCL/m05300_a3-pure.cl +++ b/OpenCL/m05300_a3-pure.cl @@ -13,6 +13,16 @@ #include "inc_scalar.cl" #include "inc_hash_md5.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + __kernel void m05300_mxx (KERN_ATTR_VECTOR_ESALT (ikepsk_t)) { /** diff --git a/OpenCL/m05400_a0-optimized.cl b/OpenCL/m05400_a0-optimized.cl index 9ec74d7cb..c37980d8c 100644 --- a/OpenCL/m05400_a0-optimized.cl +++ b/OpenCL/m05400_a0-optimized.cl @@ -15,6 +15,16 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + DECLSPEC void hmac_sha1_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05400_a0-pure.cl b/OpenCL/m05400_a0-pure.cl index 8a0e1f80b..3180e0011 100644 --- a/OpenCL/m05400_a0-pure.cl +++ b/OpenCL/m05400_a0-pure.cl @@ -15,6 +15,16 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + __kernel void m05400_mxx (KERN_ATTR_RULES_ESALT (ikepsk_t)) { /** diff --git a/OpenCL/m05400_a1-optimized.cl b/OpenCL/m05400_a1-optimized.cl index 67aa1fba7..08c2b6884 100644 --- a/OpenCL/m05400_a1-optimized.cl +++ b/OpenCL/m05400_a1-optimized.cl @@ -13,6 +13,16 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + DECLSPEC void hmac_sha1_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05400_a1-pure.cl b/OpenCL/m05400_a1-pure.cl index ff33647d2..12a2dcf52 100644 --- a/OpenCL/m05400_a1-pure.cl +++ b/OpenCL/m05400_a1-pure.cl @@ -13,6 +13,16 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + __kernel void m05400_mxx (KERN_ATTR_ESALT (ikepsk_t)) { /** diff --git a/OpenCL/m05400_a3-optimized.cl b/OpenCL/m05400_a3-optimized.cl index 7cab76cf7..88b9d1932 100644 --- a/OpenCL/m05400_a3-optimized.cl +++ b/OpenCL/m05400_a3-optimized.cl @@ -13,6 +13,16 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + DECLSPEC void hmac_sha1_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05400_a3-pure.cl b/OpenCL/m05400_a3-pure.cl index 92992936f..0d9815a34 100644 --- a/OpenCL/m05400_a3-pure.cl +++ b/OpenCL/m05400_a3-pure.cl @@ -13,6 +13,16 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct ikepsk +{ + u32 nr_buf[16]; + u32 nr_len; + + u32 msg_buf[128]; + u32 msg_len[6]; + +} ikepsk_t; + __kernel void m05400_mxx (KERN_ATTR_VECTOR_ESALT (ikepsk_t)) { /** diff --git a/OpenCL/m05500_a0-optimized.cl b/OpenCL/m05500_a0-optimized.cl index 4cf1f0007..597f79314 100644 --- a/OpenCL/m05500_a0-optimized.cl +++ b/OpenCL/m05500_a0-optimized.cl @@ -14,6 +14,18 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m05500_a0-pure.cl b/OpenCL/m05500_a0-pure.cl index 6e8302af4..caf590513 100644 --- a/OpenCL/m05500_a0-pure.cl +++ b/OpenCL/m05500_a0-pure.cl @@ -15,6 +15,18 @@ #include "inc_scalar.cl" #include "inc_hash_md4.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m05500_a1-optimized.cl b/OpenCL/m05500_a1-optimized.cl index ed4a04033..8e7bd8370 100644 --- a/OpenCL/m05500_a1-optimized.cl +++ b/OpenCL/m05500_a1-optimized.cl @@ -12,6 +12,18 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m05500_a1-pure.cl b/OpenCL/m05500_a1-pure.cl index e774bea51..89ee6bcef 100644 --- a/OpenCL/m05500_a1-pure.cl +++ b/OpenCL/m05500_a1-pure.cl @@ -13,6 +13,18 @@ #include "inc_scalar.cl" #include "inc_hash_md4.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m05500_a3-optimized.cl b/OpenCL/m05500_a3-optimized.cl index 5fb88b555..ca0aae8ca 100644 --- a/OpenCL/m05500_a3-optimized.cl +++ b/OpenCL/m05500_a3-optimized.cl @@ -12,6 +12,18 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m05500_a3-pure.cl b/OpenCL/m05500_a3-pure.cl index 04ce63171..7d5fa0529 100644 --- a/OpenCL/m05500_a3-pure.cl +++ b/OpenCL/m05500_a3-pure.cl @@ -13,6 +13,18 @@ #include "inc_simd.cl" #include "inc_hash_md4.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m05600_a0-optimized.cl b/OpenCL/m05600_a0-optimized.cl index 7fc122ca8..9b088441a 100644 --- a/OpenCL/m05600_a0-optimized.cl +++ b/OpenCL/m05600_a0-optimized.cl @@ -16,6 +16,18 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + DECLSPEC void hmac_md5_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05600_a0-pure.cl b/OpenCL/m05600_a0-pure.cl index 4440ed7de..4fbfded94 100644 --- a/OpenCL/m05600_a0-pure.cl +++ b/OpenCL/m05600_a0-pure.cl @@ -16,6 +16,18 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + __kernel void m05600_mxx (KERN_ATTR_RULES_ESALT (netntlm_t)) { /** diff --git a/OpenCL/m05600_a1-optimized.cl b/OpenCL/m05600_a1-optimized.cl index 62a424ee7..86978d520 100644 --- a/OpenCL/m05600_a1-optimized.cl +++ b/OpenCL/m05600_a1-optimized.cl @@ -14,6 +14,18 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + DECLSPEC void hmac_md5_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05600_a1-pure.cl b/OpenCL/m05600_a1-pure.cl index 2f1204932..644fde5c6 100644 --- a/OpenCL/m05600_a1-pure.cl +++ b/OpenCL/m05600_a1-pure.cl @@ -14,6 +14,18 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + __kernel void m05600_mxx (KERN_ATTR_ESALT (netntlm_t)) { /** diff --git a/OpenCL/m05600_a3-optimized.cl b/OpenCL/m05600_a3-optimized.cl index 2f9904e1a..eb30a65dd 100644 --- a/OpenCL/m05600_a3-optimized.cl +++ b/OpenCL/m05600_a3-optimized.cl @@ -14,6 +14,18 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + DECLSPEC void hmac_md5_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m05600_a3-pure.cl b/OpenCL/m05600_a3-pure.cl index 5b9515b14..d90b6551f 100644 --- a/OpenCL/m05600_a3-pure.cl +++ b/OpenCL/m05600_a3-pure.cl @@ -14,6 +14,18 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct netntlm +{ + u32 user_len; + u32 domain_len; + u32 srvchall_len; + u32 clichall_len; + + u32 userdomain_buf[64]; + u32 chall_buf[256]; + +} netntlm_t; + __kernel void m05600_mxx (KERN_ATTR_VECTOR_ESALT (netntlm_t)) { /** diff --git a/OpenCL/m05800-optimized.cl b/OpenCL/m05800-optimized.cl index ecf699a7a..661ed576d 100644 --- a/OpenCL/m05800-optimized.cl +++ b/OpenCL/m05800-optimized.cl @@ -13,6 +13,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct androidpin_tmp +{ + u32 digest_buf[5]; + +} androidpin_tmp_t; + __constant u32a c_pc_dec[1024] = { 0x00000030, diff --git a/OpenCL/m05800-pure.cl b/OpenCL/m05800-pure.cl index a757c3ef7..07547afee 100644 --- a/OpenCL/m05800-pure.cl +++ b/OpenCL/m05800-pure.cl @@ -13,6 +13,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct androidpin_tmp +{ + u32 digest_buf[5]; + +} androidpin_tmp_t; + __constant u32a c_pc_dec[1024] = { 0x00000030, diff --git a/OpenCL/m06000_a0-optimized.cl b/OpenCL/m06000_a0-optimized.cl index bc79b691f..7a97b10d9 100644 --- a/OpenCL/m06000_a0-optimized.cl +++ b/OpenCL/m06000_a0-optimized.cl @@ -20,7 +20,7 @@ DECLSPEC void ripemd160_transform_transport_vector (const u32x *w, u32x *dgst) ripemd160_transform_vector (w + 0, w + 4, w + 8, w + 12, dgst); } -__kernel void m06000_m04 (KERN_ATTR_RULES_ESALT (netntlm_t)) +__kernel void m06000_m04 (KERN_ATTR_RULES ()) { /** * modifier @@ -110,7 +110,7 @@ __kernel void m06000_m16 (KERN_ATTR_RULES ()) { } -__kernel void m06000_s04 (KERN_ATTR_RULES_ESALT (netntlm_t)) +__kernel void m06000_s04 (KERN_ATTR_RULES ()) { /** * modifier diff --git a/OpenCL/m06000_a1-optimized.cl b/OpenCL/m06000_a1-optimized.cl index cd6e25885..5533cc118 100644 --- a/OpenCL/m06000_a1-optimized.cl +++ b/OpenCL/m06000_a1-optimized.cl @@ -18,7 +18,7 @@ DECLSPEC void ripemd160_transform_transport_vector (const u32x *w, u32x *dgst) ripemd160_transform_vector (w + 0, w + 4, w + 8, w + 12, dgst); } -__kernel void m06000_m04 (KERN_ATTR_ESALT (netntlm_t)) +__kernel void m06000_m04 (KERN_ATTR_BASIC ()) { /** * modifier @@ -166,7 +166,7 @@ __kernel void m06000_m16 (KERN_ATTR_BASIC ()) { } -__kernel void m06000_s04 (KERN_ATTR_ESALT (netntlm_t)) +__kernel void m06000_s04 (KERN_ATTR_BASIC ()) { /** * modifier diff --git a/OpenCL/m06100_a0-optimized.cl b/OpenCL/m06100_a0-optimized.cl index e2f466263..bccb54b28 100644 --- a/OpenCL/m06100_a0-optimized.cl +++ b/OpenCL/m06100_a0-optimized.cl @@ -15,7 +15,7 @@ #include "inc_simd.cl" #include "inc_hash_whirlpool.cl" -DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_Ch, s_Cl); } @@ -31,9 +31,11 @@ __kernel void m06100_m04 (KERN_ATTR_RULES ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -60,6 +62,13 @@ __kernel void m06100_m04 (KERN_ATTR_RULES ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -162,9 +171,11 @@ __kernel void m06100_s04 (KERN_ATTR_RULES ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -191,6 +202,13 @@ __kernel void m06100_s04 (KERN_ATTR_RULES ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06100_a0-pure.cl b/OpenCL/m06100_a0-pure.cl index a1c94d998..020170aa3 100644 --- a/OpenCL/m06100_a0-pure.cl +++ b/OpenCL/m06100_a0-pure.cl @@ -26,9 +26,11 @@ __kernel void m06100_mxx (KERN_ATTR_RULES ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -55,6 +57,13 @@ __kernel void m06100_mxx (KERN_ATTR_RULES ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -101,9 +110,11 @@ __kernel void m06100_sxx (KERN_ATTR_RULES ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -130,6 +141,13 @@ __kernel void m06100_sxx (KERN_ATTR_RULES ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06100_a1-optimized.cl b/OpenCL/m06100_a1-optimized.cl index 02d090baa..c43528a76 100644 --- a/OpenCL/m06100_a1-optimized.cl +++ b/OpenCL/m06100_a1-optimized.cl @@ -13,7 +13,7 @@ #include "inc_simd.cl" #include "inc_hash_whirlpool.cl" -DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_Ch, s_Cl); } @@ -29,9 +29,11 @@ __kernel void m06100_m04 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -58,6 +60,13 @@ __kernel void m06100_m04 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -218,9 +227,11 @@ __kernel void m06100_s04 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -247,6 +258,13 @@ __kernel void m06100_s04 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06100_a1-pure.cl b/OpenCL/m06100_a1-pure.cl index dd4a1d769..ecc2f199d 100644 --- a/OpenCL/m06100_a1-pure.cl +++ b/OpenCL/m06100_a1-pure.cl @@ -24,9 +24,11 @@ __kernel void m06100_mxx (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -53,6 +55,13 @@ __kernel void m06100_mxx (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -97,9 +106,11 @@ __kernel void m06100_sxx (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -126,6 +137,13 @@ __kernel void m06100_sxx (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06100_a3-optimized.cl b/OpenCL/m06100_a3-optimized.cl index 6f68d1e77..fc8cd5504 100644 --- a/OpenCL/m06100_a3-optimized.cl +++ b/OpenCL/m06100_a3-optimized.cl @@ -13,12 +13,12 @@ #include "inc_simd.cl" #include "inc_hash_whirlpool.cl" -DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_Ch, s_Cl); } -DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), __local u32 (*s_Cl)[256], __local u32 (*s_Ch)[256]) +DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), SHM_TYPE u32 (*s_Cl)[256], SHM_TYPE u32 (*s_Ch)[256]) { /** * modifier @@ -87,7 +87,7 @@ DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER } } -DECLSPEC void m06100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), __local u32 (*s_Cl)[256], __local u32 (*s_Ch)[256]) +DECLSPEC void m06100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), SHM_TYPE u32 (*s_Cl)[256], SHM_TYPE u32 (*s_Ch)[256]) { /** * modifier @@ -179,9 +179,11 @@ __kernel void m06100_m04 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -208,6 +210,13 @@ __kernel void m06100_m04 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -262,9 +271,11 @@ __kernel void m06100_m08 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -291,6 +302,13 @@ __kernel void m06100_m08 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -349,9 +367,11 @@ __kernel void m06100_s04 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -378,6 +398,13 @@ __kernel void m06100_s04 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -432,9 +459,11 @@ __kernel void m06100_s08 (KERN_ATTR_BASIC ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -461,6 +490,13 @@ __kernel void m06100_s08 (KERN_ATTR_BASIC ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06100_a3-pure.cl b/OpenCL/m06100_a3-pure.cl index fe22a245c..ba002f18a 100644 --- a/OpenCL/m06100_a3-pure.cl +++ b/OpenCL/m06100_a3-pure.cl @@ -24,9 +24,11 @@ __kernel void m06100_mxx (KERN_ATTR_VECTOR ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -53,6 +55,13 @@ __kernel void m06100_mxx (KERN_ATTR_VECTOR ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -110,9 +119,11 @@ __kernel void m06100_sxx (KERN_ATTR_VECTOR ()) const u64 lsz = get_local_size (0); /** - * shared + * Whirlpool shared */ + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -139,6 +150,13 @@ __kernel void m06100_sxx (KERN_ATTR_VECTOR ()) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06211-pure.cl b/OpenCL/m06211-pure.cl index 6a43054fc..ce62c09db 100644 --- a/OpenCL/m06211-pure.cl +++ b/OpenCL/m06211-pure.cl @@ -16,13 +16,32 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" + +typedef struct tc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + +} tc_tmp_t; DECLSPEC void hmac_ripemd160_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { @@ -353,43 +372,27 @@ __kernel void m06211_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey2[6] = tmps[gid].out[14]; ukey2[7] = tmps[gid].out[15]; - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06212-pure.cl b/OpenCL/m06212-pure.cl index b1c675fa3..4c149af11 100644 --- a/OpenCL/m06212-pure.cl +++ b/OpenCL/m06212-pure.cl @@ -16,13 +16,32 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" + +typedef struct tc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + +} tc_tmp_t; DECLSPEC void hmac_ripemd160_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { @@ -353,43 +372,27 @@ __kernel void m06212_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey2[6] = tmps[gid].out[14]; ukey2[7] = tmps[gid].out[15]; - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -415,59 +418,27 @@ __kernel void m06212_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey4[6] = tmps[gid].out[30]; ukey4[7] = tmps[gid].out[31]; - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06213-pure.cl b/OpenCL/m06213-pure.cl index a15ef1298..2e1f761a6 100644 --- a/OpenCL/m06213-pure.cl +++ b/OpenCL/m06213-pure.cl @@ -16,13 +16,32 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" + +typedef struct tc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + +} tc_tmp_t; DECLSPEC void hmac_ripemd160_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { @@ -353,43 +372,27 @@ __kernel void m06213_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey2[6] = tmps[gid].out[14]; ukey2[7] = tmps[gid].out[15]; - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -415,59 +418,27 @@ __kernel void m06213_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey4[6] = tmps[gid].out[30]; ukey4[7] = tmps[gid].out[31]; - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -493,27 +464,19 @@ __kernel void m06213_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey6[6] = tmps[gid].out[46]; ukey6[7] = tmps[gid].out[47]; - if (verify_header_aes_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_twofish_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_serpent_camellia (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06221-pure.cl b/OpenCL/m06221-pure.cl index 1d25cd197..1f0a41453 100644 --- a/OpenCL/m06221-pure.cl +++ b/OpenCL/m06221-pure.cl @@ -16,13 +16,32 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" + +typedef struct tc64_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + +} tc64_tmp_t; DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { @@ -497,43 +516,27 @@ __kernel void m06221_comp (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) ukey2[6] = swap32_S (h32_from_64_S (tmps[gid].out[7])); ukey2[7] = swap32_S (l32_from_64_S (tmps[gid].out[7])); - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06222-pure.cl b/OpenCL/m06222-pure.cl index 8d4879b22..ea7697860 100644 --- a/OpenCL/m06222-pure.cl +++ b/OpenCL/m06222-pure.cl @@ -16,13 +16,32 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" + +typedef struct tc64_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + +} tc64_tmp_t; DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { @@ -497,43 +516,27 @@ __kernel void m06222_comp (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) ukey2[6] = swap32_S (h32_from_64_S (tmps[gid].out[7])); ukey2[7] = swap32_S (l32_from_64_S (tmps[gid].out[7])); - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -559,59 +562,27 @@ __kernel void m06222_comp (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) ukey4[6] = swap32_S (h32_from_64_S (tmps[gid].out[15])); ukey4[7] = swap32_S (l32_from_64_S (tmps[gid].out[15])); - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06223-pure.cl b/OpenCL/m06223-pure.cl index d6bbdec1e..fd4816401 100644 --- a/OpenCL/m06223-pure.cl +++ b/OpenCL/m06223-pure.cl @@ -16,13 +16,32 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" + +typedef struct tc64_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + +} tc64_tmp_t; DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { @@ -497,43 +516,27 @@ __kernel void m06223_comp (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) ukey2[6] = swap32_S (h32_from_64_S (tmps[gid].out[7])); ukey2[7] = swap32_S (l32_from_64_S (tmps[gid].out[7])); - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -559,59 +562,27 @@ __kernel void m06223_comp (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) ukey4[6] = swap32_S (h32_from_64_S (tmps[gid].out[15])); ukey4[7] = swap32_S (l32_from_64_S (tmps[gid].out[15])); - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -637,27 +608,19 @@ __kernel void m06223_comp (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) ukey6[6] = swap32_S (h32_from_64_S (tmps[gid].out[23])); ukey6[7] = swap32_S (l32_from_64_S (tmps[gid].out[23])); - if (verify_header_aes_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_twofish_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_serpent_camellia (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06231-pure.cl b/OpenCL/m06231-pure.cl index 76b689a31..1092562b4 100644 --- a/OpenCL/m06231-pure.cl +++ b/OpenCL/m06231-pure.cl @@ -16,15 +16,34 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +typedef struct tc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + +} tc_tmp_t; + +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -139,6 +158,14 @@ __kernel void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; } + barrier (CLK_LOCAL_MEM_FENCE); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -165,6 +192,13 @@ __kernel void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -335,16 +369,14 @@ __kernel void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) __kernel void m06231_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { /** - * modifier + * Whirlpool shared */ const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - /** - * shared - */ + #ifdef REAL_SHM __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -372,6 +404,13 @@ __kernel void m06231_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if ((gid * VECT_SIZE) >= gid_max) return; u32x ipad[16]; @@ -587,6 +626,45 @@ __kernel void m06231_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #endif + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; u32 ukey1[8]; @@ -611,43 +689,27 @@ __kernel void m06231_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey2[6] = swap32_S (tmps[gid].out[14]); ukey2[7] = swap32_S (tmps[gid].out[15]); - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06232-pure.cl b/OpenCL/m06232-pure.cl index 8b0e40aae..2c4cf0bd0 100644 --- a/OpenCL/m06232-pure.cl +++ b/OpenCL/m06232-pure.cl @@ -16,15 +16,34 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +typedef struct tc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + +} tc_tmp_t; + +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -139,6 +158,14 @@ __kernel void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; } + barrier (CLK_LOCAL_MEM_FENCE); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -165,6 +192,13 @@ __kernel void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -335,16 +369,14 @@ __kernel void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) __kernel void m06232_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { /** - * modifier + * Whirlpool shared */ const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - /** - * shared - */ + #ifdef REAL_SHM __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -372,6 +404,13 @@ __kernel void m06232_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if ((gid * VECT_SIZE) >= gid_max) return; u32x ipad[16]; @@ -587,6 +626,45 @@ __kernel void m06232_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #endif + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; u32 ukey1[8]; @@ -611,43 +689,27 @@ __kernel void m06232_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey2[6] = swap32_S (tmps[gid].out[14]); ukey2[7] = swap32_S (tmps[gid].out[15]); - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -673,59 +735,27 @@ __kernel void m06232_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey4[6] = swap32_S (tmps[gid].out[30]); ukey4[7] = swap32_S (tmps[gid].out[31]); - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06233-pure.cl b/OpenCL/m06233-pure.cl index f4992e362..30315c8c4 100644 --- a/OpenCL/m06233-pure.cl +++ b/OpenCL/m06233-pure.cl @@ -16,15 +16,34 @@ #include "inc_cipher_aes.cl" #include "inc_cipher_twofish.cl" #include "inc_cipher_serpent.cl" -#include "inc_cipher_camellia.cl" -#include "inc_cipher_kuznyechik.cl" + +typedef struct tc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + +} tc_t; #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" -#include "inc_veracrypt_xts.cl" -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, __local u32 (*s_Ch)[256], __local u32 (*s_Cl)[256]) +typedef struct tc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + +} tc_tmp_t; + +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -139,6 +158,14 @@ __kernel void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; } + barrier (CLK_LOCAL_MEM_FENCE); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -165,6 +192,13 @@ __kernel void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; /** @@ -335,16 +369,14 @@ __kernel void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) __kernel void m06233_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { /** - * modifier + * Whirlpool shared */ const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - /** - * shared - */ + #ifdef REAL_SHM __local u32 s_Ch[8][256]; __local u32 s_Cl[8][256]; @@ -372,6 +404,13 @@ __kernel void m06233_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if ((gid * VECT_SIZE) >= gid_max) return; u32x ipad[16]; @@ -587,6 +626,45 @@ __kernel void m06233_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #endif + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + if (gid >= gid_max) return; u32 ukey1[8]; @@ -611,43 +689,27 @@ __kernel void m06233_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey2[6] = swap32_S (tmps[gid].out[14]); ukey2[7] = swap32_S (tmps[gid].out[15]); - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -673,59 +735,27 @@ __kernel void m06233_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey4[6] = swap32_S (tmps[gid].out[30]); ukey4[7] = swap32_S (tmps[gid].out[31]); - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } @@ -751,27 +781,19 @@ __kernel void m06233_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) ukey6[6] = swap32_S (tmps[gid].out[46]); ukey6[7] = swap32_S (tmps[gid].out[47]); - if (verify_header_aes_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } - if (verify_header_serpent_twofish_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_serpent_camellia (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m06300-optimized.cl b/OpenCL/m06300-optimized.cl index 1f5aceedc..72442a94b 100644 --- a/OpenCL/m06300-optimized.cl +++ b/OpenCL/m06300-optimized.cl @@ -13,6 +13,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct md5crypt_tmp +{ + u32 digest_buf[4]; + +} md5crypt_tmp_t; + DECLSPEC void memcat16 (u32 *block0, u32 *block1, u32 *block2, u32 *block3, const u32 offset, const u32 *append) { u32 tmp0; diff --git a/OpenCL/m06300-pure.cl b/OpenCL/m06300-pure.cl index a3e39ca90..d81b7dfe1 100644 --- a/OpenCL/m06300-pure.cl +++ b/OpenCL/m06300-pure.cl @@ -18,6 +18,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct md5crypt_tmp +{ + u32 digest_buf[4]; + +} md5crypt_tmp_t; + __kernel void m06300_init (KERN_ATTR_TMPS (md5crypt_tmp_t)) { /** diff --git a/OpenCL/m06400-pure.cl b/OpenCL/m06400-pure.cl index a312bf990..fdcacad78 100644 --- a/OpenCL/m06400-pure.cl +++ b/OpenCL/m06400-pure.cl @@ -16,6 +16,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct sha256aix_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[8]; + u32 out[8]; + +} sha256aix_tmp_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m06500-pure.cl b/OpenCL/m06500-pure.cl index acb70f006..3983ba181 100644 --- a/OpenCL/m06500-pure.cl +++ b/OpenCL/m06500-pure.cl @@ -16,6 +16,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct sha512aix_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[8]; + u64 out[8]; + +} sha512aix_tmp_t; + DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m06600-pure.cl b/OpenCL/m06600-pure.cl index cee322339..41f6e3f8d 100644 --- a/OpenCL/m06600-pure.cl +++ b/OpenCL/m06600-pure.cl @@ -17,6 +17,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct agilekey_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[5]; + u32 out[5]; + +} agilekey_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m06700-pure.cl b/OpenCL/m06700-pure.cl index 7a6fb736f..3cea8b579 100644 --- a/OpenCL/m06700-pure.cl +++ b/OpenCL/m06700-pure.cl @@ -16,6 +16,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct sha1aix_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[5]; + u32 out[5]; + +} sha1aix_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m06800-pure.cl b/OpenCL/m06800-pure.cl index bb4fbbab2..00daeff7b 100644 --- a/OpenCL/m06800-pure.cl +++ b/OpenCL/m06800-pure.cl @@ -17,6 +17,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct lastpass_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[8]; + u32 out[8]; + +} lastpass_tmp_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -365,7 +375,7 @@ __kernel void m06800_comp (KERN_ATTR_TMPS (lastpass_tmp_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m07100-pure.cl b/OpenCL/m07100-pure.cl index 3651b1dd0..acbd0e82a 100644 --- a/OpenCL/m07100-pure.cl +++ b/OpenCL/m07100-pure.cl @@ -16,6 +16,22 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[16]; + u64 out[16]; + +} pbkdf2_sha512_tmp_t; + +typedef struct pbkdf2_sha512 +{ + u32 salt_buf[64]; + +} pbkdf2_sha512_t; + DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m07300_a0-optimized.cl b/OpenCL/m07300_a0-optimized.cl index 82335c3a5..911889c09 100644 --- a/OpenCL/m07300_a0-optimized.cl +++ b/OpenCL/m07300_a0-optimized.cl @@ -15,6 +15,13 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct rakp +{ + u32 salt_buf[128]; + u32 salt_len; + +} rakp_t; + DECLSPEC void hmac_sha1_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m07300_a0-pure.cl b/OpenCL/m07300_a0-pure.cl index 7121f970e..346d8c199 100644 --- a/OpenCL/m07300_a0-pure.cl +++ b/OpenCL/m07300_a0-pure.cl @@ -15,6 +15,13 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct rakp +{ + u32 salt_buf[128]; + u32 salt_len; + +} rakp_t; + __kernel void m07300_mxx (KERN_ATTR_RULES_ESALT (rakp_t)) { /** diff --git a/OpenCL/m07300_a1-optimized.cl b/OpenCL/m07300_a1-optimized.cl index 6f096a277..28e18eab7 100644 --- a/OpenCL/m07300_a1-optimized.cl +++ b/OpenCL/m07300_a1-optimized.cl @@ -13,6 +13,13 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct rakp +{ + u32 salt_buf[128]; + u32 salt_len; + +} rakp_t; + DECLSPEC void hmac_sha1_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m07300_a1-pure.cl b/OpenCL/m07300_a1-pure.cl index 34e087878..1353e5290 100644 --- a/OpenCL/m07300_a1-pure.cl +++ b/OpenCL/m07300_a1-pure.cl @@ -13,6 +13,13 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct rakp +{ + u32 salt_buf[128]; + u32 salt_len; + +} rakp_t; + __kernel void m07300_mxx (KERN_ATTR_ESALT (rakp_t)) { /** diff --git a/OpenCL/m07300_a3-optimized.cl b/OpenCL/m07300_a3-optimized.cl index 0929992db..fad09a0a4 100644 --- a/OpenCL/m07300_a3-optimized.cl +++ b/OpenCL/m07300_a3-optimized.cl @@ -13,6 +13,13 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct rakp +{ + u32 salt_buf[128]; + u32 salt_len; + +} rakp_t; + DECLSPEC void hmac_sha1_pad (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad) { w0[0] = w0[0] ^ 0x36363636; diff --git a/OpenCL/m07300_a3-pure.cl b/OpenCL/m07300_a3-pure.cl index 05525566e..ca16a4dcc 100644 --- a/OpenCL/m07300_a3-pure.cl +++ b/OpenCL/m07300_a3-pure.cl @@ -13,6 +13,13 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct rakp +{ + u32 salt_buf[128]; + u32 salt_len; + +} rakp_t; + __kernel void m07300_mxx (KERN_ATTR_VECTOR_ESALT (rakp_t)) { /** diff --git a/OpenCL/m07400-optimized.cl b/OpenCL/m07400-optimized.cl index 0ee8ad118..b5db1fc7e 100644 --- a/OpenCL/m07400-optimized.cl +++ b/OpenCL/m07400-optimized.cl @@ -13,6 +13,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct sha256crypt_tmp +{ + // pure version + + u32 alt_result[8]; + u32 p_bytes[64]; + u32 s_bytes[64]; + +} sha256crypt_tmp_t; + DECLSPEC void sha256_transform_transport (const u32 *w, u32 *digest) { u32 w0[4]; diff --git a/OpenCL/m07400-pure.cl b/OpenCL/m07400-pure.cl index 2935d79cb..87aa97322 100644 --- a/OpenCL/m07400-pure.cl +++ b/OpenCL/m07400-pure.cl @@ -13,6 +13,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct sha256crypt_tmp +{ + // pure version + + u32 alt_result[8]; + u32 p_bytes[64]; + u32 s_bytes[64]; + +} sha256crypt_tmp_t; + __kernel void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) { /** diff --git a/OpenCL/m07500_a0-optimized.cl b/OpenCL/m07500_a0-optimized.cl index f1a76fde8..ee4ade751 100644 --- a/OpenCL/m07500_a0-optimized.cl +++ b/OpenCL/m07500_a0-optimized.cl @@ -17,6 +17,16 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5pa +{ + u32 user[16]; + u32 realm[16]; + u32 salt[32]; + u32 timestamp[16]; + u32 checksum[4]; + +} krb5pa_t; + typedef struct { u8 S[256]; @@ -384,7 +394,7 @@ DECLSPEC void kerb_prepare (const u32 *w0, const u32 *w1, const u32 pw_len, cons hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m04 (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_m04 (KERN_ATTR_RULES_ESALT (krb5pa_t)) { /** * modifier @@ -476,21 +486,21 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m08 (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_m08 (KERN_ATTR_RULES_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m16 (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_m16 (KERN_ATTR_RULES_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s04 (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_s04 (KERN_ATTR_RULES_ESALT (krb5pa_t)) { /** * modifier @@ -582,16 +592,16 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s08 (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_s08 (KERN_ATTR_RULES_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s16 (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_s16 (KERN_ATTR_RULES_ESALT (krb5pa_t)) { } diff --git a/OpenCL/m07500_a0-pure.cl b/OpenCL/m07500_a0-pure.cl index 73384904b..184496f57 100644 --- a/OpenCL/m07500_a0-pure.cl +++ b/OpenCL/m07500_a0-pure.cl @@ -16,6 +16,16 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5pa +{ + u32 user[16]; + u32 realm[16]; + u32 salt[32]; + u32 timestamp[16]; + u32 checksum[4]; + +} krb5pa_t; + typedef struct { u8 S[256]; @@ -268,7 +278,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest) digest[3] = ctx.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_mxx (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_mxx (KERN_ATTR_RULES_ESALT (krb5pa_t)) { /** * modifier @@ -333,13 +343,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_sxx (KERN_ATTR_RULES_ESALT (krb5pa_t)) +__kernel void m07500_sxx (KERN_ATTR_RULES_ESALT (krb5pa_t)) { /** * modifier @@ -404,7 +414,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m07500_a1-optimized.cl b/OpenCL/m07500_a1-optimized.cl index e732afb77..620d344b3 100644 --- a/OpenCL/m07500_a1-optimized.cl +++ b/OpenCL/m07500_a1-optimized.cl @@ -15,6 +15,16 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5pa +{ + u32 user[16]; + u32 realm[16]; + u32 salt[32]; + u32 timestamp[16]; + u32 checksum[4]; + +} krb5pa_t; + typedef struct { u8 S[256]; @@ -382,7 +392,7 @@ DECLSPEC void kerb_prepare (const u32 *w0, const u32 *w1, const u32 pw_len, cons hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m04 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_m04 (KERN_ATTR_ESALT (krb5pa_t)) { /** * modifier @@ -524,21 +534,21 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m08 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_m08 (KERN_ATTR_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m16 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_m16 (KERN_ATTR_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s04 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_s04 (KERN_ATTR_ESALT (krb5pa_t)) { /** * modifier @@ -680,16 +690,16 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s08 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_s08 (KERN_ATTR_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s16 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_s16 (KERN_ATTR_ESALT (krb5pa_t)) { } diff --git a/OpenCL/m07500_a1-pure.cl b/OpenCL/m07500_a1-pure.cl index 7109a9a59..f24d1595f 100644 --- a/OpenCL/m07500_a1-pure.cl +++ b/OpenCL/m07500_a1-pure.cl @@ -14,6 +14,16 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5pa +{ + u32 user[16]; + u32 realm[16]; + u32 salt[32]; + u32 timestamp[16]; + u32 checksum[4]; + +} krb5pa_t; + typedef struct { u8 S[256]; @@ -266,7 +276,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest) digest[3] = ctx.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_mxx (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_mxx (KERN_ATTR_ESALT (krb5pa_t)) { /** * modifier @@ -329,13 +339,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_sxx (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_sxx (KERN_ATTR_ESALT (krb5pa_t)) { /** * modifier @@ -398,7 +408,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m07500_a3-optimized.cl b/OpenCL/m07500_a3-optimized.cl index 14cd3680b..6d6dbeb92 100644 --- a/OpenCL/m07500_a3-optimized.cl +++ b/OpenCL/m07500_a3-optimized.cl @@ -15,6 +15,16 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5pa +{ + u32 user[16]; + u32 realm[16]; + u32 salt[32]; + u32 timestamp[16]; + u32 checksum[4]; + +} krb5pa_t; + typedef struct { u8 S[256]; @@ -466,13 +476,13 @@ DECLSPEC void m07500 (__local RC4_KEY *rc4_key, u32 *w0, u32 *w1, u32 *w2, u32 * { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m04 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_m04 (KERN_ATTR_ESALT (krb5pa_t)) { /** * base @@ -524,7 +534,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m04 (KERN_A m07500 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m08 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_m08 (KERN_ATTR_ESALT (krb5pa_t)) { /** * base @@ -576,11 +586,11 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m08 (KERN_A m07500 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_m16 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_m16 (KERN_ATTR_ESALT (krb5pa_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s04 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_s04 (KERN_ATTR_ESALT (krb5pa_t)) { /** * base @@ -632,7 +642,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s04 (KERN_A m07500 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s08 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_s08 (KERN_ATTR_ESALT (krb5pa_t)) { /** * base @@ -684,6 +694,6 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s08 (KERN_A m07500 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_s16 (KERN_ATTR_ESALT (krb5pa_t)) +__kernel void m07500_s16 (KERN_ATTR_ESALT (krb5pa_t)) { } diff --git a/OpenCL/m07500_a3-pure.cl b/OpenCL/m07500_a3-pure.cl index 4fd5b124f..e610b1eac 100644 --- a/OpenCL/m07500_a3-pure.cl +++ b/OpenCL/m07500_a3-pure.cl @@ -14,6 +14,16 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5pa +{ + u32 user[16]; + u32 realm[16]; + u32 salt[32]; + u32 timestamp[16]; + u32 checksum[4]; + +} krb5pa_t; + typedef struct { u8 S[256]; @@ -266,7 +276,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest) digest[3] = ctx.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_mxx (KERN_ATTR_VECTOR_ESALT (krb5pa_t)) +__kernel void m07500_mxx (KERN_ATTR_VECTOR_ESALT (krb5pa_t)) { /** * modifier @@ -354,13 +364,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_sxx (KERN_ATTR_VECTOR_ESALT (krb5pa_t)) +__kernel void m07500_sxx (KERN_ATTR_VECTOR_ESALT (krb5pa_t)) { /** * modifier @@ -448,7 +458,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m07500_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m07900-pure.cl b/OpenCL/m07900-pure.cl index 61b393c2c..fa25a1354 100644 --- a/OpenCL/m07900-pure.cl +++ b/OpenCL/m07900-pure.cl @@ -13,6 +13,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct drupal7_tmp +{ + u64 digest_buf[8]; + +} drupal7_tmp_t; + __kernel void m07900_init (KERN_ATTR_TMPS (drupal7_tmp_t)) { /** diff --git a/OpenCL/m08200-pure.cl b/OpenCL/m08200-pure.cl index 5be1abfc0..e405b885c 100644 --- a/OpenCL/m08200-pure.cl +++ b/OpenCL/m08200-pure.cl @@ -17,6 +17,23 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[16]; + u64 out[16]; + +} pbkdf2_sha512_tmp_t; + +typedef struct cloudkey +{ + u32 data_len; + u32 data_buf[512]; + +} cloudkey_t; + DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m08800-pure.cl b/OpenCL/m08800-pure.cl index dd5c35366..91db82eb2 100644 --- a/OpenCL/m08800-pure.cl +++ b/OpenCL/m08800-pure.cl @@ -15,6 +15,22 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_aes.cl" +typedef struct androidfde_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[10]; + u32 out[10]; + +} androidfde_tmp_t; + +typedef struct androidfde +{ + u32 data[384]; + +} androidfde_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -400,7 +416,7 @@ __kernel void m08800_comp (KERN_ATTR_TMPS_ESALT (androidfde_tmp_t, androidfde_t) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } @@ -459,7 +475,7 @@ __kernel void m08800_comp (KERN_ATTR_TMPS_ESALT (androidfde_tmp_t, androidfde_t) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m08900-pure.cl b/OpenCL/m08900-pure.cl index 86421f48a..15f81cd44 100644 --- a/OpenCL/m08900-pure.cl +++ b/OpenCL/m08900-pure.cl @@ -13,6 +13,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct +{ + #ifndef SCRYPT_TMP_ELEM + #define SCRYPT_TMP_ELEM 1 + #endif + + uint4 P[SCRYPT_TMP_ELEM]; + +} scrypt_tmp_t; + DECLSPEC uint4 swap32_4 (uint4 v) { return (rotate ((v & 0x00FF00FF), 24u) | rotate ((v & 0xFF00FF00), 8u)); @@ -205,8 +215,6 @@ DECLSPEC void scrypt_smix (uint4 *X, uint4 *T, __global uint4 * restrict V0, __g } } -// there can be no __attribute__((reqd_work_group_size(16, 1, 1))) because kernel is used by both -m 8900 and -m 9300 - __kernel void m08900_init (KERN_ATTR_TMPS (scrypt_tmp_t)) { /** diff --git a/OpenCL/m09000-pure.cl b/OpenCL/m09000-pure.cl index 6f4496e48..bf7fa986c 100644 --- a/OpenCL/m09000-pure.cl +++ b/OpenCL/m09000-pure.cl @@ -12,6 +12,19 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pwsafe2_tmp +{ + u32 digest[2]; + + u32 P[18]; + + u32 S0[256]; + u32 S1[256]; + u32 S2[256]; + u32 S3[256]; + +} pwsafe2_tmp_t; + // http://www.schneier.com/code/constants.txt __constant u32a c_sbox0[256] = @@ -499,7 +512,7 @@ DECLSPEC void sha1_transform (const u32 *w0, const u32 *w1, const u32 *w2, const digest[4] += E; } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m09000_init (KERN_ATTR_TMPS (pwsafe2_tmp_t)) +__kernel void m09000_init (KERN_ATTR_TMPS (pwsafe2_tmp_t)) { /** * base @@ -718,7 +731,7 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m09000_init (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m09000_loop (KERN_ATTR_TMPS (pwsafe2_tmp_t)) +__kernel void m09000_loop (KERN_ATTR_TMPS (pwsafe2_tmp_t)) { /** * base @@ -780,7 +793,7 @@ __kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m09000_loop (KERN_A tmps[gid].digest[1] = R0; } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m09000_comp (KERN_ATTR_TMPS (pwsafe2_tmp_t)) +__kernel void m09000_comp (KERN_ATTR_TMPS (pwsafe2_tmp_t)) { /** * base diff --git a/OpenCL/m09100-pure.cl b/OpenCL/m09100-pure.cl index 58a05f2c5..7d286d448 100644 --- a/OpenCL/m09100-pure.cl +++ b/OpenCL/m09100-pure.cl @@ -16,6 +16,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct lotus8_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[5]; + u32 out[5]; + +} lotus8_tmp_t; + __constant u32 lotus64_table[64] = { '0', '1', '2', '3', '4', '5', '6', '7', diff --git a/OpenCL/m09400-pure.cl b/OpenCL/m09400-pure.cl index 6950da73b..196a087a3 100644 --- a/OpenCL/m09400-pure.cl +++ b/OpenCL/m09400-pure.cl @@ -17,6 +17,21 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct office2007_tmp +{ + u32 out[5]; + +} office2007_tmp_t; + +typedef struct office2007 +{ + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + + u32 keySize; + +} office2007_t; + __kernel void m09400_init (KERN_ATTR_TMPS_ESALT (office2007_tmp_t, office2007_t)) { /** diff --git a/OpenCL/m09500-pure.cl b/OpenCL/m09500-pure.cl index a90e973c2..f56e347de 100644 --- a/OpenCL/m09500-pure.cl +++ b/OpenCL/m09500-pure.cl @@ -17,6 +17,19 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct office2010 +{ + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[8]; + +} office2010_t; + +typedef struct office2010_tmp +{ + u32 out[5]; + +} office2010_tmp_t; + __kernel void m09500_init (KERN_ATTR_TMPS_ESALT (office2010_tmp_t, office2010_t)) { /** diff --git a/OpenCL/m09600-pure.cl b/OpenCL/m09600-pure.cl index 56840d548..9467ef360 100644 --- a/OpenCL/m09600-pure.cl +++ b/OpenCL/m09600-pure.cl @@ -17,6 +17,19 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct office2013_tmp +{ + u64 out[8]; + +} office2013_tmp_t; + +typedef struct office2013 +{ + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[8]; + +} office2013_t; + __kernel void m09600_init (KERN_ATTR_TMPS_ESALT (office2013_tmp_t, office2013_t)) { /** diff --git a/OpenCL/m09700_a0-optimized.cl b/OpenCL/m09700_a0-optimized.cl index 4e62f287f..8f1f660f9 100644 --- a/OpenCL/m09700_a0-optimized.cl +++ b/OpenCL/m09700_a0-optimized.cl @@ -16,6 +16,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + typedef struct { u8 S[256]; @@ -483,7 +492,7 @@ DECLSPEC void gen336 (u32 *digest_pre, u32 *salt_buf, u32 *digest) md5_transform (w0_t, w1_t, w2_t, w3_t, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09700_m04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { /** * modifier @@ -664,15 +673,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09700_m08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09700_m16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09700_s04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { /** * modifier @@ -865,10 +874,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09700_s08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09700_s16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } diff --git a/OpenCL/m09700_a1-optimized.cl b/OpenCL/m09700_a1-optimized.cl index 2fedbafdc..8d0b44d3d 100644 --- a/OpenCL/m09700_a1-optimized.cl +++ b/OpenCL/m09700_a1-optimized.cl @@ -14,6 +14,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + typedef struct { u8 S[256]; @@ -481,7 +490,7 @@ DECLSPEC void gen336 (u32 *digest_pre, u32 *salt_buf, u32 *digest) md5_transform (w0_t, w1_t, w2_t, w3_t, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_m04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * modifier @@ -720,15 +729,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_m08 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_m16 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_s04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * modifier @@ -979,10 +988,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_s08 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_s16 (KERN_ATTR_ESALT (oldoffice01_t)) { } diff --git a/OpenCL/m09700_a3-optimized.cl b/OpenCL/m09700_a3-optimized.cl index e136fe2d1..e68c44824 100644 --- a/OpenCL/m09700_a3-optimized.cl +++ b/OpenCL/m09700_a3-optimized.cl @@ -11,6 +11,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + typedef struct { u8 S[256]; @@ -966,7 +975,7 @@ DECLSPEC void m09700s (__local RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_m04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -1015,7 +1024,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m04 (KERN_A m09700m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_m08 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -1064,7 +1073,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m08 (KERN_A m09700m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_m16 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -1113,7 +1122,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_m16 (KERN_A m09700m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_s04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -1162,7 +1171,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s04 (KERN_A m09700s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_s08 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -1211,7 +1220,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s08 (KERN_A m09700s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09700_s16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09700_s16 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base diff --git a/OpenCL/m09710_a0-optimized.cl b/OpenCL/m09710_a0-optimized.cl index 09fd289e1..59c06f97a 100644 --- a/OpenCL/m09710_a0-optimized.cl +++ b/OpenCL/m09710_a0-optimized.cl @@ -16,6 +16,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + typedef struct { u8 S[256]; @@ -139,7 +148,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09710_m04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { /** * modifier @@ -271,15 +280,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09710_m08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09710_m16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09710_s04 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { /** * modifier @@ -423,10 +432,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09710_s08 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) +__kernel void m09710_s16 (KERN_ATTR_RULES_ESALT (oldoffice01_t)) { } diff --git a/OpenCL/m09710_a1-optimized.cl b/OpenCL/m09710_a1-optimized.cl index 5cd5a923d..b3855abf5 100644 --- a/OpenCL/m09710_a1-optimized.cl +++ b/OpenCL/m09710_a1-optimized.cl @@ -14,6 +14,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + typedef struct { u8 S[256]; @@ -137,7 +146,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_m04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * modifier @@ -315,15 +324,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_m08 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_m16 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_s04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * modifier @@ -513,10 +522,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_s08 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_s16 (KERN_ATTR_ESALT (oldoffice01_t)) { } diff --git a/OpenCL/m09710_a3-optimized.cl b/OpenCL/m09710_a3-optimized.cl index 0dcc6ffd3..8defd484b 100644 --- a/OpenCL/m09710_a3-optimized.cl +++ b/OpenCL/m09710_a3-optimized.cl @@ -14,6 +14,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + typedef struct { u8 S[256]; @@ -371,7 +380,7 @@ DECLSPEC void m09710s (__local RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_m04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -420,15 +429,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m04 (KERN_A m09710m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_m08 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_m16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_m16 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_s04 (KERN_ATTR_ESALT (oldoffice01_t)) { /** * base @@ -477,10 +486,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s04 (KERN_A m09710s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_s08 (KERN_ATTR_ESALT (oldoffice01_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09710_s16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m09710_s16 (KERN_ATTR_ESALT (oldoffice01_t)) { } diff --git a/OpenCL/m09720_a0-optimized.cl b/OpenCL/m09720_a0-optimized.cl index b1dd35f30..698a9cf01 100644 --- a/OpenCL/m09720_a0-optimized.cl +++ b/OpenCL/m09720_a0-optimized.cl @@ -15,6 +15,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + DECLSPEC void gen336 (u32x *digest_pre, u32 *salt_buf, u32x *digest) { u32x digest_t0[2]; diff --git a/OpenCL/m09720_a1-optimized.cl b/OpenCL/m09720_a1-optimized.cl index 956d9b5a6..b590a9486 100644 --- a/OpenCL/m09720_a1-optimized.cl +++ b/OpenCL/m09720_a1-optimized.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + DECLSPEC void gen336 (u32x *digest_pre, u32 *salt_buf, u32x *digest) { u32x digest_t0[2]; diff --git a/OpenCL/m09720_a3-optimized.cl b/OpenCL/m09720_a3-optimized.cl index b0cff0fc1..c6fad8678 100644 --- a/OpenCL/m09720_a3-optimized.cl +++ b/OpenCL/m09720_a3-optimized.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct oldoffice01 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[4]; + u32 rc4key[2]; + +} oldoffice01_t; + DECLSPEC void gen336 (u32x *digest_pre, u32 *salt_buf, u32x *digest) { u32x digest_t0[2]; diff --git a/OpenCL/m09800_a0-optimized.cl b/OpenCL/m09800_a0-optimized.cl index 44c65b558..094e319da 100644 --- a/OpenCL/m09800_a0-optimized.cl +++ b/OpenCL/m09800_a0-optimized.cl @@ -16,6 +16,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + typedef struct { u8 S[256]; @@ -139,7 +148,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09800_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { /** * modifier @@ -331,15 +340,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09800_m08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09800_m16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09800_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { /** * modifier @@ -543,10 +552,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09800_s08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09800_s16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } diff --git a/OpenCL/m09800_a1-optimized.cl b/OpenCL/m09800_a1-optimized.cl index ba64ac196..d900e17d5 100644 --- a/OpenCL/m09800_a1-optimized.cl +++ b/OpenCL/m09800_a1-optimized.cl @@ -14,6 +14,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + typedef struct { u8 S[256]; @@ -137,7 +146,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * modifier @@ -379,15 +388,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_m08 (KERN_ATTR_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_m16 (KERN_ATTR_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * modifier @@ -641,10 +650,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_s08 (KERN_ATTR_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_s16 (KERN_ATTR_ESALT (oldoffice34_t)) { } diff --git a/OpenCL/m09800_a3-optimized.cl b/OpenCL/m09800_a3-optimized.cl index 38d07fc7d..2aace0202 100644 --- a/OpenCL/m09800_a3-optimized.cl +++ b/OpenCL/m09800_a3-optimized.cl @@ -11,6 +11,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + typedef struct { u8 S[256]; @@ -482,7 +491,7 @@ DECLSPEC void m09800s (__local RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -531,7 +540,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m04 (KERN_A m09800m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_m08 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -580,7 +589,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m08 (KERN_A m09800m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_m16 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -629,7 +638,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_m16 (KERN_A m09800m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -678,7 +687,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s04 (KERN_A m09800s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_s08 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -727,7 +736,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s08 (KERN_A m09800s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09800_s16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09800_s16 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base diff --git a/OpenCL/m09810_a0-optimized.cl b/OpenCL/m09810_a0-optimized.cl index a90363f7a..a76503b26 100644 --- a/OpenCL/m09810_a0-optimized.cl +++ b/OpenCL/m09810_a0-optimized.cl @@ -16,6 +16,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + typedef struct { u8 S[256]; @@ -139,7 +148,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09810_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { /** * modifier @@ -258,15 +267,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09810_m08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09810_m16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09810_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { /** * modifier @@ -397,10 +406,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09810_s08 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) +__kernel void m09810_s16 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { } diff --git a/OpenCL/m09810_a1-optimized.cl b/OpenCL/m09810_a1-optimized.cl index e0cce2e77..4326cf63e 100644 --- a/OpenCL/m09810_a1-optimized.cl +++ b/OpenCL/m09810_a1-optimized.cl @@ -14,6 +14,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + typedef struct { u8 S[256]; @@ -137,7 +146,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_m04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * modifier @@ -302,15 +311,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_m08 (KERN_ATTR_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_m16 (KERN_ATTR_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_s04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * modifier @@ -487,10 +496,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_s08 (KERN_ATTR_ESALT (oldoffice34_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_s16 (KERN_ATTR_ESALT (oldoffice34_t)) { } diff --git a/OpenCL/m09810_a3-optimized.cl b/OpenCL/m09810_a3-optimized.cl index 5607f7258..6d5bfc74d 100644 --- a/OpenCL/m09810_a3-optimized.cl +++ b/OpenCL/m09810_a3-optimized.cl @@ -14,6 +14,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + typedef struct { u8 S[256]; @@ -341,7 +350,7 @@ DECLSPEC void m09810s (__local RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_m04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -390,7 +399,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m04 (KERN_A m09810m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_m08 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -439,7 +448,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m08 (KERN_A m09810m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_m16 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -488,7 +497,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_m16 (KERN_A m09810m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s04 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_s04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -537,7 +546,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s04 (KERN_A m09810s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s08 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_s08 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base @@ -586,7 +595,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s08 (KERN_A m09810s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m09810_s16 (KERN_ATTR_ESALT (oldoffice34_t)) +__kernel void m09810_s16 (KERN_ATTR_ESALT (oldoffice34_t)) { /** * base diff --git a/OpenCL/m09820_a0-optimized.cl b/OpenCL/m09820_a0-optimized.cl index 9c3f06cb3..d312a212c 100644 --- a/OpenCL/m09820_a0-optimized.cl +++ b/OpenCL/m09820_a0-optimized.cl @@ -15,6 +15,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + __kernel void m09820_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { /** diff --git a/OpenCL/m09820_a1-optimized.cl b/OpenCL/m09820_a1-optimized.cl index cc07760a4..89bb2249e 100644 --- a/OpenCL/m09820_a1-optimized.cl +++ b/OpenCL/m09820_a1-optimized.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + __kernel void m09820_m04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** diff --git a/OpenCL/m09820_a3-optimized.cl b/OpenCL/m09820_a3-optimized.cl index efa6ad967..5c23d43b4 100644 --- a/OpenCL/m09820_a3-optimized.cl +++ b/OpenCL/m09820_a3-optimized.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct oldoffice34 +{ + u32 version; + u32 encryptedVerifier[4]; + u32 encryptedVerifierHash[5]; + u32 rc4key[2]; + +} oldoffice34_t; + DECLSPEC void m09820m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice34_t)) { /** diff --git a/OpenCL/m10300-pure.cl b/OpenCL/m10300-pure.cl index 6541ce2b2..cf956e741 100644 --- a/OpenCL/m10300-pure.cl +++ b/OpenCL/m10300-pure.cl @@ -13,6 +13,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct saph_sha1_tmp +{ + u32 digest_buf[5]; + +} saph_sha1_tmp_t; + __kernel void m10300_init (KERN_ATTR_TMPS (saph_sha1_tmp_t)) { /** diff --git a/OpenCL/m10400_a0-optimized.cl b/OpenCL/m10400_a0-optimized.cl index f74f233e8..6aa99fa26 100644 --- a/OpenCL/m10400_a0-optimized.cl +++ b/OpenCL/m10400_a0-optimized.cl @@ -28,6 +28,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + typedef struct { u8 S[256]; @@ -136,7 +157,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, __constant u32 *i return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m04 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10400_m04 (KERN_ATTR_RULES_ESALT (pdf_t)) { /** * modifier @@ -304,15 +325,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m08 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10400_m08 (KERN_ATTR_RULES_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m16 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10400_m16 (KERN_ATTR_RULES_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s04 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10400_s04 (KERN_ATTR_RULES_ESALT (pdf_t)) { /** * modifier @@ -492,10 +513,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s08 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10400_s08 (KERN_ATTR_RULES_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s16 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10400_s16 (KERN_ATTR_RULES_ESALT (pdf_t)) { } diff --git a/OpenCL/m10400_a1-optimized.cl b/OpenCL/m10400_a1-optimized.cl index 2b843c695..e11f2f8eb 100644 --- a/OpenCL/m10400_a1-optimized.cl +++ b/OpenCL/m10400_a1-optimized.cl @@ -26,6 +26,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + typedef struct { u8 S[256]; @@ -134,7 +155,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, __constant u32 *i return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_m04 (KERN_ATTR_ESALT (pdf_t)) { /** * modifier @@ -362,15 +383,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_m08 (KERN_ATTR_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_m16 (KERN_ATTR_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_s04 (KERN_ATTR_ESALT (pdf_t)) { /** * modifier @@ -610,10 +631,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_s08 (KERN_ATTR_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_s16 (KERN_ATTR_ESALT (pdf_t)) { } diff --git a/OpenCL/m10400_a3-optimized.cl b/OpenCL/m10400_a3-optimized.cl index a625d7534..4f454ee7b 100644 --- a/OpenCL/m10400_a3-optimized.cl +++ b/OpenCL/m10400_a3-optimized.cl @@ -26,6 +26,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + typedef struct { u8 S[256]; @@ -478,7 +499,7 @@ DECLSPEC void m10400s (__local RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_m04 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -527,7 +548,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m04 (KERN_A m10400m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_m08 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -576,7 +597,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m08 (KERN_A m10400m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_m16 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -625,7 +646,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_m16 (KERN_A m10400m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_s04 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -674,7 +695,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s04 (KERN_A m10400s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_s08 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -723,7 +744,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s08 (KERN_A m10400s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10400_s16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10400_s16 (KERN_ATTR_ESALT (pdf_t)) { /** * base diff --git a/OpenCL/m10410_a0-optimized.cl b/OpenCL/m10410_a0-optimized.cl index d50247790..4d0a252e5 100644 --- a/OpenCL/m10410_a0-optimized.cl +++ b/OpenCL/m10410_a0-optimized.cl @@ -28,6 +28,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + typedef struct { u8 S[256]; @@ -136,7 +157,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, __constant u32 *i return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m04 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10410_m04 (KERN_ATTR_RULES_ESALT (pdf_t)) { /** * modifier @@ -200,15 +221,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m08 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10410_m08 (KERN_ATTR_RULES_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m16 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10410_m16 (KERN_ATTR_RULES_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s04 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10410_s04 (KERN_ATTR_RULES_ESALT (pdf_t)) { /** * modifier @@ -284,10 +305,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s08 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10410_s08 (KERN_ATTR_RULES_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s16 (KERN_ATTR_RULES_ESALT (pdf_t)) +__kernel void m10410_s16 (KERN_ATTR_RULES_ESALT (pdf_t)) { } diff --git a/OpenCL/m10410_a1-optimized.cl b/OpenCL/m10410_a1-optimized.cl index a5d5a6ed7..b37ce6483 100644 --- a/OpenCL/m10410_a1-optimized.cl +++ b/OpenCL/m10410_a1-optimized.cl @@ -26,6 +26,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + typedef struct { u8 S[256]; @@ -134,7 +155,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, __constant u32 *i return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_m04 (KERN_ATTR_ESALT (pdf_t)) { /** * modifier @@ -268,15 +289,15 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_m08 (KERN_ATTR_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_m16 (KERN_ATTR_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_s04 (KERN_ATTR_ESALT (pdf_t)) { /** * modifier @@ -422,10 +443,10 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s04 (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_s08 (KERN_ATTR_ESALT (pdf_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_s16 (KERN_ATTR_ESALT (pdf_t)) { } diff --git a/OpenCL/m10410_a3-optimized.cl b/OpenCL/m10410_a3-optimized.cl index 13e7de4a8..46980fae1 100644 --- a/OpenCL/m10410_a3-optimized.cl +++ b/OpenCL/m10410_a3-optimized.cl @@ -26,6 +26,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + typedef struct { u8 S[256]; @@ -232,7 +253,7 @@ DECLSPEC void m10410s (__local RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_m04 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -281,7 +302,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m04 (KERN_A m10410m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_m08 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -330,7 +351,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m08 (KERN_A m10410m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_m16 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -379,7 +400,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_m16 (KERN_A m10410m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s04 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_s04 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -428,7 +449,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s04 (KERN_A m10410s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s08 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_s08 (KERN_ATTR_ESALT (pdf_t)) { /** * base @@ -477,7 +498,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s08 (KERN_A m10410s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10410_s16 (KERN_ATTR_ESALT (pdf_t)) +__kernel void m10410_s16 (KERN_ATTR_ESALT (pdf_t)) { /** * base diff --git a/OpenCL/m10420_a0-optimized.cl b/OpenCL/m10420_a0-optimized.cl index 38ef96a0a..0174fb91a 100644 --- a/OpenCL/m10420_a0-optimized.cl +++ b/OpenCL/m10420_a0-optimized.cl @@ -27,6 +27,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + __kernel void m10420_m04 (KERN_ATTR_RULES_ESALT (pdf_t)) { /** diff --git a/OpenCL/m10420_a1-optimized.cl b/OpenCL/m10420_a1-optimized.cl index 853135537..70fffdb6b 100644 --- a/OpenCL/m10420_a1-optimized.cl +++ b/OpenCL/m10420_a1-optimized.cl @@ -25,6 +25,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + __kernel void m10420_m04 (KERN_ATTR_ESALT (pdf_t)) { /** diff --git a/OpenCL/m10420_a3-optimized.cl b/OpenCL/m10420_a3-optimized.cl index df61ce41d..847197d20 100644 --- a/OpenCL/m10420_a3-optimized.cl +++ b/OpenCL/m10420_a3-optimized.cl @@ -25,6 +25,27 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + DECLSPEC void m10420m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (pdf_t)) { /** diff --git a/OpenCL/m10500-pure.cl b/OpenCL/m10500-pure.cl index 4669f65ea..05c48f794 100644 --- a/OpenCL/m10500-pure.cl +++ b/OpenCL/m10500-pure.cl @@ -25,6 +25,34 @@ __constant u32a padding[8] = 0x7a695364 }; +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + +typedef struct pdf14_tmp +{ + u32 digest[4]; + u32 out[4]; + +} pdf14_tmp_t; + typedef struct { u8 S[256]; @@ -151,7 +179,7 @@ DECLSPEC u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u3 return j; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10500_init (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) +__kernel void m10500_init (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) { /** * base @@ -333,7 +361,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10500_init (KERN_ tmps[gid].out[3] = 0; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10500_loop (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) +__kernel void m10500_loop (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) { /** * base @@ -436,7 +464,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10500_loop (KERN_ tmps[gid].out[3] = out[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m10500_comp (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) +__kernel void m10500_comp (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) { /** * modifier diff --git a/OpenCL/m10700-optimized.cl b/OpenCL/m10700-optimized.cl index d6e22ef81..54acead6f 100644 --- a/OpenCL/m10700-optimized.cl +++ b/OpenCL/m10700-optimized.cl @@ -16,6 +16,40 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + +typedef struct pdf17l8_tmp +{ + union + { + u32 dgst32[16]; + u64 dgst64[8]; + }; + + u32 dgst_len; + u32 W_len; + +} pdf17l8_tmp_t; + typedef struct { union diff --git a/OpenCL/m10700-pure.cl b/OpenCL/m10700-pure.cl index bcf436d4e..fd9183f13 100644 --- a/OpenCL/m10700-pure.cl +++ b/OpenCL/m10700-pure.cl @@ -22,6 +22,40 @@ #define PUTCHAR_BE(a,p,c) ((u8 *)(a))[(p) ^ 3] = (u8) (c) #define GETCHAR_BE(a,p) ((u8 *)(a))[(p) ^ 3] +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + +} pdf_t; + +typedef struct pdf17l8_tmp +{ + union + { + u32 dgst32[16]; + u64 dgst64[8]; + }; + + u32 dgst_len; + u32 W_len; + +} pdf17l8_tmp_t; + DECLSPEC void aes128_encrypt_cbc (const u32 *aes_ks, u32 *aes_iv, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { u32 data[4]; diff --git a/OpenCL/m10900-pure.cl b/OpenCL/m10900-pure.cl index c228d3403..15b1763c3 100644 --- a/OpenCL/m10900-pure.cl +++ b/OpenCL/m10900-pure.cl @@ -16,6 +16,22 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256 +{ + u32 salt_buf[64]; + +} pbkdf2_sha256_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m11300-pure.cl b/OpenCL/m11300-pure.cl index f0e59d4a8..43bd8d93f 100644 --- a/OpenCL/m11300-pure.cl +++ b/OpenCL/m11300-pure.cl @@ -14,6 +14,19 @@ #include "inc_hash_sha512.cl" #include "inc_cipher_aes.cl" +typedef struct bitcoin_wallet_tmp +{ + u64 dgst[8]; + +} bitcoin_wallet_tmp_t; + +typedef struct bitcoin_wallet +{ + u32 cry_master_buf[64]; + u32 cry_master_len; + +} bitcoin_wallet_t; + DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { digest[0] = ipad[0]; @@ -340,7 +353,7 @@ __kernel void m11300_comp (KERN_ATTR_TMPS_ESALT (bitcoin_wallet_tmp_t, bitcoin_w { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m11400_a0-pure.cl b/OpenCL/m11400_a0-pure.cl index 4e72a4936..d267e5b0f 100644 --- a/OpenCL/m11400_a0-pure.cl +++ b/OpenCL/m11400_a0-pure.cl @@ -15,6 +15,16 @@ #include "inc_scalar.cl" #include "inc_hash_md5.cl" +typedef struct sip +{ + u32 salt_buf[32]; + u32 salt_len; + + u32 esalt_buf[256]; + u32 esalt_len; + +} sip_t; + #if VECT_SIZE == 1 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)]) #elif VECT_SIZE == 2 diff --git a/OpenCL/m11400_a1-pure.cl b/OpenCL/m11400_a1-pure.cl index b73f363fc..b408d2ec7 100644 --- a/OpenCL/m11400_a1-pure.cl +++ b/OpenCL/m11400_a1-pure.cl @@ -13,6 +13,16 @@ #include "inc_scalar.cl" #include "inc_hash_md5.cl" +typedef struct sip +{ + u32 salt_buf[32]; + u32 salt_len; + + u32 esalt_buf[256]; + u32 esalt_len; + +} sip_t; + #if VECT_SIZE == 1 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)]) #elif VECT_SIZE == 2 diff --git a/OpenCL/m11400_a3-pure.cl b/OpenCL/m11400_a3-pure.cl index 75332bcc7..6c2e48797 100644 --- a/OpenCL/m11400_a3-pure.cl +++ b/OpenCL/m11400_a3-pure.cl @@ -13,6 +13,16 @@ #include "inc_simd.cl" #include "inc_hash_md5.cl" +typedef struct sip +{ + u32 salt_buf[32]; + u32 salt_len; + + u32 esalt_buf[256]; + u32 esalt_len; + +} sip_t; + #if VECT_SIZE == 1 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)]) #elif VECT_SIZE == 2 diff --git a/OpenCL/m11600-pure.cl b/OpenCL/m11600-pure.cl index 7a762ab09..dc4b7bb93 100644 --- a/OpenCL/m11600-pure.cl +++ b/OpenCL/m11600-pure.cl @@ -10,6 +10,27 @@ #include "inc_common.cl" #include "inc_hash_sha256.cl" +typedef struct seven_zip_tmp +{ + u32 h[8]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + int len; + +} seven_zip_tmp_t; + +typedef struct +{ + u32 ukey[8]; + + u32 hook_success; + +} seven_zip_hook_t; + DECLSPEC void memcat8c_be (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 len, const u32 append, u32 *digest) { const u32 func_len = len & 63; @@ -325,7 +346,7 @@ __kernel void m11600_comp (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } return; diff --git a/OpenCL/m11900-pure.cl b/OpenCL/m11900-pure.cl index 12e00ed2f..7fbe43814 100644 --- a/OpenCL/m11900-pure.cl +++ b/OpenCL/m11900-pure.cl @@ -16,6 +16,22 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_md5 +{ + u32 salt_buf[64]; + +} pbkdf2_md5_t; + +typedef struct pbkdf2_md5_tmp +{ + u32 ipad[4]; + u32 opad[4]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_md5_tmp_t; + DECLSPEC void hmac_md5_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m12000-pure.cl b/OpenCL/m12000-pure.cl index e9ac20e59..e89a9d10e 100644 --- a/OpenCL/m12000-pure.cl +++ b/OpenCL/m12000-pure.cl @@ -16,6 +16,22 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha1_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha1_tmp_t; + +typedef struct pbkdf2_sha1 +{ + u32 salt_buf[64]; + +} pbkdf2_sha1_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m12200-pure.cl b/OpenCL/m12200-pure.cl index 2f8ddc03f..70578ea08 100644 --- a/OpenCL/m12200-pure.cl +++ b/OpenCL/m12200-pure.cl @@ -16,6 +16,12 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct ecryptfs_tmp +{ + u64 out[8]; + +} ecryptfs_tmp_t; + __kernel void m12200_init (KERN_ATTR_TMPS (ecryptfs_tmp_t)) { /** diff --git a/OpenCL/m12300-pure.cl b/OpenCL/m12300-pure.cl index 0dddcacf5..e68e9970e 100644 --- a/OpenCL/m12300-pure.cl +++ b/OpenCL/m12300-pure.cl @@ -16,6 +16,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct oraclet_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[16]; + u64 out[16]; + +} oraclet_tmp_t; + DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m12400-pure.cl b/OpenCL/m12400-pure.cl index fcb403056..7f1aa2127 100644 --- a/OpenCL/m12400-pure.cl +++ b/OpenCL/m12400-pure.cl @@ -12,6 +12,15 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct bsdicrypt_tmp +{ + u32 Kc[16]; + u32 Kd[16]; + + u32 iv[2]; + +} bsdicrypt_tmp_t; + #define PERM_OP(a,b,tt,n,m) \ { \ tt = a >> n; \ diff --git a/OpenCL/m12500-pure.cl b/OpenCL/m12500-pure.cl index ae1f9a7f8..1ba2ab6d5 100644 --- a/OpenCL/m12500-pure.cl +++ b/OpenCL/m12500-pure.cl @@ -23,6 +23,18 @@ #define MIN(a,b) (((a) < (b)) ? (a) : (b)) +typedef struct pbkdf2_sha1 +{ + u32 salt_buf[64]; + +} pbkdf2_sha1_t; + +typedef struct rar3_tmp +{ + u32 dgst[17][5]; + +} rar3_tmp_t; + DECLSPEC void sha1_transform (const u32 *w, u32 *digest) { u32 A = digest[0]; diff --git a/OpenCL/m12700-pure.cl b/OpenCL/m12700-pure.cl index 1fde0a42a..6c0ebbc11 100644 --- a/OpenCL/m12700-pure.cl +++ b/OpenCL/m12700-pure.cl @@ -17,6 +17,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct mywallet_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[10]; + u32 out[10]; + +} mywallet_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m12800-pure.cl b/OpenCL/m12800-pure.cl index 8d472aabf..737da4093 100644 --- a/OpenCL/m12800-pure.cl +++ b/OpenCL/m12800-pure.cl @@ -17,6 +17,22 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256 +{ + u32 salt_buf[64]; + +} pbkdf2_sha256_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m12900-pure.cl b/OpenCL/m12900-pure.cl index a6999ceab..19eaac2fd 100644 --- a/OpenCL/m12900-pure.cl +++ b/OpenCL/m12900-pure.cl @@ -16,6 +16,22 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256 +{ + u32 salt_buf[64]; + +} pbkdf2_sha256_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m13000-pure.cl b/OpenCL/m13000-pure.cl index b371def0c..b9c6fd4bf 100644 --- a/OpenCL/m13000-pure.cl +++ b/OpenCL/m13000-pure.cl @@ -16,6 +16,16 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -58,7 +68,7 @@ DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *i sha256_transform_vector (w0, w1, w2, w3, digest); } -__kernel void m13000_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_t)) +__kernel void m13000_init (KERN_ATTR_TMPS (pbkdf2_sha256_tmp_t)) { /** * base @@ -142,7 +152,7 @@ __kernel void m13000_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha } } -__kernel void m13000_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_t)) +__kernel void m13000_loop (KERN_ATTR_TMPS (pbkdf2_sha256_tmp_t)) { const u64 gid = get_global_id (0); @@ -248,7 +258,7 @@ __kernel void m13000_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha } } -__kernel void m13000_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_t)) +__kernel void m13000_comp (KERN_ATTR_TMPS (pbkdf2_sha256_tmp_t)) { /** * base diff --git a/OpenCL/m13100_a0-optimized.cl b/OpenCL/m13100_a0-optimized.cl index e61092d08..9e42b7ba6 100644 --- a/OpenCL/m13100_a0-optimized.cl +++ b/OpenCL/m13100_a0-optimized.cl @@ -17,6 +17,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5tgs +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_t; + typedef struct { u8 S[256]; @@ -565,7 +574,7 @@ DECLSPEC void kerb_prepare (const u32 *w0, const u32 *w1, const u32 pw_len, cons hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m04 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_m04 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { /** * modifier @@ -649,21 +658,21 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m08 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_m08 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m16 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_m16 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s04 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_s04 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { /** * modifier @@ -747,16 +756,16 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s08 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_s08 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s16 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_s16 (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { } diff --git a/OpenCL/m13100_a0-pure.cl b/OpenCL/m13100_a0-pure.cl index 470d580dd..88bd97c56 100644 --- a/OpenCL/m13100_a0-pure.cl +++ b/OpenCL/m13100_a0-pure.cl @@ -16,6 +16,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5tgs +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_t; + typedef struct { u8 S[256]; @@ -377,7 +386,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest, u32 K2[3] = ctx1.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_mxx (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_mxx (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { /** * modifier @@ -433,13 +442,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_sxx (KERN_ATTR_RULES_ESALT (krb5tgs_t)) +__kernel void m13100_sxx (KERN_ATTR_RULES_ESALT (krb5tgs_t)) { /** * modifier @@ -495,7 +504,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m13100_a1-optimized.cl b/OpenCL/m13100_a1-optimized.cl index 0e257946b..bab4b12f2 100644 --- a/OpenCL/m13100_a1-optimized.cl +++ b/OpenCL/m13100_a1-optimized.cl @@ -15,6 +15,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5tgs +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_t; + typedef struct { u8 S[256]; @@ -563,7 +572,7 @@ DECLSPEC void kerb_prepare (const u32 *w0, const u32 *w1, const u32 pw_len, cons hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m04 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_m04 (KERN_ATTR_ESALT (krb5tgs_t)) { /** * modifier @@ -696,21 +705,21 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m08 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_m08 (KERN_ATTR_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m16 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_m16 (KERN_ATTR_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s04 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_s04 (KERN_ATTR_ESALT (krb5tgs_t)) { /** * modifier @@ -843,16 +852,16 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s08 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_s08 (KERN_ATTR_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s16 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_s16 (KERN_ATTR_ESALT (krb5tgs_t)) { } diff --git a/OpenCL/m13100_a1-pure.cl b/OpenCL/m13100_a1-pure.cl index 5e0988168..017f98fea 100644 --- a/OpenCL/m13100_a1-pure.cl +++ b/OpenCL/m13100_a1-pure.cl @@ -14,6 +14,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5tgs +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_t; + typedef struct { u8 S[256]; @@ -375,7 +384,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest, u32 K2[3] = ctx1.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_mxx (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_mxx (KERN_ATTR_ESALT (krb5tgs_t)) { /** * modifier @@ -429,13 +438,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_sxx (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_sxx (KERN_ATTR_ESALT (krb5tgs_t)) { /** * modifier @@ -489,7 +498,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m13100_a3-optimized.cl b/OpenCL/m13100_a3-optimized.cl index 7c09680a5..22b6f9214 100644 --- a/OpenCL/m13100_a3-optimized.cl +++ b/OpenCL/m13100_a3-optimized.cl @@ -15,6 +15,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5tgs +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_t; + typedef struct { u8 S[256]; @@ -616,13 +625,13 @@ DECLSPEC void m13100 (__local RC4_KEY *rc4_key, u32 *w0, u32 *w1, u32 *w2, u32 * { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m04 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_m04 (KERN_ATTR_ESALT (krb5tgs_t)) { /** * base @@ -674,7 +683,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m04 (KERN_A m13100 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m08 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_m08 (KERN_ATTR_ESALT (krb5tgs_t)) { /** * base @@ -726,11 +735,11 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m08 (KERN_A m13100 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_m16 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_m16 (KERN_ATTR_ESALT (krb5tgs_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s04 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_s04 (KERN_ATTR_ESALT (krb5tgs_t)) { /** * base @@ -782,7 +791,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s04 (KERN_A m13100 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s08 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_s08 (KERN_ATTR_ESALT (krb5tgs_t)) { /** * base @@ -834,6 +843,6 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s08 (KERN_A m13100 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_s16 (KERN_ATTR_ESALT (krb5tgs_t)) +__kernel void m13100_s16 (KERN_ATTR_ESALT (krb5tgs_t)) { } diff --git a/OpenCL/m13100_a3-pure.cl b/OpenCL/m13100_a3-pure.cl index 114f11017..738d92dab 100644 --- a/OpenCL/m13100_a3-pure.cl +++ b/OpenCL/m13100_a3-pure.cl @@ -14,6 +14,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5tgs +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_t; + typedef struct { u8 S[256]; @@ -375,7 +384,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest, u32 K2[3] = ctx1.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_mxx (KERN_ATTR_VECTOR_ESALT (krb5tgs_t)) +__kernel void m13100_mxx (KERN_ATTR_VECTOR_ESALT (krb5tgs_t)) { /** * modifier @@ -442,13 +451,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_sxx (KERN_ATTR_VECTOR_ESALT (krb5tgs_t)) +__kernel void m13100_sxx (KERN_ATTR_VECTOR_ESALT (krb5tgs_t)) { /** * modifier @@ -515,7 +524,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m13100_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m13200-pure.cl b/OpenCL/m13200-pure.cl index d85dd5e05..d88e36e8b 100644 --- a/OpenCL/m13200-pure.cl +++ b/OpenCL/m13200-pure.cl @@ -11,6 +11,14 @@ #include "inc_hash_sha1.cl" #include "inc_cipher_aes.cl" +typedef struct axcrypt_tmp +{ + u32 KEK[4]; + u32 lsb[4]; + u32 cipher[4]; + +} axcrypt_tmp_t; + __kernel void m13200_init (KERN_ATTR_TMPS (axcrypt_tmp_t)) { /** @@ -220,7 +228,7 @@ __kernel void m13200_comp (KERN_ATTR_TMPS (axcrypt_tmp_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m13400-pure.cl b/OpenCL/m13400-pure.cl index 9dc28e6f5..8fa9da925 100644 --- a/OpenCL/m13400-pure.cl +++ b/OpenCL/m13400-pure.cl @@ -15,6 +15,35 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct keepass_tmp +{ + u32 tmp_digest[8]; + +} keepass_tmp_t; + +typedef struct keepass +{ + u32 version; + u32 algorithm; + + /* key-file handling */ + u32 keyfile_len; + u32 keyfile[8]; + + u32 final_random_seed[8]; + u32 transf_random_seed[8]; + u32 enc_iv[4]; + u32 contents_hash[8]; + + /* specific to version 1 */ + u32 contents_len; + u32 contents[75000]; + + /* specific to version 2 */ + u32 expected_bytes[8]; + +} keepass_t; + __kernel void m13400_init (KERN_ATTR_TMPS_ESALT (keepass_tmp_t, keepass_t)) { /** diff --git a/OpenCL/m13500_a0-optimized.cl b/OpenCL/m13500_a0-optimized.cl index 0c553ec56..20feceb7c 100644 --- a/OpenCL/m13500_a0-optimized.cl +++ b/OpenCL/m13500_a0-optimized.cl @@ -15,6 +15,16 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct pstoken +{ + u32 salt_buf[128]; + u32 salt_len; + + u32 pc_digest[5]; + u32 pc_offset; + +} pstoken_t; + __kernel void m13500_m04 (KERN_ATTR_RULES_ESALT (pstoken_t)) { /** diff --git a/OpenCL/m13500_a0-pure.cl b/OpenCL/m13500_a0-pure.cl index 09311b92d..70d11b517 100644 --- a/OpenCL/m13500_a0-pure.cl +++ b/OpenCL/m13500_a0-pure.cl @@ -15,6 +15,16 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct pstoken +{ + u32 salt_buf[128]; + u32 salt_len; + + u32 pc_digest[5]; + u32 pc_offset; + +} pstoken_t; + __kernel void m13500_mxx (KERN_ATTR_RULES_ESALT (pstoken_t)) { /** diff --git a/OpenCL/m13500_a1-optimized.cl b/OpenCL/m13500_a1-optimized.cl index 453392b4e..f9defa844 100644 --- a/OpenCL/m13500_a1-optimized.cl +++ b/OpenCL/m13500_a1-optimized.cl @@ -13,6 +13,16 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct pstoken +{ + u32 salt_buf[128]; + u32 salt_len; + + u32 pc_digest[5]; + u32 pc_offset; + +} pstoken_t; + __kernel void m13500_m04 (KERN_ATTR_ESALT (pstoken_t)) { /** diff --git a/OpenCL/m13500_a1-pure.cl b/OpenCL/m13500_a1-pure.cl index 526609e0e..25096e242 100644 --- a/OpenCL/m13500_a1-pure.cl +++ b/OpenCL/m13500_a1-pure.cl @@ -13,6 +13,16 @@ #include "inc_scalar.cl" #include "inc_hash_sha1.cl" +typedef struct pstoken +{ + u32 salt_buf[128]; + u32 salt_len; + + u32 pc_digest[5]; + u32 pc_offset; + +} pstoken_t; + __kernel void m13500_mxx (KERN_ATTR_ESALT (pstoken_t)) { /** diff --git a/OpenCL/m13500_a3-optimized.cl b/OpenCL/m13500_a3-optimized.cl index db2035b51..74f41133c 100644 --- a/OpenCL/m13500_a3-optimized.cl +++ b/OpenCL/m13500_a3-optimized.cl @@ -13,6 +13,16 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct pstoken +{ + u32 salt_buf[128]; + u32 salt_len; + + u32 pc_digest[5]; + u32 pc_offset; + +} pstoken_t; + DECLSPEC void m13500m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (pstoken_t)) { /** diff --git a/OpenCL/m13500_a3-pure.cl b/OpenCL/m13500_a3-pure.cl index 26af0447a..9e594244c 100644 --- a/OpenCL/m13500_a3-pure.cl +++ b/OpenCL/m13500_a3-pure.cl @@ -13,6 +13,16 @@ #include "inc_simd.cl" #include "inc_hash_sha1.cl" +typedef struct pstoken +{ + u32 salt_buf[128]; + u32 salt_len; + + u32 pc_digest[5]; + u32 pc_offset; + +} pstoken_t; + __kernel void m13500_mxx (KERN_ATTR_VECTOR_ESALT (pstoken_t)) { /** diff --git a/OpenCL/m13600-pure.cl b/OpenCL/m13600-pure.cl index cb4f967d0..eb07e44a1 100644 --- a/OpenCL/m13600-pure.cl +++ b/OpenCL/m13600-pure.cl @@ -16,6 +16,32 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha1_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha1_tmp_t; + +typedef struct zip2 +{ + u32 type; + u32 mode; + u32 magic; + u32 salt_len; + u32 salt_buf[4]; + u32 verify_bytes; + u32 compress_length; + u32 data_len; + u32 data_buf[2048]; + u32 auth_len; + u32 auth_buf[4]; + +} zip2_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m13711-pure.cl b/OpenCL/m13711-pure.cl new file mode 100644 index 000000000..664a9d2a7 --- /dev/null +++ b/OpenCL/m13711-pure.cl @@ -0,0 +1,513 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_ripemd160.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = key[ 0]; + key1[1] = key[ 1]; + key1[2] = key[ 2]; + key1[3] = key[ 3]; + key1[4] = key[ 4]; + key1[5] = key[ 5]; + key1[6] = key[ 6]; + key1[7] = key[ 7]; + key2[0] = key[ 8]; + key2[1] = key[ 9]; + key2[2] = key[10]; + key2[3] = key[11]; + key2[4] = key[12]; + key2[5] = key[13]; + key2[6] = key[14]; + key2[7] = key[15]; + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_ripemd160_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + ripemd160_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = (64 + 20) * 8; + w3[3] = 0; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + ripemd160_transform_vector (w0, w1, w2, w3, digest); +} + +__kernel void m13711_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + ripemd160_hmac_ctx_t ripemd160_hmac_ctx; + + ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + + tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = ripemd160_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = ripemd160_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = ripemd160_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = ripemd160_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = ripemd160_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = ripemd160_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4]; + + ripemd160_hmac_update_global (&ripemd160_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 16; i += 5, j += 1) + { + ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + + w0[0] = j << 24; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + ripemd160_hmac_update_64 (&ripemd160_hmac_ctx2, w0, w1, w2, w3, 4); + + ripemd160_hmac_final (&ripemd160_hmac_ctx2); + + tmps[gid].dgst[i + 0] = ripemd160_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = ripemd160_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = ripemd160_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = ripemd160_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = ripemd160_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +__kernel void m13711_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 16; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = (64 + 20) * 8; + w3[3] = 0; + + hmac_ripemd160_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + } + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13711_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13712-pure.cl b/OpenCL/m13712-pure.cl new file mode 100644 index 000000000..6e0760b3c --- /dev/null +++ b/OpenCL/m13712-pure.cl @@ -0,0 +1,573 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_ripemd160.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = key[ 0]; + key1[1] = key[ 1]; + key1[2] = key[ 2]; + key1[3] = key[ 3]; + key1[4] = key[ 4]; + key1[5] = key[ 5]; + key1[6] = key[ 6]; + key1[7] = key[ 7]; + key2[0] = key[ 8]; + key2[1] = key[ 9]; + key2[2] = key[10]; + key2[3] = key[11]; + key2[4] = key[12]; + key2[5] = key[13]; + key2[6] = key[14]; + key2[7] = key[15]; + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = key[ 0]; + key1[1] = key[ 1]; + key1[2] = key[ 2]; + key1[3] = key[ 3]; + key1[4] = key[ 4]; + key1[5] = key[ 5]; + key1[6] = key[ 6]; + key1[7] = key[ 7]; + key2[0] = key[ 8]; + key2[1] = key[ 9]; + key2[2] = key[10]; + key2[3] = key[11]; + key2[4] = key[12]; + key2[5] = key[13]; + key2[6] = key[14]; + key2[7] = key[15]; + key3[0] = key[16]; + key3[1] = key[17]; + key3[2] = key[18]; + key3[3] = key[19]; + key3[4] = key[20]; + key3[5] = key[21]; + key3[6] = key[22]; + key3[7] = key[23]; + key4[0] = key[24]; + key4[1] = key[25]; + key4[2] = key[26]; + key4[3] = key[27]; + key4[4] = key[28]; + key4[5] = key[29]; + key4[6] = key[30]; + key4[7] = key[31]; + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_ripemd160_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + ripemd160_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = (64 + 20) * 8; + w3[3] = 0; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + ripemd160_transform_vector (w0, w1, w2, w3, digest); +} + +__kernel void m13712_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + ripemd160_hmac_ctx_t ripemd160_hmac_ctx; + + ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + + tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = ripemd160_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = ripemd160_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = ripemd160_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = ripemd160_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = ripemd160_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = ripemd160_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4]; + + ripemd160_hmac_update_global (&ripemd160_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 32; i += 5, j += 1) + { + ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + + w0[0] = j << 24; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + ripemd160_hmac_update_64 (&ripemd160_hmac_ctx2, w0, w1, w2, w3, 4); + + ripemd160_hmac_final (&ripemd160_hmac_ctx2); + + tmps[gid].dgst[i + 0] = ripemd160_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = ripemd160_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = ripemd160_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = ripemd160_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = ripemd160_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +__kernel void m13712_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 32; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = (64 + 20) * 8; + w3[3] = 0; + + hmac_ripemd160_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + } + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13712_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13713-pure.cl b/OpenCL/m13713-pure.cl new file mode 100644 index 000000000..467c0f8cc --- /dev/null +++ b/OpenCL/m13713-pure.cl @@ -0,0 +1,647 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_ripemd160.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = key[ 0]; + key1[1] = key[ 1]; + key1[2] = key[ 2]; + key1[3] = key[ 3]; + key1[4] = key[ 4]; + key1[5] = key[ 5]; + key1[6] = key[ 6]; + key1[7] = key[ 7]; + key2[0] = key[ 8]; + key2[1] = key[ 9]; + key2[2] = key[10]; + key2[3] = key[11]; + key2[4] = key[12]; + key2[5] = key[13]; + key2[6] = key[14]; + key2[7] = key[15]; + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = key[ 0]; + key1[1] = key[ 1]; + key1[2] = key[ 2]; + key1[3] = key[ 3]; + key1[4] = key[ 4]; + key1[5] = key[ 5]; + key1[6] = key[ 6]; + key1[7] = key[ 7]; + key2[0] = key[ 8]; + key2[1] = key[ 9]; + key2[2] = key[10]; + key2[3] = key[11]; + key2[4] = key[12]; + key2[5] = key[13]; + key2[6] = key[14]; + key2[7] = key[15]; + key3[0] = key[16]; + key3[1] = key[17]; + key3[2] = key[18]; + key3[3] = key[19]; + key3[4] = key[20]; + key3[5] = key[21]; + key3[6] = key[22]; + key3[7] = key[23]; + key4[0] = key[24]; + key4[1] = key[25]; + key4[2] = key[26]; + key4[3] = key[27]; + key4[4] = key[28]; + key4[5] = key[29]; + key4[6] = key[30]; + key4[7] = key[31]; + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1536 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + u32 key5[8]; + u32 key6[8]; + + key1[0] = key[ 0]; + key1[1] = key[ 1]; + key1[2] = key[ 2]; + key1[3] = key[ 3]; + key1[4] = key[ 4]; + key1[5] = key[ 5]; + key1[6] = key[ 6]; + key1[7] = key[ 7]; + key2[0] = key[ 8]; + key2[1] = key[ 9]; + key2[2] = key[10]; + key2[3] = key[11]; + key2[4] = key[12]; + key2[5] = key[13]; + key2[6] = key[14]; + key2[7] = key[15]; + key3[0] = key[16]; + key3[1] = key[17]; + key3[2] = key[18]; + key3[3] = key[19]; + key3[4] = key[20]; + key3[5] = key[21]; + key3[6] = key[22]; + key3[7] = key[23]; + key4[0] = key[24]; + key4[1] = key[25]; + key4[2] = key[26]; + key4[3] = key[27]; + key4[4] = key[28]; + key4[5] = key[29]; + key4[6] = key[30]; + key4[7] = key[31]; + key5[0] = key[32]; + key5[1] = key[33]; + key5[2] = key[34]; + key5[3] = key[35]; + key5[4] = key[36]; + key5[5] = key[37]; + key5[6] = key[38]; + key5[7] = key[39]; + key6[0] = key[40]; + key6[1] = key[41]; + key6[2] = key[42]; + key6[3] = key[43]; + key6[4] = key[44]; + key6[5] = key[45]; + key6[6] = key[46]; + key6[7] = key[47]; + + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_serpent_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_ripemd160_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + ripemd160_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = (64 + 20) * 8; + w3[3] = 0; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + ripemd160_transform_vector (w0, w1, w2, w3, digest); +} + +__kernel void m13713_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + ripemd160_hmac_ctx_t ripemd160_hmac_ctx; + + ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + + tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = ripemd160_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = ripemd160_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = ripemd160_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = ripemd160_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = ripemd160_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = ripemd160_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4]; + + ripemd160_hmac_update_global (&ripemd160_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 48; i += 5, j += 1) + { + ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + + w0[0] = j << 24; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + ripemd160_hmac_update_64 (&ripemd160_hmac_ctx2, w0, w1, w2, w3, 4); + + ripemd160_hmac_final (&ripemd160_hmac_ctx2); + + tmps[gid].dgst[i + 0] = ripemd160_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = ripemd160_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = ripemd160_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = ripemd160_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = ripemd160_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +__kernel void m13713_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 48; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = (64 + 20) * 8; + w3[3] = 0; + + hmac_ripemd160_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + } + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13713_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1536 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl new file mode 100644 index 000000000..04c371f65 --- /dev/null +++ b/OpenCL/m13721-pure.cl @@ -0,0 +1,660 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc64_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + +} vc64_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (h32_from_64_S (key[0])); + key1[1] = swap32_S (l32_from_64_S (key[0])); + key1[2] = swap32_S (h32_from_64_S (key[1])); + key1[3] = swap32_S (l32_from_64_S (key[1])); + key1[4] = swap32_S (h32_from_64_S (key[2])); + key1[5] = swap32_S (l32_from_64_S (key[2])); + key1[6] = swap32_S (h32_from_64_S (key[3])); + key1[7] = swap32_S (l32_from_64_S (key[3])); + key2[0] = swap32_S (h32_from_64_S (key[4])); + key2[1] = swap32_S (l32_from_64_S (key[4])); + key2[2] = swap32_S (h32_from_64_S (key[5])); + key2[3] = swap32_S (l32_from_64_S (key[5])); + key2[4] = swap32_S (h32_from_64_S (key[6])); + key2[5] = swap32_S (l32_from_64_S (key[6])); + key2[6] = swap32_S (h32_from_64_S (key[7])); + key2[7] = swap32_S (l32_from_64_S (key[7])); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +__kernel void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + w4[0] = pws[gid].i[16]; + w4[1] = pws[gid].i[17]; + w4[2] = pws[gid].i[18]; + w4[3] = pws[gid].i[19]; + w5[0] = pws[gid].i[20]; + w5[1] = pws[gid].i[21]; + w5[2] = pws[gid].i[22]; + w5[3] = pws[gid].i[23]; + w6[0] = pws[gid].i[24]; + w6[1] = pws[gid].i[25]; + w6[2] = pws[gid].i[26]; + w6[3] = pws[gid].i[27]; + w7[0] = pws[gid].i[28]; + w7[1] = pws[gid].i[29]; + w7[2] = pws[gid].i[30]; + w7[3] = pws[gid].i[31]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + w0[0] = swap32_S (w0[0]); + w0[1] = swap32_S (w0[1]); + w0[2] = swap32_S (w0[2]); + w0[3] = swap32_S (w0[3]); + w1[0] = swap32_S (w1[0]); + w1[1] = swap32_S (w1[1]); + w1[2] = swap32_S (w1[2]); + w1[3] = swap32_S (w1[3]); + w2[0] = swap32_S (w2[0]); + w2[1] = swap32_S (w2[1]); + w2[2] = swap32_S (w2[2]); + w2[3] = swap32_S (w2[3]); + w3[0] = swap32_S (w3[0]); + w3[1] = swap32_S (w3[1]); + w3[2] = swap32_S (w3[2]); + w3[3] = swap32_S (w3[3]); + w4[0] = swap32_S (w4[0]); + w4[1] = swap32_S (w4[1]); + w4[2] = swap32_S (w4[2]); + w4[3] = swap32_S (w4[3]); + w5[0] = swap32_S (w5[0]); + w5[1] = swap32_S (w5[1]); + w5[2] = swap32_S (w5[2]); + w5[3] = swap32_S (w5[3]); + w6[0] = swap32_S (w6[0]); + w6[1] = swap32_S (w6[1]); + w6[2] = swap32_S (w6[2]); + w6[3] = swap32_S (w6[3]); + w7[0] = swap32_S (w7[0]); + w7[1] = swap32_S (w7[1]); + w7[2] = swap32_S (w7[2]); + w7[3] = swap32_S (w7[3]); + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + sha512_hmac_update_global_swap (&sha512_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx2, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha512_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha512_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha512_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha512_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha512_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha512_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha512_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha512_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +__kernel void m13721_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * shared lookup table + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, i + 0); + dgst[1] = pack64v (tmps, dgst, gid, i + 1); + dgst[2] = pack64v (tmps, dgst, gid, i + 2); + dgst[3] = pack64v (tmps, dgst, gid, i + 3); + dgst[4] = pack64v (tmps, dgst, gid, i + 4); + dgst[5] = pack64v (tmps, dgst, gid, i + 5); + dgst[6] = pack64v (tmps, dgst, gid, i + 6); + dgst[7] = pack64v (tmps, dgst, gid, i + 7); + + out[0] = pack64v (tmps, out, gid, i + 0); + out[1] = pack64v (tmps, out, gid, i + 1); + out[2] = pack64v (tmps, out, gid, i + 2); + out[3] = pack64v (tmps, out, gid, i + 3); + out[4] = pack64v (tmps, out, gid, i + 4); + out[5] = pack64v (tmps, out, gid, i + 5); + out[6] = pack64v (tmps, out, gid, i + 6); + out[7] = pack64v (tmps, out, gid, i + 7); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } + } + + unpack64v (tmps, dgst, gid, i + 0, dgst[0]); + unpack64v (tmps, dgst, gid, i + 1, dgst[1]); + unpack64v (tmps, dgst, gid, i + 2, dgst[2]); + unpack64v (tmps, dgst, gid, i + 3, dgst[3]); + unpack64v (tmps, dgst, gid, i + 4, dgst[4]); + unpack64v (tmps, dgst, gid, i + 5, dgst[5]); + unpack64v (tmps, dgst, gid, i + 6, dgst[6]); + unpack64v (tmps, dgst, gid, i + 7, dgst[7]); + + unpack64v (tmps, out, gid, i + 0, out[0]); + unpack64v (tmps, out, gid, i + 1, out[1]); + unpack64v (tmps, out, gid, i + 2, out[2]); + unpack64v (tmps, out, gid, i + 3, out[3]); + unpack64v (tmps, out, gid, i + 4, out[4]); + unpack64v (tmps, out, gid, i + 5, out[5]); + unpack64v (tmps, out, gid, i + 6, out[6]); + unpack64v (tmps, out, gid, i + 7, out[7]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13721_comp (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl new file mode 100644 index 000000000..559908682 --- /dev/null +++ b/OpenCL/m13722-pure.cl @@ -0,0 +1,720 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc64_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + +} vc64_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (h32_from_64_S (key[0])); + key1[1] = swap32_S (l32_from_64_S (key[0])); + key1[2] = swap32_S (h32_from_64_S (key[1])); + key1[3] = swap32_S (l32_from_64_S (key[1])); + key1[4] = swap32_S (h32_from_64_S (key[2])); + key1[5] = swap32_S (l32_from_64_S (key[2])); + key1[6] = swap32_S (h32_from_64_S (key[3])); + key1[7] = swap32_S (l32_from_64_S (key[3])); + key2[0] = swap32_S (h32_from_64_S (key[4])); + key2[1] = swap32_S (l32_from_64_S (key[4])); + key2[2] = swap32_S (h32_from_64_S (key[5])); + key2[3] = swap32_S (l32_from_64_S (key[5])); + key2[4] = swap32_S (h32_from_64_S (key[6])); + key2[5] = swap32_S (l32_from_64_S (key[6])); + key2[6] = swap32_S (h32_from_64_S (key[7])); + key2[7] = swap32_S (l32_from_64_S (key[7])); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (h32_from_64_S (key[ 0])); + key1[1] = swap32_S (l32_from_64_S (key[ 0])); + key1[2] = swap32_S (h32_from_64_S (key[ 1])); + key1[3] = swap32_S (l32_from_64_S (key[ 1])); + key1[4] = swap32_S (h32_from_64_S (key[ 2])); + key1[5] = swap32_S (l32_from_64_S (key[ 2])); + key1[6] = swap32_S (h32_from_64_S (key[ 3])); + key1[7] = swap32_S (l32_from_64_S (key[ 3])); + key2[0] = swap32_S (h32_from_64_S (key[ 4])); + key2[1] = swap32_S (l32_from_64_S (key[ 4])); + key2[2] = swap32_S (h32_from_64_S (key[ 5])); + key2[3] = swap32_S (l32_from_64_S (key[ 5])); + key2[4] = swap32_S (h32_from_64_S (key[ 6])); + key2[5] = swap32_S (l32_from_64_S (key[ 6])); + key2[6] = swap32_S (h32_from_64_S (key[ 7])); + key2[7] = swap32_S (l32_from_64_S (key[ 7])); + key3[0] = swap32_S (h32_from_64_S (key[ 8])); + key3[1] = swap32_S (l32_from_64_S (key[ 8])); + key3[2] = swap32_S (h32_from_64_S (key[ 9])); + key3[3] = swap32_S (l32_from_64_S (key[ 9])); + key3[4] = swap32_S (h32_from_64_S (key[10])); + key3[5] = swap32_S (l32_from_64_S (key[10])); + key3[6] = swap32_S (h32_from_64_S (key[11])); + key3[7] = swap32_S (l32_from_64_S (key[11])); + key4[0] = swap32_S (h32_from_64_S (key[12])); + key4[1] = swap32_S (l32_from_64_S (key[12])); + key4[2] = swap32_S (h32_from_64_S (key[13])); + key4[3] = swap32_S (l32_from_64_S (key[13])); + key4[4] = swap32_S (h32_from_64_S (key[14])); + key4[5] = swap32_S (l32_from_64_S (key[14])); + key4[6] = swap32_S (h32_from_64_S (key[15])); + key4[7] = swap32_S (l32_from_64_S (key[15])); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +__kernel void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + w4[0] = pws[gid].i[16]; + w4[1] = pws[gid].i[17]; + w4[2] = pws[gid].i[18]; + w4[3] = pws[gid].i[19]; + w5[0] = pws[gid].i[20]; + w5[1] = pws[gid].i[21]; + w5[2] = pws[gid].i[22]; + w5[3] = pws[gid].i[23]; + w6[0] = pws[gid].i[24]; + w6[1] = pws[gid].i[25]; + w6[2] = pws[gid].i[26]; + w6[3] = pws[gid].i[27]; + w7[0] = pws[gid].i[28]; + w7[1] = pws[gid].i[29]; + w7[2] = pws[gid].i[30]; + w7[3] = pws[gid].i[31]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + w0[0] = swap32_S (w0[0]); + w0[1] = swap32_S (w0[1]); + w0[2] = swap32_S (w0[2]); + w0[3] = swap32_S (w0[3]); + w1[0] = swap32_S (w1[0]); + w1[1] = swap32_S (w1[1]); + w1[2] = swap32_S (w1[2]); + w1[3] = swap32_S (w1[3]); + w2[0] = swap32_S (w2[0]); + w2[1] = swap32_S (w2[1]); + w2[2] = swap32_S (w2[2]); + w2[3] = swap32_S (w2[3]); + w3[0] = swap32_S (w3[0]); + w3[1] = swap32_S (w3[1]); + w3[2] = swap32_S (w3[2]); + w3[3] = swap32_S (w3[3]); + w4[0] = swap32_S (w4[0]); + w4[1] = swap32_S (w4[1]); + w4[2] = swap32_S (w4[2]); + w4[3] = swap32_S (w4[3]); + w5[0] = swap32_S (w5[0]); + w5[1] = swap32_S (w5[1]); + w5[2] = swap32_S (w5[2]); + w5[3] = swap32_S (w5[3]); + w6[0] = swap32_S (w6[0]); + w6[1] = swap32_S (w6[1]); + w6[2] = swap32_S (w6[2]); + w6[3] = swap32_S (w6[3]); + w7[0] = swap32_S (w7[0]); + w7[1] = swap32_S (w7[1]); + w7[2] = swap32_S (w7[2]); + w7[3] = swap32_S (w7[3]); + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + sha512_hmac_update_global_swap (&sha512_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 16; i += 8, j += 1) + { + sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx2, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha512_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha512_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha512_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha512_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha512_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha512_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha512_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha512_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +__kernel void m13722_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * shared lookup table + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + for (u32 i = 0; i < 16; i += 8) + { + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, i + 0); + dgst[1] = pack64v (tmps, dgst, gid, i + 1); + dgst[2] = pack64v (tmps, dgst, gid, i + 2); + dgst[3] = pack64v (tmps, dgst, gid, i + 3); + dgst[4] = pack64v (tmps, dgst, gid, i + 4); + dgst[5] = pack64v (tmps, dgst, gid, i + 5); + dgst[6] = pack64v (tmps, dgst, gid, i + 6); + dgst[7] = pack64v (tmps, dgst, gid, i + 7); + + out[0] = pack64v (tmps, out, gid, i + 0); + out[1] = pack64v (tmps, out, gid, i + 1); + out[2] = pack64v (tmps, out, gid, i + 2); + out[3] = pack64v (tmps, out, gid, i + 3); + out[4] = pack64v (tmps, out, gid, i + 4); + out[5] = pack64v (tmps, out, gid, i + 5); + out[6] = pack64v (tmps, out, gid, i + 6); + out[7] = pack64v (tmps, out, gid, i + 7); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } + } + + unpack64v (tmps, dgst, gid, i + 0, dgst[0]); + unpack64v (tmps, dgst, gid, i + 1, dgst[1]); + unpack64v (tmps, dgst, gid, i + 2, dgst[2]); + unpack64v (tmps, dgst, gid, i + 3, dgst[3]); + unpack64v (tmps, dgst, gid, i + 4, dgst[4]); + unpack64v (tmps, dgst, gid, i + 5, dgst[5]); + unpack64v (tmps, dgst, gid, i + 6, dgst[6]); + unpack64v (tmps, dgst, gid, i + 7, dgst[7]); + + unpack64v (tmps, out, gid, i + 0, out[0]); + unpack64v (tmps, out, gid, i + 1, out[1]); + unpack64v (tmps, out, gid, i + 2, out[2]); + unpack64v (tmps, out, gid, i + 3, out[3]); + unpack64v (tmps, out, gid, i + 4, out[4]); + unpack64v (tmps, out, gid, i + 5, out[5]); + unpack64v (tmps, out, gid, i + 6, out[6]); + unpack64v (tmps, out, gid, i + 7, out[7]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13722_comp (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl new file mode 100644 index 000000000..176aa5993 --- /dev/null +++ b/OpenCL/m13723-pure.cl @@ -0,0 +1,794 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc64_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + +} vc64_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (h32_from_64_S (key[0])); + key1[1] = swap32_S (l32_from_64_S (key[0])); + key1[2] = swap32_S (h32_from_64_S (key[1])); + key1[3] = swap32_S (l32_from_64_S (key[1])); + key1[4] = swap32_S (h32_from_64_S (key[2])); + key1[5] = swap32_S (l32_from_64_S (key[2])); + key1[6] = swap32_S (h32_from_64_S (key[3])); + key1[7] = swap32_S (l32_from_64_S (key[3])); + key2[0] = swap32_S (h32_from_64_S (key[4])); + key2[1] = swap32_S (l32_from_64_S (key[4])); + key2[2] = swap32_S (h32_from_64_S (key[5])); + key2[3] = swap32_S (l32_from_64_S (key[5])); + key2[4] = swap32_S (h32_from_64_S (key[6])); + key2[5] = swap32_S (l32_from_64_S (key[6])); + key2[6] = swap32_S (h32_from_64_S (key[7])); + key2[7] = swap32_S (l32_from_64_S (key[7])); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (h32_from_64_S (key[ 0])); + key1[1] = swap32_S (l32_from_64_S (key[ 0])); + key1[2] = swap32_S (h32_from_64_S (key[ 1])); + key1[3] = swap32_S (l32_from_64_S (key[ 1])); + key1[4] = swap32_S (h32_from_64_S (key[ 2])); + key1[5] = swap32_S (l32_from_64_S (key[ 2])); + key1[6] = swap32_S (h32_from_64_S (key[ 3])); + key1[7] = swap32_S (l32_from_64_S (key[ 3])); + key2[0] = swap32_S (h32_from_64_S (key[ 4])); + key2[1] = swap32_S (l32_from_64_S (key[ 4])); + key2[2] = swap32_S (h32_from_64_S (key[ 5])); + key2[3] = swap32_S (l32_from_64_S (key[ 5])); + key2[4] = swap32_S (h32_from_64_S (key[ 6])); + key2[5] = swap32_S (l32_from_64_S (key[ 6])); + key2[6] = swap32_S (h32_from_64_S (key[ 7])); + key2[7] = swap32_S (l32_from_64_S (key[ 7])); + key3[0] = swap32_S (h32_from_64_S (key[ 8])); + key3[1] = swap32_S (l32_from_64_S (key[ 8])); + key3[2] = swap32_S (h32_from_64_S (key[ 9])); + key3[3] = swap32_S (l32_from_64_S (key[ 9])); + key3[4] = swap32_S (h32_from_64_S (key[10])); + key3[5] = swap32_S (l32_from_64_S (key[10])); + key3[6] = swap32_S (h32_from_64_S (key[11])); + key3[7] = swap32_S (l32_from_64_S (key[11])); + key4[0] = swap32_S (h32_from_64_S (key[12])); + key4[1] = swap32_S (l32_from_64_S (key[12])); + key4[2] = swap32_S (h32_from_64_S (key[13])); + key4[3] = swap32_S (l32_from_64_S (key[13])); + key4[4] = swap32_S (h32_from_64_S (key[14])); + key4[5] = swap32_S (l32_from_64_S (key[14])); + key4[6] = swap32_S (h32_from_64_S (key[15])); + key4[7] = swap32_S (l32_from_64_S (key[15])); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1536 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + u32 key5[8]; + u32 key6[8]; + + key1[0] = swap32_S (h32_from_64_S (key[ 0])); + key1[1] = swap32_S (l32_from_64_S (key[ 0])); + key1[2] = swap32_S (h32_from_64_S (key[ 1])); + key1[3] = swap32_S (l32_from_64_S (key[ 1])); + key1[4] = swap32_S (h32_from_64_S (key[ 2])); + key1[5] = swap32_S (l32_from_64_S (key[ 2])); + key1[6] = swap32_S (h32_from_64_S (key[ 3])); + key1[7] = swap32_S (l32_from_64_S (key[ 3])); + key2[0] = swap32_S (h32_from_64_S (key[ 4])); + key2[1] = swap32_S (l32_from_64_S (key[ 4])); + key2[2] = swap32_S (h32_from_64_S (key[ 5])); + key2[3] = swap32_S (l32_from_64_S (key[ 5])); + key2[4] = swap32_S (h32_from_64_S (key[ 6])); + key2[5] = swap32_S (l32_from_64_S (key[ 6])); + key2[6] = swap32_S (h32_from_64_S (key[ 7])); + key2[7] = swap32_S (l32_from_64_S (key[ 7])); + key3[0] = swap32_S (h32_from_64_S (key[ 8])); + key3[1] = swap32_S (l32_from_64_S (key[ 8])); + key3[2] = swap32_S (h32_from_64_S (key[ 9])); + key3[3] = swap32_S (l32_from_64_S (key[ 9])); + key3[4] = swap32_S (h32_from_64_S (key[10])); + key3[5] = swap32_S (l32_from_64_S (key[10])); + key3[6] = swap32_S (h32_from_64_S (key[11])); + key3[7] = swap32_S (l32_from_64_S (key[11])); + key4[0] = swap32_S (h32_from_64_S (key[12])); + key4[1] = swap32_S (l32_from_64_S (key[12])); + key4[2] = swap32_S (h32_from_64_S (key[13])); + key4[3] = swap32_S (l32_from_64_S (key[13])); + key4[4] = swap32_S (h32_from_64_S (key[14])); + key4[5] = swap32_S (l32_from_64_S (key[14])); + key4[6] = swap32_S (h32_from_64_S (key[15])); + key4[7] = swap32_S (l32_from_64_S (key[15])); + key5[0] = swap32_S (h32_from_64_S (key[16])); + key5[1] = swap32_S (l32_from_64_S (key[16])); + key5[2] = swap32_S (h32_from_64_S (key[17])); + key5[3] = swap32_S (l32_from_64_S (key[17])); + key5[4] = swap32_S (h32_from_64_S (key[18])); + key5[5] = swap32_S (l32_from_64_S (key[18])); + key5[6] = swap32_S (h32_from_64_S (key[19])); + key5[7] = swap32_S (l32_from_64_S (key[19])); + key6[0] = swap32_S (h32_from_64_S (key[20])); + key6[1] = swap32_S (l32_from_64_S (key[20])); + key6[2] = swap32_S (h32_from_64_S (key[21])); + key6[3] = swap32_S (l32_from_64_S (key[21])); + key6[4] = swap32_S (h32_from_64_S (key[22])); + key6[5] = swap32_S (l32_from_64_S (key[22])); + key6[6] = swap32_S (h32_from_64_S (key[23])); + key6[7] = swap32_S (l32_from_64_S (key[23])); + + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_serpent_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +__kernel void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + w4[0] = pws[gid].i[16]; + w4[1] = pws[gid].i[17]; + w4[2] = pws[gid].i[18]; + w4[3] = pws[gid].i[19]; + w5[0] = pws[gid].i[20]; + w5[1] = pws[gid].i[21]; + w5[2] = pws[gid].i[22]; + w5[3] = pws[gid].i[23]; + w6[0] = pws[gid].i[24]; + w6[1] = pws[gid].i[25]; + w6[2] = pws[gid].i[26]; + w6[3] = pws[gid].i[27]; + w7[0] = pws[gid].i[28]; + w7[1] = pws[gid].i[29]; + w7[2] = pws[gid].i[30]; + w7[3] = pws[gid].i[31]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + w0[0] = swap32_S (w0[0]); + w0[1] = swap32_S (w0[1]); + w0[2] = swap32_S (w0[2]); + w0[3] = swap32_S (w0[3]); + w1[0] = swap32_S (w1[0]); + w1[1] = swap32_S (w1[1]); + w1[2] = swap32_S (w1[2]); + w1[3] = swap32_S (w1[3]); + w2[0] = swap32_S (w2[0]); + w2[1] = swap32_S (w2[1]); + w2[2] = swap32_S (w2[2]); + w2[3] = swap32_S (w2[3]); + w3[0] = swap32_S (w3[0]); + w3[1] = swap32_S (w3[1]); + w3[2] = swap32_S (w3[2]); + w3[3] = swap32_S (w3[3]); + w4[0] = swap32_S (w4[0]); + w4[1] = swap32_S (w4[1]); + w4[2] = swap32_S (w4[2]); + w4[3] = swap32_S (w4[3]); + w5[0] = swap32_S (w5[0]); + w5[1] = swap32_S (w5[1]); + w5[2] = swap32_S (w5[2]); + w5[3] = swap32_S (w5[3]); + w6[0] = swap32_S (w6[0]); + w6[1] = swap32_S (w6[1]); + w6[2] = swap32_S (w6[2]); + w6[3] = swap32_S (w6[3]); + w7[0] = swap32_S (w7[0]); + w7[1] = swap32_S (w7[1]); + w7[2] = swap32_S (w7[2]); + w7[3] = swap32_S (w7[3]); + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + sha512_hmac_update_global_swap (&sha512_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 24; i += 8, j += 1) + { + sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx2, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha512_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha512_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha512_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha512_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha512_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha512_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha512_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha512_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +__kernel void m13723_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * shared lookup table + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + for (u32 i = 0; i < 24; i += 8) + { + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, i + 0); + dgst[1] = pack64v (tmps, dgst, gid, i + 1); + dgst[2] = pack64v (tmps, dgst, gid, i + 2); + dgst[3] = pack64v (tmps, dgst, gid, i + 3); + dgst[4] = pack64v (tmps, dgst, gid, i + 4); + dgst[5] = pack64v (tmps, dgst, gid, i + 5); + dgst[6] = pack64v (tmps, dgst, gid, i + 6); + dgst[7] = pack64v (tmps, dgst, gid, i + 7); + + out[0] = pack64v (tmps, out, gid, i + 0); + out[1] = pack64v (tmps, out, gid, i + 1); + out[2] = pack64v (tmps, out, gid, i + 2); + out[3] = pack64v (tmps, out, gid, i + 3); + out[4] = pack64v (tmps, out, gid, i + 4); + out[5] = pack64v (tmps, out, gid, i + 5); + out[6] = pack64v (tmps, out, gid, i + 6); + out[7] = pack64v (tmps, out, gid, i + 7); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } + } + + unpack64v (tmps, dgst, gid, i + 0, dgst[0]); + unpack64v (tmps, dgst, gid, i + 1, dgst[1]); + unpack64v (tmps, dgst, gid, i + 2, dgst[2]); + unpack64v (tmps, dgst, gid, i + 3, dgst[3]); + unpack64v (tmps, dgst, gid, i + 4, dgst[4]); + unpack64v (tmps, dgst, gid, i + 5, dgst[5]); + unpack64v (tmps, dgst, gid, i + 6, dgst[6]); + unpack64v (tmps, dgst, gid, i + 7, dgst[7]); + + unpack64v (tmps, out, gid, i + 0, out[0]); + unpack64v (tmps, out, gid, i + 1, out[1]); + unpack64v (tmps, out, gid, i + 2, out[2]); + unpack64v (tmps, out, gid, i + 3, out[3]); + unpack64v (tmps, out, gid, i + 4, out[4]); + unpack64v (tmps, out, gid, i + 5, out[5]); + unpack64v (tmps, out, gid, i + 6, out[6]); + unpack64v (tmps, out, gid, i + 7, out[7]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13723_comp (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1536 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13731-pure.cl b/OpenCL/m13731-pure.cl new file mode 100644 index 000000000..84affaf5e --- /dev/null +++ b/OpenCL/m13731-pure.cl @@ -0,0 +1,839 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +//#undef LOCAL_MEM_TYPE +//#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_whirlpool.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +{ + digest[ 0] = ipad[ 0]; + digest[ 1] = ipad[ 1]; + digest[ 2] = ipad[ 2]; + digest[ 3] = ipad[ 3]; + digest[ 4] = ipad[ 4]; + digest[ 5] = ipad[ 5]; + digest[ 6] = ipad[ 6]; + digest[ 7] = ipad[ 7]; + digest[ 8] = ipad[ 8]; + digest[ 9] = ipad[ 9]; + digest[10] = ipad[10]; + digest[11] = ipad[11]; + digest[12] = ipad[12]; + digest[13] = ipad[13]; + digest[14] = ipad[14]; + digest[15] = ipad[15]; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 64) * 8; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = digest[ 0]; + w0[1] = digest[ 1]; + w0[2] = digest[ 2]; + w0[3] = digest[ 3]; + w1[0] = digest[ 4]; + w1[1] = digest[ 5]; + w1[2] = digest[ 6]; + w1[3] = digest[ 7]; + w2[0] = digest[ 8]; + w2[1] = digest[ 9]; + w2[2] = digest[10]; + w2[3] = digest[11]; + w3[0] = digest[12]; + w3[1] = digest[13]; + w3[2] = digest[14]; + w3[3] = digest[15]; + + digest[ 0] = opad[ 0]; + digest[ 1] = opad[ 1]; + digest[ 2] = opad[ 2]; + digest[ 3] = opad[ 3]; + digest[ 4] = opad[ 4]; + digest[ 5] = opad[ 5]; + digest[ 6] = opad[ 6]; + digest[ 7] = opad[ 7]; + digest[ 8] = opad[ 8]; + digest[ 9] = opad[ 9]; + digest[10] = opad[10]; + digest[11] = opad[11]; + digest[12] = opad[12]; + digest[13] = opad[13]; + digest[14] = opad[14]; + digest[15] = opad[15]; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 64) * 8; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); +} + +__kernel void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + w0[0] = swap32_S (w0[0]); + w0[1] = swap32_S (w0[1]); + w0[2] = swap32_S (w0[2]); + w0[3] = swap32_S (w0[3]); + w1[0] = swap32_S (w1[0]); + w1[1] = swap32_S (w1[1]); + w1[2] = swap32_S (w1[2]); + w1[3] = swap32_S (w1[3]); + w2[0] = swap32_S (w2[0]); + w2[1] = swap32_S (w2[1]); + w2[2] = swap32_S (w2[2]); + w2[3] = swap32_S (w2[3]); + w3[0] = swap32_S (w3[0]); + w3[1] = swap32_S (w3[1]); + w3[2] = swap32_S (w3[2]); + w3[3] = swap32_S (w3[3]); + + whirlpool_hmac_ctx_t whirlpool_hmac_ctx; + + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + + tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; + tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; + tmps[gid].ipad[ 2] = whirlpool_hmac_ctx.ipad.h[ 2]; + tmps[gid].ipad[ 3] = whirlpool_hmac_ctx.ipad.h[ 3]; + tmps[gid].ipad[ 4] = whirlpool_hmac_ctx.ipad.h[ 4]; + tmps[gid].ipad[ 5] = whirlpool_hmac_ctx.ipad.h[ 5]; + tmps[gid].ipad[ 6] = whirlpool_hmac_ctx.ipad.h[ 6]; + tmps[gid].ipad[ 7] = whirlpool_hmac_ctx.ipad.h[ 7]; + tmps[gid].ipad[ 8] = whirlpool_hmac_ctx.ipad.h[ 8]; + tmps[gid].ipad[ 9] = whirlpool_hmac_ctx.ipad.h[ 9]; + tmps[gid].ipad[10] = whirlpool_hmac_ctx.ipad.h[10]; + tmps[gid].ipad[11] = whirlpool_hmac_ctx.ipad.h[11]; + tmps[gid].ipad[12] = whirlpool_hmac_ctx.ipad.h[12]; + tmps[gid].ipad[13] = whirlpool_hmac_ctx.ipad.h[13]; + tmps[gid].ipad[14] = whirlpool_hmac_ctx.ipad.h[14]; + tmps[gid].ipad[15] = whirlpool_hmac_ctx.ipad.h[15]; + + tmps[gid].opad[ 0] = whirlpool_hmac_ctx.opad.h[ 0]; + tmps[gid].opad[ 1] = whirlpool_hmac_ctx.opad.h[ 1]; + tmps[gid].opad[ 2] = whirlpool_hmac_ctx.opad.h[ 2]; + tmps[gid].opad[ 3] = whirlpool_hmac_ctx.opad.h[ 3]; + tmps[gid].opad[ 4] = whirlpool_hmac_ctx.opad.h[ 4]; + tmps[gid].opad[ 5] = whirlpool_hmac_ctx.opad.h[ 5]; + tmps[gid].opad[ 6] = whirlpool_hmac_ctx.opad.h[ 6]; + tmps[gid].opad[ 7] = whirlpool_hmac_ctx.opad.h[ 7]; + tmps[gid].opad[ 8] = whirlpool_hmac_ctx.opad.h[ 8]; + tmps[gid].opad[ 9] = whirlpool_hmac_ctx.opad.h[ 9]; + tmps[gid].opad[10] = whirlpool_hmac_ctx.opad.h[10]; + tmps[gid].opad[11] = whirlpool_hmac_ctx.opad.h[11]; + tmps[gid].opad[12] = whirlpool_hmac_ctx.opad.h[12]; + tmps[gid].opad[13] = whirlpool_hmac_ctx.opad.h[13]; + tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14]; + tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15]; + + whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 16; i += 16, j += 1) + { + whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + whirlpool_hmac_update_64 (&whirlpool_hmac_ctx2, w0, w1, w2, w3, 4); + + whirlpool_hmac_final (&whirlpool_hmac_ctx2); + + tmps[gid].dgst[i + 0] = whirlpool_hmac_ctx2.opad.h[ 0]; + tmps[gid].dgst[i + 1] = whirlpool_hmac_ctx2.opad.h[ 1]; + tmps[gid].dgst[i + 2] = whirlpool_hmac_ctx2.opad.h[ 2]; + tmps[gid].dgst[i + 3] = whirlpool_hmac_ctx2.opad.h[ 3]; + tmps[gid].dgst[i + 4] = whirlpool_hmac_ctx2.opad.h[ 4]; + tmps[gid].dgst[i + 5] = whirlpool_hmac_ctx2.opad.h[ 5]; + tmps[gid].dgst[i + 6] = whirlpool_hmac_ctx2.opad.h[ 6]; + tmps[gid].dgst[i + 7] = whirlpool_hmac_ctx2.opad.h[ 7]; + tmps[gid].dgst[i + 8] = whirlpool_hmac_ctx2.opad.h[ 8]; + tmps[gid].dgst[i + 9] = whirlpool_hmac_ctx2.opad.h[ 9]; + tmps[gid].dgst[i + 10] = whirlpool_hmac_ctx2.opad.h[10]; + tmps[gid].dgst[i + 11] = whirlpool_hmac_ctx2.opad.h[11]; + tmps[gid].dgst[i + 12] = whirlpool_hmac_ctx2.opad.h[12]; + tmps[gid].dgst[i + 13] = whirlpool_hmac_ctx2.opad.h[13]; + tmps[gid].dgst[i + 14] = whirlpool_hmac_ctx2.opad.h[14]; + tmps[gid].dgst[i + 15] = whirlpool_hmac_ctx2.opad.h[15]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + tmps[gid].out[i + 8] = tmps[gid].dgst[i + 8]; + tmps[gid].out[i + 9] = tmps[gid].dgst[i + 9]; + tmps[gid].out[i + 10] = tmps[gid].dgst[i + 10]; + tmps[gid].out[i + 11] = tmps[gid].dgst[i + 11]; + tmps[gid].out[i + 12] = tmps[gid].dgst[i + 12]; + tmps[gid].out[i + 13] = tmps[gid].dgst[i + 13]; + tmps[gid].out[i + 14] = tmps[gid].dgst[i + 14]; + tmps[gid].out[i + 15] = tmps[gid].dgst[i + 15]; + } +} + +__kernel void m13731_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u32x ipad[16]; + u32x opad[16]; + + ipad[ 0] = packv (tmps, ipad, gid, 0); + ipad[ 1] = packv (tmps, ipad, gid, 1); + ipad[ 2] = packv (tmps, ipad, gid, 2); + ipad[ 3] = packv (tmps, ipad, gid, 3); + ipad[ 4] = packv (tmps, ipad, gid, 4); + ipad[ 5] = packv (tmps, ipad, gid, 5); + ipad[ 6] = packv (tmps, ipad, gid, 6); + ipad[ 7] = packv (tmps, ipad, gid, 7); + ipad[ 8] = packv (tmps, ipad, gid, 8); + ipad[ 9] = packv (tmps, ipad, gid, 9); + ipad[10] = packv (tmps, ipad, gid, 10); + ipad[11] = packv (tmps, ipad, gid, 11); + ipad[12] = packv (tmps, ipad, gid, 12); + ipad[13] = packv (tmps, ipad, gid, 13); + ipad[14] = packv (tmps, ipad, gid, 14); + ipad[15] = packv (tmps, ipad, gid, 15); + + opad[ 0] = packv (tmps, opad, gid, 0); + opad[ 1] = packv (tmps, opad, gid, 1); + opad[ 2] = packv (tmps, opad, gid, 2); + opad[ 3] = packv (tmps, opad, gid, 3); + opad[ 4] = packv (tmps, opad, gid, 4); + opad[ 5] = packv (tmps, opad, gid, 5); + opad[ 6] = packv (tmps, opad, gid, 6); + opad[ 7] = packv (tmps, opad, gid, 7); + opad[ 8] = packv (tmps, opad, gid, 8); + opad[ 9] = packv (tmps, opad, gid, 9); + opad[10] = packv (tmps, opad, gid, 10); + opad[11] = packv (tmps, opad, gid, 11); + opad[12] = packv (tmps, opad, gid, 12); + opad[13] = packv (tmps, opad, gid, 13); + opad[14] = packv (tmps, opad, gid, 14); + opad[15] = packv (tmps, opad, gid, 15); + + for (u32 i = 0; i < 16; i += 16) + { + u32x dgst[16]; + u32x out[16]; + + dgst[ 0] = packv (tmps, dgst, gid, i + 0); + dgst[ 1] = packv (tmps, dgst, gid, i + 1); + dgst[ 2] = packv (tmps, dgst, gid, i + 2); + dgst[ 3] = packv (tmps, dgst, gid, i + 3); + dgst[ 4] = packv (tmps, dgst, gid, i + 4); + dgst[ 5] = packv (tmps, dgst, gid, i + 5); + dgst[ 6] = packv (tmps, dgst, gid, i + 6); + dgst[ 7] = packv (tmps, dgst, gid, i + 7); + dgst[ 8] = packv (tmps, dgst, gid, i + 8); + dgst[ 9] = packv (tmps, dgst, gid, i + 9); + dgst[10] = packv (tmps, dgst, gid, i + 10); + dgst[11] = packv (tmps, dgst, gid, i + 11); + dgst[12] = packv (tmps, dgst, gid, i + 12); + dgst[13] = packv (tmps, dgst, gid, i + 13); + dgst[14] = packv (tmps, dgst, gid, i + 14); + dgst[15] = packv (tmps, dgst, gid, i + 15); + + out[ 0] = packv (tmps, out, gid, i + 0); + out[ 1] = packv (tmps, out, gid, i + 1); + out[ 2] = packv (tmps, out, gid, i + 2); + out[ 3] = packv (tmps, out, gid, i + 3); + out[ 4] = packv (tmps, out, gid, i + 4); + out[ 5] = packv (tmps, out, gid, i + 5); + out[ 6] = packv (tmps, out, gid, i + 6); + out[ 7] = packv (tmps, out, gid, i + 7); + out[ 8] = packv (tmps, out, gid, i + 8); + out[ 9] = packv (tmps, out, gid, i + 9); + out[10] = packv (tmps, out, gid, i + 10); + out[11] = packv (tmps, out, gid, i + 11); + out[12] = packv (tmps, out, gid, i + 12); + out[13] = packv (tmps, out, gid, i + 13); + out[14] = packv (tmps, out, gid, i + 14); + out[15] = packv (tmps, out, gid, i + 15); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[ 0]; + w0[1] = dgst[ 1]; + w0[2] = dgst[ 2]; + w0[3] = dgst[ 3]; + w1[0] = dgst[ 4]; + w1[1] = dgst[ 5]; + w1[2] = dgst[ 6]; + w1[3] = dgst[ 7]; + w2[0] = dgst[ 8]; + w2[1] = dgst[ 9]; + w2[2] = dgst[10]; + w2[3] = dgst[11]; + w3[0] = dgst[12]; + w3[1] = dgst[13]; + w3[2] = dgst[14]; + w3[3] = dgst[15]; + + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + + out[ 0] ^= dgst[ 0]; + out[ 1] ^= dgst[ 1]; + out[ 2] ^= dgst[ 2]; + out[ 3] ^= dgst[ 3]; + out[ 4] ^= dgst[ 4]; + out[ 5] ^= dgst[ 5]; + out[ 6] ^= dgst[ 6]; + out[ 7] ^= dgst[ 7]; + out[ 8] ^= dgst[ 8]; + out[ 9] ^= dgst[ 9]; + out[10] ^= dgst[10]; + out[11] ^= dgst[11]; + out[12] ^= dgst[12]; + out[13] ^= dgst[13]; + out[14] ^= dgst[14]; + out[15] ^= dgst[15]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[ 0]; + tmps[gid].pim_key[i + 1] = out[ 1]; + tmps[gid].pim_key[i + 2] = out[ 2]; + tmps[gid].pim_key[i + 3] = out[ 3]; + tmps[gid].pim_key[i + 4] = out[ 4]; + tmps[gid].pim_key[i + 5] = out[ 5]; + tmps[gid].pim_key[i + 6] = out[ 6]; + tmps[gid].pim_key[i + 7] = out[ 7]; + tmps[gid].pim_key[i + 8] = out[ 8]; + tmps[gid].pim_key[i + 9] = out[ 9]; + tmps[gid].pim_key[i + 10] = out[10]; + tmps[gid].pim_key[i + 11] = out[11]; + tmps[gid].pim_key[i + 12] = out[12]; + tmps[gid].pim_key[i + 13] = out[13]; + tmps[gid].pim_key[i + 14] = out[14]; + tmps[gid].pim_key[i + 15] = out[15]; + } + } + + unpackv (tmps, dgst, gid, i + 0, dgst[ 0]); + unpackv (tmps, dgst, gid, i + 1, dgst[ 1]); + unpackv (tmps, dgst, gid, i + 2, dgst[ 2]); + unpackv (tmps, dgst, gid, i + 3, dgst[ 3]); + unpackv (tmps, dgst, gid, i + 4, dgst[ 4]); + unpackv (tmps, dgst, gid, i + 5, dgst[ 5]); + unpackv (tmps, dgst, gid, i + 6, dgst[ 6]); + unpackv (tmps, dgst, gid, i + 7, dgst[ 7]); + unpackv (tmps, dgst, gid, i + 8, dgst[ 8]); + unpackv (tmps, dgst, gid, i + 9, dgst[ 9]); + unpackv (tmps, dgst, gid, i + 10, dgst[10]); + unpackv (tmps, dgst, gid, i + 11, dgst[11]); + unpackv (tmps, dgst, gid, i + 12, dgst[12]); + unpackv (tmps, dgst, gid, i + 13, dgst[13]); + unpackv (tmps, dgst, gid, i + 14, dgst[14]); + unpackv (tmps, dgst, gid, i + 15, dgst[15]); + + unpackv (tmps, out, gid, i + 0, out[ 0]); + unpackv (tmps, out, gid, i + 1, out[ 1]); + unpackv (tmps, out, gid, i + 2, out[ 2]); + unpackv (tmps, out, gid, i + 3, out[ 3]); + unpackv (tmps, out, gid, i + 4, out[ 4]); + unpackv (tmps, out, gid, i + 5, out[ 5]); + unpackv (tmps, out, gid, i + 6, out[ 6]); + unpackv (tmps, out, gid, i + 7, out[ 7]); + unpackv (tmps, out, gid, i + 8, out[ 8]); + unpackv (tmps, out, gid, i + 9, out[ 9]); + unpackv (tmps, out, gid, i + 10, out[10]); + unpackv (tmps, out, gid, i + 11, out[11]); + unpackv (tmps, out, gid, i + 12, out[12]); + unpackv (tmps, out, gid, i + 13, out[13]); + unpackv (tmps, out, gid, i + 14, out[14]); + unpackv (tmps, out, gid, i + 15, out[15]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13731_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13732-pure.cl b/OpenCL/m13732-pure.cl new file mode 100644 index 000000000..105f062f4 --- /dev/null +++ b/OpenCL/m13732-pure.cl @@ -0,0 +1,899 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +//#undef LOCAL_MEM_TYPE +//#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_whirlpool.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + key3[0] = swap32_S (key[16]); + key3[1] = swap32_S (key[17]); + key3[2] = swap32_S (key[18]); + key3[3] = swap32_S (key[19]); + key3[4] = swap32_S (key[20]); + key3[5] = swap32_S (key[21]); + key3[6] = swap32_S (key[22]); + key3[7] = swap32_S (key[23]); + key4[0] = swap32_S (key[24]); + key4[1] = swap32_S (key[25]); + key4[2] = swap32_S (key[26]); + key4[3] = swap32_S (key[27]); + key4[4] = swap32_S (key[28]); + key4[5] = swap32_S (key[29]); + key4[6] = swap32_S (key[30]); + key4[7] = swap32_S (key[31]); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +{ + digest[ 0] = ipad[ 0]; + digest[ 1] = ipad[ 1]; + digest[ 2] = ipad[ 2]; + digest[ 3] = ipad[ 3]; + digest[ 4] = ipad[ 4]; + digest[ 5] = ipad[ 5]; + digest[ 6] = ipad[ 6]; + digest[ 7] = ipad[ 7]; + digest[ 8] = ipad[ 8]; + digest[ 9] = ipad[ 9]; + digest[10] = ipad[10]; + digest[11] = ipad[11]; + digest[12] = ipad[12]; + digest[13] = ipad[13]; + digest[14] = ipad[14]; + digest[15] = ipad[15]; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 64) * 8; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = digest[ 0]; + w0[1] = digest[ 1]; + w0[2] = digest[ 2]; + w0[3] = digest[ 3]; + w1[0] = digest[ 4]; + w1[1] = digest[ 5]; + w1[2] = digest[ 6]; + w1[3] = digest[ 7]; + w2[0] = digest[ 8]; + w2[1] = digest[ 9]; + w2[2] = digest[10]; + w2[3] = digest[11]; + w3[0] = digest[12]; + w3[1] = digest[13]; + w3[2] = digest[14]; + w3[3] = digest[15]; + + digest[ 0] = opad[ 0]; + digest[ 1] = opad[ 1]; + digest[ 2] = opad[ 2]; + digest[ 3] = opad[ 3]; + digest[ 4] = opad[ 4]; + digest[ 5] = opad[ 5]; + digest[ 6] = opad[ 6]; + digest[ 7] = opad[ 7]; + digest[ 8] = opad[ 8]; + digest[ 9] = opad[ 9]; + digest[10] = opad[10]; + digest[11] = opad[11]; + digest[12] = opad[12]; + digest[13] = opad[13]; + digest[14] = opad[14]; + digest[15] = opad[15]; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 64) * 8; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); +} + +__kernel void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + w0[0] = swap32_S (w0[0]); + w0[1] = swap32_S (w0[1]); + w0[2] = swap32_S (w0[2]); + w0[3] = swap32_S (w0[3]); + w1[0] = swap32_S (w1[0]); + w1[1] = swap32_S (w1[1]); + w1[2] = swap32_S (w1[2]); + w1[3] = swap32_S (w1[3]); + w2[0] = swap32_S (w2[0]); + w2[1] = swap32_S (w2[1]); + w2[2] = swap32_S (w2[2]); + w2[3] = swap32_S (w2[3]); + w3[0] = swap32_S (w3[0]); + w3[1] = swap32_S (w3[1]); + w3[2] = swap32_S (w3[2]); + w3[3] = swap32_S (w3[3]); + + whirlpool_hmac_ctx_t whirlpool_hmac_ctx; + + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + + tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; + tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; + tmps[gid].ipad[ 2] = whirlpool_hmac_ctx.ipad.h[ 2]; + tmps[gid].ipad[ 3] = whirlpool_hmac_ctx.ipad.h[ 3]; + tmps[gid].ipad[ 4] = whirlpool_hmac_ctx.ipad.h[ 4]; + tmps[gid].ipad[ 5] = whirlpool_hmac_ctx.ipad.h[ 5]; + tmps[gid].ipad[ 6] = whirlpool_hmac_ctx.ipad.h[ 6]; + tmps[gid].ipad[ 7] = whirlpool_hmac_ctx.ipad.h[ 7]; + tmps[gid].ipad[ 8] = whirlpool_hmac_ctx.ipad.h[ 8]; + tmps[gid].ipad[ 9] = whirlpool_hmac_ctx.ipad.h[ 9]; + tmps[gid].ipad[10] = whirlpool_hmac_ctx.ipad.h[10]; + tmps[gid].ipad[11] = whirlpool_hmac_ctx.ipad.h[11]; + tmps[gid].ipad[12] = whirlpool_hmac_ctx.ipad.h[12]; + tmps[gid].ipad[13] = whirlpool_hmac_ctx.ipad.h[13]; + tmps[gid].ipad[14] = whirlpool_hmac_ctx.ipad.h[14]; + tmps[gid].ipad[15] = whirlpool_hmac_ctx.ipad.h[15]; + + tmps[gid].opad[ 0] = whirlpool_hmac_ctx.opad.h[ 0]; + tmps[gid].opad[ 1] = whirlpool_hmac_ctx.opad.h[ 1]; + tmps[gid].opad[ 2] = whirlpool_hmac_ctx.opad.h[ 2]; + tmps[gid].opad[ 3] = whirlpool_hmac_ctx.opad.h[ 3]; + tmps[gid].opad[ 4] = whirlpool_hmac_ctx.opad.h[ 4]; + tmps[gid].opad[ 5] = whirlpool_hmac_ctx.opad.h[ 5]; + tmps[gid].opad[ 6] = whirlpool_hmac_ctx.opad.h[ 6]; + tmps[gid].opad[ 7] = whirlpool_hmac_ctx.opad.h[ 7]; + tmps[gid].opad[ 8] = whirlpool_hmac_ctx.opad.h[ 8]; + tmps[gid].opad[ 9] = whirlpool_hmac_ctx.opad.h[ 9]; + tmps[gid].opad[10] = whirlpool_hmac_ctx.opad.h[10]; + tmps[gid].opad[11] = whirlpool_hmac_ctx.opad.h[11]; + tmps[gid].opad[12] = whirlpool_hmac_ctx.opad.h[12]; + tmps[gid].opad[13] = whirlpool_hmac_ctx.opad.h[13]; + tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14]; + tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15]; + + whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 32; i += 16, j += 1) + { + whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + whirlpool_hmac_update_64 (&whirlpool_hmac_ctx2, w0, w1, w2, w3, 4); + + whirlpool_hmac_final (&whirlpool_hmac_ctx2); + + tmps[gid].dgst[i + 0] = whirlpool_hmac_ctx2.opad.h[ 0]; + tmps[gid].dgst[i + 1] = whirlpool_hmac_ctx2.opad.h[ 1]; + tmps[gid].dgst[i + 2] = whirlpool_hmac_ctx2.opad.h[ 2]; + tmps[gid].dgst[i + 3] = whirlpool_hmac_ctx2.opad.h[ 3]; + tmps[gid].dgst[i + 4] = whirlpool_hmac_ctx2.opad.h[ 4]; + tmps[gid].dgst[i + 5] = whirlpool_hmac_ctx2.opad.h[ 5]; + tmps[gid].dgst[i + 6] = whirlpool_hmac_ctx2.opad.h[ 6]; + tmps[gid].dgst[i + 7] = whirlpool_hmac_ctx2.opad.h[ 7]; + tmps[gid].dgst[i + 8] = whirlpool_hmac_ctx2.opad.h[ 8]; + tmps[gid].dgst[i + 9] = whirlpool_hmac_ctx2.opad.h[ 9]; + tmps[gid].dgst[i + 10] = whirlpool_hmac_ctx2.opad.h[10]; + tmps[gid].dgst[i + 11] = whirlpool_hmac_ctx2.opad.h[11]; + tmps[gid].dgst[i + 12] = whirlpool_hmac_ctx2.opad.h[12]; + tmps[gid].dgst[i + 13] = whirlpool_hmac_ctx2.opad.h[13]; + tmps[gid].dgst[i + 14] = whirlpool_hmac_ctx2.opad.h[14]; + tmps[gid].dgst[i + 15] = whirlpool_hmac_ctx2.opad.h[15]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + tmps[gid].out[i + 8] = tmps[gid].dgst[i + 8]; + tmps[gid].out[i + 9] = tmps[gid].dgst[i + 9]; + tmps[gid].out[i + 10] = tmps[gid].dgst[i + 10]; + tmps[gid].out[i + 11] = tmps[gid].dgst[i + 11]; + tmps[gid].out[i + 12] = tmps[gid].dgst[i + 12]; + tmps[gid].out[i + 13] = tmps[gid].dgst[i + 13]; + tmps[gid].out[i + 14] = tmps[gid].dgst[i + 14]; + tmps[gid].out[i + 15] = tmps[gid].dgst[i + 15]; + } +} + +__kernel void m13732_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u32x ipad[16]; + u32x opad[16]; + + ipad[ 0] = packv (tmps, ipad, gid, 0); + ipad[ 1] = packv (tmps, ipad, gid, 1); + ipad[ 2] = packv (tmps, ipad, gid, 2); + ipad[ 3] = packv (tmps, ipad, gid, 3); + ipad[ 4] = packv (tmps, ipad, gid, 4); + ipad[ 5] = packv (tmps, ipad, gid, 5); + ipad[ 6] = packv (tmps, ipad, gid, 6); + ipad[ 7] = packv (tmps, ipad, gid, 7); + ipad[ 8] = packv (tmps, ipad, gid, 8); + ipad[ 9] = packv (tmps, ipad, gid, 9); + ipad[10] = packv (tmps, ipad, gid, 10); + ipad[11] = packv (tmps, ipad, gid, 11); + ipad[12] = packv (tmps, ipad, gid, 12); + ipad[13] = packv (tmps, ipad, gid, 13); + ipad[14] = packv (tmps, ipad, gid, 14); + ipad[15] = packv (tmps, ipad, gid, 15); + + opad[ 0] = packv (tmps, opad, gid, 0); + opad[ 1] = packv (tmps, opad, gid, 1); + opad[ 2] = packv (tmps, opad, gid, 2); + opad[ 3] = packv (tmps, opad, gid, 3); + opad[ 4] = packv (tmps, opad, gid, 4); + opad[ 5] = packv (tmps, opad, gid, 5); + opad[ 6] = packv (tmps, opad, gid, 6); + opad[ 7] = packv (tmps, opad, gid, 7); + opad[ 8] = packv (tmps, opad, gid, 8); + opad[ 9] = packv (tmps, opad, gid, 9); + opad[10] = packv (tmps, opad, gid, 10); + opad[11] = packv (tmps, opad, gid, 11); + opad[12] = packv (tmps, opad, gid, 12); + opad[13] = packv (tmps, opad, gid, 13); + opad[14] = packv (tmps, opad, gid, 14); + opad[15] = packv (tmps, opad, gid, 15); + + for (u32 i = 0; i < 32; i += 16) + { + u32x dgst[16]; + u32x out[16]; + + dgst[ 0] = packv (tmps, dgst, gid, i + 0); + dgst[ 1] = packv (tmps, dgst, gid, i + 1); + dgst[ 2] = packv (tmps, dgst, gid, i + 2); + dgst[ 3] = packv (tmps, dgst, gid, i + 3); + dgst[ 4] = packv (tmps, dgst, gid, i + 4); + dgst[ 5] = packv (tmps, dgst, gid, i + 5); + dgst[ 6] = packv (tmps, dgst, gid, i + 6); + dgst[ 7] = packv (tmps, dgst, gid, i + 7); + dgst[ 8] = packv (tmps, dgst, gid, i + 8); + dgst[ 9] = packv (tmps, dgst, gid, i + 9); + dgst[10] = packv (tmps, dgst, gid, i + 10); + dgst[11] = packv (tmps, dgst, gid, i + 11); + dgst[12] = packv (tmps, dgst, gid, i + 12); + dgst[13] = packv (tmps, dgst, gid, i + 13); + dgst[14] = packv (tmps, dgst, gid, i + 14); + dgst[15] = packv (tmps, dgst, gid, i + 15); + + out[ 0] = packv (tmps, out, gid, i + 0); + out[ 1] = packv (tmps, out, gid, i + 1); + out[ 2] = packv (tmps, out, gid, i + 2); + out[ 3] = packv (tmps, out, gid, i + 3); + out[ 4] = packv (tmps, out, gid, i + 4); + out[ 5] = packv (tmps, out, gid, i + 5); + out[ 6] = packv (tmps, out, gid, i + 6); + out[ 7] = packv (tmps, out, gid, i + 7); + out[ 8] = packv (tmps, out, gid, i + 8); + out[ 9] = packv (tmps, out, gid, i + 9); + out[10] = packv (tmps, out, gid, i + 10); + out[11] = packv (tmps, out, gid, i + 11); + out[12] = packv (tmps, out, gid, i + 12); + out[13] = packv (tmps, out, gid, i + 13); + out[14] = packv (tmps, out, gid, i + 14); + out[15] = packv (tmps, out, gid, i + 15); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[ 0]; + w0[1] = dgst[ 1]; + w0[2] = dgst[ 2]; + w0[3] = dgst[ 3]; + w1[0] = dgst[ 4]; + w1[1] = dgst[ 5]; + w1[2] = dgst[ 6]; + w1[3] = dgst[ 7]; + w2[0] = dgst[ 8]; + w2[1] = dgst[ 9]; + w2[2] = dgst[10]; + w2[3] = dgst[11]; + w3[0] = dgst[12]; + w3[1] = dgst[13]; + w3[2] = dgst[14]; + w3[3] = dgst[15]; + + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + + out[ 0] ^= dgst[ 0]; + out[ 1] ^= dgst[ 1]; + out[ 2] ^= dgst[ 2]; + out[ 3] ^= dgst[ 3]; + out[ 4] ^= dgst[ 4]; + out[ 5] ^= dgst[ 5]; + out[ 6] ^= dgst[ 6]; + out[ 7] ^= dgst[ 7]; + out[ 8] ^= dgst[ 8]; + out[ 9] ^= dgst[ 9]; + out[10] ^= dgst[10]; + out[11] ^= dgst[11]; + out[12] ^= dgst[12]; + out[13] ^= dgst[13]; + out[14] ^= dgst[14]; + out[15] ^= dgst[15]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[ 0]; + tmps[gid].pim_key[i + 1] = out[ 1]; + tmps[gid].pim_key[i + 2] = out[ 2]; + tmps[gid].pim_key[i + 3] = out[ 3]; + tmps[gid].pim_key[i + 4] = out[ 4]; + tmps[gid].pim_key[i + 5] = out[ 5]; + tmps[gid].pim_key[i + 6] = out[ 6]; + tmps[gid].pim_key[i + 7] = out[ 7]; + tmps[gid].pim_key[i + 8] = out[ 8]; + tmps[gid].pim_key[i + 9] = out[ 9]; + tmps[gid].pim_key[i + 10] = out[10]; + tmps[gid].pim_key[i + 11] = out[11]; + tmps[gid].pim_key[i + 12] = out[12]; + tmps[gid].pim_key[i + 13] = out[13]; + tmps[gid].pim_key[i + 14] = out[14]; + tmps[gid].pim_key[i + 15] = out[15]; + } + } + + unpackv (tmps, dgst, gid, i + 0, dgst[ 0]); + unpackv (tmps, dgst, gid, i + 1, dgst[ 1]); + unpackv (tmps, dgst, gid, i + 2, dgst[ 2]); + unpackv (tmps, dgst, gid, i + 3, dgst[ 3]); + unpackv (tmps, dgst, gid, i + 4, dgst[ 4]); + unpackv (tmps, dgst, gid, i + 5, dgst[ 5]); + unpackv (tmps, dgst, gid, i + 6, dgst[ 6]); + unpackv (tmps, dgst, gid, i + 7, dgst[ 7]); + unpackv (tmps, dgst, gid, i + 8, dgst[ 8]); + unpackv (tmps, dgst, gid, i + 9, dgst[ 9]); + unpackv (tmps, dgst, gid, i + 10, dgst[10]); + unpackv (tmps, dgst, gid, i + 11, dgst[11]); + unpackv (tmps, dgst, gid, i + 12, dgst[12]); + unpackv (tmps, dgst, gid, i + 13, dgst[13]); + unpackv (tmps, dgst, gid, i + 14, dgst[14]); + unpackv (tmps, dgst, gid, i + 15, dgst[15]); + + unpackv (tmps, out, gid, i + 0, out[ 0]); + unpackv (tmps, out, gid, i + 1, out[ 1]); + unpackv (tmps, out, gid, i + 2, out[ 2]); + unpackv (tmps, out, gid, i + 3, out[ 3]); + unpackv (tmps, out, gid, i + 4, out[ 4]); + unpackv (tmps, out, gid, i + 5, out[ 5]); + unpackv (tmps, out, gid, i + 6, out[ 6]); + unpackv (tmps, out, gid, i + 7, out[ 7]); + unpackv (tmps, out, gid, i + 8, out[ 8]); + unpackv (tmps, out, gid, i + 9, out[ 9]); + unpackv (tmps, out, gid, i + 10, out[10]); + unpackv (tmps, out, gid, i + 11, out[11]); + unpackv (tmps, out, gid, i + 12, out[12]); + unpackv (tmps, out, gid, i + 13, out[13]); + unpackv (tmps, out, gid, i + 14, out[14]); + unpackv (tmps, out, gid, i + 15, out[15]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13732_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13733-pure.cl b/OpenCL/m13733-pure.cl new file mode 100644 index 000000000..affc31f51 --- /dev/null +++ b/OpenCL/m13733-pure.cl @@ -0,0 +1,973 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +//#undef LOCAL_MEM_TYPE +//#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_whirlpool.cl" + +#include "inc_cipher_aes.cl" +#include "inc_cipher_twofish.cl" +#include "inc_cipher_serpent.cl" +#include "inc_cipher_camellia.cl" +#include "inc_cipher_kuznyechik.cl" + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +#include "inc_truecrypt_keyfile.cl" +#include "inc_truecrypt_crc32.cl" +#include "inc_truecrypt_xts.cl" +#include "inc_veracrypt_xts.cl" + +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + key3[0] = swap32_S (key[16]); + key3[1] = swap32_S (key[17]); + key3[2] = swap32_S (key[18]); + key3[3] = swap32_S (key[19]); + key3[4] = swap32_S (key[20]); + key3[5] = swap32_S (key[21]); + key3[6] = swap32_S (key[22]); + key3[7] = swap32_S (key[23]); + key4[0] = swap32_S (key[24]); + key4[1] = swap32_S (key[25]); + key4[2] = swap32_S (key[26]); + key4[3] = swap32_S (key[27]); + key4[4] = swap32_S (key[28]); + key4[5] = swap32_S (key[29]); + key4[6] = swap32_S (key[30]); + key4[7] = swap32_S (key[31]); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1536 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + u32 key5[8]; + u32 key6[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + key3[0] = swap32_S (key[16]); + key3[1] = swap32_S (key[17]); + key3[2] = swap32_S (key[18]); + key3[3] = swap32_S (key[19]); + key3[4] = swap32_S (key[20]); + key3[5] = swap32_S (key[21]); + key3[6] = swap32_S (key[22]); + key3[7] = swap32_S (key[23]); + key4[0] = swap32_S (key[24]); + key4[1] = swap32_S (key[25]); + key4[2] = swap32_S (key[26]); + key4[3] = swap32_S (key[27]); + key4[4] = swap32_S (key[28]); + key4[5] = swap32_S (key[29]); + key4[6] = swap32_S (key[30]); + key4[7] = swap32_S (key[31]); + key5[0] = swap32_S (key[32]); + key5[1] = swap32_S (key[33]); + key5[2] = swap32_S (key[34]); + key5[3] = swap32_S (key[35]); + key5[4] = swap32_S (key[36]); + key5[5] = swap32_S (key[37]); + key5[6] = swap32_S (key[38]); + key5[7] = swap32_S (key[39]); + key6[0] = swap32_S (key[40]); + key6[1] = swap32_S (key[41]); + key6[2] = swap32_S (key[42]); + key6[3] = swap32_S (key[43]); + key6[4] = swap32_S (key[44]); + key6[5] = swap32_S (key[45]); + key6[6] = swap32_S (key[46]); + key6[7] = swap32_S (key[47]); + + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_serpent_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6) == 1) return 0; + + return -1; +} + +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +{ + digest[ 0] = ipad[ 0]; + digest[ 1] = ipad[ 1]; + digest[ 2] = ipad[ 2]; + digest[ 3] = ipad[ 3]; + digest[ 4] = ipad[ 4]; + digest[ 5] = ipad[ 5]; + digest[ 6] = ipad[ 6]; + digest[ 7] = ipad[ 7]; + digest[ 8] = ipad[ 8]; + digest[ 9] = ipad[ 9]; + digest[10] = ipad[10]; + digest[11] = ipad[11]; + digest[12] = ipad[12]; + digest[13] = ipad[13]; + digest[14] = ipad[14]; + digest[15] = ipad[15]; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 64) * 8; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = digest[ 0]; + w0[1] = digest[ 1]; + w0[2] = digest[ 2]; + w0[3] = digest[ 3]; + w1[0] = digest[ 4]; + w1[1] = digest[ 5]; + w1[2] = digest[ 6]; + w1[3] = digest[ 7]; + w2[0] = digest[ 8]; + w2[1] = digest[ 9]; + w2[2] = digest[10]; + w2[3] = digest[11]; + w3[0] = digest[12]; + w3[1] = digest[13]; + w3[2] = digest[14]; + w3[3] = digest[15]; + + digest[ 0] = opad[ 0]; + digest[ 1] = opad[ 1]; + digest[ 2] = opad[ 2]; + digest[ 3] = opad[ 3]; + digest[ 4] = opad[ 4]; + digest[ 5] = opad[ 5]; + digest[ 6] = opad[ 6]; + digest[ 7] = opad[ 7]; + digest[ 8] = opad[ 8]; + digest[ 9] = opad[ 9]; + digest[10] = opad[10]; + digest[11] = opad[11]; + digest[12] = opad[12]; + digest[13] = opad[13]; + digest[14] = opad[14]; + digest[15] = opad[15]; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 64) * 8; + + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); +} + +__kernel void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * keyboard layout shared + */ + + const int keyboard_layout_mapping_cnt = esalt_bufs[digests_offset].keyboard_layout_mapping_cnt; + + __local keyboard_layout_mapping_t s_keyboard_layout_mapping_buf[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len; + + execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + + w0[0] = u8add (w0[0], esalt_bufs[digests_offset].keyfile_buf[ 0]); + w0[1] = u8add (w0[1], esalt_bufs[digests_offset].keyfile_buf[ 1]); + w0[2] = u8add (w0[2], esalt_bufs[digests_offset].keyfile_buf[ 2]); + w0[3] = u8add (w0[3], esalt_bufs[digests_offset].keyfile_buf[ 3]); + w1[0] = u8add (w1[0], esalt_bufs[digests_offset].keyfile_buf[ 4]); + w1[1] = u8add (w1[1], esalt_bufs[digests_offset].keyfile_buf[ 5]); + w1[2] = u8add (w1[2], esalt_bufs[digests_offset].keyfile_buf[ 6]); + w1[3] = u8add (w1[3], esalt_bufs[digests_offset].keyfile_buf[ 7]); + w2[0] = u8add (w2[0], esalt_bufs[digests_offset].keyfile_buf[ 8]); + w2[1] = u8add (w2[1], esalt_bufs[digests_offset].keyfile_buf[ 9]); + w2[2] = u8add (w2[2], esalt_bufs[digests_offset].keyfile_buf[10]); + w2[3] = u8add (w2[3], esalt_bufs[digests_offset].keyfile_buf[11]); + w3[0] = u8add (w3[0], esalt_bufs[digests_offset].keyfile_buf[12]); + w3[1] = u8add (w3[1], esalt_bufs[digests_offset].keyfile_buf[13]); + w3[2] = u8add (w3[2], esalt_bufs[digests_offset].keyfile_buf[14]); + w3[3] = u8add (w3[3], esalt_bufs[digests_offset].keyfile_buf[15]); + + w0[0] = swap32_S (w0[0]); + w0[1] = swap32_S (w0[1]); + w0[2] = swap32_S (w0[2]); + w0[3] = swap32_S (w0[3]); + w1[0] = swap32_S (w1[0]); + w1[1] = swap32_S (w1[1]); + w1[2] = swap32_S (w1[2]); + w1[3] = swap32_S (w1[3]); + w2[0] = swap32_S (w2[0]); + w2[1] = swap32_S (w2[1]); + w2[2] = swap32_S (w2[2]); + w2[3] = swap32_S (w2[3]); + w3[0] = swap32_S (w3[0]); + w3[1] = swap32_S (w3[1]); + w3[2] = swap32_S (w3[2]); + w3[3] = swap32_S (w3[3]); + + whirlpool_hmac_ctx_t whirlpool_hmac_ctx; + + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + + tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; + tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; + tmps[gid].ipad[ 2] = whirlpool_hmac_ctx.ipad.h[ 2]; + tmps[gid].ipad[ 3] = whirlpool_hmac_ctx.ipad.h[ 3]; + tmps[gid].ipad[ 4] = whirlpool_hmac_ctx.ipad.h[ 4]; + tmps[gid].ipad[ 5] = whirlpool_hmac_ctx.ipad.h[ 5]; + tmps[gid].ipad[ 6] = whirlpool_hmac_ctx.ipad.h[ 6]; + tmps[gid].ipad[ 7] = whirlpool_hmac_ctx.ipad.h[ 7]; + tmps[gid].ipad[ 8] = whirlpool_hmac_ctx.ipad.h[ 8]; + tmps[gid].ipad[ 9] = whirlpool_hmac_ctx.ipad.h[ 9]; + tmps[gid].ipad[10] = whirlpool_hmac_ctx.ipad.h[10]; + tmps[gid].ipad[11] = whirlpool_hmac_ctx.ipad.h[11]; + tmps[gid].ipad[12] = whirlpool_hmac_ctx.ipad.h[12]; + tmps[gid].ipad[13] = whirlpool_hmac_ctx.ipad.h[13]; + tmps[gid].ipad[14] = whirlpool_hmac_ctx.ipad.h[14]; + tmps[gid].ipad[15] = whirlpool_hmac_ctx.ipad.h[15]; + + tmps[gid].opad[ 0] = whirlpool_hmac_ctx.opad.h[ 0]; + tmps[gid].opad[ 1] = whirlpool_hmac_ctx.opad.h[ 1]; + tmps[gid].opad[ 2] = whirlpool_hmac_ctx.opad.h[ 2]; + tmps[gid].opad[ 3] = whirlpool_hmac_ctx.opad.h[ 3]; + tmps[gid].opad[ 4] = whirlpool_hmac_ctx.opad.h[ 4]; + tmps[gid].opad[ 5] = whirlpool_hmac_ctx.opad.h[ 5]; + tmps[gid].opad[ 6] = whirlpool_hmac_ctx.opad.h[ 6]; + tmps[gid].opad[ 7] = whirlpool_hmac_ctx.opad.h[ 7]; + tmps[gid].opad[ 8] = whirlpool_hmac_ctx.opad.h[ 8]; + tmps[gid].opad[ 9] = whirlpool_hmac_ctx.opad.h[ 9]; + tmps[gid].opad[10] = whirlpool_hmac_ctx.opad.h[10]; + tmps[gid].opad[11] = whirlpool_hmac_ctx.opad.h[11]; + tmps[gid].opad[12] = whirlpool_hmac_ctx.opad.h[12]; + tmps[gid].opad[13] = whirlpool_hmac_ctx.opad.h[13]; + tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14]; + tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15]; + + whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, esalt_bufs[digests_offset].salt_buf, 64); + + for (u32 i = 0, j = 1; i < 48; i += 16, j += 1) + { + whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + whirlpool_hmac_update_64 (&whirlpool_hmac_ctx2, w0, w1, w2, w3, 4); + + whirlpool_hmac_final (&whirlpool_hmac_ctx2); + + tmps[gid].dgst[i + 0] = whirlpool_hmac_ctx2.opad.h[ 0]; + tmps[gid].dgst[i + 1] = whirlpool_hmac_ctx2.opad.h[ 1]; + tmps[gid].dgst[i + 2] = whirlpool_hmac_ctx2.opad.h[ 2]; + tmps[gid].dgst[i + 3] = whirlpool_hmac_ctx2.opad.h[ 3]; + tmps[gid].dgst[i + 4] = whirlpool_hmac_ctx2.opad.h[ 4]; + tmps[gid].dgst[i + 5] = whirlpool_hmac_ctx2.opad.h[ 5]; + tmps[gid].dgst[i + 6] = whirlpool_hmac_ctx2.opad.h[ 6]; + tmps[gid].dgst[i + 7] = whirlpool_hmac_ctx2.opad.h[ 7]; + tmps[gid].dgst[i + 8] = whirlpool_hmac_ctx2.opad.h[ 8]; + tmps[gid].dgst[i + 9] = whirlpool_hmac_ctx2.opad.h[ 9]; + tmps[gid].dgst[i + 10] = whirlpool_hmac_ctx2.opad.h[10]; + tmps[gid].dgst[i + 11] = whirlpool_hmac_ctx2.opad.h[11]; + tmps[gid].dgst[i + 12] = whirlpool_hmac_ctx2.opad.h[12]; + tmps[gid].dgst[i + 13] = whirlpool_hmac_ctx2.opad.h[13]; + tmps[gid].dgst[i + 14] = whirlpool_hmac_ctx2.opad.h[14]; + tmps[gid].dgst[i + 15] = whirlpool_hmac_ctx2.opad.h[15]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + tmps[gid].out[i + 8] = tmps[gid].dgst[i + 8]; + tmps[gid].out[i + 9] = tmps[gid].dgst[i + 9]; + tmps[gid].out[i + 10] = tmps[gid].dgst[i + 10]; + tmps[gid].out[i + 11] = tmps[gid].dgst[i + 11]; + tmps[gid].out[i + 12] = tmps[gid].dgst[i + 12]; + tmps[gid].out[i + 13] = tmps[gid].dgst[i + 13]; + tmps[gid].out[i + 14] = tmps[gid].dgst[i + 14]; + tmps[gid].out[i + 15] = tmps[gid].dgst[i + 15]; + } +} + +__kernel void m13733_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here + + u32x ipad[16]; + u32x opad[16]; + + ipad[ 0] = packv (tmps, ipad, gid, 0); + ipad[ 1] = packv (tmps, ipad, gid, 1); + ipad[ 2] = packv (tmps, ipad, gid, 2); + ipad[ 3] = packv (tmps, ipad, gid, 3); + ipad[ 4] = packv (tmps, ipad, gid, 4); + ipad[ 5] = packv (tmps, ipad, gid, 5); + ipad[ 6] = packv (tmps, ipad, gid, 6); + ipad[ 7] = packv (tmps, ipad, gid, 7); + ipad[ 8] = packv (tmps, ipad, gid, 8); + ipad[ 9] = packv (tmps, ipad, gid, 9); + ipad[10] = packv (tmps, ipad, gid, 10); + ipad[11] = packv (tmps, ipad, gid, 11); + ipad[12] = packv (tmps, ipad, gid, 12); + ipad[13] = packv (tmps, ipad, gid, 13); + ipad[14] = packv (tmps, ipad, gid, 14); + ipad[15] = packv (tmps, ipad, gid, 15); + + opad[ 0] = packv (tmps, opad, gid, 0); + opad[ 1] = packv (tmps, opad, gid, 1); + opad[ 2] = packv (tmps, opad, gid, 2); + opad[ 3] = packv (tmps, opad, gid, 3); + opad[ 4] = packv (tmps, opad, gid, 4); + opad[ 5] = packv (tmps, opad, gid, 5); + opad[ 6] = packv (tmps, opad, gid, 6); + opad[ 7] = packv (tmps, opad, gid, 7); + opad[ 8] = packv (tmps, opad, gid, 8); + opad[ 9] = packv (tmps, opad, gid, 9); + opad[10] = packv (tmps, opad, gid, 10); + opad[11] = packv (tmps, opad, gid, 11); + opad[12] = packv (tmps, opad, gid, 12); + opad[13] = packv (tmps, opad, gid, 13); + opad[14] = packv (tmps, opad, gid, 14); + opad[15] = packv (tmps, opad, gid, 15); + + for (u32 i = 0; i < 48; i += 16) + { + u32x dgst[16]; + u32x out[16]; + + dgst[ 0] = packv (tmps, dgst, gid, i + 0); + dgst[ 1] = packv (tmps, dgst, gid, i + 1); + dgst[ 2] = packv (tmps, dgst, gid, i + 2); + dgst[ 3] = packv (tmps, dgst, gid, i + 3); + dgst[ 4] = packv (tmps, dgst, gid, i + 4); + dgst[ 5] = packv (tmps, dgst, gid, i + 5); + dgst[ 6] = packv (tmps, dgst, gid, i + 6); + dgst[ 7] = packv (tmps, dgst, gid, i + 7); + dgst[ 8] = packv (tmps, dgst, gid, i + 8); + dgst[ 9] = packv (tmps, dgst, gid, i + 9); + dgst[10] = packv (tmps, dgst, gid, i + 10); + dgst[11] = packv (tmps, dgst, gid, i + 11); + dgst[12] = packv (tmps, dgst, gid, i + 12); + dgst[13] = packv (tmps, dgst, gid, i + 13); + dgst[14] = packv (tmps, dgst, gid, i + 14); + dgst[15] = packv (tmps, dgst, gid, i + 15); + + out[ 0] = packv (tmps, out, gid, i + 0); + out[ 1] = packv (tmps, out, gid, i + 1); + out[ 2] = packv (tmps, out, gid, i + 2); + out[ 3] = packv (tmps, out, gid, i + 3); + out[ 4] = packv (tmps, out, gid, i + 4); + out[ 5] = packv (tmps, out, gid, i + 5); + out[ 6] = packv (tmps, out, gid, i + 6); + out[ 7] = packv (tmps, out, gid, i + 7); + out[ 8] = packv (tmps, out, gid, i + 8); + out[ 9] = packv (tmps, out, gid, i + 9); + out[10] = packv (tmps, out, gid, i + 10); + out[11] = packv (tmps, out, gid, i + 11); + out[12] = packv (tmps, out, gid, i + 12); + out[13] = packv (tmps, out, gid, i + 13); + out[14] = packv (tmps, out, gid, i + 14); + out[15] = packv (tmps, out, gid, i + 15); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[ 0]; + w0[1] = dgst[ 1]; + w0[2] = dgst[ 2]; + w0[3] = dgst[ 3]; + w1[0] = dgst[ 4]; + w1[1] = dgst[ 5]; + w1[2] = dgst[ 6]; + w1[3] = dgst[ 7]; + w2[0] = dgst[ 8]; + w2[1] = dgst[ 9]; + w2[2] = dgst[10]; + w2[3] = dgst[11]; + w3[0] = dgst[12]; + w3[1] = dgst[13]; + w3[2] = dgst[14]; + w3[3] = dgst[15]; + + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + + out[ 0] ^= dgst[ 0]; + out[ 1] ^= dgst[ 1]; + out[ 2] ^= dgst[ 2]; + out[ 3] ^= dgst[ 3]; + out[ 4] ^= dgst[ 4]; + out[ 5] ^= dgst[ 5]; + out[ 6] ^= dgst[ 6]; + out[ 7] ^= dgst[ 7]; + out[ 8] ^= dgst[ 8]; + out[ 9] ^= dgst[ 9]; + out[10] ^= dgst[10]; + out[11] ^= dgst[11]; + out[12] ^= dgst[12]; + out[13] ^= dgst[13]; + out[14] ^= dgst[14]; + out[15] ^= dgst[15]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[ 0]; + tmps[gid].pim_key[i + 1] = out[ 1]; + tmps[gid].pim_key[i + 2] = out[ 2]; + tmps[gid].pim_key[i + 3] = out[ 3]; + tmps[gid].pim_key[i + 4] = out[ 4]; + tmps[gid].pim_key[i + 5] = out[ 5]; + tmps[gid].pim_key[i + 6] = out[ 6]; + tmps[gid].pim_key[i + 7] = out[ 7]; + tmps[gid].pim_key[i + 8] = out[ 8]; + tmps[gid].pim_key[i + 9] = out[ 9]; + tmps[gid].pim_key[i + 10] = out[10]; + tmps[gid].pim_key[i + 11] = out[11]; + tmps[gid].pim_key[i + 12] = out[12]; + tmps[gid].pim_key[i + 13] = out[13]; + tmps[gid].pim_key[i + 14] = out[14]; + tmps[gid].pim_key[i + 15] = out[15]; + } + } + + unpackv (tmps, dgst, gid, i + 0, dgst[ 0]); + unpackv (tmps, dgst, gid, i + 1, dgst[ 1]); + unpackv (tmps, dgst, gid, i + 2, dgst[ 2]); + unpackv (tmps, dgst, gid, i + 3, dgst[ 3]); + unpackv (tmps, dgst, gid, i + 4, dgst[ 4]); + unpackv (tmps, dgst, gid, i + 5, dgst[ 5]); + unpackv (tmps, dgst, gid, i + 6, dgst[ 6]); + unpackv (tmps, dgst, gid, i + 7, dgst[ 7]); + unpackv (tmps, dgst, gid, i + 8, dgst[ 8]); + unpackv (tmps, dgst, gid, i + 9, dgst[ 9]); + unpackv (tmps, dgst, gid, i + 10, dgst[10]); + unpackv (tmps, dgst, gid, i + 11, dgst[11]); + unpackv (tmps, dgst, gid, i + 12, dgst[12]); + unpackv (tmps, dgst, gid, i + 13, dgst[13]); + unpackv (tmps, dgst, gid, i + 14, dgst[14]); + unpackv (tmps, dgst, gid, i + 15, dgst[15]); + + unpackv (tmps, out, gid, i + 0, out[ 0]); + unpackv (tmps, out, gid, i + 1, out[ 1]); + unpackv (tmps, out, gid, i + 2, out[ 2]); + unpackv (tmps, out, gid, i + 3, out[ 3]); + unpackv (tmps, out, gid, i + 4, out[ 4]); + unpackv (tmps, out, gid, i + 5, out[ 5]); + unpackv (tmps, out, gid, i + 6, out[ 6]); + unpackv (tmps, out, gid, i + 7, out[ 7]); + unpackv (tmps, out, gid, i + 8, out[ 8]); + unpackv (tmps, out, gid, i + 9, out[ 9]); + unpackv (tmps, out, gid, i + 10, out[10]); + unpackv (tmps, out, gid, i + 11, out[11]); + unpackv (tmps, out, gid, i + 12, out[12]); + unpackv (tmps, out, gid, i + 13, out[13]); + unpackv (tmps, out, gid, i + 14, out[14]); + unpackv (tmps, out, gid, i + 15, out[15]); + } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; +} + +__kernel void m13733_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + __local u32 s_Ch[8][256]; + __local u32 s_Cl[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_Ch[0][i] = Ch[0][i]; + s_Ch[1][i] = Ch[1][i]; + s_Ch[2][i] = Ch[2][i]; + s_Ch[3][i] = Ch[3][i]; + s_Ch[4][i] = Ch[4][i]; + s_Ch[5][i] = Ch[5][i]; + s_Ch[6][i] = Ch[6][i]; + s_Ch[7][i] = Ch[7][i]; + + s_Cl[0][i] = Cl[0][i]; + s_Cl[1][i] = Cl[1][i]; + s_Cl[2][i] = Cl[2][i]; + s_Cl[3][i] = Cl[3][i]; + s_Cl[4][i] = Cl[4][i]; + s_Cl[5][i] = Cl[5][i]; + s_Cl[6][i] = Cl[6][i]; + s_Cl[7][i] = Cl[7][i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a (*s_Ch)[256] = Ch; + __constant u32a (*s_Cl)[256] = Cl; + + #endif + + if (gid >= gid_max) return; + + if (tmps[gid].pim) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); + } + } + else + { + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + + if (check_header_1536 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } + } + } +} diff --git a/OpenCL/m13751-pure.cl b/OpenCL/m13751-pure.cl index 96c4ee0f9..a5448a248 100644 --- a/OpenCL/m13751-pure.cl +++ b/OpenCL/m13751-pure.cl @@ -3,7 +3,10 @@ * License.....: MIT */ -#define NEW_SIMD_CODE +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL #include "inc_vendor.cl" #include "inc_hash_constants.h" @@ -19,11 +22,71 @@ #include "inc_cipher_camellia.cl" #include "inc_cipher_kuznyechik.cl" +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -66,7 +129,7 @@ DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *i sha256_transform_vector (w0, w1, w2, w3, digest); } -__kernel void m13751_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13751_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -222,11 +285,124 @@ __kernel void m13751_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) } } -__kernel void m13751_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13751_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if ((gid * VECT_SIZE) >= gid_max) return; + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + /* this feels harder to read than the loop variant + const int j_start = 1 + loop_pos + 0; + const int j_stop = 1 + loop_pos + loop_cnt; + + const int pim_start = j_start / 1000; + const int pim_stop = j_stop / 1000; + const int at_start = j_start - (pim_start * 1000); + const int at_stop = j_stop - (pim_stop * 1000); + + const int pim_start1 = pim_start + 1; + + if ((pim_start1 >= esalt_bufs[digests_offset].pim_start) && (pim_start1 <= esalt_bufs[digests_offset].pim_stop)) + { + if (pim_start == pim_stop) + { + if (at_stop == 999) + { + pim = pim_start1; + pim_at = loop_cnt; + } + } + else + { + pim = pim_start1; + pim_at = 999 - at_start; + } + } + */ + + // irregular pbkdf2 from here u32x ipad[8]; u32x opad[8]; @@ -306,6 +482,20 @@ __kernel void m13751_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) out[5] ^= dgst[5]; out[6] ^= dgst[6]; out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } } unpackv (tmps, dgst, gid, i + 0, dgst[0]); @@ -326,9 +516,13 @@ __kernel void m13751_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) unpackv (tmps, out, gid, i + 6, out[6]); unpackv (tmps, out, gid, i + 7, out[7]); } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; } -__kernel void m13751_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13751_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -387,65 +581,21 @@ __kernel void m13751_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) if (gid >= gid_max) return; - u32 ukey1[8]; - - ukey1[0] = swap32_S (tmps[gid].out[ 0]); - ukey1[1] = swap32_S (tmps[gid].out[ 1]); - ukey1[2] = swap32_S (tmps[gid].out[ 2]); - ukey1[3] = swap32_S (tmps[gid].out[ 3]); - ukey1[4] = swap32_S (tmps[gid].out[ 4]); - ukey1[5] = swap32_S (tmps[gid].out[ 5]); - ukey1[6] = swap32_S (tmps[gid].out[ 6]); - ukey1[7] = swap32_S (tmps[gid].out[ 7]); - - u32 ukey2[8]; - - ukey2[0] = swap32_S (tmps[gid].out[ 8]); - ukey2[1] = swap32_S (tmps[gid].out[ 9]); - ukey2[2] = swap32_S (tmps[gid].out[10]); - ukey2[3] = swap32_S (tmps[gid].out[11]); - ukey2[4] = swap32_S (tmps[gid].out[12]); - ukey2[5] = swap32_S (tmps[gid].out[13]); - ukey2[6] = swap32_S (tmps[gid].out[14]); - ukey2[7] = swap32_S (tmps[gid].out[15]); - - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (tmps[gid].pim) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); } } - - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + else { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } } } diff --git a/OpenCL/m13752-pure.cl b/OpenCL/m13752-pure.cl index 9c251821b..6996d48c1 100644 --- a/OpenCL/m13752-pure.cl +++ b/OpenCL/m13752-pure.cl @@ -3,7 +3,10 @@ * License.....: MIT */ -#define NEW_SIMD_CODE +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL #include "inc_vendor.cl" #include "inc_hash_constants.h" @@ -19,11 +22,122 @@ #include "inc_cipher_camellia.cl" #include "inc_cipher_kuznyechik.cl" +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + key3[0] = swap32_S (key[16]); + key3[1] = swap32_S (key[17]); + key3[2] = swap32_S (key[18]); + key3[3] = swap32_S (key[19]); + key3[4] = swap32_S (key[20]); + key3[5] = swap32_S (key[21]); + key3[6] = swap32_S (key[22]); + key3[7] = swap32_S (key[23]); + key4[0] = swap32_S (key[24]); + key4[1] = swap32_S (key[25]); + key4[2] = swap32_S (key[26]); + key4[3] = swap32_S (key[27]); + key4[4] = swap32_S (key[28]); + key4[5] = swap32_S (key[29]); + key4[6] = swap32_S (key[30]); + key4[7] = swap32_S (key[31]); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -66,7 +180,7 @@ DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *i sha256_transform_vector (w0, w1, w2, w3, digest); } -__kernel void m13752_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13752_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -222,11 +336,95 @@ __kernel void m13752_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) } } -__kernel void m13752_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13752_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if ((gid * VECT_SIZE) >= gid_max) return; + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here u32x ipad[8]; u32x opad[8]; @@ -306,6 +504,20 @@ __kernel void m13752_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) out[5] ^= dgst[5]; out[6] ^= dgst[6]; out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } } unpackv (tmps, dgst, gid, i + 0, dgst[0]); @@ -326,9 +538,14 @@ __kernel void m13752_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) unpackv (tmps, out, gid, i + 6, out[6]); unpackv (tmps, out, gid, i + 7, out[7]); } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; } -__kernel void m13752_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13752_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -387,143 +604,29 @@ __kernel void m13752_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) if (gid >= gid_max) return; - u32 ukey1[8]; - - ukey1[0] = swap32_S (tmps[gid].out[ 0]); - ukey1[1] = swap32_S (tmps[gid].out[ 1]); - ukey1[2] = swap32_S (tmps[gid].out[ 2]); - ukey1[3] = swap32_S (tmps[gid].out[ 3]); - ukey1[4] = swap32_S (tmps[gid].out[ 4]); - ukey1[5] = swap32_S (tmps[gid].out[ 5]); - ukey1[6] = swap32_S (tmps[gid].out[ 6]); - ukey1[7] = swap32_S (tmps[gid].out[ 7]); - - u32 ukey2[8]; - - ukey2[0] = swap32_S (tmps[gid].out[ 8]); - ukey2[1] = swap32_S (tmps[gid].out[ 9]); - ukey2[2] = swap32_S (tmps[gid].out[10]); - ukey2[3] = swap32_S (tmps[gid].out[11]); - ukey2[4] = swap32_S (tmps[gid].out[12]); - ukey2[5] = swap32_S (tmps[gid].out[13]); - ukey2[6] = swap32_S (tmps[gid].out[14]); - ukey2[7] = swap32_S (tmps[gid].out[15]); - - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (tmps[gid].pim) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); } } - - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + else { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } - } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - u32 ukey3[8]; - - ukey3[0] = swap32_S (tmps[gid].out[16]); - ukey3[1] = swap32_S (tmps[gid].out[17]); - ukey3[2] = swap32_S (tmps[gid].out[18]); - ukey3[3] = swap32_S (tmps[gid].out[19]); - ukey3[4] = swap32_S (tmps[gid].out[20]); - ukey3[5] = swap32_S (tmps[gid].out[21]); - ukey3[6] = swap32_S (tmps[gid].out[22]); - ukey3[7] = swap32_S (tmps[gid].out[23]); - - u32 ukey4[8]; - - ukey4[0] = swap32_S (tmps[gid].out[24]); - ukey4[1] = swap32_S (tmps[gid].out[25]); - ukey4[2] = swap32_S (tmps[gid].out[26]); - ukey4[3] = swap32_S (tmps[gid].out[27]); - ukey4[4] = swap32_S (tmps[gid].out[28]); - ukey4[5] = swap32_S (tmps[gid].out[29]); - ukey4[6] = swap32_S (tmps[gid].out[30]); - ukey4[7] = swap32_S (tmps[gid].out[31]); - - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } } } diff --git a/OpenCL/m13753-pure.cl b/OpenCL/m13753-pure.cl index 152556f19..5f77f3a56 100644 --- a/OpenCL/m13753-pure.cl +++ b/OpenCL/m13753-pure.cl @@ -3,7 +3,10 @@ * License.....: MIT */ -#define NEW_SIMD_CODE +//#define NEW_SIMD_CODE + +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL #include "inc_vendor.cl" #include "inc_hash_constants.h" @@ -19,11 +22,187 @@ #include "inc_cipher_camellia.cl" #include "inc_cipher_kuznyechik.cl" +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +typedef struct vc_tmp +{ + u32 ipad[16]; + u32 opad[16]; + + u32 dgst[64]; + u32 out[64]; + + u32 pim_key[64]; + int pim; // marker for cracked + +} vc_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + key3[0] = swap32_S (key[16]); + key3[1] = swap32_S (key[17]); + key3[2] = swap32_S (key[18]); + key3[3] = swap32_S (key[19]); + key3[4] = swap32_S (key[20]); + key3[5] = swap32_S (key[21]); + key3[6] = swap32_S (key[22]); + key3[7] = swap32_S (key[23]); + key4[0] = swap32_S (key[24]); + key4[1] = swap32_S (key[25]); + key4[2] = swap32_S (key[26]); + key4[3] = swap32_S (key[27]); + key4[4] = swap32_S (key[28]); + key4[5] = swap32_S (key[29]); + key4[6] = swap32_S (key[30]); + key4[7] = swap32_S (key[31]); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1536 (__global const vc_t *esalt_bufs, __global u32 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + u32 key5[8]; + u32 key6[8]; + + key1[0] = swap32_S (key[ 0]); + key1[1] = swap32_S (key[ 1]); + key1[2] = swap32_S (key[ 2]); + key1[3] = swap32_S (key[ 3]); + key1[4] = swap32_S (key[ 4]); + key1[5] = swap32_S (key[ 5]); + key1[6] = swap32_S (key[ 6]); + key1[7] = swap32_S (key[ 7]); + key2[0] = swap32_S (key[ 8]); + key2[1] = swap32_S (key[ 9]); + key2[2] = swap32_S (key[10]); + key2[3] = swap32_S (key[11]); + key2[4] = swap32_S (key[12]); + key2[5] = swap32_S (key[13]); + key2[6] = swap32_S (key[14]); + key2[7] = swap32_S (key[15]); + key3[0] = swap32_S (key[16]); + key3[1] = swap32_S (key[17]); + key3[2] = swap32_S (key[18]); + key3[3] = swap32_S (key[19]); + key3[4] = swap32_S (key[20]); + key3[5] = swap32_S (key[21]); + key3[6] = swap32_S (key[22]); + key3[7] = swap32_S (key[23]); + key4[0] = swap32_S (key[24]); + key4[1] = swap32_S (key[25]); + key4[2] = swap32_S (key[26]); + key4[3] = swap32_S (key[27]); + key4[4] = swap32_S (key[28]); + key4[5] = swap32_S (key[29]); + key4[6] = swap32_S (key[30]); + key4[7] = swap32_S (key[31]); + key5[0] = swap32_S (key[32]); + key5[1] = swap32_S (key[33]); + key5[2] = swap32_S (key[34]); + key5[3] = swap32_S (key[35]); + key5[4] = swap32_S (key[36]); + key5[5] = swap32_S (key[37]); + key5[6] = swap32_S (key[38]); + key5[7] = swap32_S (key[39]); + key6[0] = swap32_S (key[40]); + key6[1] = swap32_S (key[41]); + key6[2] = swap32_S (key[42]); + key6[3] = swap32_S (key[43]); + key6[4] = swap32_S (key[44]); + key6[5] = swap32_S (key[45]); + key6[6] = swap32_S (key[46]); + key6[7] = swap32_S (key[47]); + + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_serpent_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6) == 1) return 0; + + return -1; +} + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -66,7 +245,7 @@ DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *i sha256_transform_vector (w0, w1, w2, w3, digest); } -__kernel void m13753_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13753_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -222,11 +401,95 @@ __kernel void m13753_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) } } -__kernel void m13753_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13753_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if ((gid * VECT_SIZE) >= gid_max) return; + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here u32x ipad[8]; u32x opad[8]; @@ -306,6 +569,20 @@ __kernel void m13753_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) out[5] ^= dgst[5]; out[6] ^= dgst[6]; out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } } unpackv (tmps, dgst, gid, i + 0, dgst[0]); @@ -326,9 +603,15 @@ __kernel void m13753_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) unpackv (tmps, out, gid, i + 6, out[6]); unpackv (tmps, out, gid, i + 7, out[7]); } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; } -__kernel void m13753_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) +__kernel void m13753_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -387,189 +670,37 @@ __kernel void m13753_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) if (gid >= gid_max) return; - u32 ukey1[8]; - - ukey1[0] = swap32_S (tmps[gid].out[ 0]); - ukey1[1] = swap32_S (tmps[gid].out[ 1]); - ukey1[2] = swap32_S (tmps[gid].out[ 2]); - ukey1[3] = swap32_S (tmps[gid].out[ 3]); - ukey1[4] = swap32_S (tmps[gid].out[ 4]); - ukey1[5] = swap32_S (tmps[gid].out[ 5]); - ukey1[6] = swap32_S (tmps[gid].out[ 6]); - ukey1[7] = swap32_S (tmps[gid].out[ 7]); - - u32 ukey2[8]; - - ukey2[0] = swap32_S (tmps[gid].out[ 8]); - ukey2[1] = swap32_S (tmps[gid].out[ 9]); - ukey2[2] = swap32_S (tmps[gid].out[10]); - ukey2[3] = swap32_S (tmps[gid].out[11]); - ukey2[4] = swap32_S (tmps[gid].out[12]); - ukey2[5] = swap32_S (tmps[gid].out[13]); - ukey2[6] = swap32_S (tmps[gid].out[14]); - ukey2[7] = swap32_S (tmps[gid].out[15]); - - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (tmps[gid].pim) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); } } - - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + else { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } - } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } - } - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_1536 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - u32 ukey3[8]; - - ukey3[0] = swap32_S (tmps[gid].out[16]); - ukey3[1] = swap32_S (tmps[gid].out[17]); - ukey3[2] = swap32_S (tmps[gid].out[18]); - ukey3[3] = swap32_S (tmps[gid].out[19]); - ukey3[4] = swap32_S (tmps[gid].out[20]); - ukey3[5] = swap32_S (tmps[gid].out[21]); - ukey3[6] = swap32_S (tmps[gid].out[22]); - ukey3[7] = swap32_S (tmps[gid].out[23]); - - u32 ukey4[8]; - - ukey4[0] = swap32_S (tmps[gid].out[24]); - ukey4[1] = swap32_S (tmps[gid].out[25]); - ukey4[2] = swap32_S (tmps[gid].out[26]); - ukey4[3] = swap32_S (tmps[gid].out[27]); - ukey4[4] = swap32_S (tmps[gid].out[28]); - ukey4[5] = swap32_S (tmps[gid].out[29]); - ukey4[6] = swap32_S (tmps[gid].out[30]); - ukey4[7] = swap32_S (tmps[gid].out[31]); - - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - u32 ukey5[8]; - - ukey5[0] = swap32_S (tmps[gid].out[32]); - ukey5[1] = swap32_S (tmps[gid].out[33]); - ukey5[2] = swap32_S (tmps[gid].out[34]); - ukey5[3] = swap32_S (tmps[gid].out[35]); - ukey5[4] = swap32_S (tmps[gid].out[36]); - ukey5[5] = swap32_S (tmps[gid].out[37]); - ukey5[6] = swap32_S (tmps[gid].out[38]); - ukey5[7] = swap32_S (tmps[gid].out[39]); - - u32 ukey6[8]; - - ukey6[0] = swap32_S (tmps[gid].out[40]); - ukey6[1] = swap32_S (tmps[gid].out[41]); - ukey6[2] = swap32_S (tmps[gid].out[42]); - ukey6[3] = swap32_S (tmps[gid].out[43]); - ukey6[4] = swap32_S (tmps[gid].out[44]); - ukey6[5] = swap32_S (tmps[gid].out[45]); - ukey6[6] = swap32_S (tmps[gid].out[46]); - ukey6[7] = swap32_S (tmps[gid].out[47]); - - if (verify_header_aes_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_serpent_twofish_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_serpent_camellia (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } } } diff --git a/OpenCL/m13771-pure.cl b/OpenCL/m13771-pure.cl index ff7a57623..bad84d31f 100644 --- a/OpenCL/m13771-pure.cl +++ b/OpenCL/m13771-pure.cl @@ -5,6 +5,9 @@ //#define NEW_SIMD_CODE +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + #include "inc_vendor.cl" #include "inc_hash_constants.h" #include "inc_hash_functions.cl" @@ -19,11 +22,74 @@ #include "inc_cipher_camellia.cl" #include "inc_cipher_kuznyechik.cl" +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +typedef struct vc64_sbog_tmp +{ + u64 ipad_raw[8]; + u64 opad_raw[8]; + + u64 ipad_hash[8]; + u64 opad_hash[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + +} vc64_sbog_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (h32_from_64_S (key[7])); + key1[1] = swap32_S (l32_from_64_S (key[7])); + key1[2] = swap32_S (h32_from_64_S (key[6])); + key1[3] = swap32_S (l32_from_64_S (key[6])); + key1[4] = swap32_S (h32_from_64_S (key[5])); + key1[5] = swap32_S (l32_from_64_S (key[5])); + key1[6] = swap32_S (h32_from_64_S (key[4])); + key1[7] = swap32_S (l32_from_64_S (key[4])); + key2[0] = swap32_S (h32_from_64_S (key[3])); + key2[1] = swap32_S (l32_from_64_S (key[3])); + key2[2] = swap32_S (h32_from_64_S (key[2])); + key2[3] = swap32_S (l32_from_64_S (key[2])); + key2[4] = swap32_S (h32_from_64_S (key[1])); + key2[5] = swap32_S (l32_from_64_S (key[1])); + key2[6] = swap32_S (h32_from_64_S (key[0])); + key2[7] = swap32_S (l32_from_64_S (key[0])); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + DECLSPEC void hmac_streebog512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u64x *ipad_hash, u64x *opad_hash, u64x *ipad_raw, u64x *opad_raw, u64x *digest, SHM_TYPE u64a (*s_sbob_sl64)[256]) { const u64x nullbuf[8] = { 0 }; @@ -109,7 +175,7 @@ DECLSPEC void hmac_streebog512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u6 streebog512_g_vector (digest, nullbuf, message, s_sbob_sl64); } -__kernel void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -124,6 +190,8 @@ __kernel void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; } + barrier (CLK_LOCAL_MEM_FENCE); + #ifdef REAL_SHM __local u64a s_sbob_sl64[8][256]; @@ -301,7 +369,7 @@ __kernel void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) } } -__kernel void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -313,6 +381,33 @@ __kernel void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) #ifdef REAL_SHM + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + __local u64a s_sbob_sl64[8][256]; for (u32 i = lid; i < 256; i += lsz) @@ -331,11 +426,54 @@ __kernel void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) #else + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + __constant u64a (*s_sbob_sl64)[256] = sbob_sl64; #endif - if ((gid * VECT_SIZE) >= gid_max) return; + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here u64x ipad_hash[8]; u64x opad_hash[8]; @@ -436,6 +574,20 @@ __kernel void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) out[5] ^= dgst[5]; out[6] ^= dgst[6]; out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } } unpack64v (tmps, dgst, gid, i + 0, dgst[0]); @@ -456,9 +608,13 @@ __kernel void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; } -__kernel void m13771_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13771_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -517,64 +673,21 @@ __kernel void m13771_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) if (gid >= gid_max) return; - u32 ukey1[8]; - u32 ukey2[8]; - - ukey1[0] = swap32_S (h32_from_64_S (tmps[gid].out[7])); - ukey1[1] = swap32_S (l32_from_64_S (tmps[gid].out[7])); - ukey1[2] = swap32_S (h32_from_64_S (tmps[gid].out[6])); - ukey1[3] = swap32_S (l32_from_64_S (tmps[gid].out[6])); - ukey1[4] = swap32_S (h32_from_64_S (tmps[gid].out[5])); - ukey1[5] = swap32_S (l32_from_64_S (tmps[gid].out[5])); - ukey1[6] = swap32_S (h32_from_64_S (tmps[gid].out[4])); - ukey1[7] = swap32_S (l32_from_64_S (tmps[gid].out[4])); - - ukey2[0] = swap32_S (h32_from_64_S (tmps[gid].out[3])); - ukey2[1] = swap32_S (l32_from_64_S (tmps[gid].out[3])); - ukey2[2] = swap32_S (h32_from_64_S (tmps[gid].out[2])); - ukey2[3] = swap32_S (l32_from_64_S (tmps[gid].out[2])); - ukey2[4] = swap32_S (h32_from_64_S (tmps[gid].out[1])); - ukey2[5] = swap32_S (l32_from_64_S (tmps[gid].out[1])); - ukey2[6] = swap32_S (h32_from_64_S (tmps[gid].out[0])); - ukey2[7] = swap32_S (l32_from_64_S (tmps[gid].out[0])); - - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (tmps[gid].pim) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); } } - - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + else { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } } } diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index c4107c4b4..8d76b560f 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -5,6 +5,9 @@ //#define NEW_SIMD_CODE +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + #include "inc_vendor.cl" #include "inc_hash_constants.h" #include "inc_hash_functions.cl" @@ -19,11 +22,125 @@ #include "inc_cipher_camellia.cl" #include "inc_cipher_kuznyechik.cl" +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +typedef struct vc64_sbog_tmp +{ + u64 ipad_raw[8]; + u64 opad_raw[8]; + + u64 ipad_hash[8]; + u64 opad_hash[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + +} vc64_sbog_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (h32_from_64_S (key[7])); + key1[1] = swap32_S (l32_from_64_S (key[7])); + key1[2] = swap32_S (h32_from_64_S (key[6])); + key1[3] = swap32_S (l32_from_64_S (key[6])); + key1[4] = swap32_S (h32_from_64_S (key[5])); + key1[5] = swap32_S (l32_from_64_S (key[5])); + key1[6] = swap32_S (h32_from_64_S (key[4])); + key1[7] = swap32_S (l32_from_64_S (key[4])); + key2[0] = swap32_S (h32_from_64_S (key[3])); + key2[1] = swap32_S (l32_from_64_S (key[3])); + key2[2] = swap32_S (h32_from_64_S (key[2])); + key2[3] = swap32_S (l32_from_64_S (key[2])); + key2[4] = swap32_S (h32_from_64_S (key[1])); + key2[5] = swap32_S (l32_from_64_S (key[1])); + key2[6] = swap32_S (h32_from_64_S (key[0])); + key2[7] = swap32_S (l32_from_64_S (key[0])); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (h32_from_64_S (key[ 7])); + key1[1] = swap32_S (l32_from_64_S (key[ 7])); + key1[2] = swap32_S (h32_from_64_S (key[ 6])); + key1[3] = swap32_S (l32_from_64_S (key[ 6])); + key1[4] = swap32_S (h32_from_64_S (key[ 5])); + key1[5] = swap32_S (l32_from_64_S (key[ 5])); + key1[6] = swap32_S (h32_from_64_S (key[ 4])); + key1[7] = swap32_S (l32_from_64_S (key[ 4])); + key2[0] = swap32_S (h32_from_64_S (key[ 3])); + key2[1] = swap32_S (l32_from_64_S (key[ 3])); + key2[2] = swap32_S (h32_from_64_S (key[ 2])); + key2[3] = swap32_S (l32_from_64_S (key[ 2])); + key2[4] = swap32_S (h32_from_64_S (key[ 1])); + key2[5] = swap32_S (l32_from_64_S (key[ 1])); + key2[6] = swap32_S (h32_from_64_S (key[ 0])); + key2[7] = swap32_S (l32_from_64_S (key[ 0])); + key3[0] = swap32_S (h32_from_64_S (key[15])); + key3[1] = swap32_S (l32_from_64_S (key[15])); + key3[2] = swap32_S (h32_from_64_S (key[14])); + key3[3] = swap32_S (l32_from_64_S (key[14])); + key3[4] = swap32_S (h32_from_64_S (key[13])); + key3[5] = swap32_S (l32_from_64_S (key[13])); + key3[6] = swap32_S (h32_from_64_S (key[12])); + key3[7] = swap32_S (l32_from_64_S (key[12])); + key4[0] = swap32_S (h32_from_64_S (key[11])); + key4[1] = swap32_S (l32_from_64_S (key[11])); + key4[2] = swap32_S (h32_from_64_S (key[10])); + key4[3] = swap32_S (l32_from_64_S (key[10])); + key4[4] = swap32_S (h32_from_64_S (key[ 9])); + key4[5] = swap32_S (l32_from_64_S (key[ 9])); + key4[6] = swap32_S (h32_from_64_S (key[ 8])); + key4[7] = swap32_S (l32_from_64_S (key[ 8])); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + DECLSPEC void hmac_streebog512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u64x *ipad_hash, u64x *opad_hash, u64x *ipad_raw, u64x *opad_raw, u64x *digest, SHM_TYPE u64a (*s_sbob_sl64)[256]) { const u64x nullbuf[8] = { 0 }; @@ -109,7 +226,7 @@ DECLSPEC void hmac_streebog512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u6 streebog512_g_vector (digest, nullbuf, message, s_sbob_sl64); } -__kernel void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -124,6 +241,8 @@ __kernel void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; } + barrier (CLK_LOCAL_MEM_FENCE); + #ifdef REAL_SHM __local u64a s_sbob_sl64[8][256]; @@ -301,7 +420,7 @@ __kernel void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) } } -__kernel void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -313,6 +432,33 @@ __kernel void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) #ifdef REAL_SHM + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + __local u64a s_sbob_sl64[8][256]; for (u32 i = lid; i < 256; i += lsz) @@ -331,11 +477,54 @@ __kernel void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) #else + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + __constant u64a (*s_sbob_sl64)[256] = sbob_sl64; #endif - if ((gid * VECT_SIZE) >= gid_max) return; + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here u64x ipad_hash[8]; u64x opad_hash[8]; @@ -436,6 +625,20 @@ __kernel void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) out[5] ^= dgst[5]; out[6] ^= dgst[6]; out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } } unpack64v (tmps, dgst, gid, i + 0, dgst[0]); @@ -456,9 +659,14 @@ __kernel void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; } -__kernel void m13772_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13772_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -517,143 +725,29 @@ __kernel void m13772_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) if (gid >= gid_max) return; - u32 ukey1[8]; - - ukey1[0] = swap32_S (h32_from_64_S (tmps[gid].out[7])); - ukey1[1] = swap32_S (l32_from_64_S (tmps[gid].out[7])); - ukey1[2] = swap32_S (h32_from_64_S (tmps[gid].out[6])); - ukey1[3] = swap32_S (l32_from_64_S (tmps[gid].out[6])); - ukey1[4] = swap32_S (h32_from_64_S (tmps[gid].out[5])); - ukey1[5] = swap32_S (l32_from_64_S (tmps[gid].out[5])); - ukey1[6] = swap32_S (h32_from_64_S (tmps[gid].out[4])); - ukey1[7] = swap32_S (l32_from_64_S (tmps[gid].out[4])); - - u32 ukey2[8]; - - ukey2[0] = swap32_S (h32_from_64_S (tmps[gid].out[3])); - ukey2[1] = swap32_S (l32_from_64_S (tmps[gid].out[3])); - ukey2[2] = swap32_S (h32_from_64_S (tmps[gid].out[2])); - ukey2[3] = swap32_S (l32_from_64_S (tmps[gid].out[2])); - ukey2[4] = swap32_S (h32_from_64_S (tmps[gid].out[1])); - ukey2[5] = swap32_S (l32_from_64_S (tmps[gid].out[1])); - ukey2[6] = swap32_S (h32_from_64_S (tmps[gid].out[0])); - ukey2[7] = swap32_S (l32_from_64_S (tmps[gid].out[0])); - - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (tmps[gid].pim) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); } } - - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + else { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } - } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - u32 ukey3[8]; - - ukey3[0] = swap32_S (h32_from_64_S (tmps[gid].out[15])); - ukey3[1] = swap32_S (l32_from_64_S (tmps[gid].out[15])); - ukey3[2] = swap32_S (h32_from_64_S (tmps[gid].out[14])); - ukey3[3] = swap32_S (l32_from_64_S (tmps[gid].out[14])); - ukey3[4] = swap32_S (h32_from_64_S (tmps[gid].out[13])); - ukey3[5] = swap32_S (l32_from_64_S (tmps[gid].out[13])); - ukey3[6] = swap32_S (h32_from_64_S (tmps[gid].out[12])); - ukey3[7] = swap32_S (l32_from_64_S (tmps[gid].out[12])); - - u32 ukey4[8]; - - ukey4[0] = swap32_S (h32_from_64_S (tmps[gid].out[11])); - ukey4[1] = swap32_S (l32_from_64_S (tmps[gid].out[11])); - ukey4[2] = swap32_S (h32_from_64_S (tmps[gid].out[10])); - ukey4[3] = swap32_S (l32_from_64_S (tmps[gid].out[10])); - ukey4[4] = swap32_S (h32_from_64_S (tmps[gid].out[ 9])); - ukey4[5] = swap32_S (l32_from_64_S (tmps[gid].out[ 9])); - ukey4[6] = swap32_S (h32_from_64_S (tmps[gid].out[ 8])); - ukey4[7] = swap32_S (l32_from_64_S (tmps[gid].out[ 8])); - - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } } } diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index a63ad3a0f..854c192b3 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -5,6 +5,9 @@ //#define NEW_SIMD_CODE +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + #include "inc_vendor.cl" #include "inc_hash_constants.h" #include "inc_hash_functions.cl" @@ -19,11 +22,190 @@ #include "inc_cipher_camellia.cl" #include "inc_cipher_kuznyechik.cl" +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf[16]; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + #include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +typedef struct vc64_sbog_tmp +{ + u64 ipad_raw[8]; + u64 opad_raw[8]; + + u64 ipad_hash[8]; + u64 opad_hash[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + +} vc64_sbog_tmp_t; + +DECLSPEC int check_header_0512 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + + key1[0] = swap32_S (h32_from_64_S (key[7])); + key1[1] = swap32_S (l32_from_64_S (key[7])); + key1[2] = swap32_S (h32_from_64_S (key[6])); + key1[3] = swap32_S (l32_from_64_S (key[6])); + key1[4] = swap32_S (h32_from_64_S (key[5])); + key1[5] = swap32_S (l32_from_64_S (key[5])); + key1[6] = swap32_S (h32_from_64_S (key[4])); + key1[7] = swap32_S (l32_from_64_S (key[4])); + key2[0] = swap32_S (h32_from_64_S (key[3])); + key2[1] = swap32_S (l32_from_64_S (key[3])); + key2[2] = swap32_S (h32_from_64_S (key[2])); + key2[3] = swap32_S (l32_from_64_S (key[2])); + key2[4] = swap32_S (h32_from_64_S (key[1])); + key2[5] = swap32_S (l32_from_64_S (key[1])); + key2[6] = swap32_S (h32_from_64_S (key[0])); + key2[7] = swap32_S (l32_from_64_S (key[0])); + + if (verify_header_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + if (verify_header_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1024 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + + key1[0] = swap32_S (h32_from_64_S (key[ 7])); + key1[1] = swap32_S (l32_from_64_S (key[ 7])); + key1[2] = swap32_S (h32_from_64_S (key[ 6])); + key1[3] = swap32_S (l32_from_64_S (key[ 6])); + key1[4] = swap32_S (h32_from_64_S (key[ 5])); + key1[5] = swap32_S (l32_from_64_S (key[ 5])); + key1[6] = swap32_S (h32_from_64_S (key[ 4])); + key1[7] = swap32_S (l32_from_64_S (key[ 4])); + key2[0] = swap32_S (h32_from_64_S (key[ 3])); + key2[1] = swap32_S (l32_from_64_S (key[ 3])); + key2[2] = swap32_S (h32_from_64_S (key[ 2])); + key2[3] = swap32_S (l32_from_64_S (key[ 2])); + key2[4] = swap32_S (h32_from_64_S (key[ 1])); + key2[5] = swap32_S (l32_from_64_S (key[ 1])); + key2[6] = swap32_S (h32_from_64_S (key[ 0])); + key2[7] = swap32_S (l32_from_64_S (key[ 0])); + key3[0] = swap32_S (h32_from_64_S (key[15])); + key3[1] = swap32_S (l32_from_64_S (key[15])); + key3[2] = swap32_S (h32_from_64_S (key[14])); + key3[3] = swap32_S (l32_from_64_S (key[14])); + key3[4] = swap32_S (h32_from_64_S (key[13])); + key3[5] = swap32_S (l32_from_64_S (key[13])); + key3[6] = swap32_S (h32_from_64_S (key[12])); + key3[7] = swap32_S (l32_from_64_S (key[12])); + key4[0] = swap32_S (h32_from_64_S (key[11])); + key4[1] = swap32_S (l32_from_64_S (key[11])); + key4[2] = swap32_S (h32_from_64_S (key[10])); + key4[3] = swap32_S (l32_from_64_S (key[10])); + key4[4] = swap32_S (h32_from_64_S (key[ 9])); + key4[5] = swap32_S (l32_from_64_S (key[ 9])); + key4[6] = swap32_S (h32_from_64_S (key[ 8])); + key4[7] = swap32_S (l32_from_64_S (key[ 8])); + + if (verify_header_aes_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_kuznyechik (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_camellia_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + if (verify_header_kuznyechik_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_twofish (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4) == 1) return 0; + + return -1; +} + +DECLSPEC int check_header_1536 (__global const vc_t *esalt_bufs, __global u64 *key, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + u32 key1[8]; + u32 key2[8]; + u32 key3[8]; + u32 key4[8]; + u32 key5[8]; + u32 key6[8]; + + key1[0] = swap32_S (h32_from_64_S (key[ 7])); + key1[1] = swap32_S (l32_from_64_S (key[ 7])); + key1[2] = swap32_S (h32_from_64_S (key[ 6])); + key1[3] = swap32_S (l32_from_64_S (key[ 6])); + key1[4] = swap32_S (h32_from_64_S (key[ 5])); + key1[5] = swap32_S (l32_from_64_S (key[ 5])); + key1[6] = swap32_S (h32_from_64_S (key[ 4])); + key1[7] = swap32_S (l32_from_64_S (key[ 4])); + key2[0] = swap32_S (h32_from_64_S (key[ 3])); + key2[1] = swap32_S (l32_from_64_S (key[ 3])); + key2[2] = swap32_S (h32_from_64_S (key[ 2])); + key2[3] = swap32_S (l32_from_64_S (key[ 2])); + key2[4] = swap32_S (h32_from_64_S (key[ 1])); + key2[5] = swap32_S (l32_from_64_S (key[ 1])); + key2[6] = swap32_S (h32_from_64_S (key[ 0])); + key2[7] = swap32_S (l32_from_64_S (key[ 0])); + key3[0] = swap32_S (h32_from_64_S (key[15])); + key3[1] = swap32_S (l32_from_64_S (key[15])); + key3[2] = swap32_S (h32_from_64_S (key[14])); + key3[3] = swap32_S (l32_from_64_S (key[14])); + key3[4] = swap32_S (h32_from_64_S (key[13])); + key3[5] = swap32_S (l32_from_64_S (key[13])); + key3[6] = swap32_S (h32_from_64_S (key[12])); + key3[7] = swap32_S (l32_from_64_S (key[12])); + key4[0] = swap32_S (h32_from_64_S (key[11])); + key4[1] = swap32_S (l32_from_64_S (key[11])); + key4[2] = swap32_S (h32_from_64_S (key[10])); + key4[3] = swap32_S (l32_from_64_S (key[10])); + key4[4] = swap32_S (h32_from_64_S (key[ 9])); + key4[5] = swap32_S (l32_from_64_S (key[ 9])); + key4[6] = swap32_S (h32_from_64_S (key[ 8])); + key4[7] = swap32_S (l32_from_64_S (key[ 8])); + key5[0] = swap32_S (h32_from_64_S (key[23])); + key5[1] = swap32_S (l32_from_64_S (key[23])); + key5[2] = swap32_S (h32_from_64_S (key[22])); + key5[3] = swap32_S (l32_from_64_S (key[22])); + key5[4] = swap32_S (h32_from_64_S (key[21])); + key5[5] = swap32_S (l32_from_64_S (key[21])); + key5[6] = swap32_S (h32_from_64_S (key[20])); + key5[7] = swap32_S (l32_from_64_S (key[20])); + key6[0] = swap32_S (h32_from_64_S (key[19])); + key6[1] = swap32_S (l32_from_64_S (key[19])); + key6[2] = swap32_S (h32_from_64_S (key[18])); + key6[3] = swap32_S (l32_from_64_S (key[18])); + key6[4] = swap32_S (h32_from_64_S (key[17])); + key6[5] = swap32_S (l32_from_64_S (key[17])); + key6[6] = swap32_S (h32_from_64_S (key[16])); + key6[7] = swap32_S (l32_from_64_S (key[16])); + + if (verify_header_aes_twofish_serpent (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_serpent_twofish_aes (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) return 0; + if (verify_header_kuznyechik_serpent_camellia (esalt_bufs[0].data_buf, esalt_bufs[0].signature, key1, key2, key3, key4, key5, key6) == 1) return 0; + + return -1; +} + DECLSPEC void hmac_streebog512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u64x *ipad_hash, u64x *opad_hash, u64x *ipad_raw, u64x *opad_raw, u64x *digest, SHM_TYPE u64a (*s_sbob_sl64)[256]) { const u64x nullbuf[8] = { 0 }; @@ -109,7 +291,7 @@ DECLSPEC void hmac_streebog512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u6 streebog512_g_vector (digest, nullbuf, message, s_sbob_sl64); } -__kernel void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -124,6 +306,8 @@ __kernel void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) s_keyboard_layout_mapping_buf[i] = esalt_bufs[digests_offset].keyboard_layout_mapping_buf[i]; } + barrier (CLK_LOCAL_MEM_FENCE); + #ifdef REAL_SHM __local u64a s_sbob_sl64[8][256]; @@ -301,7 +485,7 @@ __kernel void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) } } -__kernel void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -313,6 +497,33 @@ __kernel void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) #ifdef REAL_SHM + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + __local u64a s_sbob_sl64[8][256]; for (u32 i = lid; i < 256; i += lsz) @@ -331,11 +542,54 @@ __kernel void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) #else + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + __constant u64a (*s_sbob_sl64)[256] = sbob_sl64; #endif - if ((gid * VECT_SIZE) >= gid_max) return; + if (gid >= gid_max) return; + + // this is the pim range check + // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) + // therefore the module limits the inner loop iteration count to 1000 + // if the key_pim is set, we know that we have to save and check the key for this pim + + const int pim_multi = esalt_bufs[digests_offset].pim_multi; + const int pim_start = esalt_bufs[digests_offset].pim_start; + const int pim_stop = esalt_bufs[digests_offset].pim_stop; + + int pim = 0; + int pim_at = 0; + + for (u32 j = 0; j < loop_cnt; j++) + { + const int iter_abs = 1 + loop_pos + j; + + if ((iter_abs % pim_multi) == pim_multi - 1) + { + const int pim_cur = (iter_abs / pim_multi) + 1; + + if ((pim_cur >= pim_start) && (pim_cur <= pim_stop)) + { + pim = pim_cur; + + pim_at = j; + } + } + } + + // irregular pbkdf2 from here u64x ipad_hash[8]; u64x opad_hash[8]; @@ -436,6 +690,20 @@ __kernel void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) out[5] ^= dgst[5]; out[6] ^= dgst[6]; out[7] ^= dgst[7]; + + // this iteration creates a valid pim + + if (j == pim_at) + { + tmps[gid].pim_key[i + 0] = out[0]; + tmps[gid].pim_key[i + 1] = out[1]; + tmps[gid].pim_key[i + 2] = out[2]; + tmps[gid].pim_key[i + 3] = out[3]; + tmps[gid].pim_key[i + 4] = out[4]; + tmps[gid].pim_key[i + 5] = out[5]; + tmps[gid].pim_key[i + 6] = out[6]; + tmps[gid].pim_key[i + 7] = out[7]; + } } unpack64v (tmps, dgst, gid, i + 0, dgst[0]); @@ -456,9 +724,15 @@ __kernel void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } + + if (pim == 0) return; + + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; } -__kernel void m13773_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) +__kernel void m13773_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); @@ -517,189 +791,37 @@ __kernel void m13773_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, tc_t)) if (gid >= gid_max) return; - u32 ukey1[8]; - - ukey1[0] = swap32_S (h32_from_64_S (tmps[gid].out[7])); - ukey1[1] = swap32_S (l32_from_64_S (tmps[gid].out[7])); - ukey1[2] = swap32_S (h32_from_64_S (tmps[gid].out[6])); - ukey1[3] = swap32_S (l32_from_64_S (tmps[gid].out[6])); - ukey1[4] = swap32_S (h32_from_64_S (tmps[gid].out[5])); - ukey1[5] = swap32_S (l32_from_64_S (tmps[gid].out[5])); - ukey1[6] = swap32_S (h32_from_64_S (tmps[gid].out[4])); - ukey1[7] = swap32_S (l32_from_64_S (tmps[gid].out[4])); - - u32 ukey2[8]; - - ukey2[0] = swap32_S (h32_from_64_S (tmps[gid].out[3])); - ukey2[1] = swap32_S (l32_from_64_S (tmps[gid].out[3])); - ukey2[2] = swap32_S (h32_from_64_S (tmps[gid].out[2])); - ukey2[3] = swap32_S (l32_from_64_S (tmps[gid].out[2])); - ukey2[4] = swap32_S (h32_from_64_S (tmps[gid].out[1])); - ukey2[5] = swap32_S (l32_from_64_S (tmps[gid].out[1])); - ukey2[6] = swap32_S (h32_from_64_S (tmps[gid].out[0])); - ukey2[7] = swap32_S (l32_from_64_S (tmps[gid].out[0])); - - if (verify_header_aes (esalt_bufs, ukey1, ukey2, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) + if (tmps[gid].pim) { if (atomic_inc (&hashes_shown[0]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, tmps[gid].pim, 0); } } - - if (verify_header_serpent (esalt_bufs, ukey1, ukey2) == 1) + else { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_0512 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } - } - if (verify_header_twofish (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_1024 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } - } - if (verify_header_camellia (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) + if (check_header_1536 (esalt_bufs, tmps[gid].out, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik (esalt_bufs, ukey1, ukey2) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - u32 ukey3[8]; - - ukey3[0] = swap32_S (h32_from_64_S (tmps[gid].out[15])); - ukey3[1] = swap32_S (l32_from_64_S (tmps[gid].out[15])); - ukey3[2] = swap32_S (h32_from_64_S (tmps[gid].out[14])); - ukey3[3] = swap32_S (l32_from_64_S (tmps[gid].out[14])); - ukey3[4] = swap32_S (h32_from_64_S (tmps[gid].out[13])); - ukey3[5] = swap32_S (l32_from_64_S (tmps[gid].out[13])); - ukey3[6] = swap32_S (h32_from_64_S (tmps[gid].out[12])); - ukey3[7] = swap32_S (l32_from_64_S (tmps[gid].out[12])); - - u32 ukey4[8]; - - ukey4[0] = swap32_S (h32_from_64_S (tmps[gid].out[11])); - ukey4[1] = swap32_S (l32_from_64_S (tmps[gid].out[11])); - ukey4[2] = swap32_S (h32_from_64_S (tmps[gid].out[10])); - ukey4[3] = swap32_S (l32_from_64_S (tmps[gid].out[10])); - ukey4[4] = swap32_S (h32_from_64_S (tmps[gid].out[ 9])); - ukey4[5] = swap32_S (l32_from_64_S (tmps[gid].out[ 9])); - ukey4[6] = swap32_S (h32_from_64_S (tmps[gid].out[ 8])); - ukey4[7] = swap32_S (l32_from_64_S (tmps[gid].out[ 8])); - - if (verify_header_aes_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_serpent_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_kuznyechik (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_camellia_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_twofish (esalt_bufs, ukey1, ukey2, ukey3, ukey4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - u32 ukey5[8]; - - ukey5[0] = swap32_S (h32_from_64_S (tmps[gid].out[23])); - ukey5[1] = swap32_S (l32_from_64_S (tmps[gid].out[23])); - ukey5[2] = swap32_S (h32_from_64_S (tmps[gid].out[22])); - ukey5[3] = swap32_S (l32_from_64_S (tmps[gid].out[22])); - ukey5[4] = swap32_S (h32_from_64_S (tmps[gid].out[21])); - ukey5[5] = swap32_S (l32_from_64_S (tmps[gid].out[21])); - ukey5[6] = swap32_S (h32_from_64_S (tmps[gid].out[20])); - ukey5[7] = swap32_S (l32_from_64_S (tmps[gid].out[20])); - - u32 ukey6[8]; - - ukey6[0] = swap32_S (h32_from_64_S (tmps[gid].out[19])); - ukey6[1] = swap32_S (l32_from_64_S (tmps[gid].out[19])); - ukey6[2] = swap32_S (h32_from_64_S (tmps[gid].out[18])); - ukey6[3] = swap32_S (l32_from_64_S (tmps[gid].out[18])); - ukey6[4] = swap32_S (h32_from_64_S (tmps[gid].out[17])); - ukey6[5] = swap32_S (l32_from_64_S (tmps[gid].out[17])); - ukey6[6] = swap32_S (h32_from_64_S (tmps[gid].out[16])); - ukey6[7] = swap32_S (l32_from_64_S (tmps[gid].out[16])); - - if (verify_header_aes_twofish_serpent (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_serpent_twofish_aes (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); - } - } - - if (verify_header_kuznyechik_serpent_camellia (esalt_bufs, ukey1, ukey2, ukey3, ukey4, ukey5, ukey6) == 1) - { - if (atomic_inc (&hashes_shown[0]) == 0) - { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + if (atomic_inc (&hashes_shown[0]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); + } } } } diff --git a/OpenCL/m13800_a0-optimized.cl b/OpenCL/m13800_a0-optimized.cl index 1f7bad962..d973fcc78 100644 --- a/OpenCL/m13800_a0-optimized.cl +++ b/OpenCL/m13800_a0-optimized.cl @@ -16,6 +16,12 @@ #include "inc_simd.cl" #include "inc_hash_sha256.cl" +typedef struct win8phone +{ + u32 salt_buf[32]; + +} win8phone_t; + DECLSPEC void sha256_transform_transport_vector (const u32x *w, u32x *digest) { sha256_transform_vector (w + 0, w + 4, w + 8, w + 12, digest); diff --git a/OpenCL/m13800_a0-pure.cl b/OpenCL/m13800_a0-pure.cl index 57fd5b261..3b704f036 100644 --- a/OpenCL/m13800_a0-pure.cl +++ b/OpenCL/m13800_a0-pure.cl @@ -15,6 +15,12 @@ #include "inc_scalar.cl" #include "inc_hash_sha256.cl" +typedef struct win8phone +{ + u32 salt_buf[32]; + +} win8phone_t; + __kernel void m13800_mxx (KERN_ATTR_RULES_ESALT (win8phone_t)) { /** diff --git a/OpenCL/m13800_a1-optimized.cl b/OpenCL/m13800_a1-optimized.cl index b0905ab50..b4118da9f 100644 --- a/OpenCL/m13800_a1-optimized.cl +++ b/OpenCL/m13800_a1-optimized.cl @@ -14,6 +14,12 @@ #include "inc_simd.cl" #include "inc_hash_sha256.cl" +typedef struct win8phone +{ + u32 salt_buf[32]; + +} win8phone_t; + DECLSPEC void sha256_transform_transport_vector (const u32x *w, u32x *digest) { sha256_transform_vector (w + 0, w + 4, w + 8, w + 12, digest); diff --git a/OpenCL/m13800_a1-pure.cl b/OpenCL/m13800_a1-pure.cl index 9a3d73538..24699c4d6 100644 --- a/OpenCL/m13800_a1-pure.cl +++ b/OpenCL/m13800_a1-pure.cl @@ -13,6 +13,12 @@ #include "inc_scalar.cl" #include "inc_hash_sha256.cl" +typedef struct win8phone +{ + u32 salt_buf[32]; + +} win8phone_t; + __kernel void m13800_mxx (KERN_ATTR_ESALT (win8phone_t)) { /** diff --git a/OpenCL/m13800_a3-optimized.cl b/OpenCL/m13800_a3-optimized.cl index 4ea3aa390..73f0c7223 100644 --- a/OpenCL/m13800_a3-optimized.cl +++ b/OpenCL/m13800_a3-optimized.cl @@ -13,6 +13,12 @@ #include "inc_simd.cl" #include "inc_hash_sha256.cl" +typedef struct win8phone +{ + u32 salt_buf[32]; + +} win8phone_t; + DECLSPEC void sha256_transform_transport_vector (const u32x *w, u32x *digest) { sha256_transform_vector (w + 0, w + 4, w + 8, w + 12, digest); diff --git a/OpenCL/m13800_a3-pure.cl b/OpenCL/m13800_a3-pure.cl index 2a0de8d04..a3b2ccff4 100644 --- a/OpenCL/m13800_a3-pure.cl +++ b/OpenCL/m13800_a3-pure.cl @@ -13,6 +13,12 @@ #include "inc_simd.cl" #include "inc_hash_sha256.cl" +typedef struct win8phone +{ + u32 salt_buf[32]; + +} win8phone_t; + __kernel void m13800_mxx (KERN_ATTR_VECTOR_ESALT (win8phone_t)) { /** diff --git a/OpenCL/m14611-pure.cl b/OpenCL/m14611-pure.cl index 080ca0f53..44bbbc9eb 100644 --- a/OpenCL/m14611-pure.cl +++ b/OpenCL/m14611-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha1.cl" #include "inc_cipher_aes.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -297,7 +362,7 @@ __kernel void m14611_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14612-pure.cl b/OpenCL/m14612-pure.cl index d8db96cdb..844077011 100644 --- a/OpenCL/m14612-pure.cl +++ b/OpenCL/m14612-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha1.cl" #include "inc_cipher_serpent.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -244,7 +309,7 @@ __kernel void m14612_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14613-pure.cl b/OpenCL/m14613-pure.cl index c7315c6fe..a7c3aef4d 100644 --- a/OpenCL/m14613-pure.cl +++ b/OpenCL/m14613-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha1.cl" #include "inc_cipher_twofish.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -244,7 +309,7 @@ __kernel void m14613_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14621-pure.cl b/OpenCL/m14621-pure.cl index 779fd2bbb..d1481b27b 100644 --- a/OpenCL/m14621-pure.cl +++ b/OpenCL/m14621-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_aes.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -336,7 +401,7 @@ __kernel void m14621_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14622-pure.cl b/OpenCL/m14622-pure.cl index 7594ca53c..84c647f5a 100644 --- a/OpenCL/m14622-pure.cl +++ b/OpenCL/m14622-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_serpent.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -283,7 +348,7 @@ __kernel void m14622_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14623-pure.cl b/OpenCL/m14623-pure.cl index 1f70d96d3..56a41ae7d 100644 --- a/OpenCL/m14623-pure.cl +++ b/OpenCL/m14623-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_twofish.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -283,7 +348,7 @@ __kernel void m14623_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14631-pure.cl b/OpenCL/m14631-pure.cl index c31ee140f..85930ef9f 100644 --- a/OpenCL/m14631-pure.cl +++ b/OpenCL/m14631-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha512.cl" #include "inc_cipher_aes.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -392,7 +457,7 @@ __kernel void m14631_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14632-pure.cl b/OpenCL/m14632-pure.cl index 24b647db0..8bf3a7b85 100644 --- a/OpenCL/m14632-pure.cl +++ b/OpenCL/m14632-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha512.cl" #include "inc_cipher_serpent.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -339,7 +404,7 @@ __kernel void m14632_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14633-pure.cl b/OpenCL/m14633-pure.cl index c12632dfc..9565908b3 100644 --- a/OpenCL/m14633-pure.cl +++ b/OpenCL/m14633-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_sha512.cl" #include "inc_cipher_twofish.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -339,7 +404,7 @@ __kernel void m14633_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14641-pure.cl b/OpenCL/m14641-pure.cl index 4c97d27d6..f73db5d59 100644 --- a/OpenCL/m14641-pure.cl +++ b/OpenCL/m14641-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_ripemd160.cl" #include "inc_cipher_aes.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -297,7 +362,7 @@ __kernel void m14641_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14642-pure.cl b/OpenCL/m14642-pure.cl index 2fbbadb8b..dd5536546 100644 --- a/OpenCL/m14642-pure.cl +++ b/OpenCL/m14642-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_ripemd160.cl" #include "inc_cipher_serpent.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -244,7 +309,7 @@ __kernel void m14642_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14643-pure.cl b/OpenCL/m14643-pure.cl index 23895de0e..d9a02c811 100644 --- a/OpenCL/m14643-pure.cl +++ b/OpenCL/m14643-pure.cl @@ -14,6 +14,71 @@ #include "inc_hash_ripemd160.cl" #include "inc_cipher_twofish.cl" +#define LUKS_STRIPES 4000 + +typedef enum hc_luks_hash_type +{ + HC_LUKS_HASH_TYPE_SHA1 = 1, + HC_LUKS_HASH_TYPE_SHA256 = 2, + HC_LUKS_HASH_TYPE_SHA512 = 3, + HC_LUKS_HASH_TYPE_RIPEMD160 = 4, + HC_LUKS_HASH_TYPE_WHIRLPOOL = 5, + +} hc_luks_hash_type_t; + +typedef enum hc_luks_key_size +{ + HC_LUKS_KEY_SIZE_128 = 128, + HC_LUKS_KEY_SIZE_256 = 256, + HC_LUKS_KEY_SIZE_512 = 512, + +} hc_luks_key_size_t; + +typedef enum hc_luks_cipher_type +{ + HC_LUKS_CIPHER_TYPE_AES = 1, + HC_LUKS_CIPHER_TYPE_SERPENT = 2, + HC_LUKS_CIPHER_TYPE_TWOFISH = 3, + +} hc_luks_cipher_type_t; + +typedef enum hc_luks_cipher_mode +{ + HC_LUKS_CIPHER_MODE_CBC_ESSIV = 1, + HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2, + HC_LUKS_CIPHER_MODE_XTS_PLAIN = 3, + +} hc_luks_cipher_mode_t; + +typedef struct luks +{ + int hash_type; // hc_luks_hash_type_t + int key_size; // hc_luks_key_size_t + int cipher_type; // hc_luks_cipher_type_t + int cipher_mode; // hc_luks_cipher_mode_t + + u32 ct_buf[128]; + + u32 af_src_buf[((HC_LUKS_KEY_SIZE_512 / 8) * LUKS_STRIPES) / 4]; + +} luks_t; + +typedef struct luks_tmp +{ + u32 ipad32[8]; + u64 ipad64[8]; + + u32 opad32[8]; + u64 opad64[8]; + + u32 dgst32[32]; + u64 dgst64[16]; + + u32 out32[32]; + u64 out64[16]; + +} luks_tmp_t; + #include "inc_luks_af.cl" #include "inc_luks_essiv.cl" #include "inc_luks_xts.cl" @@ -244,7 +309,7 @@ __kernel void m14643_comp (KERN_ATTR_TMPS_ESALT (luks_tmp_t, luks_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m14700-pure.cl b/OpenCL/m14700-pure.cl index e8f84071b..0a091346d 100644 --- a/OpenCL/m14700-pure.cl +++ b/OpenCL/m14700-pure.cl @@ -17,6 +17,23 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct itunes_backup +{ + u32 wpky[10]; + u32 dpsl[5]; + +} itunes_backup_t; + +typedef struct pbkdf2_sha1_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha1_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -363,7 +380,7 @@ __kernel void m14700_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha1_tmp_t, itunes_backu { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } return; diff --git a/OpenCL/m14800-pure.cl b/OpenCL/m14800-pure.cl index d01de2098..7ee7a69b3 100644 --- a/OpenCL/m14800-pure.cl +++ b/OpenCL/m14800-pure.cl @@ -15,6 +15,23 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_aes.cl" +typedef struct itunes_backup +{ + u32 wpky[10]; + u32 dpsl[5]; + +} itunes_backup_t; + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -627,7 +644,7 @@ __kernel void m14800_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, itunes_bac { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } return; diff --git a/OpenCL/m14900_a3-optimized.cl b/OpenCL/m14900_a3-optimized.cl index 8aca7b066..c6b565bca 100644 --- a/OpenCL/m14900_a3-optimized.cl +++ b/OpenCL/m14900_a3-optimized.cl @@ -102,7 +102,7 @@ DECLSPEC u32 skip32 (__local u8 *s_ftable, const u32 KP, const u32 *key) return r; } -DECLSPEC void m14900m (__local u8 *s_ftable, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice01_t)) +DECLSPEC void m14900m (__local u8 *s_ftable, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) { /** * modifier @@ -150,7 +150,7 @@ DECLSPEC void m14900m (__local u8 *s_ftable, u32 *w0, u32 *w1, u32 *w2, u32 *w3, } } -DECLSPEC void m14900s (__local u8 *s_ftable, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice01_t)) +DECLSPEC void m14900s (__local u8 *s_ftable, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) { /** * modifier @@ -210,7 +210,7 @@ DECLSPEC void m14900s (__local u8 *s_ftable, u32 *w0, u32 *w1, u32 *w2, u32 *w3, } } -__kernel void m14900_m04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m14900_m04 (KERN_ATTR_BASIC ()) { /** * modifier @@ -276,15 +276,15 @@ __kernel void m14900_m04 (KERN_ATTR_ESALT (oldoffice01_t)) m14900m (s_ftable, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void m14900_m08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m14900_m08 (KERN_ATTR_BASIC ()) { } -__kernel void m14900_m16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m14900_m16 (KERN_ATTR_BASIC ()) { } -__kernel void m14900_s04 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m14900_s04 (KERN_ATTR_BASIC ()) { /** * modifier @@ -350,10 +350,10 @@ __kernel void m14900_s04 (KERN_ATTR_ESALT (oldoffice01_t)) m14900s (s_ftable, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void m14900_s08 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m14900_s08 (KERN_ATTR_BASIC ()) { } -__kernel void m14900_s16 (KERN_ATTR_ESALT (oldoffice01_t)) +__kernel void m14900_s16 (KERN_ATTR_BASIC ()) { } diff --git a/OpenCL/m15100-pure.cl b/OpenCL/m15100-pure.cl index e79ffb5e2..f3a439a25 100644 --- a/OpenCL/m15100-pure.cl +++ b/OpenCL/m15100-pure.cl @@ -16,6 +16,17 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf1_sha1_tmp +{ + // pbkdf1-sha1 is limited to 160 bits + + u32 ipad[5]; + u32 opad[5]; + + u32 out[5]; + +} pbkdf1_sha1_tmp_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m15300-pure.cl b/OpenCL/m15300-pure.cl index d3f68d6dc..103c0338d 100644 --- a/OpenCL/m15300-pure.cl +++ b/OpenCL/m15300-pure.cl @@ -5,6 +5,12 @@ #define NEW_SIMD_CODE +// we don't need fast local memory +// it's used in _comp kernel only +// not using it helps some opencl runtimes to survive +#undef LOCAL_MEM_TYPE +#define LOCAL_MEM_TYPE LOCAL_MEM_TYPE_GLOBAL + #include "inc_vendor.cl" #include "inc_hash_constants.h" #include "inc_hash_functions.cl" @@ -13,534 +19,41 @@ #include "inc_simd.cl" #include "inc_hash_md4.cl" #include "inc_hash_sha1.cl" +#include "inc_cipher_des.cl" #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" -#define PERM_OP(a,b,tt,n,m) \ -{ \ - tt = a >> n; \ - tt = tt ^ b; \ - tt = tt & m; \ - b = b ^ tt; \ - tt = tt << n; \ - a = a ^ tt; \ -} - -#define HPERM_OP(a,tt,n,m) \ -{ \ - tt = a << (16 + n); \ - tt = tt ^ a; \ - tt = tt & m; \ - a = a ^ tt; \ - tt = tt >> (16 + n); \ - a = a ^ tt; \ -} - -#define IP(l,r,tt) \ -{ \ - PERM_OP (r, l, tt, 4, 0x0f0f0f0f); \ - PERM_OP (l, r, tt, 16, 0x0000ffff); \ - PERM_OP (r, l, tt, 2, 0x33333333); \ - PERM_OP (l, r, tt, 8, 0x00ff00ff); \ - PERM_OP (r, l, tt, 1, 0x55555555); \ -} - -#define FP(l,r,tt) \ -{ \ - PERM_OP (l, r, tt, 1, 0x55555555); \ - PERM_OP (r, l, tt, 8, 0x00ff00ff); \ - PERM_OP (l, r, tt, 2, 0x33333333); \ - PERM_OP (r, l, tt, 16, 0x0000ffff); \ - PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \ -} - -__constant u32a c_SPtrans[8][64] = +typedef struct dpapimk { - { - /* nibble 0 */ - 0x02080800, 0x00080000, 0x02000002, 0x02080802, - 0x02000000, 0x00080802, 0x00080002, 0x02000002, - 0x00080802, 0x02080800, 0x02080000, 0x00000802, - 0x02000802, 0x02000000, 0x00000000, 0x00080002, - 0x00080000, 0x00000002, 0x02000800, 0x00080800, - 0x02080802, 0x02080000, 0x00000802, 0x02000800, - 0x00000002, 0x00000800, 0x00080800, 0x02080002, - 0x00000800, 0x02000802, 0x02080002, 0x00000000, - 0x00000000, 0x02080802, 0x02000800, 0x00080002, - 0x02080800, 0x00080000, 0x00000802, 0x02000800, - 0x02080002, 0x00000800, 0x00080800, 0x02000002, - 0x00080802, 0x00000002, 0x02000002, 0x02080000, - 0x02080802, 0x00080800, 0x02080000, 0x02000802, - 0x02000000, 0x00000802, 0x00080002, 0x00000000, - 0x00080000, 0x02000000, 0x02000802, 0x02080800, - 0x00000002, 0x02080002, 0x00000800, 0x00080802, - }, - { - /* nibble 1 */ - 0x40108010, 0x00000000, 0x00108000, 0x40100000, - 0x40000010, 0x00008010, 0x40008000, 0x00108000, - 0x00008000, 0x40100010, 0x00000010, 0x40008000, - 0x00100010, 0x40108000, 0x40100000, 0x00000010, - 0x00100000, 0x40008010, 0x40100010, 0x00008000, - 0x00108010, 0x40000000, 0x00000000, 0x00100010, - 0x40008010, 0x00108010, 0x40108000, 0x40000010, - 0x40000000, 0x00100000, 0x00008010, 0x40108010, - 0x00100010, 0x40108000, 0x40008000, 0x00108010, - 0x40108010, 0x00100010, 0x40000010, 0x00000000, - 0x40000000, 0x00008010, 0x00100000, 0x40100010, - 0x00008000, 0x40000000, 0x00108010, 0x40008010, - 0x40108000, 0x00008000, 0x00000000, 0x40000010, - 0x00000010, 0x40108010, 0x00108000, 0x40100000, - 0x40100010, 0x00100000, 0x00008010, 0x40008000, - 0x40008010, 0x00000010, 0x40100000, 0x00108000, - }, - { - /* nibble 2 */ - 0x04000001, 0x04040100, 0x00000100, 0x04000101, - 0x00040001, 0x04000000, 0x04000101, 0x00040100, - 0x04000100, 0x00040000, 0x04040000, 0x00000001, - 0x04040101, 0x00000101, 0x00000001, 0x04040001, - 0x00000000, 0x00040001, 0x04040100, 0x00000100, - 0x00000101, 0x04040101, 0x00040000, 0x04000001, - 0x04040001, 0x04000100, 0x00040101, 0x04040000, - 0x00040100, 0x00000000, 0x04000000, 0x00040101, - 0x04040100, 0x00000100, 0x00000001, 0x00040000, - 0x00000101, 0x00040001, 0x04040000, 0x04000101, - 0x00000000, 0x04040100, 0x00040100, 0x04040001, - 0x00040001, 0x04000000, 0x04040101, 0x00000001, - 0x00040101, 0x04000001, 0x04000000, 0x04040101, - 0x00040000, 0x04000100, 0x04000101, 0x00040100, - 0x04000100, 0x00000000, 0x04040001, 0x00000101, - 0x04000001, 0x00040101, 0x00000100, 0x04040000, - }, - { - /* nibble 3 */ - 0x00401008, 0x10001000, 0x00000008, 0x10401008, - 0x00000000, 0x10400000, 0x10001008, 0x00400008, - 0x10401000, 0x10000008, 0x10000000, 0x00001008, - 0x10000008, 0x00401008, 0x00400000, 0x10000000, - 0x10400008, 0x00401000, 0x00001000, 0x00000008, - 0x00401000, 0x10001008, 0x10400000, 0x00001000, - 0x00001008, 0x00000000, 0x00400008, 0x10401000, - 0x10001000, 0x10400008, 0x10401008, 0x00400000, - 0x10400008, 0x00001008, 0x00400000, 0x10000008, - 0x00401000, 0x10001000, 0x00000008, 0x10400000, - 0x10001008, 0x00000000, 0x00001000, 0x00400008, - 0x00000000, 0x10400008, 0x10401000, 0x00001000, - 0x10000000, 0x10401008, 0x00401008, 0x00400000, - 0x10401008, 0x00000008, 0x10001000, 0x00401008, - 0x00400008, 0x00401000, 0x10400000, 0x10001008, - 0x00001008, 0x10000000, 0x10000008, 0x10401000, - }, - { - /* nibble 4 */ - 0x08000000, 0x00010000, 0x00000400, 0x08010420, - 0x08010020, 0x08000400, 0x00010420, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x00010400, - 0x08000420, 0x08010020, 0x08010400, 0x00000000, - 0x00010400, 0x08000000, 0x00010020, 0x00000420, - 0x08000400, 0x00010420, 0x00000000, 0x08000020, - 0x00000020, 0x08000420, 0x08010420, 0x00010020, - 0x08010000, 0x00000400, 0x00000420, 0x08010400, - 0x08010400, 0x08000420, 0x00010020, 0x08010000, - 0x00010000, 0x00000020, 0x08000020, 0x08000400, - 0x08000000, 0x00010400, 0x08010420, 0x00000000, - 0x00010420, 0x08000000, 0x00000400, 0x00010020, - 0x08000420, 0x00000400, 0x00000000, 0x08010420, - 0x08010020, 0x08010400, 0x00000420, 0x00010000, - 0x00010400, 0x08010020, 0x08000400, 0x00000420, - 0x00000020, 0x00010420, 0x08010000, 0x08000020, - }, - { - /* nibble 5 */ - 0x80000040, 0x00200040, 0x00000000, 0x80202000, - 0x00200040, 0x00002000, 0x80002040, 0x00200000, - 0x00002040, 0x80202040, 0x00202000, 0x80000000, - 0x80002000, 0x80000040, 0x80200000, 0x00202040, - 0x00200000, 0x80002040, 0x80200040, 0x00000000, - 0x00002000, 0x00000040, 0x80202000, 0x80200040, - 0x80202040, 0x80200000, 0x80000000, 0x00002040, - 0x00000040, 0x00202000, 0x00202040, 0x80002000, - 0x00002040, 0x80000000, 0x80002000, 0x00202040, - 0x80202000, 0x00200040, 0x00000000, 0x80002000, - 0x80000000, 0x00002000, 0x80200040, 0x00200000, - 0x00200040, 0x80202040, 0x00202000, 0x00000040, - 0x80202040, 0x00202000, 0x00200000, 0x80002040, - 0x80000040, 0x80200000, 0x00202040, 0x00000000, - 0x00002000, 0x80000040, 0x80002040, 0x80202000, - 0x80200000, 0x00002040, 0x00000040, 0x80200040, - }, - { - /* nibble 6 */ - 0x00004000, 0x00000200, 0x01000200, 0x01000004, - 0x01004204, 0x00004004, 0x00004200, 0x00000000, - 0x01000000, 0x01000204, 0x00000204, 0x01004000, - 0x00000004, 0x01004200, 0x01004000, 0x00000204, - 0x01000204, 0x00004000, 0x00004004, 0x01004204, - 0x00000000, 0x01000200, 0x01000004, 0x00004200, - 0x01004004, 0x00004204, 0x01004200, 0x00000004, - 0x00004204, 0x01004004, 0x00000200, 0x01000000, - 0x00004204, 0x01004000, 0x01004004, 0x00000204, - 0x00004000, 0x00000200, 0x01000000, 0x01004004, - 0x01000204, 0x00004204, 0x00004200, 0x00000000, - 0x00000200, 0x01000004, 0x00000004, 0x01000200, - 0x00000000, 0x01000204, 0x01000200, 0x00004200, - 0x00000204, 0x00004000, 0x01004204, 0x01000000, - 0x01004200, 0x00000004, 0x00004004, 0x01004204, - 0x01000004, 0x01004200, 0x01004000, 0x00004004, - }, - { - /* nibble 7 */ - 0x20800080, 0x20820000, 0x00020080, 0x00000000, - 0x20020000, 0x00800080, 0x20800000, 0x20820080, - 0x00000080, 0x20000000, 0x00820000, 0x00020080, - 0x00820080, 0x20020080, 0x20000080, 0x20800000, - 0x00020000, 0x00820080, 0x00800080, 0x20020000, - 0x20820080, 0x20000080, 0x00000000, 0x00820000, - 0x20000000, 0x00800000, 0x20020080, 0x20800080, - 0x00800000, 0x00020000, 0x20820000, 0x00000080, - 0x00800000, 0x00020000, 0x20000080, 0x20820080, - 0x00020080, 0x20000000, 0x00000000, 0x00820000, - 0x20800080, 0x20020080, 0x20020000, 0x00800080, - 0x20820000, 0x00000080, 0x00800080, 0x20020000, - 0x20820080, 0x00800000, 0x20800000, 0x20000080, - 0x00820000, 0x00020080, 0x20020080, 0x20800000, - 0x00000080, 0x20820000, 0x00820080, 0x00000000, - 0x20000000, 0x20800080, 0x00020000, 0x00820080, - }, -}; + u32 context; -__constant u32a c_skb[8][64] = + u32 SID[32]; + u32 SID_len; + u32 SID_offset; + + /* here only for possible + forward compatibiliy + */ + // u8 cipher_algo[16]; + // u8 hash_algo[16]; + + u32 iv[4]; + u32 contents_len; + u32 contents[128]; + +} dpapimk_t; + +typedef struct dpapimk_tmp_v1 { - { - 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00010000, 0x00010010, 0x20010000, 0x20010010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00010800, 0x00010810, 0x20010800, 0x20010810, - 0x00000020, 0x00000030, 0x20000020, 0x20000030, - 0x00010020, 0x00010030, 0x20010020, 0x20010030, - 0x00000820, 0x00000830, 0x20000820, 0x20000830, - 0x00010820, 0x00010830, 0x20010820, 0x20010830, - 0x00080000, 0x00080010, 0x20080000, 0x20080010, - 0x00090000, 0x00090010, 0x20090000, 0x20090010, - 0x00080800, 0x00080810, 0x20080800, 0x20080810, - 0x00090800, 0x00090810, 0x20090800, 0x20090810, - 0x00080020, 0x00080030, 0x20080020, 0x20080030, - 0x00090020, 0x00090030, 0x20090020, 0x20090030, - 0x00080820, 0x00080830, 0x20080820, 0x20080830, - 0x00090820, 0x00090830, 0x20090820, 0x20090830, - }, - { - 0x00000000, 0x02000000, 0x00002000, 0x02002000, - 0x00200000, 0x02200000, 0x00202000, 0x02202000, - 0x00000004, 0x02000004, 0x00002004, 0x02002004, - 0x00200004, 0x02200004, 0x00202004, 0x02202004, - 0x00000400, 0x02000400, 0x00002400, 0x02002400, - 0x00200400, 0x02200400, 0x00202400, 0x02202400, - 0x00000404, 0x02000404, 0x00002404, 0x02002404, - 0x00200404, 0x02200404, 0x00202404, 0x02202404, - 0x10000000, 0x12000000, 0x10002000, 0x12002000, - 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, - 0x10200004, 0x12200004, 0x10202004, 0x12202004, - 0x10000400, 0x12000400, 0x10002400, 0x12002400, - 0x10200400, 0x12200400, 0x10202400, 0x12202400, - 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404, - }, - { - 0x00000000, 0x00000001, 0x00040000, 0x00040001, - 0x01000000, 0x01000001, 0x01040000, 0x01040001, - 0x00000002, 0x00000003, 0x00040002, 0x00040003, - 0x01000002, 0x01000003, 0x01040002, 0x01040003, - 0x00000200, 0x00000201, 0x00040200, 0x00040201, - 0x01000200, 0x01000201, 0x01040200, 0x01040201, - 0x00000202, 0x00000203, 0x00040202, 0x00040203, - 0x01000202, 0x01000203, 0x01040202, 0x01040203, - 0x08000000, 0x08000001, 0x08040000, 0x08040001, - 0x09000000, 0x09000001, 0x09040000, 0x09040001, - 0x08000002, 0x08000003, 0x08040002, 0x08040003, - 0x09000002, 0x09000003, 0x09040002, 0x09040003, - 0x08000200, 0x08000201, 0x08040200, 0x08040201, - 0x09000200, 0x09000201, 0x09040200, 0x09040201, - 0x08000202, 0x08000203, 0x08040202, 0x08040203, - 0x09000202, 0x09000203, 0x09040202, 0x09040203, - }, - { - 0x00000000, 0x00100000, 0x00000100, 0x00100100, - 0x00000008, 0x00100008, 0x00000108, 0x00100108, - 0x00001000, 0x00101000, 0x00001100, 0x00101100, - 0x00001008, 0x00101008, 0x00001108, 0x00101108, - 0x04000000, 0x04100000, 0x04000100, 0x04100100, - 0x04000008, 0x04100008, 0x04000108, 0x04100108, - 0x04001000, 0x04101000, 0x04001100, 0x04101100, - 0x04001008, 0x04101008, 0x04001108, 0x04101108, - 0x00020000, 0x00120000, 0x00020100, 0x00120100, - 0x00020008, 0x00120008, 0x00020108, 0x00120108, - 0x00021000, 0x00121000, 0x00021100, 0x00121100, - 0x00021008, 0x00121008, 0x00021108, 0x00121108, - 0x04020000, 0x04120000, 0x04020100, 0x04120100, - 0x04020008, 0x04120008, 0x04020108, 0x04120108, - 0x04021000, 0x04121000, 0x04021100, 0x04121100, - 0x04021008, 0x04121008, 0x04021108, 0x04121108, - }, - { - 0x00000000, 0x10000000, 0x00010000, 0x10010000, - 0x00000004, 0x10000004, 0x00010004, 0x10010004, - 0x20000000, 0x30000000, 0x20010000, 0x30010000, - 0x20000004, 0x30000004, 0x20010004, 0x30010004, - 0x00100000, 0x10100000, 0x00110000, 0x10110000, - 0x00100004, 0x10100004, 0x00110004, 0x10110004, - 0x20100000, 0x30100000, 0x20110000, 0x30110000, - 0x20100004, 0x30100004, 0x20110004, 0x30110004, - 0x00001000, 0x10001000, 0x00011000, 0x10011000, - 0x00001004, 0x10001004, 0x00011004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, - 0x20001004, 0x30001004, 0x20011004, 0x30011004, - 0x00101000, 0x10101000, 0x00111000, 0x10111000, - 0x00101004, 0x10101004, 0x00111004, 0x10111004, - 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004, - }, - { - 0x00000000, 0x08000000, 0x00000008, 0x08000008, - 0x00000400, 0x08000400, 0x00000408, 0x08000408, - 0x00020000, 0x08020000, 0x00020008, 0x08020008, - 0x00020400, 0x08020400, 0x00020408, 0x08020408, - 0x00000001, 0x08000001, 0x00000009, 0x08000009, - 0x00000401, 0x08000401, 0x00000409, 0x08000409, - 0x00020001, 0x08020001, 0x00020009, 0x08020009, - 0x00020401, 0x08020401, 0x00020409, 0x08020409, - 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, - 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, - 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, - 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, - 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, - 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, - 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, - 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, - }, - { - 0x00000000, 0x00000100, 0x00080000, 0x00080100, - 0x01000000, 0x01000100, 0x01080000, 0x01080100, - 0x00000010, 0x00000110, 0x00080010, 0x00080110, - 0x01000010, 0x01000110, 0x01080010, 0x01080110, - 0x00200000, 0x00200100, 0x00280000, 0x00280100, - 0x01200000, 0x01200100, 0x01280000, 0x01280100, - 0x00200010, 0x00200110, 0x00280010, 0x00280110, - 0x01200010, 0x01200110, 0x01280010, 0x01280110, - 0x00000200, 0x00000300, 0x00080200, 0x00080300, - 0x01000200, 0x01000300, 0x01080200, 0x01080300, - 0x00000210, 0x00000310, 0x00080210, 0x00080310, - 0x01000210, 0x01000310, 0x01080210, 0x01080310, - 0x00200200, 0x00200300, 0x00280200, 0x00280300, - 0x01200200, 0x01200300, 0x01280200, 0x01280300, - 0x00200210, 0x00200310, 0x00280210, 0x00280310, - 0x01200210, 0x01200310, 0x01280210, 0x01280310, - }, - { - 0x00000000, 0x04000000, 0x00040000, 0x04040000, - 0x00000002, 0x04000002, 0x00040002, 0x04040002, - 0x00002000, 0x04002000, 0x00042000, 0x04042000, - 0x00002002, 0x04002002, 0x00042002, 0x04042002, - 0x00000020, 0x04000020, 0x00040020, 0x04040020, - 0x00000022, 0x04000022, 0x00040022, 0x04040022, - 0x00002020, 0x04002020, 0x00042020, 0x04042020, - 0x00002022, 0x04002022, 0x00042022, 0x04042022, - 0x00000800, 0x04000800, 0x00040800, 0x04040800, - 0x00000802, 0x04000802, 0x00040802, 0x04040802, - 0x00002800, 0x04002800, 0x00042800, 0x04042800, - 0x00002802, 0x04002802, 0x00042802, 0x04042802, - 0x00000820, 0x04000820, 0x00040820, 0x04040820, - 0x00000822, 0x04000822, 0x00040822, 0x04040822, - 0x00002820, 0x04002820, 0x00042820, 0x04042820, - 0x00002822, 0x04002822, 0x00042822, 0x04042822 - } -}; + u32 ipad[5]; + u32 opad[5]; + u32 dgst[10]; + u32 out[10]; -#define BOX(i,n,S) (S)[(n)][(i)] -#define BOX1(i,S) (S)[(i)] + u32 userKey[5]; -DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, __local u32 (*s_SPtrans)[64]) -{ - u32 tt; - - u32 r = data[0]; - u32 l = data[1]; - - IP (r, l, tt); - - r = rotl32_S (r, 3u); - l = rotl32_S (l, 3u); - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i += 2) - { - u32 u; - u32 t; - - u = Kc[i + 0] ^ r; - t = Kd[i + 0] ^ rotl32_S (r, 28u); - - l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - - u = Kc[i + 1] ^ l; - t = Kd[i + 1] ^ rotl32_S (l, 28u); - - r ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - } - - l = rotl32_S (l, 29u); - r = rotl32_S (r, 29u); - - FP (r, l, tt); - - iv[0] = l; - iv[1] = r; -} - -DECLSPEC void _des_crypt_decrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, __local u32 (*s_SPtrans)[64]) -{ - u32 tt; - - u32 r = data[0]; - u32 l = data[1]; - - IP (r, l, tt); - - r = rotl32_S (r, 3u); - l = rotl32_S (l, 3u); - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 16; i > 0; i -= 2) - { - u32 u; - u32 t; - - u = Kc[i - 1] ^ r; - t = Kd[i - 1] ^ rotl32_S (r, 28u); - - l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - - u = Kc[i - 2] ^ l; - t = Kd[i - 2] ^ rotl32_S (l, 28u); - - r ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) - | BOX (((u >> 10) & 0x3f), 2, s_SPtrans) - | BOX (((u >> 18) & 0x3f), 4, s_SPtrans) - | BOX (((u >> 26) & 0x3f), 6, s_SPtrans) - | BOX (((t >> 2) & 0x3f), 1, s_SPtrans) - | BOX (((t >> 10) & 0x3f), 3, s_SPtrans) - | BOX (((t >> 18) & 0x3f), 5, s_SPtrans) - | BOX (((t >> 26) & 0x3f), 7, s_SPtrans); - } - - l = rotl32_S (l, 29u); - r = rotl32_S (r, 29u); - - FP (r, l, tt); - - iv[0] = l; - iv[1] = r; -} - -DECLSPEC void _des_crypt_keysetup (u32 c, u32 d, u32 *Kc, u32 *Kd, __local u32 (*s_skb)[64]) -{ - u32 tt; - - PERM_OP (d, c, tt, 4, 0x0f0f0f0f); - HPERM_OP (c, tt, 2, 0xcccc0000); - HPERM_OP (d, tt, 2, 0xcccc0000); - PERM_OP (d, c, tt, 1, 0x55555555); - PERM_OP (c, d, tt, 8, 0x00ff00ff); - PERM_OP (d, c, tt, 1, 0x55555555); - - d = ((d & 0x000000ff) << 16) - | ((d & 0x0000ff00) << 0) - | ((d & 0x00ff0000) >> 16) - | ((c & 0xf0000000) >> 4); - - c = c & 0x0fffffff; - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 16; i++) - { - if ((i < 2) || (i == 8) || (i == 15)) - { - c = ((c >> 1) | (c << 27)); - d = ((d >> 1) | (d << 27)); - } - else - { - c = ((c >> 2) | (c << 26)); - d = ((d >> 2) | (d << 26)); - } - - c = c & 0x0fffffff; - d = d & 0x0fffffff; - - const u32 c00 = (c >> 0) & 0x0000003f; - const u32 c06 = (c >> 6) & 0x00383003; - const u32 c07 = (c >> 7) & 0x0000003c; - const u32 c13 = (c >> 13) & 0x0000060f; - const u32 c20 = (c >> 20) & 0x00000001; - - u32 s = BOX (((c00 >> 0) & 0xff), 0, s_skb) - | BOX (((c06 >> 0) & 0xff) - |((c07 >> 0) & 0xff), 1, s_skb) - | BOX (((c13 >> 0) & 0xff) - |((c06 >> 8) & 0xff), 2, s_skb) - | BOX (((c20 >> 0) & 0xff) - |((c13 >> 8) & 0xff) - |((c06 >> 16) & 0xff), 3, s_skb); - - const u32 d00 = (d >> 0) & 0x00003c3f; - const u32 d07 = (d >> 7) & 0x00003f03; - const u32 d21 = (d >> 21) & 0x0000000f; - const u32 d22 = (d >> 22) & 0x00000030; - - u32 t = BOX (((d00 >> 0) & 0xff), 4, s_skb) - | BOX (((d07 >> 0) & 0xff) - |((d00 >> 8) & 0xff), 5, s_skb) - | BOX (((d07 >> 8) & 0xff), 6, s_skb) - | BOX (((d21 >> 0) & 0xff) - |((d22 >> 0) & 0xff), 7, s_skb); - - Kc[i] = ((t << 16) | (s & 0x0000ffff)); - Kd[i] = ((s >> 16) | (t & 0xffff0000)); - - Kc[i] = rotl32_S (Kc[i], 2u); - Kd[i] = rotl32_S (Kd[i], 2u); - } -} +} dpapimk_tmp_v1_t; DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { @@ -874,6 +387,8 @@ __kernel void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) * des shared */ + #ifdef REAL_SHM + __local u32 s_SPtrans[8][64]; __local u32 s_skb[8][64]; @@ -900,6 +415,13 @@ __kernel void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) barrier (CLK_LOCAL_MEM_FENCE); + #else + + __constant u32a (*s_SPtrans)[64] = c_SPtrans; + __constant u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -911,9 +433,6 @@ __kernel void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) u32 w2[4]; u32 w3[4]; - u32 ipad[5]; - u32 opad[5]; - u32 key[6]; key[0] = swap32_S (tmps[gid].out[0]); @@ -1105,7 +624,7 @@ __kernel void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m15400_a0-optimized.cl b/OpenCL/m15400_a0-optimized.cl index 2e5e7536c..cb018105c 100644 --- a/OpenCL/m15400_a0-optimized.cl +++ b/OpenCL/m15400_a0-optimized.cl @@ -14,6 +14,15 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct chacha20 +{ + u32 iv[2]; + u32 plain[2]; + u32 position[2]; + u32 offset; + +} chacha20_t; + #define CHACHA_CONST_00 0x61707865 #define CHACHA_CONST_01 0x3320646e #define CHACHA_CONST_02 0x79622d32 diff --git a/OpenCL/m15400_a1-optimized.cl b/OpenCL/m15400_a1-optimized.cl index 13378b279..5ffedf3dd 100644 --- a/OpenCL/m15400_a1-optimized.cl +++ b/OpenCL/m15400_a1-optimized.cl @@ -14,6 +14,15 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct chacha20 +{ + u32 iv[2]; + u32 plain[2]; + u32 position[2]; + u32 offset; + +} chacha20_t; + #define CHACHA_CONST_00 0x61707865 #define CHACHA_CONST_01 0x3320646e #define CHACHA_CONST_02 0x79622d32 diff --git a/OpenCL/m15400_a3-optimized.cl b/OpenCL/m15400_a3-optimized.cl index 4db30c3bc..57e24d579 100644 --- a/OpenCL/m15400_a3-optimized.cl +++ b/OpenCL/m15400_a3-optimized.cl @@ -12,6 +12,15 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct chacha20 +{ + u32 iv[2]; + u32 plain[2]; + u32 position[2]; + u32 offset; + +} chacha20_t; + #define CHACHA_CONST_00 0x61707865 #define CHACHA_CONST_01 0x3320646e #define CHACHA_CONST_02 0x79622d32 diff --git a/OpenCL/m15600-pure.cl b/OpenCL/m15600-pure.cl index 711903a13..2cb0523b8 100644 --- a/OpenCL/m15600-pure.cl +++ b/OpenCL/m15600-pure.cl @@ -13,6 +13,23 @@ #include "inc_simd.cl" #include "inc_hash_sha256.cl" +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct ethereum_pbkdf2 +{ + u32 salt_buf[16]; + u32 ciphertext[8]; + +} ethereum_pbkdf2_t; + #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" diff --git a/OpenCL/m15700-pure.cl b/OpenCL/m15700-pure.cl index 20dd83009..a5274733b 100644 --- a/OpenCL/m15700-pure.cl +++ b/OpenCL/m15700-pure.cl @@ -13,6 +13,23 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct +{ + #ifndef SCRYPT_TMP_ELEM + #define SCRYPT_TMP_ELEM 1 + #endif + + uint4 P[SCRYPT_TMP_ELEM]; + +} scrypt_tmp_t; + +typedef struct ethereum_scrypt +{ + u32 salt_buf[16]; + u32 ciphertext[8]; + +} ethereum_scrypt_t; + DECLSPEC uint4 swap32_4 (uint4 v) { return (rotate ((v & 0x00FF00FF), 24u) | rotate ((v & 0xFF00FF00), 8u)); @@ -336,7 +353,7 @@ DECLSPEC void keccak_transform_S (u64 *st) } } -__kernel void __attribute__((reqd_work_group_size(1, 1, 1))) m15700_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_t)) +__kernel void m15700_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_t)) { /** * base @@ -401,7 +418,7 @@ __kernel void __attribute__((reqd_work_group_size(1, 1, 1))) m15700_init (KERN_A } } -__kernel void __attribute__((reqd_work_group_size(1, 1, 1))) m15700_loop (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_t)) +__kernel void m15700_loop (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_t)) { const u64 gid = get_global_id (0); @@ -439,7 +456,7 @@ __kernel void __attribute__((reqd_work_group_size(1, 1, 1))) m15700_loop (KERN_A #endif } -__kernel void __attribute__((reqd_work_group_size(1, 1, 1))) m15700_comp (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_t)) +__kernel void m15700_comp (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_t)) { /** * base diff --git a/OpenCL/m15900-pure.cl b/OpenCL/m15900-pure.cl index 807b30b64..c144b2242 100644 --- a/OpenCL/m15900-pure.cl +++ b/OpenCL/m15900-pure.cl @@ -19,6 +19,37 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct dpapimk_tmp_v2 +{ + u64 ipad64[8]; + u64 opad64[8]; + u64 dgst64[16]; + u64 out64[16]; + + u32 userKey[8]; + +} dpapimk_tmp_v2_t; + +typedef struct dpapimk +{ + u32 context; + + u32 SID[32]; + u32 SID_len; + u32 SID_offset; + + /* here only for possible + forward compatibiliy + */ + // u8 cipher_algo[16]; + // u8 hash_algo[16]; + + u32 iv[4]; + u32 contents_len; + u32 contents[128]; + +} dpapimk_t; + DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) { digest[0] = ipad[0]; @@ -775,7 +806,7 @@ __kernel void m15900_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v2_t, dpapimk_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16100_a0-optimized.cl b/OpenCL/m16100_a0-optimized.cl index be6caa422..4411c8304 100644 --- a/OpenCL/m16100_a0-optimized.cl +++ b/OpenCL/m16100_a0-optimized.cl @@ -14,6 +14,17 @@ #include "inc_rp_optimized.cl" #include "inc_simd.cl" +typedef struct tacacs_plus +{ + u32 session_buf[16]; + + u32 ct_data_buf[64]; + u32 ct_data_len; + + u32 sequence_buf[16]; + +} tacacs_plus_t; + __kernel void m16100_m04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { /** @@ -247,7 +258,7 @@ __kernel void m16100_m04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -265,7 +276,7 @@ __kernel void m16100_m04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -284,7 +295,7 @@ __kernel void m16100_m04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -532,7 +543,7 @@ __kernel void m16100_s04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -550,7 +561,7 @@ __kernel void m16100_s04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -569,7 +580,7 @@ __kernel void m16100_s04 (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16100_a0-pure.cl b/OpenCL/m16100_a0-pure.cl index 061b26a96..d7c6c2371 100644 --- a/OpenCL/m16100_a0-pure.cl +++ b/OpenCL/m16100_a0-pure.cl @@ -15,6 +15,17 @@ #include "inc_scalar.cl" #include "inc_hash_md5.cl" +typedef struct tacacs_plus +{ + u32 session_buf[16]; + + u32 ct_data_buf[64]; + u32 ct_data_len; + + u32 sequence_buf[16]; + +} tacacs_plus_t; + __kernel void m16100_mxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { /** @@ -133,7 +144,7 @@ __kernel void m16100_mxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -151,7 +162,7 @@ __kernel void m16100_mxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -170,7 +181,7 @@ __kernel void m16100_mxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -295,7 +306,7 @@ __kernel void m16100_sxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -313,7 +324,7 @@ __kernel void m16100_sxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -332,7 +343,7 @@ __kernel void m16100_sxx (KERN_ATTR_RULES_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16100_a1-optimized.cl b/OpenCL/m16100_a1-optimized.cl index 8ae70c8ff..46c45a392 100644 --- a/OpenCL/m16100_a1-optimized.cl +++ b/OpenCL/m16100_a1-optimized.cl @@ -12,6 +12,17 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct tacacs_plus +{ + u32 session_buf[16]; + + u32 ct_data_buf[64]; + u32 ct_data_len; + + u32 sequence_buf[16]; + +} tacacs_plus_t; + __kernel void m16100_m04 (KERN_ATTR_ESALT (tacacs_plus_t)) { /** @@ -306,7 +317,7 @@ __kernel void m16100_m04 (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -324,7 +335,7 @@ __kernel void m16100_m04 (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -343,7 +354,7 @@ __kernel void m16100_m04 (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -652,7 +663,7 @@ __kernel void m16100_s04 (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -670,7 +681,7 @@ __kernel void m16100_s04 (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -689,7 +700,7 @@ __kernel void m16100_s04 (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16100_a1-pure.cl b/OpenCL/m16100_a1-pure.cl index 749db59aa..15b4ed1a0 100644 --- a/OpenCL/m16100_a1-pure.cl +++ b/OpenCL/m16100_a1-pure.cl @@ -12,6 +12,17 @@ #include "inc_common.cl" #include "inc_hash_md5.cl" +typedef struct tacacs_plus +{ + u32 session_buf[16]; + + u32 ct_data_buf[64]; + u32 ct_data_len; + + u32 sequence_buf[16]; + +} tacacs_plus_t; + __kernel void m16100_mxx (KERN_ATTR_ESALT (tacacs_plus_t)) { /** @@ -126,7 +137,7 @@ __kernel void m16100_mxx (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -144,7 +155,7 @@ __kernel void m16100_mxx (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -163,7 +174,7 @@ __kernel void m16100_mxx (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -284,7 +295,7 @@ __kernel void m16100_sxx (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -302,7 +313,7 @@ __kernel void m16100_sxx (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -321,7 +332,7 @@ __kernel void m16100_sxx (KERN_ATTR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16100_a3-optimized.cl b/OpenCL/m16100_a3-optimized.cl index 2d4fae198..fcfedac74 100644 --- a/OpenCL/m16100_a3-optimized.cl +++ b/OpenCL/m16100_a3-optimized.cl @@ -12,6 +12,17 @@ #include "inc_common.cl" #include "inc_simd.cl" +typedef struct tacacs_plus +{ + u32 session_buf[16]; + + u32 ct_data_buf[64]; + u32 ct_data_len; + + u32 sequence_buf[16]; + +} tacacs_plus_t; + DECLSPEC void m16100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (tacacs_plus_t)) { /** @@ -221,7 +232,7 @@ DECLSPEC void m16100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -239,7 +250,7 @@ DECLSPEC void m16100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -258,7 +269,7 @@ DECLSPEC void m16100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -474,7 +485,7 @@ DECLSPEC void m16100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -492,7 +503,7 @@ DECLSPEC void m16100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -511,7 +522,7 @@ DECLSPEC void m16100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16100_a3-pure.cl b/OpenCL/m16100_a3-pure.cl index 3133b5c8b..4e8e7b0a8 100644 --- a/OpenCL/m16100_a3-pure.cl +++ b/OpenCL/m16100_a3-pure.cl @@ -12,6 +12,17 @@ #include "inc_common.cl" #include "inc_hash_md5.cl" +typedef struct tacacs_plus +{ + u32 session_buf[16]; + + u32 ct_data_buf[64]; + u32 ct_data_len; + + u32 sequence_buf[16]; + +} tacacs_plus_t; + __kernel void m16100_mxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { /** @@ -143,7 +154,7 @@ __kernel void m16100_mxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -161,7 +172,7 @@ __kernel void m16100_mxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -180,7 +191,7 @@ __kernel void m16100_mxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -318,7 +329,7 @@ __kernel void m16100_sxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -336,7 +347,7 @@ __kernel void m16100_sxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -355,7 +366,7 @@ __kernel void m16100_sxx (KERN_ATTR_VECTOR_ESALT (tacacs_plus_t)) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16200-pure.cl b/OpenCL/m16200-pure.cl index 34d13117d..6039d84aa 100644 --- a/OpenCL/m16200-pure.cl +++ b/OpenCL/m16200-pure.cl @@ -17,6 +17,25 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct apple_secure_notes_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[8]; + u32 out[8]; + +} apple_secure_notes_tmp_t; + +typedef struct apple_secure_notes +{ + u32 Z_PK; + u32 ZCRYPTOITERATIONCOUNT; + u32 ZCRYPTOSALT[16]; + u32 ZCRYPTOWRAPPEDKEY[16]; + +} apple_secure_notes_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -376,7 +395,7 @@ __kernel void m16200_comp (KERN_ATTR_TMPS_ESALT (apple_secure_notes_tmp_t, apple { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m16300-pure.cl b/OpenCL/m16300-pure.cl index ae6c0261d..c23dc5c64 100644 --- a/OpenCL/m16300-pure.cl +++ b/OpenCL/m16300-pure.cl @@ -17,6 +17,24 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct ethereum_presale +{ + u32 iv[4]; + u32 enc_seed[152]; + u32 enc_seed_len; + +} ethereum_presale_t; + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + __constant u64a keccakf_rndc[24] = { 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, diff --git a/OpenCL/m16511_a0-pure.cl b/OpenCL/m16511_a0-pure.cl index 895e4fb77..bad4b7030 100644 --- a/OpenCL/m16511_a0-pure.cl +++ b/OpenCL/m16511_a0-pure.cl @@ -15,6 +15,15 @@ #include "inc_scalar.cl" #include "inc_hash_sha256.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16511_mxx (KERN_ATTR_RULES_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16511_a1-pure.cl b/OpenCL/m16511_a1-pure.cl index 742b6dc39..e6df24d78 100644 --- a/OpenCL/m16511_a1-pure.cl +++ b/OpenCL/m16511_a1-pure.cl @@ -13,6 +13,15 @@ #include "inc_scalar.cl" #include "inc_hash_sha256.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16511_mxx (KERN_ATTR_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16511_a3-pure.cl b/OpenCL/m16511_a3-pure.cl index 8cef28d2c..2812273da 100644 --- a/OpenCL/m16511_a3-pure.cl +++ b/OpenCL/m16511_a3-pure.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_sha256.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16511_mxx (KERN_ATTR_VECTOR_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16512_a0-pure.cl b/OpenCL/m16512_a0-pure.cl index 356f2f9bf..4a048297b 100644 --- a/OpenCL/m16512_a0-pure.cl +++ b/OpenCL/m16512_a0-pure.cl @@ -15,6 +15,15 @@ #include "inc_scalar.cl" #include "inc_hash_sha384.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16512_mxx (KERN_ATTR_RULES_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16512_a1-pure.cl b/OpenCL/m16512_a1-pure.cl index 2ce9234ae..9a3d9baeb 100644 --- a/OpenCL/m16512_a1-pure.cl +++ b/OpenCL/m16512_a1-pure.cl @@ -13,6 +13,15 @@ #include "inc_scalar.cl" #include "inc_hash_sha384.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16512_mxx (KERN_ATTR_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16512_a3-pure.cl b/OpenCL/m16512_a3-pure.cl index 0df0be7f5..52b453031 100644 --- a/OpenCL/m16512_a3-pure.cl +++ b/OpenCL/m16512_a3-pure.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_sha384.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16512_mxx (KERN_ATTR_VECTOR_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16513_a0-pure.cl b/OpenCL/m16513_a0-pure.cl index ac756e765..29490ae05 100644 --- a/OpenCL/m16513_a0-pure.cl +++ b/OpenCL/m16513_a0-pure.cl @@ -15,6 +15,15 @@ #include "inc_scalar.cl" #include "inc_hash_sha512.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16513_mxx (KERN_ATTR_RULES_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16513_a1-pure.cl b/OpenCL/m16513_a1-pure.cl index 8d1f7717d..09586726e 100644 --- a/OpenCL/m16513_a1-pure.cl +++ b/OpenCL/m16513_a1-pure.cl @@ -13,6 +13,15 @@ #include "inc_scalar.cl" #include "inc_hash_sha512.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16513_mxx (KERN_ATTR_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16513_a3-pure.cl b/OpenCL/m16513_a3-pure.cl index 5fb4445f1..590d41568 100644 --- a/OpenCL/m16513_a3-pure.cl +++ b/OpenCL/m16513_a3-pure.cl @@ -13,6 +13,15 @@ #include "inc_simd.cl" #include "inc_hash_sha512.cl" +typedef struct jwt +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} jwt_t; + __kernel void m16513_mxx (KERN_ATTR_VECTOR_ESALT (jwt_t)) { /** diff --git a/OpenCL/m16600_a0-optimized.cl b/OpenCL/m16600_a0-optimized.cl index 67c16956b..e7754fa40 100644 --- a/OpenCL/m16600_a0-optimized.cl +++ b/OpenCL/m16600_a0-optimized.cl @@ -15,6 +15,14 @@ #include "inc_simd.cl" #include "inc_cipher_aes.cl" +typedef struct electrum_wallet +{ + u32 salt_type; + u32 iv[4]; + u32 encrypted[4]; + +} electrum_wallet_t; + __kernel void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) { /** @@ -370,7 +378,7 @@ __kernel void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -386,7 +394,7 @@ __kernel void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -755,7 +763,7 @@ __kernel void m16600_s04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -771,7 +779,7 @@ __kernel void m16600_s04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16600_a0-pure.cl b/OpenCL/m16600_a0-pure.cl index 714fbd967..65ecd0c35 100644 --- a/OpenCL/m16600_a0-pure.cl +++ b/OpenCL/m16600_a0-pure.cl @@ -16,6 +16,14 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_aes.cl" +typedef struct electrum_wallet +{ + u32 salt_type; + u32 iv[4]; + u32 encrypted[4]; + +} electrum_wallet_t; + __kernel void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) { /** @@ -185,7 +193,7 @@ __kernel void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -201,7 +209,7 @@ __kernel void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -376,7 +384,7 @@ __kernel void m16600_sxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -392,7 +400,7 @@ __kernel void m16600_sxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16600_a1-optimized.cl b/OpenCL/m16600_a1-optimized.cl index 2f8e59e17..f993b520d 100644 --- a/OpenCL/m16600_a1-optimized.cl +++ b/OpenCL/m16600_a1-optimized.cl @@ -13,6 +13,14 @@ #include "inc_simd.cl" #include "inc_cipher_aes.cl" +typedef struct electrum_wallet +{ + u32 salt_type; + u32 iv[4]; + u32 encrypted[4]; + +} electrum_wallet_t; + __kernel void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) { /** @@ -426,7 +434,7 @@ __kernel void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -442,7 +450,7 @@ __kernel void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -869,7 +877,7 @@ __kernel void m16600_s04 (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -885,7 +893,7 @@ __kernel void m16600_s04 (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16600_a1-pure.cl b/OpenCL/m16600_a1-pure.cl index 58eb1e03a..b818631f6 100644 --- a/OpenCL/m16600_a1-pure.cl +++ b/OpenCL/m16600_a1-pure.cl @@ -14,6 +14,14 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_aes.cl" +typedef struct electrum_wallet +{ + u32 salt_type; + u32 iv[4]; + u32 encrypted[4]; + +} electrum_wallet_t; + __kernel void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) { /** @@ -181,7 +189,7 @@ __kernel void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -197,7 +205,7 @@ __kernel void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -370,7 +378,7 @@ __kernel void m16600_sxx (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -386,7 +394,7 @@ __kernel void m16600_sxx (KERN_ATTR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16600_a3-optimized.cl b/OpenCL/m16600_a3-optimized.cl index 4c65ca104..96bda402b 100644 --- a/OpenCL/m16600_a3-optimized.cl +++ b/OpenCL/m16600_a3-optimized.cl @@ -13,6 +13,14 @@ #include "inc_simd.cl" #include "inc_cipher_aes.cl" +typedef struct electrum_wallet +{ + u32 salt_type; + u32 iv[4]; + u32 encrypted[4]; + +} electrum_wallet_t; + DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a *s_te2, SHM_TYPE u32a *s_te3, SHM_TYPE u32a *s_te4, SHM_TYPE u32a *s_td0, SHM_TYPE u32a *s_td1, SHM_TYPE u32a *s_td2, SHM_TYPE u32a *s_td3, SHM_TYPE u32a *s_td4, u32 *w, const u32 pw_len, KERN_ATTR_ESALT (electrum_wallet_t)) { /** @@ -288,7 +296,7 @@ DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -304,7 +312,7 @@ DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16600_a3-pure.cl b/OpenCL/m16600_a3-pure.cl index 215109afb..6120c855c 100644 --- a/OpenCL/m16600_a3-pure.cl +++ b/OpenCL/m16600_a3-pure.cl @@ -14,6 +14,14 @@ #include "inc_hash_sha256.cl" #include "inc_cipher_aes.cl" +typedef struct electrum_wallet +{ + u32 salt_type; + u32 iv[4]; + u32 encrypted[4]; + +} electrum_wallet_t; + __kernel void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) { /** @@ -194,7 +202,7 @@ __kernel void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -210,7 +218,7 @@ __kernel void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } @@ -396,7 +404,7 @@ __kernel void m16600_sxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } @@ -412,7 +420,7 @@ __kernel void m16600_sxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m16800-pure.cl b/OpenCL/m16800-pure.cl index 5526d4250..2415b78f8 100644 --- a/OpenCL/m16800-pure.cl +++ b/OpenCL/m16800-pure.cl @@ -16,6 +16,27 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct wpa_pbkdf2_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[10]; + u32 out[10]; + +} wpa_pbkdf2_tmp_t; + +typedef struct wpa_pmkid +{ + u32 pmkid[4]; + u32 pmkid_data[16]; + u8 orig_mac_ap[6]; + u8 orig_mac_sta[6]; + u8 essid_len; + u32 essid_buf[16]; + +} wpa_pmkid_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m16801-pure.cl b/OpenCL/m16801-pure.cl index 87cdb7c21..e57133fb0 100644 --- a/OpenCL/m16801-pure.cl +++ b/OpenCL/m16801-pure.cl @@ -16,6 +16,23 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct wpa_pmk_tmp +{ + u32 out[8]; + +} wpa_pmk_tmp_t; + +typedef struct wpa_pmkid +{ + u32 pmkid[4]; + u32 pmkid_data[16]; + u8 orig_mac_ap[6]; + u8 orig_mac_sta[6]; + u8 essid_len; + u32 essid_buf[16]; + +} wpa_pmkid_t; + DECLSPEC u8 hex_convert (const u8 c) { return (c & 15) + (c >> 6) * 9; diff --git a/OpenCL/m16900-pure.cl b/OpenCL/m16900-pure.cl index 89322a47a..c017757d4 100644 --- a/OpenCL/m16900-pure.cl +++ b/OpenCL/m16900-pure.cl @@ -16,6 +16,25 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct ansible_vault +{ + u32 cipher; + u32 version; + u32 ct_data_buf[4096]; + u32 ct_data_len; + +} ansible_vault_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m18200_a0-optimized.cl b/OpenCL/m18200_a0-optimized.cl index ac01f9c41..19119e97d 100644 --- a/OpenCL/m18200_a0-optimized.cl +++ b/OpenCL/m18200_a0-optimized.cl @@ -17,6 +17,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5asrep +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5asrep_t; + typedef struct { u8 S[256]; @@ -563,7 +572,7 @@ DECLSPEC void kerb_prepare (const u32 *w0, const u32 *w1, const u32 pw_len, cons hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m04 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_m04 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { /** * modifier @@ -647,21 +656,21 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m08 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_m08 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m16 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_m16 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s04 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_s04 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { /** * modifier @@ -745,16 +754,16 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s08 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_s08 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s16 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_s16 (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { } diff --git a/OpenCL/m18200_a0-pure.cl b/OpenCL/m18200_a0-pure.cl index 63012b5c3..a44e2cbf7 100644 --- a/OpenCL/m18200_a0-pure.cl +++ b/OpenCL/m18200_a0-pure.cl @@ -16,6 +16,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5asrep +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5asrep_t; + typedef struct { u8 S[256]; @@ -375,7 +384,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest, u32 K2[3] = ctx1.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_mxx (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_mxx (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { /** * modifier @@ -431,13 +440,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_sxx (KERN_ATTR_RULES_ESALT (krb5asrep_t)) +__kernel void m18200_sxx (KERN_ATTR_RULES_ESALT (krb5asrep_t)) { /** * modifier @@ -493,7 +502,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m18200_a1-optimized.cl b/OpenCL/m18200_a1-optimized.cl index 7de38dae1..b52e99b48 100644 --- a/OpenCL/m18200_a1-optimized.cl +++ b/OpenCL/m18200_a1-optimized.cl @@ -15,6 +15,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5asrep +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5asrep_t; + typedef struct { u8 S[256]; @@ -561,7 +570,7 @@ DECLSPEC void kerb_prepare (const u32 *w0, const u32 *w1, const u32 pw_len, cons hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m04 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_m04 (KERN_ATTR_ESALT (krb5asrep_t)) { /** * modifier @@ -694,21 +703,21 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m08 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_m08 (KERN_ATTR_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m16 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_m16 (KERN_ATTR_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s04 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_s04 (KERN_ATTR_ESALT (krb5asrep_t)) { /** * modifier @@ -841,16 +850,16 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s04 (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s08 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_s08 (KERN_ATTR_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s16 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_s16 (KERN_ATTR_ESALT (krb5asrep_t)) { } diff --git a/OpenCL/m18200_a1-pure.cl b/OpenCL/m18200_a1-pure.cl index dc6d6d9f1..f4c7a6788 100644 --- a/OpenCL/m18200_a1-pure.cl +++ b/OpenCL/m18200_a1-pure.cl @@ -14,6 +14,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5asrep +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5asrep_t; + typedef struct { u8 S[256]; @@ -373,7 +382,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest, u32 K2[3] = ctx1.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_mxx (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_mxx (KERN_ATTR_ESALT (krb5asrep_t)) { /** * modifier @@ -427,13 +436,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_sxx (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_sxx (KERN_ATTR_ESALT (krb5asrep_t)) { /** * modifier @@ -487,7 +496,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m18200_a3-optimized.cl b/OpenCL/m18200_a3-optimized.cl index f429e33b5..052b10ea6 100644 --- a/OpenCL/m18200_a3-optimized.cl +++ b/OpenCL/m18200_a3-optimized.cl @@ -15,6 +15,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5asrep +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5asrep_t; + typedef struct { u8 S[256]; @@ -614,13 +623,13 @@ DECLSPEC void m18200 (__local RC4_KEY *rc4_key, u32 *w0, u32 *w1, u32 *w2, u32 * { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m04 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_m04 (KERN_ATTR_ESALT (krb5asrep_t)) { /** * base @@ -672,7 +681,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m04 (KERN_A m18200 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m08 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_m08 (KERN_ATTR_ESALT (krb5asrep_t)) { /** * base @@ -724,11 +733,11 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m08 (KERN_A m18200 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_m16 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_m16 (KERN_ATTR_ESALT (krb5asrep_t)) { } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s04 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_s04 (KERN_ATTR_ESALT (krb5asrep_t)) { /** * base @@ -780,7 +789,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s04 (KERN_A m18200 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s08 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_s08 (KERN_ATTR_ESALT (krb5asrep_t)) { /** * base @@ -832,6 +841,6 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s08 (KERN_A m18200 (rc4_key, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_s16 (KERN_ATTR_ESALT (krb5asrep_t)) +__kernel void m18200_s16 (KERN_ATTR_ESALT (krb5asrep_t)) { } diff --git a/OpenCL/m18200_a3-pure.cl b/OpenCL/m18200_a3-pure.cl index cb27d0b3f..9cc85a39c 100644 --- a/OpenCL/m18200_a3-pure.cl +++ b/OpenCL/m18200_a3-pure.cl @@ -14,6 +14,15 @@ #include "inc_hash_md4.cl" #include "inc_hash_md5.cl" +typedef struct krb5asrep +{ + u32 account_info[512]; + u32 checksum[4]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5asrep_t; + typedef struct { u8 S[256]; @@ -373,7 +382,7 @@ DECLSPEC void kerb_prepare (const u32 *K, const u32 *checksum, u32 *digest, u32 K2[3] = ctx1.opad.h[3]; } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_mxx (KERN_ATTR_VECTOR_ESALT (krb5asrep_t)) +__kernel void m18200_mxx (KERN_ATTR_VECTOR_ESALT (krb5asrep_t)) { /** * modifier @@ -440,13 +449,13 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_mxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } } -__kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_sxx (KERN_ATTR_VECTOR_ESALT (krb5asrep_t)) +__kernel void m18200_sxx (KERN_ATTR_VECTOR_ESALT (krb5asrep_t)) { /** * modifier @@ -513,7 +522,7 @@ __kernel void __attribute__((reqd_work_group_size(64, 1, 1))) m18200_sxx (KERN_A { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); } } } diff --git a/OpenCL/m18300-pure.cl b/OpenCL/m18300-pure.cl index 00bca9557..cceeb5f70 100644 --- a/OpenCL/m18300-pure.cl +++ b/OpenCL/m18300-pure.cl @@ -17,6 +17,25 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct apple_secure_notes_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[8]; + u32 out[8]; + +} apple_secure_notes_tmp_t; + +typedef struct apple_secure_notes +{ + u32 Z_PK; + u32 ZCRYPTOITERATIONCOUNT; + u32 ZCRYPTOSALT[16]; + u32 ZCRYPTOWRAPPEDKEY[16]; + +} apple_secure_notes_t; + DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -416,7 +435,7 @@ __kernel void m18300_comp (KERN_ATTR_TMPS_ESALT (apple_secure_notes_tmp_t, apple { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m18400-pure.cl b/OpenCL/m18400-pure.cl index 9e2cf0975..5f1c08ee2 100644 --- a/OpenCL/m18400-pure.cl +++ b/OpenCL/m18400-pure.cl @@ -18,6 +18,25 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct odf12_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[10]; + u32 out[10]; + +} odf12_tmp_t; + +typedef struct odf12 +{ + u32 iterations; + u32 iv[4]; + u32 checksum[8]; + u32 encrypted_data[256]; + +} odf12_t; + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; diff --git a/OpenCL/m18600-pure.cl b/OpenCL/m18600-pure.cl index 75ee593d1..f57e6dd7e 100644 --- a/OpenCL/m18600-pure.cl +++ b/OpenCL/m18600-pure.cl @@ -16,6 +16,25 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +typedef struct odf11_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[5]; + u32 out[5]; + +} odf11_tmp_t; + +typedef struct odf11 +{ + u32 iterations; + u32 iv[2]; + u32 checksum[5]; + u32 encrypted_data[256]; + +} odf11_t; + // http://www.schneier.com/code/constants.txt __constant u32a c_sbox0[256] = @@ -563,7 +582,7 @@ __kernel void m18600_loop (KERN_ATTR_TMPS_ESALT (odf11_tmp_t, odf11_t)) } } -__kernel void __attribute__((reqd_work_group_size(8, 1, 1))) m18600_comp (KERN_ATTR_TMPS_ESALT (odf11_tmp_t, odf11_t)) +__kernel void m18600_comp (KERN_ATTR_TMPS_ESALT (odf11_tmp_t, odf11_t)) { const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); diff --git a/OpenCL/m18900-pure.cl b/OpenCL/m18900-pure.cl index 6fd861728..426a8a3d3 100644 --- a/OpenCL/m18900-pure.cl +++ b/OpenCL/m18900-pure.cl @@ -339,7 +339,7 @@ __kernel void m18900_comp (KERN_ATTR_TMPS_ESALT (android_backup_tmp_t, android_b { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { - mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0); + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); } } } diff --git a/OpenCL/m19600-pure.cl b/OpenCL/m19600-pure.cl new file mode 100644 index 000000000..c6e323bbc --- /dev/null +++ b/OpenCL/m19600-pure.cl @@ -0,0 +1,1007 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha1.cl" +#include "inc_cipher_aes.cl" + +typedef struct krb5tgs_17 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_17_t; + +typedef struct krb5tgs_17_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[10]; + u32 out[10]; + +} krb5tgs_17_tmp_t; + +DECLSPEC void aes128_encrypt_cbc (const u32 *aes_ks, u32 *aes_iv, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + u32 data[4]; + + data[0] = swap32_S (in[0]); + data[1] = swap32_S (in[1]); + data[2] = swap32_S (in[2]); + data[3] = swap32_S (in[3]); + + data[0] ^= aes_iv[0]; + data[1] ^= aes_iv[1]; + data[2] ^= aes_iv[2]; + data[3] ^= aes_iv[3]; + + aes128_encrypt (aes_ks, data, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + aes_iv[0] = out[0]; + aes_iv[1] = out[1]; + aes_iv[2] = out[2]; + aes_iv[3] = out[3]; + + out[0] = swap32_S (out[0]); + out[1] = swap32_S (out[1]); + out[2] = swap32_S (out[2]); + out[3] = swap32_S (out[3]); +} + +DECLSPEC void aes128_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + aes128_decrypt (ks1, in, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= essiv[0]; + out[1] ^= essiv[1]; + out[2] ^= essiv[2]; + out[3] ^= essiv[3]; + + essiv[0] = in[0]; + essiv[1] = in[1]; + essiv[2] = in[2]; + essiv[3] = in[3]; +} + +DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); +} + +__kernel void m19600_init (KERN_ATTR_TMPS_ESALT (krb5tgs_17_tmp_t, krb5tgs_17_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * main + */ + + /* initialize hmac-sha1 for pbkdf2(password, account, 4096, account_len) */ + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init_global_swap (&sha1_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha1_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha1_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha1_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha1_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha1_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = sha1_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha1_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha1_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha1_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha1_hmac_ctx.opad.h[4]; + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, esalt_bufs[digests_offset].account_info, esalt_bufs[digests_offset].account_info_len); + + for (u32 i = 0, j = 1; i < 4; i += 5, j += 1) + { + sha1_hmac_ctx_t sha1_hmac_ctx2 = sha1_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx2, w0, w1, w2, w3, 4); + + sha1_hmac_final (&sha1_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha1_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha1_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha1_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha1_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha1_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +__kernel void m19600_loop (KERN_ATTR_TMPS_ESALT (krb5tgs_17_tmp_t, krb5tgs_17_t)) +{ + /** + * base + */ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= gid_max) return; + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 4; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } +} + +__kernel void m19600_comp (KERN_ATTR_TMPS_ESALT (krb5tgs_17_tmp_t, krb5tgs_17_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + #endif + + if (gid >= gid_max) return; + + /* + at this point, the output ('seed') will be used to generate AES keys: + + key_bytes = derive(seed, 'kerberos'.encode(), seedsize) + + 'key_bytes' will be the AES key used to generate 'ke' and 'ki' + 'ke' will be the AES key to decrypt the ticket + 'ki' will be the key to compute the final HMAC + */ + + u32 nfolded[4]; + + // we can precompute _nfold('kerberos', 16) + nfolded[0] = 0x6b657262; + nfolded[1] = 0x65726f73; + nfolded[2] = 0x7b9b5b2b; + nfolded[3] = 0x93132b93; + + // then aes_cbc encrypt this nfolded value with 'seed' as key along with a null IV + u32 aes_key[4]; + + aes_key[0] = swap32_S (tmps[gid].out[0]); + aes_key[1] = swap32_S (tmps[gid].out[1]); + aes_key[2] = swap32_S (tmps[gid].out[2]); + aes_key[3] = swap32_S (tmps[gid].out[3]); + + u32 aes_iv[4]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + u32 aes_ks[44]; + + aes128_set_encrypt_key (aes_ks, aes_key, s_te0, s_te1, s_te2, s_te3, s_te4); + + u32 key_bytes[4]; + + aes128_encrypt_cbc (aes_ks, aes_iv, nfolded, key_bytes, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* we will now compute 'ki', having 'key_bytes' */ + + u32 ki[4]; + + key_bytes[0] = swap32_S (key_bytes[0]); + key_bytes[1] = swap32_S (key_bytes[1]); + key_bytes[2] = swap32_S (key_bytes[2]); + key_bytes[3] = swap32_S (key_bytes[3]); + + // we can precompute _nfold(pack('>IB', 2, 0x55), 16) + nfolded[0] = 0x62dc6e37; + nfolded[1] = 0x1a63a809; + nfolded[2] = 0x58ac562b; + nfolded[3] = 0x15404ac5; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes128_set_encrypt_key (aes_ks, key_bytes, s_te0, s_te1, s_te2, s_te3, s_te4); + + aes128_encrypt_cbc (aes_ks, aes_iv, nfolded, ki, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* we will now compute 'ke' */ + + u32 ke[4]; + + // we can precompute _nfold(pack('>IB', 2, 0xAA), 16) + nfolded[0] = 0xb5b0582c; + nfolded[1] = 0x14b6500a; + nfolded[2] = 0xad56ab55; + nfolded[3] = 0xaa80556a; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes128_encrypt_cbc (aes_ks, aes_iv, nfolded, ke, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* + we now have 'ke' and 'ki' + + we will decrypt (with 'ke') the 32 first bytes to search for ASN.1 structs + and if we find ASN.1 structs, we will compute the hmac (with 'ki') + + if length >= 128 bytes: + length is on 2 bytes and type is \x63\x82 (encode_krb5_enc_tkt_part) and data is an ASN1 sequence \x30\x82 + else: + length is on 1 byte and type is \x63\x81 and data is an ASN1 sequence \x30\x81 + + next headers follow the same ASN1 "type-length-data" scheme + */ + + u32 first_blocks[16]; + + u32 decrypted_block[4]; + + first_blocks[0] = esalt_bufs[digests_offset].edata2[0]; + first_blocks[1] = esalt_bufs[digests_offset].edata2[1]; + first_blocks[2] = esalt_bufs[digests_offset].edata2[2]; + first_blocks[3] = esalt_bufs[digests_offset].edata2[3]; + + first_blocks[4] = esalt_bufs[digests_offset].edata2[4]; // possible ASN1 structs + first_blocks[5] = esalt_bufs[digests_offset].edata2[5]; + first_blocks[6] = esalt_bufs[digests_offset].edata2[6]; // possible ASN1 structs + first_blocks[7] = esalt_bufs[digests_offset].edata2[7]; + + /* + we will decrypt them here in order to be able to compute hmac directly + if ASN1 structs were to be found + */ + first_blocks[8] = esalt_bufs[digests_offset].edata2[8]; + first_blocks[9] = esalt_bufs[digests_offset].edata2[9]; + first_blocks[10] = esalt_bufs[digests_offset].edata2[10]; + first_blocks[11] = esalt_bufs[digests_offset].edata2[11]; + + first_blocks[12] = esalt_bufs[digests_offset].edata2[12]; + first_blocks[13] = esalt_bufs[digests_offset].edata2[13]; + first_blocks[14] = esalt_bufs[digests_offset].edata2[14]; + first_blocks[15] = esalt_bufs[digests_offset].edata2[15]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 aes_cts_decrypt_ks[44]; + + AES128_set_decrypt_key (aes_cts_decrypt_ks, ke, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + if (((decrypted_block[0] & 0xff00ffff) == 0x30008163) || ((decrypted_block[0] & 0x0000ffff) == 0x00008263)) + { + if (((decrypted_block[2] & 0x00ffffff) == 0x00000503) || (decrypted_block[2] == 0x050307A0)) + { + // now we decrypt all the ticket to verify checksum + int block_position; + + int edata2_len = esalt_bufs[digests_offset].edata2_len; + + int edata2_left; + + u32 block[16]; + + int last_block_size = edata2_len % 16; + + if(last_block_size == 0) + { + last_block_size = 16; + } + + int last_part = last_block_size + 16; + + int need = edata2_len - last_part; + + int last_block_cbc_position = (need - 16) / 4; + + // we need to decrypt also the 2 following blocks in order to be able to compute the hmac directly + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = swap32_S (decrypted_block[0]); + w2[1] = swap32_S (decrypted_block[1]); + w2[2] = swap32_S (decrypted_block[2]); + w2[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = swap32_S (decrypted_block[0]); + w3[1] = swap32_S (decrypted_block[1]); + w3[2] = swap32_S (decrypted_block[2]); + w3[3] = swap32_S (decrypted_block[3]); + + sha1_hmac_ctx_t sha1_hmac_ctx; + + /* + hmac message = plaintext + hmac key = ki + */ + + u32 k0[4]; + u32 k1[4]; + u32 k2[4]; + u32 k3[4]; + + k0[0] = ki[0]; + k0[1] = ki[1]; + k0[2] = ki[2]; + k0[3] = ki[3]; + + k1[0] = 0; + k1[1] = 0; + k1[2] = 0; + k1[3] = 0; + + k2[0] = 0; + k2[1] = 0; + k2[2] = 0; + k2[3] = 0; + + k3[0] = 0; + k3[1] = 0; + k3[2] = 0; + k3[3] = 0; + + sha1_hmac_init_64 (&sha1_hmac_ctx, k0, k1, k2, k3); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position = 16; + + // first 4 blocks are already decrypted + for (edata2_left = need - 64; edata2_left >= 64; edata2_left -= 64) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + block[4] = esalt_bufs[digests_offset].edata2[block_position + 4]; + block[5] = esalt_bufs[digests_offset].edata2[block_position + 5]; + block[6] = esalt_bufs[digests_offset].edata2[block_position + 6]; + block[7] = esalt_bufs[digests_offset].edata2[block_position + 7]; + block[8] = esalt_bufs[digests_offset].edata2[block_position + 8]; + block[9] = esalt_bufs[digests_offset].edata2[block_position + 9]; + block[10] = esalt_bufs[digests_offset].edata2[block_position + 10]; + block[11] = esalt_bufs[digests_offset].edata2[block_position + 11]; + block[12] = esalt_bufs[digests_offset].edata2[block_position + 12]; + block[13] = esalt_bufs[digests_offset].edata2[block_position + 13]; + block[14] = esalt_bufs[digests_offset].edata2[block_position + 14]; + block[15] = esalt_bufs[digests_offset].edata2[block_position + 15]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = swap32_S (decrypted_block[0]); + w2[1] = swap32_S (decrypted_block[1]); + w2[2] = swap32_S (decrypted_block[2]); + w2[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = swap32_S (decrypted_block[0]); + w3[1] = swap32_S (decrypted_block[1]); + w3[2] = swap32_S (decrypted_block[2]); + w3[3] = swap32_S (decrypted_block[3]); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position += 16; + } + + if (edata2_left == 16) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16); + + block_position += 4; + } + else if (edata2_left == 32) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + block[4] = esalt_bufs[digests_offset].edata2[block_position + 4]; + block[5] = esalt_bufs[digests_offset].edata2[block_position + 5]; + block[6] = esalt_bufs[digests_offset].edata2[block_position + 6]; + block[7] = esalt_bufs[digests_offset].edata2[block_position + 7]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 32); + + block_position += 8; + } + else if (edata2_left == 48) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + block[4] = esalt_bufs[digests_offset].edata2[block_position + 4]; + block[5] = esalt_bufs[digests_offset].edata2[block_position + 5]; + block[6] = esalt_bufs[digests_offset].edata2[block_position + 6]; + block[7] = esalt_bufs[digests_offset].edata2[block_position + 7]; + block[8] = esalt_bufs[digests_offset].edata2[block_position + 8]; + block[9] = esalt_bufs[digests_offset].edata2[block_position + 9]; + block[10] = esalt_bufs[digests_offset].edata2[block_position + 10]; + block[11] = esalt_bufs[digests_offset].edata2[block_position + 11]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = swap32_S (decrypted_block[0]); + w2[1] = swap32_S (decrypted_block[1]); + w2[2] = swap32_S (decrypted_block[2]); + w2[3] = swap32_S (decrypted_block[3]); + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 48); + + block_position += 12; + } + + /* + now all the ticket should be decrypted until block n-1 (not included) + and n + */ + + // this is block n-2, it will be xored with the n-1 block later crafted + u32 last_block_cbc[4]; + + last_block_cbc[0] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 0]; + last_block_cbc[1] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 1]; + last_block_cbc[2] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 2]; + last_block_cbc[3] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 3]; + + // n-1 block is decrypted separately from the previous blocks which were cbc decrypted + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + + aes128_decrypt (aes_cts_decrypt_ks, block, decrypted_block, s_td0, s_td1, s_td2, s_td3, s_td4); + + u32 last_block[4]; + + int last_block_position = (edata2_len - last_block_size) / 4; + + u32 n_1_crafted[4]; + + u32 last_plaintext[4]; + + last_plaintext[0] = 0; + last_plaintext[1] = 0; + last_plaintext[2] = 0; + last_plaintext[3] = 0; + + /* + n-1 block is first computed as follows: + - fill n-1 block with the X first bytes of the encrypted last block (n) + with X == length of last block + - complete the rest of the block with + + Final block (n) is computed as follows: + - fill with the X first bytes from n-1 block decrypted and xor them with last block (n) + with X == length of last block + */ + int remaining_blocks = last_block_size / 4; + + /* + last block is not necessarily aligned on 4 bytes so we will have + to shift values for the CTS crap... + */ + u32 shift = last_block_size % 4; + + switch (remaining_blocks) + { + case 0: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + + u32 mask = (0xffffffff >> ((4 - last_block_size) * 8)); + + last_plaintext[0] = last_block[0] ^ (decrypted_block[0] & mask); + last_plaintext[0] = swap32_S (last_plaintext[0]); + + n_1_crafted[0] = (last_block[0] & mask) | (decrypted_block[0] & (mask ^ 0xffffffff)); + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + break; + + case 1: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[0] = swap32_S (last_plaintext[0]); + } + else + { + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + + u32 mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ (decrypted_block[1] & mask); + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = (last_block[1] & mask) | (decrypted_block[1] & (mask ^ 0xffffffff)); + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 2: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + } + else + { + last_block[2] = esalt_bufs[digests_offset].edata2[last_block_position + 2]; + + u32 mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ (decrypted_block[2] & mask); + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = (last_block[2] & mask) | (decrypted_block[2] & (mask ^ 0xffffffff)); + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 3: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[digests_offset].edata2[last_block_position + 2]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + } + else + { + last_block[3] = esalt_bufs[digests_offset].edata2[last_block_position + 3]; + + u32 mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ (decrypted_block[3] & mask); + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + last_plaintext[3] = swap32_S (last_plaintext[3]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = (last_block[3] & mask) | (decrypted_block[3] & (mask ^ 0xffffffff)); + } + break; + + case 4: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[digests_offset].edata2[last_block_position + 2]; + last_block[3] = esalt_bufs[digests_offset].edata2[last_block_position + 3]; + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = last_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ decrypted_block[3]; + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + last_plaintext[3] = swap32_S (last_plaintext[3]); + break; + + default: + return; + } + + // then decrypt this newly created n-1 with 'ke' + aes128_decrypt (aes_cts_decrypt_ks, n_1_crafted, n_1_crafted, s_td0, s_td1, s_td2, s_td3, s_td4); + + // then xor with the encrypted n-2 block + n_1_crafted[0] ^= last_block_cbc[0]; + n_1_crafted[1] ^= last_block_cbc[1]; + n_1_crafted[2] ^= last_block_cbc[2]; + n_1_crafted[3] ^= last_block_cbc[3]; + + w0[0] = swap32_S (n_1_crafted[0]); + w0[1] = swap32_S (n_1_crafted[1]); + w0[2] = swap32_S (n_1_crafted[2]); + w0[3] = swap32_S (n_1_crafted[3]); + + w1[0] = last_plaintext[0]; + w1[1] = last_plaintext[1]; + w1[2] = last_plaintext[2]; + w1[3] = last_plaintext[3]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16 + last_block_size); + + sha1_hmac_final(&sha1_hmac_ctx); + + if(sha1_hmac_ctx.opad.h[0] == esalt_bufs[digests_offset].checksum[0] + && sha1_hmac_ctx.opad.h[1] == esalt_bufs[digests_offset].checksum[1] + && sha1_hmac_ctx.opad.h[2] == esalt_bufs[digests_offset].checksum[2]) + { + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + #define il_pos 0 + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } + } + } +} \ No newline at end of file diff --git a/OpenCL/m19700-pure.cl b/OpenCL/m19700-pure.cl new file mode 100644 index 000000000..67f9b0096 --- /dev/null +++ b/OpenCL/m19700-pure.cl @@ -0,0 +1,1071 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#include "inc_vendor.cl" +#include "inc_hash_constants.h" +#include "inc_hash_functions.cl" +#include "inc_types.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha1.cl" +#include "inc_cipher_aes.cl" + +typedef struct krb5tgs_18 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_18_t; + +typedef struct krb5tgs_18_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[16]; + u32 out[16]; + +} krb5tgs_18_tmp_t; + +DECLSPEC void aes256_encrypt_cbc (const u32 *aes_ks, u32 *aes_iv, const u32 *in, u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + u32 data[4]; + + data[0] = swap32_S (in[0]); + data[1] = swap32_S (in[1]); + data[2] = swap32_S (in[2]); + data[3] = swap32_S (in[3]); + + data[0] ^= aes_iv[0]; + data[1] ^= aes_iv[1]; + data[2] ^= aes_iv[2]; + data[3] ^= aes_iv[3]; + + aes256_encrypt (aes_ks, data, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + aes_iv[0] = out[0]; + aes_iv[1] = out[1]; + aes_iv[2] = out[2]; + aes_iv[3] = out[3]; + + out[0] = swap32_S (out[0]); + out[1] = swap32_S (out[1]); + out[2] = swap32_S (out[2]); + out[3] = swap32_S (out[3]); +} + +DECLSPEC void aes256_decrypt_cbc (const u32 *ks1, const u32 *in, u32 *out, u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + aes256_decrypt (ks1, in, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= essiv[0]; + out[1] ^= essiv[1]; + out[2] ^= essiv[2]; + out[3] ^= essiv[3]; + + essiv[0] = in[0]; + essiv[1] = in[1]; + essiv[2] = in[2]; + essiv[3] = in[3]; +} + +DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); +} + +__kernel void m19700_init (KERN_ATTR_TMPS_ESALT (krb5tgs_18_tmp_t, krb5tgs_18_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * main + */ + + /* initialize hmac-sha1 for pbkdf2(password, account, 4096, account_len) */ + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init_global_swap (&sha1_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha1_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha1_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha1_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha1_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha1_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = sha1_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha1_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha1_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha1_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha1_hmac_ctx.opad.h[4]; + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, esalt_bufs[digests_offset].account_info, esalt_bufs[digests_offset].account_info_len); + + for (u32 i = 0, j = 1; i < 8; i += 5, j += 1) + { + sha1_hmac_ctx_t sha1_hmac_ctx2 = sha1_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx2, w0, w1, w2, w3, 4); + + sha1_hmac_final (&sha1_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha1_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha1_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha1_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha1_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha1_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +__kernel void m19700_loop (KERN_ATTR_TMPS_ESALT (krb5tgs_18_tmp_t, krb5tgs_18_t)) +{ + /** + * base + */ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= gid_max) return; + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 8; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } +} + +__kernel void m19700_comp (KERN_ATTR_TMPS_ESALT (krb5tgs_18_tmp_t, krb5tgs_18_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + __local u32 s_td0[256]; + __local u32 s_td1[256]; + __local u32 s_td2[256]; + __local u32 s_td3[256]; + __local u32 s_td4[256]; + + __local u32 s_te0[256]; + __local u32 s_te1[256]; + __local u32 s_te2[256]; + __local u32 s_te3[256]; + __local u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + barrier (CLK_LOCAL_MEM_FENCE); + + #else + + __constant u32a *s_td0 = td0; + __constant u32a *s_td1 = td1; + __constant u32a *s_td2 = td2; + __constant u32a *s_td3 = td3; + __constant u32a *s_td4 = td4; + + __constant u32a *s_te0 = te0; + __constant u32a *s_te1 = te1; + __constant u32a *s_te2 = te2; + __constant u32a *s_te3 = te3; + __constant u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /* + at this point, the output ('seed') will be used to generate AES keys: + + key_bytes = derive(seed, 'kerberos'.encode(), seedsize) + + 'key_bytes' will be the AES key used to generate 'ke' and 'ki' + 'ke' will be the AES key to decrypt the ticket + 'ki' will be the key to compute the final HMAC + */ + + u32 nfolded[4]; + + // we can precompute _nfold('kerberos', 16) + nfolded[0] = 0x6b657262; + nfolded[1] = 0x65726f73; + nfolded[2] = 0x7b9b5b2b; + nfolded[3] = 0x93132b93; + + // then aes_cbc encrypt this nfolded value with 'seed' as key along with a null IV + u32 aes_key[8]; + + aes_key[0] = swap32_S (tmps[gid].out[0]); + aes_key[1] = swap32_S (tmps[gid].out[1]); + aes_key[2] = swap32_S (tmps[gid].out[2]); + aes_key[3] = swap32_S (tmps[gid].out[3]); + aes_key[4] = swap32_S (tmps[gid].out[4]); + aes_key[5] = swap32_S (tmps[gid].out[5]); + aes_key[6] = swap32_S (tmps[gid].out[6]); + aes_key[7] = swap32_S (tmps[gid].out[7]); + + u32 aes_iv[4]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + u32 aes_ks[60]; + + aes256_set_encrypt_key (aes_ks, aes_key, s_te0, s_te1, s_te2, s_te3, s_te4); + + u32 key_bytes[8]; + + u32 out[4]; + aes256_encrypt_cbc (aes_ks, aes_iv, nfolded, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + key_bytes[0] = out[0]; + key_bytes[1] = out[1]; + key_bytes[2] = out[2]; + key_bytes[3] = out[3]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_encrypt_cbc (aes_ks, aes_iv, out, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + key_bytes[4] = out[0]; + key_bytes[5] = out[1]; + key_bytes[6] = out[2]; + key_bytes[7] = out[3]; + + /* we will now compute 'ki', having 'key_bytes' */ + + u32 ki[8]; + + // we can precompute _nfold(pack('>IB', 2, 0x55), 16) + nfolded[0] = 0x62dc6e37; + nfolded[1] = 0x1a63a809; + nfolded[2] = 0x58ac562b; + nfolded[3] = 0x15404ac5; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + key_bytes[0] = swap32_S (key_bytes[0]); + key_bytes[1] = swap32_S (key_bytes[1]); + key_bytes[2] = swap32_S (key_bytes[2]); + key_bytes[3] = swap32_S (key_bytes[3]); + key_bytes[4] = swap32_S (key_bytes[4]); + key_bytes[5] = swap32_S (key_bytes[5]); + key_bytes[6] = swap32_S (key_bytes[6]); + key_bytes[7] = swap32_S (key_bytes[7]); + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes256_set_encrypt_key (aes_ks, key_bytes, s_te0, s_te1, s_te2, s_te3, s_te4); + + aes256_encrypt_cbc (aes_ks, aes_iv, nfolded, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ki[0] = out[0]; + ki[1] = out[1]; + ki[2] = out[2]; + ki[3] = out[3]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_encrypt_cbc (aes_ks, aes_iv, out, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ki[4] = out[0]; + ki[5] = out[1]; + ki[6] = out[2]; + ki[7] = out[3]; + + /* we will now compute 'ke' */ + + u32 ke[8]; + + // we can precompute _nfold(pack('>IB', 2, 0xAA), 16) + nfolded[0] = 0xb5b0582c; + nfolded[1] = 0x14b6500a; + nfolded[2] = 0xad56ab55; + nfolded[3] = 0xaa80556a; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes256_encrypt_cbc (aes_ks, aes_iv, nfolded, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ke[0] = out[0]; + ke[1] = out[1]; + ke[2] = out[2]; + ke[3] = out[3]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_encrypt_cbc (aes_ks, aes_iv, out, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ke[4] = out[0]; + ke[5] = out[1]; + ke[6] = out[2]; + ke[7] = out[3]; + + /* + we now have 'ke' and 'ki' + + we will decrypt (with 'ke') the 32 first bytes to search for ASN.1 structs + and if we find ASN.1 structs, we will compute the hmac (with 'ki') + + if length >= 128 bytes: + length is on 2 bytes and type is \x63\x82 (encode_krb5_enc_tkt_part) and data is an ASN1 sequence \x30\x82 + else: + length is on 1 byte and type is \x63\x81 and data is an ASN1 sequence \x30\x81 + + next headers follow the same ASN1 "type-length-data" scheme + */ + + u32 first_blocks[16]; + + u32 decrypted_block[8]; + + first_blocks[0] = esalt_bufs[digests_offset].edata2[0]; + first_blocks[1] = esalt_bufs[digests_offset].edata2[1]; + first_blocks[2] = esalt_bufs[digests_offset].edata2[2]; + first_blocks[3] = esalt_bufs[digests_offset].edata2[3]; + + first_blocks[4] = esalt_bufs[digests_offset].edata2[4]; // possible ASN1 structs + first_blocks[5] = esalt_bufs[digests_offset].edata2[5]; + first_blocks[6] = esalt_bufs[digests_offset].edata2[6]; // possible ASN1 structs + first_blocks[7] = esalt_bufs[digests_offset].edata2[7]; + + /* + we will decrypt them here in order to be able to compute hmac directly + if ASN1 structs were to be found + */ + first_blocks[8] = esalt_bufs[digests_offset].edata2[8]; + first_blocks[9] = esalt_bufs[digests_offset].edata2[9]; + first_blocks[10] = esalt_bufs[digests_offset].edata2[10]; + first_blocks[11] = esalt_bufs[digests_offset].edata2[11]; + + first_blocks[12] = esalt_bufs[digests_offset].edata2[12]; + first_blocks[13] = esalt_bufs[digests_offset].edata2[13]; + first_blocks[14] = esalt_bufs[digests_offset].edata2[14]; + first_blocks[15] = esalt_bufs[digests_offset].edata2[15]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 aes_cts_decrypt_ks[60]; + + AES256_set_decrypt_key (aes_cts_decrypt_ks, ke, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4); + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + if (((decrypted_block[0] & 0xff00ffff) == 0x30008163) || ((decrypted_block[0] & 0x0000ffff) == 0x00008263)) + { + if (((decrypted_block[2] & 0x00ffffff) == 0x00000503) || (decrypted_block[2] == 0x050307A0)) + { + + // now we decrypt all the ticket to verify checksum + + // we need to decrypt also the 2 following blocks in order to be able to compute the hmac directly + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = swap32_S (decrypted_block[0]); + w2[1] = swap32_S (decrypted_block[1]); + w2[2] = swap32_S (decrypted_block[2]); + w2[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = swap32_S (decrypted_block[0]); + w3[1] = swap32_S (decrypted_block[1]); + w3[2] = swap32_S (decrypted_block[2]); + w3[3] = swap32_S (decrypted_block[3]); + + int block_position; + + int edata2_len = esalt_bufs[digests_offset].edata2_len; + + int edata2_left; + + u32 block[16]; + + int last_block_size = edata2_len % 16; + + if(last_block_size == 0) + { + last_block_size = 16; + } + + int last_part = last_block_size + 16; + + int need = edata2_len - last_part; + + int last_block_cbc_position = (need - 16) / 4; + + sha1_hmac_ctx_t sha1_hmac_ctx; + + /* + hmac message = plaintext + hmac key = ki + */ + + u32 k0[4]; + u32 k1[4]; + u32 k2[4]; + u32 k3[4]; + + k0[0] = ki[0]; + k0[1] = ki[1]; + k0[2] = ki[2]; + k0[3] = ki[3]; + + k1[0] = ki[4]; + k1[1] = ki[5]; + k1[2] = ki[6]; + k1[3] = ki[7]; + + k2[0] = 0; + k2[1] = 0; + k2[2] = 0; + k2[3] = 0; + + k3[0] = 0; + k3[1] = 0; + k3[2] = 0; + k3[3] = 0; + + sha1_hmac_init_64 (&sha1_hmac_ctx, k0, k1, k2, k3); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position = 16; + + // first 4 blocks are already decrypted + for (edata2_left = need - 64; edata2_left >= 64; edata2_left -= 64) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + block[4] = esalt_bufs[digests_offset].edata2[block_position + 4]; + block[5] = esalt_bufs[digests_offset].edata2[block_position + 5]; + block[6] = esalt_bufs[digests_offset].edata2[block_position + 6]; + block[7] = esalt_bufs[digests_offset].edata2[block_position + 7]; + block[8] = esalt_bufs[digests_offset].edata2[block_position + 8]; + block[9] = esalt_bufs[digests_offset].edata2[block_position + 9]; + block[10] = esalt_bufs[digests_offset].edata2[block_position + 10]; + block[11] = esalt_bufs[digests_offset].edata2[block_position + 11]; + block[12] = esalt_bufs[digests_offset].edata2[block_position + 12]; + block[13] = esalt_bufs[digests_offset].edata2[block_position + 13]; + block[14] = esalt_bufs[digests_offset].edata2[block_position + 14]; + block[15] = esalt_bufs[digests_offset].edata2[block_position + 15]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = swap32_S (decrypted_block[0]); + w2[1] = swap32_S (decrypted_block[1]); + w2[2] = swap32_S (decrypted_block[2]); + w2[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = swap32_S (decrypted_block[0]); + w3[1] = swap32_S (decrypted_block[1]); + w3[2] = swap32_S (decrypted_block[2]); + w3[3] = swap32_S (decrypted_block[3]); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position += 16; + } + + if (edata2_left == 16) + { + + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16); + + block_position += 4; + } + else if (edata2_left == 32) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + block[4] = esalt_bufs[digests_offset].edata2[block_position + 4]; + block[5] = esalt_bufs[digests_offset].edata2[block_position + 5]; + block[6] = esalt_bufs[digests_offset].edata2[block_position + 6]; + block[7] = esalt_bufs[digests_offset].edata2[block_position + 7]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 32); + + block_position += 8; + } + else if (edata2_left == 48) + { + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + block[4] = esalt_bufs[digests_offset].edata2[block_position + 4]; + block[5] = esalt_bufs[digests_offset].edata2[block_position + 5]; + block[6] = esalt_bufs[digests_offset].edata2[block_position + 6]; + block[7] = esalt_bufs[digests_offset].edata2[block_position + 7]; + block[8] = esalt_bufs[digests_offset].edata2[block_position + 8]; + block[9] = esalt_bufs[digests_offset].edata2[block_position + 9]; + block[10] = esalt_bufs[digests_offset].edata2[block_position + 10]; + block[11] = esalt_bufs[digests_offset].edata2[block_position + 11]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = swap32_S (decrypted_block[0]); + w0[1] = swap32_S (decrypted_block[1]); + w0[2] = swap32_S (decrypted_block[2]); + w0[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = swap32_S (decrypted_block[0]); + w1[1] = swap32_S (decrypted_block[1]); + w1[2] = swap32_S (decrypted_block[2]); + w1[3] = swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = swap32_S (decrypted_block[0]); + w2[1] = swap32_S (decrypted_block[1]); + w2[2] = swap32_S (decrypted_block[2]); + w2[3] = swap32_S (decrypted_block[3]); + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 48); + + block_position += 12; + } + + /* + now all the ticket should be decrypted until block n-1 (not included) + and n + */ + + // this is block n-2, it will be xored with the n-1 block later crafted + u32 last_block_cbc[4]; + + last_block_cbc[0] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 0]; + last_block_cbc[1] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 1]; + last_block_cbc[2] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 2]; + last_block_cbc[3] = esalt_bufs[digests_offset].edata2[last_block_cbc_position + 3]; + + // n-1 block is decrypted separately from the previous blocks which were cbc decrypted + block[0] = esalt_bufs[digests_offset].edata2[block_position + 0]; + block[1] = esalt_bufs[digests_offset].edata2[block_position + 1]; + block[2] = esalt_bufs[digests_offset].edata2[block_position + 2]; + block[3] = esalt_bufs[digests_offset].edata2[block_position + 3]; + + aes256_decrypt (aes_cts_decrypt_ks, block, decrypted_block, s_td0, s_td1, s_td2, s_td3, s_td4); + + u32 last_block[4]; + + int last_block_position = (edata2_len - last_block_size) / 4; + + u32 n_1_crafted[4]; + + u32 last_plaintext[4]; + + last_plaintext[0] = 0; + last_plaintext[1] = 0; + last_plaintext[2] = 0; + last_plaintext[3] = 0; + + /* + n-1 block is first computed as follows: + - fill n-1 block with the X first bytes of the encrypted last block (n) + with X == length of last block + - complete the rest of the block with + + Final block (n) is computed as follows: + - fill with the X first bytes from n-1 block decrypted and xor them with last block (n) + with X == length of last block + */ + int remaining_blocks = last_block_size / 4; + + /* + last block is not necessarily aligned on 4 bytes so we will have + to shift values for the CTS crap... + */ + u32 shift = last_block_size % 4; + + switch (remaining_blocks) + { + case 0: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + + u32 mask = (0xffffffff >> ((4 - last_block_size) * 8)); + + last_plaintext[0] = last_block[0] ^ (decrypted_block[0] & mask); + last_plaintext[0] = swap32_S (last_plaintext[0]); + + n_1_crafted[0] = (last_block[0] & mask) | (decrypted_block[0] & (mask ^ 0xffffffff)); + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + break; + + case 1: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[0] = swap32_S (last_plaintext[0]); + } + else + { + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + + u32 mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ (decrypted_block[1] & mask); + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = (last_block[1] & mask) | (decrypted_block[1] & (mask ^ 0xffffffff)); + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 2: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + } + else + { + last_block[2] = esalt_bufs[digests_offset].edata2[last_block_position + 2]; + + u32 mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ (decrypted_block[2] & mask); + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = (last_block[2] & mask) | (decrypted_block[2] & (mask ^ 0xffffffff)); + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 3: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[digests_offset].edata2[last_block_position + 2]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + } + else + { + last_block[3] = esalt_bufs[digests_offset].edata2[last_block_position + 3]; + + u32 mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ (decrypted_block[3] & mask); + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + last_plaintext[3] = swap32_S (last_plaintext[3]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = (last_block[3] & mask) | (decrypted_block[3] & (mask ^ 0xffffffff)); + } + break; + + case 4: + + last_block[0] = esalt_bufs[digests_offset].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[digests_offset].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[digests_offset].edata2[last_block_position + 2]; + last_block[3] = esalt_bufs[digests_offset].edata2[last_block_position + 3]; + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = last_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ decrypted_block[3]; + + last_plaintext[0] = swap32_S (last_plaintext[0]); + last_plaintext[1] = swap32_S (last_plaintext[1]); + last_plaintext[2] = swap32_S (last_plaintext[2]); + last_plaintext[3] = swap32_S (last_plaintext[3]); + break; + + default: + return; + } + + + // then decrypt this newly created n-1 with 'ke' + aes256_decrypt (aes_cts_decrypt_ks, n_1_crafted, n_1_crafted, s_td0, s_td1, s_td2, s_td3, s_td4); + + // then xor with the encrypted n-2 block + n_1_crafted[0] ^= last_block_cbc[0]; + n_1_crafted[1] ^= last_block_cbc[1]; + n_1_crafted[2] ^= last_block_cbc[2]; + n_1_crafted[3] ^= last_block_cbc[3]; + + w0[0] = swap32_S (n_1_crafted[0]); + w0[1] = swap32_S (n_1_crafted[1]); + w0[2] = swap32_S (n_1_crafted[2]); + w0[3] = swap32_S (n_1_crafted[3]); + + w1[0] = last_plaintext[0]; + w1[1] = last_plaintext[1]; + w1[2] = last_plaintext[2]; + w1[3] = last_plaintext[3]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16 + last_block_size); + + sha1_hmac_final(&sha1_hmac_ctx); + + if(sha1_hmac_ctx.opad.h[0] == esalt_bufs[digests_offset].checksum[0] + && sha1_hmac_ctx.opad.h[1] == esalt_bufs[digests_offset].checksum[1] + && sha1_hmac_ctx.opad.h[2] == esalt_bufs[digests_offset].checksum[2]) + { + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + #define il_pos 0 + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } + } + } +} \ No newline at end of file diff --git a/OpenCL/markov_be.cl b/OpenCL/markov_be.cl index 1d9dc0ff1..ce2cb38b0 100644 --- a/OpenCL/markov_be.cl +++ b/OpenCL/markov_be.cl @@ -9,6 +9,7 @@ #include "inc_types.cl" +DECLSPEC void generate_pw (u32 *pw_buf, __global const cs_t *root_css_buf, __global const cs_t *markov_css_buf, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, u64 val); DECLSPEC void generate_pw (u32 *pw_buf, __global const cs_t *root_css_buf, __global const cs_t *markov_css_buf, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, u64 val) { __global const cs_t *cs = &root_css_buf[pw_r_len]; diff --git a/OpenCL/markov_le.cl b/OpenCL/markov_le.cl index d50c9f2d8..c59211341 100644 --- a/OpenCL/markov_le.cl +++ b/OpenCL/markov_le.cl @@ -9,6 +9,7 @@ #include "inc_types.cl" +DECLSPEC void generate_pw (u32 *pw_buf, __global const cs_t *root_css_buf, __global const cs_t *markov_css_buf, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, u64 val); DECLSPEC void generate_pw (u32 *pw_buf, __global const cs_t *root_css_buf, __global const cs_t *markov_css_buf, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, u64 val) { __global const cs_t *cs = &root_css_buf[pw_r_len]; diff --git a/docs/changes.txt b/docs/changes.txt index baed05f41..3dba99e54 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,52 +1,66 @@ * changes v5.1.0 -> v5.x.x +## +## Feature +## + +- Fully modularized hash-mode integration via plugin interface and converted all existing hash-modes +- Support for inline VeraCrypt PIM Brute-Force + ## ## Algorithms ## -- Added hash-mode 18400 (Open Document Format (ODF) 1.2 (SHA-256, AES)) -- Added hash-mode 18500 sha1(md5(md5($pass))) -- Added hash-mode 18600 (Open Document Format (ODF) 1.1 (SHA-1, Blowfish)) -- Added hash-mode 18700 Java Object hashCode() -- Added hash-mode 18800 Blockchain, My Wallet, Second Password (SHA256) -- Added hash-mode 18900 Android Backup -- Added hash-mode 19000 QNX /etc/shadow (MD5) -- Added hash-mode 19100 QNX /etc/shadow (SHA256) -- Added hash-mode 19200 QNX /etc/shadow (SHA512) -- Added hash-mode 19300 sha1($salt1.$pass.$salt2) -- Added hash-mode 19500 Ruby on Rails Restful-Authentication +- Added hash-mode: Open Document Format (ODF) 1.2 (SHA-256, AES) +- Added hash-mode: Open Document Format (ODF) 1.1 (SHA-1, Blowfish) +- Added hash-mode: Java Object hashCode() +- Added hash-mode: Blockchain, My Wallet, Second Password (SHA256) +- Added hash-mode: Android Backup +- Added hash-mode: QNX /etc/shadow (MD5) +- Added hash-mode: QNX /etc/shadow (SHA256) +- Added hash-mode: QNX /etc/shadow (SHA512) +- Added hash-mode: Kerberos 5 TGS-REP etype 17 (AES128-CTS-HMAC-SHA1-96) +- Added hash-mode: Kerberos 5 TGS-REP etype 18 (AES256-CTS-HMAC-SHA1-96) +- Added hash-mode: sha1(md5(md5($pass))) +- Added hash-mode: sha1($salt1.$pass.$salt2) +- Added hash-mode: Ruby on Rails Restful-Authentication ## ## Bugs ## -- Fixed output of IKE PSK (mode 5300 and 5400) hashes to have separators at right position -- Fixed the validation of the --brain-client-features command line argument (only values 1, 2 or 3 are allowed) - Fixed cracking of Cisco-PIX and Cisco-ASA MD5 passwords in mask-attack mode if mask > length 16 +- Fixed cracking of Electrum Wallet Salt-Type 2 hashes - Fixed cracking of NetNTLMv1 passwords in mask-attack mode if mask > length 16 (optimized kernels only) -- Fixed the 7-Zip parser to allow the entire supported range of encrypted and decrypted data lengths -- Fixed incorrect progress-only result in a special race condition -- Fixed maximum password length limit which was announced as 256 but actually was 255 - Fixed cracking raw Streebog-HMAC 256 and 512 hashes with password of length >= 64 - Fixed cracking raw Whirlpool hashes cracking with password of length >= 32 +- Fixed incorrect progress-only result in a special race condition +- Fixed maximum password length limit which was announced as 256 but actually was 255 +- Fixed output of IKE PSK (mode 5300 and 5400) hashes to have separators at right position +- Fixed the 7-Zip parser to allow the entire supported range of encrypted and decrypted data lengths +- Fixed the validation of the --brain-client-features command line argument (only values 1, 2 or 3 are allowed) ## ## Improvements ## -- Building: Updated BUILD.md -- Tuning Database: Updated hashcat.hctune with new models and refreshed vector width values +- Cracking bcrypt: Use a feedback from the OpenCL runtime to dynamically find out optimal thread count - Bitcoin Wallet: Be more user friendly by allowing a larger data range for ckey and public_key -- OpenCL Runtime: Workaround JiT compiler error on AMDGPU driver compiling WPA-EAPOL-PBKDF2 OpenCL kernel +- Building: Updated BUILD.md +- My Wallet: Added additional plaintext pattern used in newer versions +- OpenCL Runtime: Disable OpenCL kernel cache on Apple for Intel CPU (throws CL_BUILD_PROGRAM_FAILURE for no reason) - OpenCL Runtime: Improve ROCM detection and make sure to not confuse with recent AMDGPU drivers - OpenCL Runtime: Not using amd_bytealign (amd_bitalign is fine) on AMDGPU driver drastically reduces JiT segfaults -- My Wallet: Added additional plaintext pattern used in newer versions +- OpenCL Runtime: Update unstable mode warnings for Apple and AMDGPU drivers +- OpenCL Runtime: Workaround JiT compiler error on AMDGPU driver compiling WPA-EAPOL-PBKDF2 OpenCL kernel +- Tuning Database: Updated hashcat.hctune with new models and refreshed vector width values ## ## Technical ## - Binary Distribution: Removed 32 bit binary executables +- Keep Guessing: No longer automatically activate --keep-guessing for modes 9720, 9820, 14900 and 18100 * changes v5.0.0 -> v5.1.0 @@ -290,7 +304,7 @@ - Added hash-mode 16300 = Ethereum Pre-Sale Wallet, PBKDF2-SHA256 - Added hash-mode 16400 = CRAM-MD5 Dovecot - Added hash-mode 16500 = JWT (JSON Web Token) -- Added hash-mode 16600 = Electrum Wallet (Salt-Type 1) +- Added hash-mode 16600 = Electrum Wallet (Salt-Type 1-2) ## ## Bugs diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index eb9104462..482488337 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -189,8 +189,8 @@ _hashcat () local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" - local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session --stdin-timeout-abort" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" + local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session --stdin-timeout-abort" COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" diff --git a/hashcat.hctune b/hashcat.hctune index 21e0ad662..3beea7ae3 100644 --- a/hashcat.hctune +++ b/hashcat.hctune @@ -361,8 +361,8 @@ GeForce_GTX_TITAN 3 9900 2 A ## EXTREME SLOW ALGOS # ####################### -DEVICE_TYPE_GPU * 14600 1 2 M -DEVICE_TYPE_GPU * 14800 1 2 250 +#DEVICE_TYPE_GPU * 14600 1 2 M +#DEVICE_TYPE_GPU * 14800 1 2 250 ########### ## SCRYPT # diff --git a/include/convert.h b/include/convert.h index 1ee824b39..8c7212a80 100644 --- a/include/convert.h +++ b/include/convert.h @@ -58,4 +58,12 @@ size_t base64_encode (u8 (*f) (const u8), const u8 *in_buf, const size_t in_len, void lowercase (u8 *buf, const size_t len); void uppercase (u8 *buf, const size_t len); +u16 v16a_from_v32 (const u32 v32); +u16 v16b_from_v32 (const u32 v32); +u32 v32_from_v16ab (const u16 v16a, const u16 v16b); + +u32 v32a_from_v64 (const u64 v64); +u32 v32b_from_v64 (const u64 v64); +u64 v64_from_v32ab (const u32 v32a, const u32 v32b); + #endif // _CONVERT_H diff --git a/include/modules.h b/include/modules.h index 3372160b5..2b4086e47 100644 --- a/include/modules.h +++ b/include/modules.h @@ -71,7 +71,7 @@ int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *ha void module_hook12 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt); void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt); -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz); +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz); bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param); diff --git a/include/opencl.h b/include/opencl.h index 56f76dd1b..2f54952b0 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -9,17 +9,18 @@ #include #include -static const char CL_VENDOR_AMD1[] = "Advanced Micro Devices, Inc."; -static const char CL_VENDOR_AMD2[] = "AuthenticAMD"; -static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel"; -static const char CL_VENDOR_APPLE[] = "Apple"; -static const char CL_VENDOR_APPLE_USE_AMD[] = "AMD"; -static const char CL_VENDOR_APPLE_USE_NV[] = "NVIDIA"; -static const char CL_VENDOR_INTEL_BEIGNET[] = "Intel"; -static const char CL_VENDOR_INTEL_SDK[] = "Intel(R) Corporation"; -static const char CL_VENDOR_MESA[] = "Mesa"; -static const char CL_VENDOR_NV[] = "NVIDIA Corporation"; -static const char CL_VENDOR_POCL[] = "The pocl project"; +static const char CL_VENDOR_AMD1[] = "Advanced Micro Devices, Inc."; +static const char CL_VENDOR_AMD2[] = "AuthenticAMD"; +static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel"; +static const char CL_VENDOR_APPLE[] = "Apple"; +static const char CL_VENDOR_APPLE_USE_AMD[] = "AMD"; +static const char CL_VENDOR_APPLE_USE_NV[] = "NVIDIA"; +static const char CL_VENDOR_APPLE_USE_INTEL[] = "Intel Inc."; +static const char CL_VENDOR_INTEL_BEIGNET[] = "Intel"; +static const char CL_VENDOR_INTEL_SDK[] = "Intel(R) Corporation"; +static const char CL_VENDOR_MESA[] = "Mesa"; +static const char CL_VENDOR_NV[] = "NVIDIA Corporation"; +static const char CL_VENDOR_POCL[] = "The pocl project"; int ocl_init (hashcat_ctx_t *hashcat_ctx); void ocl_close (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index a49ee194f..0c61a6662 100644 --- a/include/types.h +++ b/include/types.h @@ -75,6 +75,60 @@ typedef pthread_mutex_t hc_thread_mutex_t; typedef sem_t hc_thread_semaphore_t; #endif +// unions + +typedef union vconv32 +{ + u64 v32; + + struct + { + u16 v16a; + u16 v16b; + }; + + struct + { + u8 v8a; + u8 v8b; + u8 v8c; + u8 v8d; + }; + +} vconv32_t; + +typedef union vconv64 +{ + u64 v64; + + struct + { + u32 v32a; + u32 v32b; + }; + + struct + { + u16 v16a; + u16 v16b; + u16 v16c; + u16 v16d; + }; + + struct + { + u8 v8a; + u8 v8b; + u8 v8c; + u8 v8d; + u8 v8e; + u8 v8f; + u8 v8g; + u8 v8h; + }; + +} vconv64_t; + // enums typedef enum loglevel @@ -410,6 +464,7 @@ typedef enum opts_type OPTS_TYPE_PT_ADD06 = (1ULL << 40), OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 41), OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 42), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately + OPTS_TYPE_SUGGEST_KG = (1ULL << 43), // suggest keep guessing for modules the user maybe wants to use --keep-guessing } opts_type_t; @@ -727,8 +782,9 @@ typedef enum user_options_map IDX_STDIN_TIMEOUT_ABORT = 0xff42, IDX_TRUECRYPT_KEYFILES = 0xff43, IDX_USERNAME = 0xff44, - IDX_VERACRYPT_KEYFILES = 0xff46, - IDX_VERACRYPT_PIM = 0xff47, + IDX_VERACRYPT_KEYFILES = 0xff45, + IDX_VERACRYPT_PIM_START = 0xff46, + IDX_VERACRYPT_PIM_STOP = 0xff47, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', IDX_WORDLIST_AUTOHEX_DISABLE = 0xff48, @@ -1027,6 +1083,8 @@ typedef struct plain u32 salt_pos; u32 digest_pos; u32 hash_pos; + u32 extra1; + u32 extra2; } plain_t; @@ -1871,7 +1929,8 @@ typedef struct user_options u32 segment_size; u32 status_timer; u32 stdin_timeout_abort; - u32 veracrypt_pim; + u32 veracrypt_pim_start; + u32 veracrypt_pim_stop; u32 workload_profile; u64 limit; u64 skip; @@ -2333,7 +2392,7 @@ typedef struct module_ctx void (*module_hook12) (hc_device_param_t *, const void *, const u32, const u64); void (*module_hook23) (hc_device_param_t *, const void *, const u32, const u64); - int (*module_build_plain_postprocess) (const hashconfig_t *, const hashes_t *, const u32 *, const size_t, const int, u32 *, const size_t); + int (*module_build_plain_postprocess) (const hashconfig_t *, const hashes_t *, const plain_t *, const u32 *, const size_t, const int, u32 *, const size_t); bool (*module_unstable_warning) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *, const hc_device_param_t *); diff --git a/src/brain.c b/src/brain.c index f30917a19..42e6326b8 100644 --- a/src/brain.c +++ b/src/brain.c @@ -181,9 +181,13 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx) XXH64_update (state, &nonce_error_corrections, sizeof (nonce_error_corrections)); - const int veracrypt_pim = user_options->veracrypt_pim; + const int veracrypt_pim_start = user_options->veracrypt_pim_start; - XXH64_update (state, &veracrypt_pim, sizeof (veracrypt_pim)); + XXH64_update (state, &veracrypt_pim_start, sizeof (veracrypt_pim_start)); + + const int veracrypt_pim_stop = user_options->veracrypt_pim_stop; + + XXH64_update (state, &veracrypt_pim_stop, sizeof (veracrypt_pim_stop)); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { diff --git a/src/convert.c b/src/convert.c index 47ca4164c..5308e97d8 100644 --- a/src/convert.c +++ b/src/convert.c @@ -838,3 +838,59 @@ void uppercase (u8 *buf, const size_t len) { for (size_t i = 0; i < len; i++) buf[i] = (u8) toupper ((int) buf[i]); } + +u16 v16a_from_v32 (const u32 v32) +{ + vconv32_t v; + + v.v32 = v32; + + return v.v16a; +} + +u16 v16b_from_v32 (const u32 v32) +{ + vconv32_t v; + + v.v32 = v32; + + return v.v16b; +} + +u32 v32_from_v16ab (const u16 v16a, const u16 v16b) +{ + vconv32_t v; + + v.v16a = v16a; + v.v16b = v16b; + + return v.v32; +} + +u32 v32a_from_v64 (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v32a; +} + +u32 v32b_from_v64 (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v32b; +} + +u64 v64_from_v32ab (const u32 v32a, const u32 v32b) +{ + vconv64_t v; + + v.v32a = v32a; + v.v32b = v32b; + + return v.v64; +} diff --git a/src/hashes.c b/src/hashes.c index 1de247204..479cfe3d5 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -285,7 +285,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl { u32 temp_buf[64] = { 0 }; - const int temp_len = module_ctx->module_build_plain_postprocess (hashcat_ctx->hashconfig, hashcat_ctx->hashes, plain_buf, sizeof (plain_buf), plain_len, temp_buf, sizeof (temp_buf)); + const int temp_len = module_ctx->module_build_plain_postprocess (hashcat_ctx->hashconfig, hashcat_ctx->hashes, plain, plain_buf, sizeof (plain_buf), plain_len, temp_buf, sizeof (temp_buf)); if (temp_len < (int) sizeof (plain_buf)) { @@ -604,6 +604,13 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { const int binary_count = module_ctx->module_hash_binary_count (hashes); + if (binary_count == 0) + { + event_log_error (hashcat_ctx, "No hashes loaded."); + + return -1; + } + if (binary_count == -1) { event_log_error (hashcat_ctx, "%s: %s", hashes->hashfile, strerror (errno)); diff --git a/src/interface.c b/src/interface.c index 95b305134..9e3857a69 100644 --- a/src/interface.c +++ b/src/interface.c @@ -348,6 +348,18 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) { hashconfig->opts_type |= OPTS_TYPE_PT_NEVERCRACK; } + else + { + if (hashconfig->opti_type & OPTS_TYPE_SUGGEST_KG) + { + if (user_options->quiet == false) + { + event_log_warning (hashcat_ctx, "This hash-mode is known to emit multiple valid password candidates for the same hash."); + event_log_warning (hashcat_ctx, "Use --keep-guessing to prevent hashcat from shutdown after the hash has been cracked."); + event_log_warning (hashcat_ctx, NULL); + } + } + } hashconfig->has_optimized_kernel = false; hashconfig->has_pure_kernel = false; diff --git a/src/main.c b/src/main.c index d189fdb65..19f03aed0 100644 --- a/src/main.c +++ b/src/main.c @@ -514,12 +514,21 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (hashconfig->has_optimized_kernel == true) { event_log_advice (hashcat_ctx, "ATTENTION! Pure (unoptimized) OpenCL kernels selected."); - event_log_advice (hashcat_ctx, "This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance."); + event_log_advice (hashcat_ctx, "Using pure kernels enables cracking longer passwords but for the price of drastically reduced performance."); event_log_advice (hashcat_ctx, "If you want to switch to optimized OpenCL kernels, append -O to your commandline."); + event_log_advice (hashcat_ctx, "See the above message to find out about the exact limits."); event_log_advice (hashcat_ctx, NULL); } } - + + if (user_options->keep_guessing == true) + { + event_log_advice (hashcat_ctx, "ATTENTION! --keep-guessing mode is enabled."); + event_log_advice (hashcat_ctx, "This tells hashcat to continue attacking all target hashes until exhaustion."); + event_log_advice (hashcat_ctx, "hashcat will NOT check for or remove targets present in the potfile, and"); + event_log_advice (hashcat_ctx, "will add ALL plains/collisions found, even duplicates, to the potfile."); + event_log_advice (hashcat_ctx, NULL); + } /** * Watchdog and Temperature balance */ diff --git a/src/modules/module_00022.c b/src/modules/module_00022.c index 91421f478..3df8fb62b 100644 --- a/src/modules/module_00022.c +++ b/src/modules/module_00022.c @@ -203,39 +203,37 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = byte_swap_32 (tmp[2]); tmp[3] = byte_swap_32 (tmp[3]); - u16 *ptr = (u16 *) tmp; - u8 tmp_buf[32]; tmp_buf[ 0] = sig[0]; - tmp_buf[ 1] = int_to_base64 (((ptr[1]) >> 12) & 0x3f); - tmp_buf[ 2] = int_to_base64 (((ptr[1]) >> 6) & 0x3f); - tmp_buf[ 3] = int_to_base64 (((ptr[1]) >> 0) & 0x3f); - tmp_buf[ 4] = int_to_base64 (((ptr[0]) >> 12) & 0x3f); - tmp_buf[ 5] = int_to_base64 (((ptr[0]) >> 6) & 0x3f); + tmp_buf[ 1] = int_to_base64 (((v16b_from_v32 (tmp[0])) >> 12) & 0x3f); + tmp_buf[ 2] = int_to_base64 (((v16b_from_v32 (tmp[0])) >> 6) & 0x3f); + tmp_buf[ 3] = int_to_base64 (((v16b_from_v32 (tmp[0])) >> 0) & 0x3f); + tmp_buf[ 4] = int_to_base64 (((v16a_from_v32 (tmp[0])) >> 12) & 0x3f); + tmp_buf[ 5] = int_to_base64 (((v16a_from_v32 (tmp[0])) >> 6) & 0x3f); tmp_buf[ 6] = sig[1]; - tmp_buf[ 7] = int_to_base64 (((ptr[0]) >> 0) & 0x3f); - tmp_buf[ 8] = int_to_base64 (((ptr[3]) >> 12) & 0x3f); - tmp_buf[ 9] = int_to_base64 (((ptr[3]) >> 6) & 0x3f); - tmp_buf[10] = int_to_base64 (((ptr[3]) >> 0) & 0x3f); - tmp_buf[11] = int_to_base64 (((ptr[2]) >> 12) & 0x3f); + tmp_buf[ 7] = int_to_base64 (((v16a_from_v32 (tmp[0])) >> 0) & 0x3f); + tmp_buf[ 8] = int_to_base64 (((v16b_from_v32 (tmp[1])) >> 12) & 0x3f); + tmp_buf[ 9] = int_to_base64 (((v16b_from_v32 (tmp[1])) >> 6) & 0x3f); + tmp_buf[10] = int_to_base64 (((v16b_from_v32 (tmp[1])) >> 0) & 0x3f); + tmp_buf[11] = int_to_base64 (((v16a_from_v32 (tmp[1])) >> 12) & 0x3f); tmp_buf[12] = sig[2]; - tmp_buf[13] = int_to_base64 (((ptr[2]) >> 6) & 0x3f); - tmp_buf[14] = int_to_base64 (((ptr[2]) >> 0) & 0x3f); - tmp_buf[15] = int_to_base64 (((ptr[5]) >> 12) & 0x3f); - tmp_buf[16] = int_to_base64 (((ptr[5]) >> 6) & 0x3f); + tmp_buf[13] = int_to_base64 (((v16a_from_v32 (tmp[1])) >> 6) & 0x3f); + tmp_buf[14] = int_to_base64 (((v16a_from_v32 (tmp[1])) >> 0) & 0x3f); + tmp_buf[15] = int_to_base64 (((v16b_from_v32 (tmp[2])) >> 12) & 0x3f); + tmp_buf[16] = int_to_base64 (((v16b_from_v32 (tmp[2])) >> 6) & 0x3f); tmp_buf[17] = sig[3]; - tmp_buf[18] = int_to_base64 (((ptr[5]) >> 0) & 0x3f); - tmp_buf[19] = int_to_base64 (((ptr[4]) >> 12) & 0x3f); - tmp_buf[20] = int_to_base64 (((ptr[4]) >> 6) & 0x3f); - tmp_buf[21] = int_to_base64 (((ptr[4]) >> 0) & 0x3f); - tmp_buf[22] = int_to_base64 (((ptr[7]) >> 12) & 0x3f); + tmp_buf[18] = int_to_base64 (((v16b_from_v32 (tmp[2])) >> 0) & 0x3f); + tmp_buf[19] = int_to_base64 (((v16a_from_v32 (tmp[2])) >> 12) & 0x3f); + tmp_buf[20] = int_to_base64 (((v16a_from_v32 (tmp[2])) >> 6) & 0x3f); + tmp_buf[21] = int_to_base64 (((v16a_from_v32 (tmp[2])) >> 0) & 0x3f); + tmp_buf[22] = int_to_base64 (((v16b_from_v32 (tmp[3])) >> 12) & 0x3f); tmp_buf[23] = sig[4]; - tmp_buf[24] = int_to_base64 (((ptr[7]) >> 6) & 0x3f); - tmp_buf[25] = int_to_base64 (((ptr[7]) >> 0) & 0x3f); - tmp_buf[26] = int_to_base64 (((ptr[6]) >> 12) & 0x3f); - tmp_buf[27] = int_to_base64 (((ptr[6]) >> 6) & 0x3f); - tmp_buf[28] = int_to_base64 (((ptr[6]) >> 0) & 0x3f); + tmp_buf[24] = int_to_base64 (((v16b_from_v32 (tmp[3])) >> 6) & 0x3f); + tmp_buf[25] = int_to_base64 (((v16b_from_v32 (tmp[3])) >> 0) & 0x3f); + tmp_buf[26] = int_to_base64 (((v16a_from_v32 (tmp[3])) >> 12) & 0x3f); + tmp_buf[27] = int_to_base64 (((v16a_from_v32 (tmp[3])) >> 6) & 0x3f); + tmp_buf[28] = int_to_base64 (((v16a_from_v32 (tmp[3])) >> 0) & 0x3f); tmp_buf[29] = sig[5]; tmp_buf[30] = 0; diff --git a/src/modules/module_01410.c b/src/modules/module_01410.c index 2f50e4751..57904058e 100644 --- a/src/modules/module_01410.c +++ b/src/modules/module_01410.c @@ -48,6 +48,23 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -246,6 +263,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_01411.c b/src/modules/module_01411.c index 2a1e0bfd7..33a616ccf 100644 --- a/src/modules/module_01411.c +++ b/src/modules/module_01411.c @@ -50,6 +50,23 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, static const char *SIGNATURE_SHA256B64S = "{SSHA256}"; +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -242,6 +259,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_01450.c b/src/modules/module_01450.c index 10066d4b6..775cf29c5 100644 --- a/src/modules/module_01450.c +++ b/src/modules/module_01450.c @@ -43,6 +43,40 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -191,7 +225,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -217,6 +251,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_01460.c b/src/modules/module_01460.c index ae6765e75..0ab038d80 100644 --- a/src/modules/module_01460.c +++ b/src/modules/module_01460.c @@ -44,6 +44,23 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -218,6 +235,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_01600.c b/src/modules/module_01600.c index f5cfeef50..124937dbb 100644 --- a/src/modules/module_01600.c +++ b/src/modules/module_01600.c @@ -166,10 +166,10 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } diff --git a/src/modules/module_01720.c b/src/modules/module_01720.c index a626f7369..cef0b215b 100644 --- a/src/modules/module_01720.c +++ b/src/modules/module_01720.c @@ -49,6 +49,23 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -182,7 +199,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return out_len; } - void module_init (module_ctx_t *module_ctx) { module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; @@ -222,7 +238,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01722.c b/src/modules/module_01722.c index 849ed54de..8e250af7a 100644 --- a/src/modules/module_01722.c +++ b/src/modules/module_01722.c @@ -50,6 +50,23 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -139,8 +156,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[7] += SHA512M_H; } - u32 *ptr = (u32 *) tmp; - char tmp_salt[SALT_MAX * 2]; const int salt_len = generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, (u8 *) tmp_salt); @@ -149,14 +164,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const int line_len = snprintf (line_buf, line_size, "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", tmp_salt, - ptr[ 1], ptr[ 0], - ptr[ 3], ptr[ 2], - ptr[ 5], ptr[ 4], - ptr[ 7], ptr[ 6], - ptr[ 9], ptr[ 8], - ptr[11], ptr[10], - ptr[13], ptr[12], - ptr[15], ptr[14]); + v32b_from_v64 (tmp[0]), v32a_from_v64 (tmp[0]), + v32b_from_v64 (tmp[1]), v32a_from_v64 (tmp[1]), + v32b_from_v64 (tmp[2]), v32a_from_v64 (tmp[2]), + v32b_from_v64 (tmp[3]), v32a_from_v64 (tmp[3]), + v32b_from_v64 (tmp[4]), v32a_from_v64 (tmp[4]), + v32b_from_v64 (tmp[5]), v32a_from_v64 (tmp[5]), + v32b_from_v64 (tmp[6]), v32a_from_v64 (tmp[6]), + v32b_from_v64 (tmp[7]), v32a_from_v64 (tmp[7])); return line_len; } @@ -200,7 +215,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01731.c b/src/modules/module_01731.c index 6fc3a14b0..33dd5a60c 100644 --- a/src/modules/module_01731.c +++ b/src/modules/module_01731.c @@ -149,8 +149,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[7] += SHA512M_H; } - const u32 *ptr = (const u32 *) tmp; - char tmp_salt[SALT_MAX * 2]; const int salt_len = generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, (u8 *) tmp_salt); @@ -159,14 +157,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const int line_len = snprintf (line_buf, line_size, "0x0200%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", tmp_salt, - ptr[ 1], ptr[ 0], - ptr[ 3], ptr[ 2], - ptr[ 5], ptr[ 4], - ptr[ 7], ptr[ 6], - ptr[ 9], ptr[ 8], - ptr[11], ptr[10], - ptr[13], ptr[12], - ptr[15], ptr[14]); + v32b_from_v64 (tmp[0]), v32a_from_v64 (tmp[0]), + v32b_from_v64 (tmp[1]), v32a_from_v64 (tmp[1]), + v32b_from_v64 (tmp[2]), v32a_from_v64 (tmp[2]), + v32b_from_v64 (tmp[3]), v32a_from_v64 (tmp[3]), + v32b_from_v64 (tmp[4]), v32a_from_v64 (tmp[4]), + v32b_from_v64 (tmp[5]), v32a_from_v64 (tmp[5]), + v32b_from_v64 (tmp[6]), v32a_from_v64 (tmp[6]), + v32b_from_v64 (tmp[7]), v32a_from_v64 (tmp[7])); return line_len; } diff --git a/src/modules/module_01740.c b/src/modules/module_01740.c index ea475d5e1..c6031110a 100644 --- a/src/modules/module_01740.c +++ b/src/modules/module_01740.c @@ -50,6 +50,23 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -183,7 +200,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return out_len; } - void module_init (module_ctx_t *module_ctx) { module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; @@ -223,7 +239,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01750.c b/src/modules/module_01750.c index 85494a873..4e292afa9 100644 --- a/src/modules/module_01750.c +++ b/src/modules/module_01750.c @@ -44,6 +44,35 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) + { + return true; + } + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -153,7 +182,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return out_len; } - void module_init (module_ctx_t *module_ctx) { module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; @@ -193,7 +221,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -219,6 +247,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_01760.c b/src/modules/module_01760.c index f060300d2..d59699e72 100644 --- a/src/modules/module_01760.c +++ b/src/modules/module_01760.c @@ -45,6 +45,40 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) + { + return true; + } + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -154,7 +188,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return out_len; } - void module_init (module_ctx_t *module_ctx) { module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; @@ -194,7 +227,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -220,6 +253,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_01800.c b/src/modules/module_01800.c index 3222f69e7..38e3b9d42 100644 --- a/src/modules/module_01800.c +++ b/src/modules/module_01800.c @@ -431,14 +431,43 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } + } + return false; } @@ -557,7 +586,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_03200.c b/src/modules/module_03200.c index ba35a802c..a9d4efc0c 100644 --- a/src/modules/module_03200.c +++ b/src/modules/module_03200.c @@ -72,18 +72,34 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -u32 module_kernel_threads_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { - const u32 kernel_threads_min = 8; + char *jit_build_options = NULL; - return kernel_threads_min; -} + // this uses some nice feedback effect. + // based on the device_local_mem_size the reqd_work_group_size in the kernel is set to some value + // which is then is read from the opencl host in the kernel_preferred_wgs_multiple1/2/3 result. + // therefore we do not need to set module_kernel_threads_min/max except for CPU, where the threads are set to fixed 1. + // note we need to use device_param->device_local_mem_size - 4 because opencl jit returns with: + // Entry function '...' uses too much shared data (0xc004 bytes, 0xc000 max) + // on my development system. no clue where the 4 bytes are spent. + // I did some research on this and it seems to be related with the datatype. + // For example, if i used u8 instead, there's only 1 byte wasted. -u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u32 kernel_threads_max = 8; + u32 fixed_local_size = 0; - return kernel_threads_max; + if (device_param->device_type & CL_DEVICE_TYPE_CPU) + { + fixed_local_size = 1; + } + else + { + fixed_local_size = (device_param->device_local_mem_size - 4) / 4096; + } + + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u", fixed_local_size); + + return jit_build_options; } int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) @@ -236,14 +252,14 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = MODULE_DEFAULT; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; - module_ctx->module_kernel_threads_max = module_kernel_threads_max; - module_ctx->module_kernel_threads_min = module_kernel_threads_min; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; module_ctx->module_opti_type = module_opti_type; diff --git a/src/modules/module_05200.c b/src/modules/module_05200.c index 45bc4e547..1bbfa25fd 100644 --- a/src/modules/module_05200.c +++ b/src/modules/module_05200.c @@ -87,6 +87,20 @@ bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_ return potfile_disable; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -208,6 +222,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06100.c b/src/modules/module_06100.c index ba8ae4471..03d0c582b 100644 --- a/src/modules/module_06100.c +++ b/src/modules/module_06100.c @@ -41,20 +41,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -243,6 +229,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06213.c b/src/modules/module_06213.c index bed707a0d..4f3a363f4 100644 --- a/src/modules/module_06213.c +++ b/src/modules/module_06213.c @@ -194,17 +194,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -297,6 +286,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06223.c b/src/modules/module_06223.c index 551f46bce..3e7122de1 100644 --- a/src/modules/module_06223.c +++ b/src/modules/module_06223.c @@ -197,17 +197,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -300,6 +289,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06231.c b/src/modules/module_06231.c index e2907223a..7ffc0c5ee 100644 --- a/src/modules/module_06231.c +++ b/src/modules/module_06231.c @@ -196,18 +196,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // l_opencl_p_18.1.0.013: self-test failed - // note that opencl_runtime_16.1.2_x64_rh_6.4.0.37 works fine - if (device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -300,6 +288,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06232.c b/src/modules/module_06232.c index b5d90d671..6b8103306 100644 --- a/src/modules/module_06232.c +++ b/src/modules/module_06232.c @@ -196,18 +196,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // l_opencl_p_18.1.0.013: self-test failed - // note that opencl_runtime_16.1.2_x64_rh_6.4.0.37 works fine - if (device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -300,6 +288,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06233.c b/src/modules/module_06233.c index 7e7f2d472..a18f90d36 100644 --- a/src/modules/module_06233.c +++ b/src/modules/module_06233.c @@ -196,24 +196,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // l_opencl_p_18.1.0.013: self-test failed - // note that opencl_runtime_16.1.2_x64_rh_6.4.0.37 works fine - if (hc_device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) - { - return true; - } - - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -306,6 +288,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06241.c b/src/modules/module_06241.c index 7885221c5..13c51e5a3 100644 --- a/src/modules/module_06241.c +++ b/src/modules/module_06241.c @@ -70,7 +70,7 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const tc_t *tc = (const tc_t *) hashes->esalts_buf; diff --git a/src/modules/module_06242.c b/src/modules/module_06242.c index 614cc72d7..1227fff9f 100644 --- a/src/modules/module_06242.c +++ b/src/modules/module_06242.c @@ -70,7 +70,7 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const tc_t *tc = (const tc_t *) hashes->esalts_buf; diff --git a/src/modules/module_06243.c b/src/modules/module_06243.c index f85439a59..b9ee3872a 100644 --- a/src/modules/module_06243.c +++ b/src/modules/module_06243.c @@ -70,7 +70,7 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const tc_t *tc = (const tc_t *) hashes->esalts_buf; @@ -208,17 +208,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -311,6 +300,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06300.c b/src/modules/module_06300.c index b9e3333f7..d2e8bd1ea 100644 --- a/src/modules/module_06300.c +++ b/src/modules/module_06300.c @@ -166,10 +166,10 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) { diff --git a/src/modules/module_06400.c b/src/modules/module_06400.c index 3c02106b0..dc91a6ffd 100644 --- a/src/modules/module_06400.c +++ b/src/modules/module_06400.c @@ -253,6 +253,37 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -395,7 +426,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -421,6 +452,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06500.c b/src/modules/module_06500.c index cbbbdaacb..8a42868ee 100644 --- a/src/modules/module_06500.c +++ b/src/modules/module_06500.c @@ -530,6 +530,37 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return line_len; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + void module_init (module_ctx_t *module_ctx) { module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; @@ -569,7 +600,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -595,6 +626,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_06800.c b/src/modules/module_06800.c index 99e86469b..c35a5b596 100644 --- a/src/modules/module_06800.c +++ b/src/modules/module_06800.c @@ -68,6 +68,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -180,7 +197,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_07100.c b/src/modules/module_07100.c index 594ad2207..2f206e63a 100644 --- a/src/modules/module_07100.c +++ b/src/modules/module_07100.c @@ -81,6 +81,18 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -246,7 +258,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_07200.c b/src/modules/module_07200.c index 84a1d44ef..5f853b735 100644 --- a/src/modules/module_07200.c +++ b/src/modules/module_07200.c @@ -84,6 +84,18 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -241,7 +253,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_07400.c b/src/modules/module_07400.c index 86d11fcbc..9cb1741eb 100644 --- a/src/modules/module_07400.c +++ b/src/modules/module_07400.c @@ -255,10 +255,10 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) { @@ -269,6 +269,18 @@ bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return false; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -384,7 +396,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_07500.c b/src/modules/module_07500.c index c700ec6ee..c0a517c9a 100644 --- a/src/modules/module_07500.c +++ b/src/modules/module_07500.c @@ -76,20 +76,6 @@ u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB return kernel_threads_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -304,6 +290,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_07900.c b/src/modules/module_07900.c index b4f2b24d9..28b47bffa 100644 --- a/src/modules/module_07900.c +++ b/src/modules/module_07900.c @@ -284,6 +284,32 @@ static void drupal7_encode (const u8 digest[64], u8 buf[43]) //buf[43] = int_to_itoa64 (l & 0x3f); } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -434,7 +460,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -460,6 +486,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_08000.c b/src/modules/module_08000.c index 4e57f12ff..bb113232a 100644 --- a/src/modules/module_08000.c +++ b/src/modules/module_08000.c @@ -60,7 +60,7 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + if (device_param->device_vendor_id == VENDOR_ID_AMD) { hc_asprintf (&jit_build_options, "-D NO_UNROLL"); } diff --git a/src/modules/module_08200.c b/src/modules/module_08200.c index 516a00a8c..037a5ce27 100644 --- a/src/modules/module_08200.c +++ b/src/modules/module_08200.c @@ -94,6 +94,17 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY return jit_build_options; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // trap 6 + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + return true; + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -306,6 +317,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_08300.c b/src/modules/module_08300.c index e8be49b67..839558a5d 100644 --- a/src/modules/module_08300.c +++ b/src/modules/module_08300.c @@ -42,6 +42,20 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -261,6 +275,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_08600.c b/src/modules/module_08600.c index b0a007284..f84156d6c 100644 --- a/src/modules/module_08600.c +++ b/src/modules/module_08600.c @@ -50,20 +50,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -172,6 +158,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_08900.c b/src/modules/module_08900.c index 6107f1deb..266191bf1 100644 --- a/src/modules/module_08900.c +++ b/src/modules/module_08900.c @@ -229,14 +229,23 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + return false; } diff --git a/src/modules/module_09000.c b/src/modules/module_09000.c index 70c75c379..86017b1ba 100644 --- a/src/modules/module_09000.c +++ b/src/modules/module_09000.c @@ -98,6 +98,17 @@ bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_ return potfile_disable; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake: Segmentation fault + if (device_param->platform_vendor_id == VENDOR_ID_POCL) + { + return true; + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -198,6 +209,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_09200.c b/src/modules/module_09200.c index 74ac69517..35780bfd7 100644 --- a/src/modules/module_09200.c +++ b/src/modules/module_09200.c @@ -84,6 +84,18 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -237,7 +249,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_09300.c b/src/modules/module_09300.c index 119d3e7a0..8e4695321 100644 --- a/src/modules/module_09300.c +++ b/src/modules/module_09300.c @@ -218,14 +218,23 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + return false; } diff --git a/src/modules/module_09600.c b/src/modules/module_09600.c index 555b3d6e7..fb16942ba 100644 --- a/src/modules/module_09600.c +++ b/src/modules/module_09600.c @@ -87,6 +87,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -300,7 +317,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_09720.c b/src/modules/module_09720.c index b37c540a7..738412031 100644 --- a/src/modules/module_09720.c +++ b/src/modules/module_09720.c @@ -25,7 +25,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_UTF16LE - | OPTS_TYPE_PT_NEVERCRACK; + | OPTS_TYPE_SUGGEST_KG; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$oldoffice$0*55045061647456688860411218030058*e7e24d163fbd743992d4b8892bf3f2f7*493410dbc832557d3fe1870ace8397e2:91b2e062b9"; diff --git a/src/modules/module_09800.c b/src/modules/module_09800.c index a8f510b5b..3c070c668 100644 --- a/src/modules/module_09800.c +++ b/src/modules/module_09800.c @@ -85,6 +85,17 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake: Segmentation fault + if (device_param->platform_vendor_id == VENDOR_ID_POCL) + { + return true; + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -282,6 +293,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_09820.c b/src/modules/module_09820.c index d64ea720c..9a7b555aa 100644 --- a/src/modules/module_09820.c +++ b/src/modules/module_09820.c @@ -25,7 +25,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_UTF16LE - | OPTS_TYPE_PT_NEVERCRACK; + | OPTS_TYPE_SUGGEST_KG; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$oldoffice$3*83328705222323020515404251156288*2855956a165ff6511bc7f4cd77b9e101*941861655e73a09c40f7b1e9dfd0c256ed285acd:b8f63619ca"; diff --git a/src/modules/module_10100.c b/src/modules/module_10100.c index cd4510ac4..d0eccc578 100644 --- a/src/modules/module_10100.c +++ b/src/modules/module_10100.c @@ -42,10 +42,16 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { + // OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake: self-test failed + if (device_param->platform_vendor_id == VENDOR_ID_POCL) + { + return true; + } + // rocm 1.2.0-20190: self-test failed - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == true)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) { return true; } diff --git a/src/modules/module_10700.c b/src/modules/module_10700.c index cda880f47..96e8b1127 100644 --- a/src/modules/module_10700.c +++ b/src/modules/module_10700.c @@ -108,6 +108,12 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { + // OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake: Segmentation fault + if (device_param->platform_vendor_id == VENDOR_ID_POCL) + { + return true; + } + // l_opencl_p_18.1.0.013: Segmentation fault if (device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) { diff --git a/src/modules/module_10800.c b/src/modules/module_10800.c index 487f9011e..63996a47c 100644 --- a/src/modules/module_10800.c +++ b/src/modules/module_10800.c @@ -49,6 +49,23 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -193,7 +210,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_10900.c b/src/modules/module_10900.c index bf0c82201..5c1512f3b 100644 --- a/src/modules/module_10900.c +++ b/src/modules/module_10900.c @@ -85,6 +85,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -223,7 +240,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_11000.c b/src/modules/module_11000.c index 929e1582f..5f29216dd 100644 --- a/src/modules/module_11000.c +++ b/src/modules/module_11000.c @@ -58,6 +58,18 @@ u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return salt_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -168,7 +180,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_11300.c b/src/modules/module_11300.c index 0734f7c16..01ea679cf 100644 --- a/src/modules/module_11300.c +++ b/src/modules/module_11300.c @@ -85,6 +85,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -264,7 +281,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_11600.c b/src/modules/module_11600.c index 5deeef3ad..dd0ed0abb 100644 --- a/src/modules/module_11600.c +++ b/src/modules/module_11600.c @@ -281,10 +281,22 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } @@ -680,7 +692,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = module_hook23; module_ctx->module_hook_salt_size = module_hook_salt_size; module_ctx->module_hook_size = module_hook_size; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_11700.c b/src/modules/module_11700.c index 2171cc05d..00860edd5 100644 --- a/src/modules/module_11700.c +++ b/src/modules/module_11700.c @@ -41,10 +41,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) { diff --git a/src/modules/module_11750.c b/src/modules/module_11750.c index a554d8896..361fedc4a 100644 --- a/src/modules/module_11750.c +++ b/src/modules/module_11750.c @@ -41,10 +41,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) { diff --git a/src/modules/module_11760.c b/src/modules/module_11760.c index ac8ced5ca..591f60144 100644 --- a/src/modules/module_11760.c +++ b/src/modules/module_11760.c @@ -41,10 +41,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) { diff --git a/src/modules/module_11800.c b/src/modules/module_11800.c index 7dee70b15..490d1469c 100644 --- a/src/modules/module_11800.c +++ b/src/modules/module_11800.c @@ -41,10 +41,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) { diff --git a/src/modules/module_11850.c b/src/modules/module_11850.c index ee5b31dbe..d9f216123 100644 --- a/src/modules/module_11850.c +++ b/src/modules/module_11850.c @@ -41,10 +41,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) { diff --git a/src/modules/module_11860.c b/src/modules/module_11860.c index c99e222d3..bc42dd7c0 100644 --- a/src/modules/module_11860.c +++ b/src/modules/module_11860.c @@ -41,10 +41,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) { diff --git a/src/modules/module_12100.c b/src/modules/module_12100.c index 80fa7b978..bac9338c2 100644 --- a/src/modules/module_12100.c +++ b/src/modules/module_12100.c @@ -86,6 +86,18 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -228,7 +240,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_12200.c b/src/modules/module_12200.c index d046594a1..0f46855e7 100644 --- a/src/modules/module_12200.c +++ b/src/modules/module_12200.c @@ -68,6 +68,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -204,7 +221,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_12500.c b/src/modules/module_12500.c index a36dd6660..e0806f24f 100644 --- a/src/modules/module_12500.c +++ b/src/modules/module_12500.c @@ -91,10 +91,10 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, return mask; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } diff --git a/src/modules/module_12800.c b/src/modules/module_12800.c index 8c8c051f1..304542611 100644 --- a/src/modules/module_12800.c +++ b/src/modules/module_12800.c @@ -70,6 +70,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -222,7 +239,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_12900.c b/src/modules/module_12900.c index e18d184de..8edfe6734 100644 --- a/src/modules/module_12900.c +++ b/src/modules/module_12900.c @@ -70,6 +70,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -227,7 +244,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13000.c b/src/modules/module_13000.c index dd6a26d6b..eccef7295 100644 --- a/src/modules/module_13000.c +++ b/src/modules/module_13000.c @@ -83,6 +83,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -261,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13100.c b/src/modules/module_13100.c index fc70e8f30..3f1ee81e7 100644 --- a/src/modules/module_13100.c +++ b/src/modules/module_13100.c @@ -17,12 +17,11 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; -static const char *HASH_NAME = "Kerberos 5 TGS-REP etype 23"; +static const char *HASH_NAME = "Kerberos 5 TGS-REP etype 23 (RC4-HMAC-MD5)"; static const u64 KERN_TYPE = 13100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_NOT_ITERATED; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; -static const u32 PWDUMP_COLUMN = PWDUMP_COLUMN_NTLM_HASH; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$krb5tgs$23$*user$realm$test/spn*$b548e10f5694ae018d7ad63c257af7dc$35e8e45658860bc31a859b41a08989265f4ef8afd75652ab4d7a30ef151bf6350d879ae189a8cb769e01fa573c6315232b37e4bcad9105520640a781e5fd85c09615e78267e494f433f067cc6958200a82f70627ce0eebc2ac445729c2a8a0255dc3ede2c4973d2d93ac8c1a56b26444df300cb93045d05ff2326affaa3ae97f5cd866c14b78a459f0933a550e0b6507bf8af27c2391ef69fbdd649dd059a4b9ae2440edd96c82479645ccdb06bae0eead3b7f639178a90cf24d9a"; @@ -38,7 +37,6 @@ const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } -u32 module_pwdump_column (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return PWDUMP_COLUMN; } u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } @@ -75,20 +73,6 @@ u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB return kernel_threads_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -303,7 +287,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; module_ctx->module_potfile_disable = MODULE_DEFAULT; module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; - module_ctx->module_pwdump_column = module_pwdump_column; + module_ctx->module_pwdump_column = MODULE_DEFAULT; module_ctx->module_pw_max = MODULE_DEFAULT; module_ctx->module_pw_min = MODULE_DEFAULT; module_ctx->module_salt_max = MODULE_DEFAULT; @@ -313,6 +297,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index c53974d8e..c35d22b7e 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 512 bit"; -static const u64 KERN_TYPE = 6211; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13711; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_655331 = 655331; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,10 +220,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -209,25 +236,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_655331 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_655331; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -242,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -275,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index b02668321..00077c6bf 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1024 bit"; -static const u64 KERN_TYPE = 6212; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13712; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_655331 = 655331; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,10 +220,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -209,25 +236,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_655331 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_655331; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -242,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -275,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index 72cb24887..d30b66c83 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1536 bit"; -static const u64 KERN_TYPE = 6213; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13713; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_655331 = 655331; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,50 +220,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_655331 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_655331; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -253,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -286,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; @@ -308,6 +329,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index a4062ba5c..8e33d2434 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_8_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA512 + XTS 512 bit"; -static const u64 KERN_TYPE = 6221; +static const u64 KERN_TYPE = 13721; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; @@ -54,9 +53,12 @@ typedef struct tc64_tmp u64 dgst[32]; u64 out[32]; -} tc64_tmp_t; + u64 pim_key[32]; + int pim; // marker for cracked -typedef struct tc +} vc64_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,11 +68,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -87,18 +105,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc64_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc64_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -147,8 +172,6 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); - // parse - hash_t *hashes_buf = hashes->hashes_buf; hash_t *hash = &hashes_buf[0]; @@ -161,7 +184,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -175,7 +198,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -190,7 +213,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -198,10 +221,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -212,25 +237,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -245,7 +275,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -278,7 +308,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index c7d889951..d2eec1f0b 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_8_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA512 + XTS 1024 bit"; -static const u64 KERN_TYPE = 6222; +static const u64 KERN_TYPE = 13722; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; @@ -54,9 +53,12 @@ typedef struct tc64_tmp u64 dgst[32]; u64 out[32]; -} tc64_tmp_t; + u64 pim_key[32]; + int pim; // marker for cracked -typedef struct tc +} vc64_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,11 +68,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -87,18 +105,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc64_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc64_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -159,7 +184,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -173,7 +198,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -188,7 +213,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -196,10 +221,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -210,25 +237,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -243,7 +275,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -276,7 +308,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index 225cb5e47..50c177a72 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_8_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA512 + XTS 1536 bit"; -static const u64 KERN_TYPE = 6223; +static const u64 KERN_TYPE = 13723; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; @@ -54,9 +53,12 @@ typedef struct tc64_tmp u64 dgst[32]; u64 out[32]; -} tc64_tmp_t; + u64 pim_key[32]; + int pim; // marker for cracked -typedef struct tc +} vc64_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,11 +68,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -87,18 +105,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc64_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc64_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -159,7 +184,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -173,7 +198,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -188,7 +213,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -196,50 +221,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -254,7 +275,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -287,7 +308,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; @@ -309,6 +330,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index 7f31db24e..d2c571887 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Whirlpool + XTS 512 bit"; -static const u64 KERN_TYPE = 6231; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13731; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,51 +220,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // l_opencl_p_18.1.0.013: self-test failed - // note that opencl_runtime_16.1.2_x64_rh_6.4.0.37 works fine - if (device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -254,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -287,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; @@ -309,6 +329,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index 1f296f9b8..85c95d00c 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Whirlpool + XTS 1024 bit"; -static const u64 KERN_TYPE = 6232; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13732; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,51 +220,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // l_opencl_p_18.1.0.013: self-test failed - // note that opencl_runtime_16.1.2_x64_rh_6.4.0.37 works fine - if (device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -254,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -287,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; @@ -309,6 +329,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index 0f815e384..150a57a95 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Whirlpool + XTS 1536 bit"; -static const u64 KERN_TYPE = 6233; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13733; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,57 +220,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // l_opencl_p_18.1.0.013: self-test failed - // note that opencl_runtime_16.1.2_x64_rh_6.4.0.37 works fine - if (device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) - { - return true; - } - - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -260,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -293,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; @@ -315,6 +329,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index 053e3ec2f..666ce4c32 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 512 bit + boot-mode"; -static const u64 KERN_TYPE = 6211; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13711; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_KEYBOARD_MAPPING; @@ -46,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -54,9 +53,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,21 +68,33 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_327661 = 327661; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { - const tc_t *tc = (const tc_t *) hashes->esalts_buf; + const vc_t *vc = (const vc_t *) hashes->esalts_buf; - if (src_len < (int) dst_sz) + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + if (plain->extra1 == 0) { - memcpy (dst_buf, src_buf, src_len); + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, plain->extra1); } - - return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); } bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) @@ -99,14 +113,14 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } @@ -171,7 +185,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -185,7 +199,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -200,7 +214,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -208,10 +222,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = user_options->veracrypt_pim * 2048; + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 2048; salt->salt_iter--; } @@ -222,25 +238,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_327661 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_327661; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index 6f8e679e3..2d0b5d598 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1024 bit + boot-mode"; -static const u64 KERN_TYPE = 6212; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13712; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_KEYBOARD_MAPPING; @@ -46,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -54,9 +53,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,21 +68,33 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_327661 = 327661; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { - const tc_t *tc = (const tc_t *) hashes->esalts_buf; + const vc_t *vc = (const vc_t *) hashes->esalts_buf; - if (src_len < (int) dst_sz) + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + if (plain->extra1 == 0) { - memcpy (dst_buf, src_buf, src_len); + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, plain->extra1); } - - return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); } bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) @@ -99,14 +113,14 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } @@ -171,7 +185,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -185,7 +199,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -200,7 +214,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -208,10 +222,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = user_options->veracrypt_pim * 2048; + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 2048; salt->salt_iter--; } @@ -222,25 +238,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_327661 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_327661; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index cc8a6945a..2b8d42772 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -21,9 +21,8 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1536 bit + boot-mode"; -static const u64 KERN_TYPE = 6213; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 KERN_TYPE = 13713; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_KEYBOARD_MAPPING; @@ -46,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -54,9 +53,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,21 +68,33 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_327661 = 327661; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { - const tc_t *tc = (const tc_t *) hashes->esalts_buf; + const vc_t *vc = (const vc_t *) hashes->esalts_buf; - if (src_len < (int) dst_sz) + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + if (plain->extra1 == 0) { - memcpy (dst_buf, src_buf, src_len); + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, plain->extra1); } - - return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); } bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) @@ -99,14 +113,14 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } @@ -171,7 +185,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -185,7 +199,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -200,7 +214,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -208,50 +222,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = user_options->veracrypt_pim * 2048; + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 2048; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_327661 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_327661; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -321,6 +331,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index 01e0e86c2..5a2b89b8a 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -22,8 +22,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 512 bit"; static const u64 KERN_TYPE = 13751; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,10 +220,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -209,25 +236,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -242,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -275,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index be9bb1260..41a856f2d 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -22,8 +22,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1024 bit"; static const u64 KERN_TYPE = 13752; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,10 +220,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -209,25 +236,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -242,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -275,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index c855e861e..b08969f6e 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -22,8 +22,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1536 bit"; static const u64 KERN_TYPE = 13753; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -45,7 +44,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -53,9 +52,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -65,11 +67,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -86,18 +104,25 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -158,7 +183,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -172,7 +197,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -187,7 +212,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -195,50 +220,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -253,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -286,7 +307,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; @@ -308,6 +329,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index e99c11fca..83ce4acaf 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -22,8 +22,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 512 bit + boot-mode"; static const u64 KERN_TYPE = 13751; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_KEYBOARD_MAPPING; @@ -46,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -54,9 +53,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,21 +68,33 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_200000 = 200000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { - const tc_t *tc = (const tc_t *) hashes->esalts_buf; + const vc_t *vc = (const vc_t *) hashes->esalts_buf; - if (src_len < (int) dst_sz) + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + if (plain->extra1 == 0) { - memcpy (dst_buf, src_buf, src_len); + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, plain->extra1); } - - return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); } bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) @@ -99,14 +113,14 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } @@ -171,7 +185,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -185,7 +199,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -200,7 +214,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -208,10 +222,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = user_options->veracrypt_pim * 2048; + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 2048; salt->salt_iter--; } @@ -222,25 +238,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_200000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_200000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index 078c00b2f..4b19777ab 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -22,8 +22,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1024 bit + boot-mode"; static const u64 KERN_TYPE = 13752; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_KEYBOARD_MAPPING; @@ -46,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -54,9 +53,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,21 +68,33 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_200000 = 200000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { - const tc_t *tc = (const tc_t *) hashes->esalts_buf; + const vc_t *vc = (const vc_t *) hashes->esalts_buf; - if (src_len < (int) dst_sz) + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + if (plain->extra1 == 0) { - memcpy (dst_buf, src_buf, src_len); + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, plain->extra1); } - - return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); } bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) @@ -99,14 +113,14 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } @@ -171,7 +185,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -185,7 +199,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -200,7 +214,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -208,10 +222,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = user_options->veracrypt_pim * 2048; + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 2048; salt->salt_iter--; } @@ -222,25 +238,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_200000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_200000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index 1fa2c1cf5..ea57915c1 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -22,8 +22,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1536 bit + boot-mode"; static const u64 KERN_TYPE = 13753; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_KEYBOARD_MAPPING; @@ -46,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -typedef struct tc_tmp +typedef struct vc_tmp { u32 ipad[16]; u32 opad[16]; @@ -54,9 +53,12 @@ typedef struct tc_tmp u32 dgst[64]; u32 out[64]; -} tc_tmp_t; + u32 pim_key[64]; + int pim; // marker for cracked -typedef struct tc +} vc_tmp_t; + +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -66,21 +68,33 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_200000 = 200000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { - const tc_t *tc = (const tc_t *) hashes->esalts_buf; + const vc_t *vc = (const vc_t *) hashes->esalts_buf; - if (src_len < (int) dst_sz) + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + if (plain->extra1 == 0) { - memcpy (dst_buf, src_buf, src_len); + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, plain->extra1); } - - return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); } bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) @@ -99,14 +113,14 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 tmp_size = (const u64) sizeof (tc_tmp_t); + const u64 tmp_size = (const u64) sizeof (vc_tmp_t); return tmp_size; } @@ -171,7 +185,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -185,7 +199,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -200,7 +214,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -208,50 +222,46 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = user_options->veracrypt_pim * 2048; + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 2048; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_200000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_200000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -321,6 +331,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index 5053ebe79..9d98681b5 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -23,7 +23,6 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 512 bit"; static const u64 KERN_TYPE = 13771; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; @@ -57,9 +56,12 @@ typedef struct vc64_sbog_tmp u64 dgst[32]; u64 out[32]; + u64 pim_key[32]; + int pim; // marker for cracked + } vc64_sbog_tmp_t; -typedef struct tc +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -69,11 +71,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -90,7 +108,7 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } @@ -102,6 +120,13 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -162,7 +187,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -176,7 +201,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -191,7 +216,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -199,10 +224,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -213,25 +240,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -246,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -279,7 +311,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index df3d0c3d0..225b7053e 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -23,7 +23,6 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 1024 bit"; static const u64 KERN_TYPE = 13772; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; @@ -57,9 +56,12 @@ typedef struct vc64_sbog_tmp u64 dgst[32]; u64 out[32]; + u64 pim_key[32]; + int pim; // marker for cracked + } vc64_sbog_tmp_t; -typedef struct tc +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -69,11 +71,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -90,7 +108,7 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } @@ -102,6 +120,13 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -162,7 +187,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -176,7 +201,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -191,7 +216,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -199,10 +224,12 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } @@ -213,25 +240,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -246,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -279,7 +311,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index 7dd463f6a..f95444ba3 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -23,7 +23,6 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 1536 bit"; static const u64 KERN_TYPE = 13773; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE; @@ -57,9 +56,12 @@ typedef struct vc64_sbog_tmp u64 dgst[32]; u64 out[32]; + u64 pim_key[32]; + int pim; // marker for cracked + } vc64_sbog_tmp_t; -typedef struct tc +typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; @@ -69,11 +71,27 @@ typedef struct tc keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; int keyboard_layout_mapping_cnt; -} tc_t; + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + if (plain->extra1 == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) src_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) src_buf, plain->extra1 - 15); + } +} + bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -90,7 +108,7 @@ bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u64 esalt_size = (const u64) sizeof (tc_t); + const u64 esalt_size = (const u64) sizeof (vc_t); return esalt_size; } @@ -102,6 +120,13 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1000; // lowest PIM multiplier + + return kernel_loops_max; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { // this overrides the reductions of PW_MAX in case optimized kernel is selected @@ -162,7 +187,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE // keyfiles - tc_t *tc = (tc_t *) hash->esalt; + vc_t *vc = (vc_t *) hash->esalt; if (user_options->veracrypt_keyfiles) { @@ -176,7 +201,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); @@ -191,7 +216,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (user_options->keyboard_layout_mapping)) { - initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); } } @@ -199,22 +224,30 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if (user_options->veracrypt_pim) + if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) { - salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + vc->pim_start = 15 + user_options->veracrypt_pim_start; + vc->pim_stop = 15 + user_options->veracrypt_pim_stop; + salt->salt_iter = vc->pim_stop * 1000; salt->salt_iter--; } return 1; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) { - return true; + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } } return false; @@ -224,25 +257,30 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u32 *digest = (u32 *) digest_buf; - tc_t *tc = (tc_t *) esalt_buf; + vc_t *vc = (vc_t *) esalt_buf; const float entropy = get_entropy ((const u8 *) line_buf, line_len); if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); - memcpy (tc->salt_buf, line_buf, 64); + memcpy (vc->salt_buf, line_buf, 64); - memcpy (tc->data_buf, line_buf + 64, 512 - 64); + memcpy (vc->data_buf, line_buf + 64, 512 - 64); - salt->salt_buf[0] = tc->salt_buf[0]; + salt->salt_buf[0] = vc->salt_buf[0]; salt->salt_len = 4; - salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1; + salt->salt_iter = ROUNDS_VERACRYPT_500000; + salt->salt_iter--; - tc->signature = 0x41524556; // "VERA" + vc->pim_multi = 1000; + vc->pim_start = 0; + vc->pim_stop = 0; - digest[0] = tc->data_buf[0]; + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; return (PARSER_OK); } @@ -257,7 +295,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; @@ -290,7 +328,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; diff --git a/src/modules/module_14400.c b/src/modules/module_14400.c index 1075435bb..745acc249 100644 --- a/src/modules/module_14400.c +++ b/src/modules/module_14400.c @@ -56,10 +56,10 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) { diff --git a/src/modules/module_14800.c b/src/modules/module_14800.c index 86608ebf9..692388001 100644 --- a/src/modules/module_14800.c +++ b/src/modules/module_14800.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -63,6 +64,17 @@ typedef struct pbkdf2_sha256_tmp static const char *SIGNATURE_ITUNES_BACKUP = "$itunes_backup$"; +salt_t *module_benchmark_salt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + salt_t *salt = (salt_t *) hcmalloc (sizeof (salt_t)); + + salt->salt_iter = 10000000 - 1; + salt->salt_iter2 = 10000 - 1; + salt->salt_len = 16; + + return salt; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (itunes_backup_t); @@ -364,7 +376,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_esalt = MODULE_DEFAULT; module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; - module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = module_benchmark_salt; module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; diff --git a/src/modules/module_14900.c b/src/modules/module_14900.c index f40afae56..f5a047936 100644 --- a/src/modules/module_14900.c +++ b/src/modules/module_14900.c @@ -21,7 +21,7 @@ static const char *HASH_NAME = "Skip32 (PT = $salt, key = $pass)"; static const u64 KERN_TYPE = 14900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_NEVERCRACK; + | OPTS_TYPE_SUGGEST_KG; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat!!!"; static const char *ST_HASH = "7090b6b9:04223875"; diff --git a/src/modules/module_15000.c b/src/modules/module_15000.c index cad0e9924..a82cb5a82 100644 --- a/src/modules/module_15000.c +++ b/src/modules/module_15000.c @@ -11,7 +11,6 @@ #include "shared.h" #include "inc_hash_constants.h" - static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 14; static const u32 DGST_POS1 = 15; @@ -61,6 +60,40 @@ u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return salt_max; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -225,7 +258,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -251,6 +284,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_15300.c b/src/modules/module_15300.c index 4ae2dbec9..240aa0d8a 100644 --- a/src/modules/module_15300.c +++ b/src/modules/module_15300.c @@ -97,6 +97,26 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + // self-test failed + if (device_param->device_type & CL_DEVICE_TYPE_CPU) + { + return true; + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -438,6 +458,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_15600.c b/src/modules/module_15600.c index 585e12aab..59a2326f2 100644 --- a/src/modules/module_15600.c +++ b/src/modules/module_15600.c @@ -86,6 +86,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -270,7 +287,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_15700.c b/src/modules/module_15700.c index 362887a3e..c8ad32c95 100644 --- a/src/modules/module_15700.c +++ b/src/modules/module_15700.c @@ -245,14 +245,23 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { return true; } + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + return false; } diff --git a/src/modules/module_16200.c b/src/modules/module_16200.c index 3daca1a5c..42f78cb89 100644 --- a/src/modules/module_16200.c +++ b/src/modules/module_16200.c @@ -76,6 +76,23 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -257,7 +274,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_16300.c b/src/modules/module_16300.c index b4a55e366..7f7010697 100644 --- a/src/modules/module_16300.c +++ b/src/modules/module_16300.c @@ -77,6 +77,23 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -270,7 +287,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_16600.c b/src/modules/module_16600.c index c0b8cfe54..bcf089d3b 100644 --- a/src/modules/module_16600.c +++ b/src/modules/module_16600.c @@ -17,7 +17,7 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER; -static const char *HASH_NAME = "Electrum Wallet (Salt-Type 1-3)"; +static const char *HASH_NAME = "Electrum Wallet (Salt-Type 1-2)"; static const u64 KERN_TYPE = 16600; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT; diff --git a/src/modules/module_16700.c b/src/modules/module_16700.c index 06eca3bd8..cfa5d4cca 100644 --- a/src/modules/module_16700.c +++ b/src/modules/module_16700.c @@ -76,6 +76,23 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -259,7 +276,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_16900.c b/src/modules/module_16900.c index 6ab34fbe2..72067ce1c 100644 --- a/src/modules/module_16900.c +++ b/src/modules/module_16900.c @@ -87,6 +87,23 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -293,7 +310,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_18100.c b/src/modules/module_18100.c index 9acac9945..bb62134aa 100644 --- a/src/modules/module_18100.c +++ b/src/modules/module_18100.c @@ -25,7 +25,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_ADDBITS15 - | OPTS_TYPE_PT_NEVERCRACK; + | OPTS_TYPE_SUGGEST_KG; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "597056:3600"; @@ -45,7 +45,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const plain_t *plain, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { return base32_encode (int_to_base32, (const u8 *) src_buf, src_len, (u8 *) dst_buf); } diff --git a/src/modules/module_18200.c b/src/modules/module_18200.c index 6b28e0653..1d6a8718f 100644 --- a/src/modules/module_18200.c +++ b/src/modules/module_18200.c @@ -75,20 +75,6 @@ u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB return kernel_threads_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *hc_device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((hc_device_param->device_vendor_id == VENDOR_ID_AMD) && (hc_device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -275,6 +261,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_18300.c b/src/modules/module_18300.c index 3f3ef3716..62651797c 100644 --- a/src/modules/module_18300.c +++ b/src/modules/module_18300.c @@ -76,6 +76,23 @@ u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED return esalt_size; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -267,7 +284,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_18600.c b/src/modules/module_18600.c index befb2abf8..14e9d35b1 100644 --- a/src/modules/module_18600.c +++ b/src/modules/module_18600.c @@ -100,6 +100,17 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake: self-test failed + if (device_param->platform_vendor_id == VENDOR_ID_POCL) + { + return true; + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -350,6 +361,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_18800.c b/src/modules/module_18800.c index 06bdcfb25..fcdcc8a46 100644 --- a/src/modules/module_18800.c +++ b/src/modules/module_18800.c @@ -79,6 +79,20 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -249,6 +263,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_19100.c b/src/modules/module_19100.c index 2808725a6..5f9828094 100644 --- a/src/modules/module_19100.c +++ b/src/modules/module_19100.c @@ -70,6 +70,37 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -235,7 +266,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -261,6 +292,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_19200.c b/src/modules/module_19200.c index 6be8af7c9..69afc3135 100644 --- a/src/modules/module_19200.c +++ b/src/modules/module_19200.c @@ -76,6 +76,37 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + // trap 6 + if ((device_param->device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if (device_param->device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + if (device_param->device_vendor_id == VENDOR_ID_AMD) + { + hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -241,7 +272,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -267,6 +298,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_19600.c b/src/modules/module_19600.c new file mode 100644 index 000000000..0fd685944 --- /dev/null +++ b/src/modules/module_19600.c @@ -0,0 +1,349 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; +static const char *HASH_NAME = "Kerberos 5 TGS-REP etype 17 (AES128-CTS-HMAC-SHA1-96)"; +static const u64 KERN_TYPE = 19600; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$krb5tgs$17$srv_http$synacktiv.local$849e31b3db1c1f203fa20b85$948690f5875125348286ad3346d27b43eaabc71896b620c16de7ddcdbd561628c650c508856a3f574261948b6db4b48332d30536e978046a423ad4368f9a69b4dc4642dab4e0d475d8299be718fd6f98ac85a771b457b2453e78c9411dfce572b19660fe7a5a8246d9b2a91ea2f14d1986ea0a77ecf9b8330bc8fd9ab540bcf46b74c5aa7005cfccd89ec05f66aeab30c6b2bf8595cf6c9a1b68ad885258850c4b1dd9265f270fb2af52fd76c16246df51ea67efc58a65c345686c84e43642febe908a"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct krb5tgs_17 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_17_t; + +typedef struct krb5tgs_17_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[10]; + u32 out[10]; + +} krb5tgs_17_tmp_t; + +static const char *SIGNATURE_KRB5TGS = "$krb5tgs$17$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (krb5tgs_17_tmp_t); + + return tmp_size; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (krb5tgs_17_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + krb5tgs_17_t *krb5tgs = (krb5tgs_17_t *) esalt_buf; + + token_t token; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_KRB5TGS; + + token.len[0] = 12; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + /** + * $krb5tgs$17$*user*realm*$checksum$edata2 + * $krb5tgs$17$*user*realm*spn*$checksum$edata2 + */ + + // assume no signature found + if (line_len < 12) return (PARSER_SALT_LENGTH); + + char *spn_info_start = strchr ((const char *) line_buf + 12 + 1, '*'); + + int is_spn_provided = 0; + + // assume $krb5tgs$17$user$realm$checksum$edata2 + if (spn_info_start == NULL) + { + token.token_cnt = 5; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 512; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[3] = '$'; + // hmac-sha1 stripped to 12bytes + token.len_min[3] = 24; + token.len_max[3] = 24; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '$'; + token.len_min[4] = 64; + token.len_max[4] = 40960; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + // assume $krb5tgs$17$user$realm$*spn*$checksum$edata2 + else + { + char *spn_info_stop = strchr ((const char *) spn_info_start + 1, '*'); + + if (spn_info_stop == NULL) return (PARSER_SEPARATOR_UNMATCHED); + + spn_info_stop++; // we want the * $char included + spn_info_stop++; // we want the $ char included + + const int spn_info_len = spn_info_stop - spn_info_start; + + token.token_cnt = 6; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 512; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + token.len[3] = spn_info_len; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; + + token.sep[4] = '$'; + token.len_min[4] = 24; + token.len_max[4] = 24; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[5] = '$'; + token.len_min[5] = 64; + token.len_max[5] = 40960; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + is_spn_provided = 1; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *user_pos; + const u8 *domain_pos; + const u8 *checksum_pos; + const u8 *data_pos; + + int user_len; + int domain_len; + int data_len; + int account_info_len; + + user_pos = token.buf[1]; + user_len = token.len[1]; + + memcpy(krb5tgs->user, user_pos, user_len); + + domain_pos = token.buf[2]; + domain_len = token.len[2]; + + memcpy(krb5tgs->domain, domain_pos, domain_len); + + checksum_pos = token.buf[3 + is_spn_provided]; + + data_pos = token.buf[4 + is_spn_provided]; + data_len = token.len[4 + is_spn_provided]; + + account_info_len = token.len[2] + token.len[1]; + + u8 *account_info_ptr = (u8 *) krb5tgs->account_info; + + // domain must be uppercase + u8 domain[128]; + memcpy(domain, domain_pos, domain_len); + uppercase(domain, domain_len); + + memcpy(account_info_ptr, domain, domain_len); + memcpy(account_info_ptr + domain_len, user_pos, user_len); + + krb5tgs->account_info_len = account_info_len; + + // hmac-sha1 is reduced to 12 bytes + krb5tgs->checksum[0] = byte_swap_32 (hex_to_u32 (checksum_pos + 0)); + krb5tgs->checksum[1] = byte_swap_32 (hex_to_u32 (checksum_pos + 8)); + krb5tgs->checksum[2] = byte_swap_32 (hex_to_u32 (checksum_pos + 16)); + + u8 *edata_ptr = (u8 *) krb5tgs->edata2; + + for (int i = 0; i < data_len; i += 2) + { + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; + + *edata_ptr++ = hex_convert (p1) << 0 + | hex_convert (p0) << 4; + } + + krb5tgs->edata2_len = data_len / 2; + + salt->salt_buf[0] = krb5tgs->checksum[0]; + salt->salt_buf[1] = krb5tgs->checksum[1]; + salt->salt_buf[2] = krb5tgs->checksum[2]; + + salt->salt_iter = 4096 - 1; + + digest[0] = krb5tgs->checksum[0]; + digest[1] = krb5tgs->checksum[1]; + digest[2] = krb5tgs->checksum[2]; + digest[3] = 0; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const krb5tgs_17_t *krb5tgs = (const krb5tgs_17_t *) esalt_buf; + + char data[5120 * 4 * 2] = { 0 }; + + for (u32 i = 0, j = 0; i < krb5tgs->edata2_len; i += 1, j += 2) + { + u8 *ptr_edata2 = (u8 *) krb5tgs->edata2; + + sprintf (data + j, "%02x", ptr_edata2[i]); + } + + const int line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x$%s", + SIGNATURE_KRB5TGS, + (char *) krb5tgs->user, + (char *) krb5tgs->domain, + krb5tgs->checksum[0], + krb5tgs->checksum[1], + krb5tgs->checksum[2], + data); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_outfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} \ No newline at end of file diff --git a/src/modules/module_19700.c b/src/modules/module_19700.c new file mode 100644 index 000000000..3d29b58f0 --- /dev/null +++ b/src/modules/module_19700.c @@ -0,0 +1,349 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; +static const char *HASH_NAME = "Kerberos 5 TGS-REP etype 18 (AES256-CTS-HMAC-SHA1-96)"; +static const u64 KERN_TYPE = 19700; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$krb5tgs$18$srv_http$synacktiv.local$16ce51f6eba20c8ee534ff8a$57d07b23643a516834795f0c010da8f549b7e65063e5a367ca9240f9b800adad1734df7e7d5dd8307e785de4f40aacf901df41aa6ce695f8619ec579c1fa57ee93661cf402aeef4e3a42e7e3477645d52c09dc72feade03512dffe0df517344f673c63532b790c242cc1d50f4b4b34976cb6e08ab325b3aefb2684262a5ee9faacb14d059754f50553be5bfa5c4c51e833ff2b6ac02c6e5d4c4eb193e27d7dde301bd1ddf480e5e282b8c27ef37b136c8f140b56de105b73adeb1de16232fa1ab5c9f6"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct krb5tgs_18 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + +} krb5tgs_18_t; + +typedef struct krb5tgs_18_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[16]; + u32 out[16]; + +} krb5tgs_18_tmp_t; + +static const char *SIGNATURE_KRB5TGS = "$krb5tgs$18$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (krb5tgs_18_tmp_t); + + return tmp_size; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (krb5tgs_18_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + krb5tgs_18_t *krb5tgs = (krb5tgs_18_t *) esalt_buf; + + token_t token; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_KRB5TGS; + + token.len[0] = 12; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + /** + * $krb5tgs$18$*user*realm*$checksum$edata2 + * $krb5tgs$18$*user*realm*spn*$checksum$edata2 + */ + + // assume no signature found + if (line_len < 12) return (PARSER_SALT_LENGTH); + + char *spn_info_start = strchr ((const char *) line_buf + 12 + 1, '*'); + + int is_spn_provided = 0; + + // assume $krb5tgs$17$user$realm$checksum$edata2 + if (spn_info_start == NULL) + { + token.token_cnt = 5; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 512; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[3] = '$'; + // hmac-sha1 stripped to 12bytes + token.len_min[3] = 24; + token.len_max[3] = 24; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '$'; + token.len_min[4] = 64; + token.len_max[4] = 40960; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + // assume $krb5tgs$18$user$realm$*spn*$checksum$edata2 + else + { + char *spn_info_stop = strchr ((const char *) spn_info_start + 1, '*'); + + if (spn_info_stop == NULL) return (PARSER_SEPARATOR_UNMATCHED); + + spn_info_stop++; // we want the * $char included + spn_info_stop++; // we want the $ char included + + const int spn_info_len = spn_info_stop - spn_info_start; + + token.token_cnt = 6; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 512; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + token.len[3] = spn_info_len; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; + + token.sep[4] = '$'; + token.len_min[4] = 24; + token.len_max[4] = 24; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[5] = '$'; + token.len_min[5] = 64; + token.len_max[5] = 40960; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + is_spn_provided = 1; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *user_pos; + const u8 *domain_pos; + const u8 *checksum_pos; + const u8 *data_pos; + + int user_len; + int domain_len; + int data_len; + int account_info_len; + + user_pos = token.buf[1]; + user_len = token.len[1]; + + memcpy(krb5tgs->user, user_pos, user_len); + + domain_pos = token.buf[2]; + domain_len = token.len[2]; + + memcpy(krb5tgs->domain, domain_pos, domain_len); + + checksum_pos = token.buf[3 + is_spn_provided]; + + data_pos = token.buf[4 + is_spn_provided]; + data_len = token.len[4 + is_spn_provided]; + + account_info_len = token.len[2] + token.len[1]; + + u8 *account_info_ptr = (u8 *) krb5tgs->account_info; + + // domain must be uppercase + u8 domain[128]; + memcpy(domain, domain_pos, domain_len); + uppercase(domain, domain_len); + + memcpy(account_info_ptr, domain, domain_len); + memcpy(account_info_ptr + domain_len, user_pos, user_len); + + krb5tgs->account_info_len = account_info_len; + + // hmac-sha1 is reduced to 12 bytes + krb5tgs->checksum[0] = byte_swap_32 (hex_to_u32 (checksum_pos + 0)); + krb5tgs->checksum[1] = byte_swap_32 (hex_to_u32 (checksum_pos + 8)); + krb5tgs->checksum[2] = byte_swap_32 (hex_to_u32 (checksum_pos + 16)); + + u8 *edata_ptr = (u8 *) krb5tgs->edata2; + + for (int i = 0; i < data_len; i += 2) + { + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; + + *edata_ptr++ = hex_convert (p1) << 0 + | hex_convert (p0) << 4; + } + + krb5tgs->edata2_len = data_len / 2; + + salt->salt_buf[0] = krb5tgs->checksum[0]; + salt->salt_buf[1] = krb5tgs->checksum[1]; + salt->salt_buf[2] = krb5tgs->checksum[2]; + + salt->salt_iter = 4096 - 1; + + digest[0] = krb5tgs->checksum[0]; + digest[1] = krb5tgs->checksum[1]; + digest[2] = krb5tgs->checksum[2]; + digest[3] = 0; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const krb5tgs_18_t *krb5tgs = (const krb5tgs_18_t *) esalt_buf; + + char data[5120 * 4 * 2] = { 0 }; + + for (u32 i = 0, j = 0; i < krb5tgs->edata2_len; i += 1, j += 2) + { + u8 *ptr_edata2 = (u8 *) krb5tgs->edata2; + + sprintf (data + j, "%02x", ptr_edata2[i]); + } + + const int line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x$%s", + SIGNATURE_KRB5TGS, + (char *) krb5tgs->user, + (char *) krb5tgs->domain, + krb5tgs->checksum[0], + krb5tgs->checksum[1], + krb5tgs->checksum[2], + data); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_outfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} \ No newline at end of file diff --git a/src/opencl.c b/src/opencl.c index 31e11db67..7d9d5616b 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -3376,6 +3376,10 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { device_vendor_id = VENDOR_ID_NV; } + else if (strcmp (device_vendor, CL_VENDOR_APPLE_USE_INTEL) == 0) + { + device_vendor_id = VENDOR_ID_INTEL_SDK; + } else if (strcmp (device_vendor, CL_VENDOR_INTEL_BEIGNET) == 0) { device_vendor_id = VENDOR_ID_INTEL_BEIGNET; @@ -4912,6 +4916,28 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%08x", device_name_digest_amp_mp[0]); + /** + * kernel cache + */ + + bool cache_disable = false; + + // Seems to be completely broken on Apple + (Intel?) CPU + // To reproduce set cache_disable to false and run benchmark -b + + if (device_param->platform_vendor_id == VENDOR_ID_APPLE) + { + if (device_param->device_type & CL_DEVICE_TYPE_CPU) + { + cache_disable = true; + } + } + + if (module_ctx->module_jit_cache_disable != MODULE_DEFAULT) + { + cache_disable = module_ctx->module_jit_cache_disable (hashconfig, user_options, user_options_extra, hashes, device_param); + } + /** * main kernel */ @@ -4942,6 +4968,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) bool cached = true; + if (cache_disable == true) + { + cached = false; + } + if (hc_path_read (cached_file) == false) { cached = false; @@ -4964,100 +4995,12 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) char **kernel_sources = &kernel_sources_buf; - bool cache_disable = false; - - if (module_ctx->module_jit_cache_disable != MODULE_DEFAULT) + if (cached == false) { - cache_disable = module_ctx->module_jit_cache_disable (hashconfig, user_options, user_options_extra, hashes, device_param); - } + #if defined (DEBUG) + if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + #endif - if (cache_disable == false) - { - if (cached == false) - { - #if defined (DEBUG) - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - #endif - - const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); - - if (rc_read_kernel == false) return -1; - - CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); - - if (CL_rc == -1) return -1; - - CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_options_module_buf, NULL, NULL); - - //if (CL_rc == -1) return -1; - - size_t build_log_size = 0; - - hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - - //if (CL_rc == -1) return -1; - - #if defined (DEBUG) - if ((build_log_size > 1) || (CL_rc == -1)) - #else - if (CL_rc == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - - if (CL_rc_build == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (CL_rc == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - size_t binary_size; - - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - - if (CL_rc == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); - - if (CL_rc == -1) return -1; - - const bool rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - - if (rc_write == false) return -1; - - hcfree (binary); - } - else - { - const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false); - - if (rc_read_kernel == false) return -1; - - CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program); - - if (CL_rc == -1) return -1; - - CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_options_module_buf, NULL, NULL); - - if (CL_rc == -1) return -1; - } - } - else - { const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); if (rc_read_kernel == false) return -1; @@ -5101,6 +5044,41 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) continue; } + + if (cache_disable == false) + { + size_t binary_size; + + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + + if (CL_rc == -1) return -1; + + char *binary = (char *) hcmalloc (binary_size); + + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); + + if (CL_rc == -1) return -1; + + const bool rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + + if (rc_write == false) return -1; + + hcfree (binary); + } + } + else + { + const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false); + + if (rc_read_kernel == false) return -1; + + CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program); + + if (CL_rc == -1) return -1; + + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_options_module_buf, NULL, NULL); + + if (CL_rc == -1) return -1; } hcfree (kernel_sources[0]); @@ -5144,6 +5122,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) bool cached = true; + if (cache_disable == true) + { + cached = false; + } + if (hc_path_read (cached_file) == false) { cached = false; @@ -5216,21 +5199,24 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) continue; } - size_t binary_size; + if (cache_disable == false) + { + size_t binary_size; - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (binary_size); + char *binary = (char *) hcmalloc (binary_size); - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - hcfree (binary); + hcfree (binary); + } } else { @@ -5291,6 +5277,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) bool cached = true; + if (cache_disable == true) + { + cached = false; + } + if (hc_path_read (cached_file) == false) { cached = false; @@ -5363,21 +5354,24 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) continue; } - size_t binary_size; + if (cache_disable == false) + { + size_t binary_size; - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (binary_size); + char *binary = (char *) hcmalloc (binary_size); - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - hcfree (binary); + hcfree (binary); + } } else { diff --git a/src/potfile.c b/src/potfile.c index a7d3db540..c59238684 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -373,10 +373,13 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) const hashes_t *hashes = hashcat_ctx->hashes; const module_ctx_t *module_ctx = hashcat_ctx->module_ctx; const potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; if (potfile_ctx->enabled == false) return 0; if (hashconfig->potfile_disable == true) return 0; + + if (hashconfig->opts_type & OPTS_TYPE_PT_NEVERCRACK) return 0; // if no potfile exists yet we don't need to do anything here diff --git a/src/status.c b/src/status.c index 77e489ae6..c2cff5a7b 100644 --- a/src/status.c +++ b/src/status.c @@ -872,8 +872,8 @@ char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i const u32 innerloop_first = 0; const u32 innerloop_last = device_param->innerloop_left - 1; - plain_t plain1 = { outerloop_first, innerloop_first, 0, 0, 0 }; - plain_t plain2 = { outerloop_last, innerloop_last, 0, 0, 0 }; + plain_t plain1 = { outerloop_first, innerloop_first, 0, 0, 0, 0, 0 }; + plain_t plain2 = { outerloop_last, innerloop_last, 0, 0, 0, 0, 0 }; u32 plain_buf1[(64 * 2) + 2] = { 0 }; u32 plain_buf2[(64 * 2) + 2] = { 0 }; diff --git a/src/usage.c b/src/usage.c index a6cac4569..bc4ba0d02 100644 --- a/src/usage.c +++ b/src/usage.c @@ -77,7 +77,8 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --keyboard-layout-mapping | File | Keyboard layout mapping table for special hash-modes | --keyb=german.hckmap", " --truecrypt-keyfiles | File | Keyfiles to use, separated with commas | --truecrypt-keyf=x.png", " --veracrypt-keyfiles | File | Keyfiles to use, separated with commas | --veracrypt-keyf=x.txt", - " --veracrypt-pim | Num | VeraCrypt personal iterations multiplier | --veracrypt-pim=1000", + " --veracrypt-pim-start | Num | VeraCrypt personal iterations multiplier start | --veracrypt-pim-start=450", + " --veracrypt-pim-stop | Num | VeraCrypt personal iterations multiplier stop | --veracrypt-pim-stop=500", " -b, --benchmark | | Run benchmark of selected hash-modes |", " --benchmark-all | | Run benchmark of all hash-modes (requires -b) |", " --speed-only | | Return expected speed of the attack, then quit |", diff --git a/src/user_options.c b/src/user_options.c index c7111bb7f..6ec74d28a 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -118,7 +118,8 @@ static const struct option long_options[] = {"truecrypt-keyfiles", required_argument, NULL, IDX_TRUECRYPT_KEYFILES}, {"username", no_argument, NULL, IDX_USERNAME}, {"veracrypt-keyfiles", required_argument, NULL, IDX_VERACRYPT_KEYFILES}, - {"veracrypt-pim", required_argument, NULL, IDX_VERACRYPT_PIM}, + {"veracrypt-pim-start", required_argument, NULL, IDX_VERACRYPT_PIM_START}, + {"veracrypt-pim-stop", required_argument, NULL, IDX_VERACRYPT_PIM_STOP}, {"version", no_argument, NULL, IDX_VERSION}, {"wordlist-autohex-disable", no_argument, NULL, IDX_WORDLIST_AUTOHEX_DISABLE}, {"workload-profile", required_argument, NULL, IDX_WORKLOAD_PROFILE}, @@ -248,7 +249,8 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->usage = USAGE; user_options->username = USERNAME; user_options->veracrypt_keyfiles = NULL; - user_options->veracrypt_pim = 0; + user_options->veracrypt_pim_start = 0; + user_options->veracrypt_pim_stop = 0; user_options->version = VERSION; user_options->wordlist_autohex_disable = WORDLIST_AUTOHEX_DISABLE; user_options->workload_profile = WORKLOAD_PROFILE; @@ -312,7 +314,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_HWMON_TEMP_ABORT: case IDX_HCCAPX_MESSAGE_PAIR: case IDX_NONCE_ERROR_CORRECTIONS: - case IDX_VERACRYPT_PIM: + case IDX_VERACRYPT_PIM_START: + case IDX_VERACRYPT_PIM_STOP: case IDX_SEGMENT_SIZE: case IDX_SCRYPT_TMTO: case IDX_BITMAP_MIN: @@ -447,7 +450,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_KEYBOARD_LAYOUT_MAPPING: user_options->keyboard_layout_mapping = optarg; break; case IDX_TRUECRYPT_KEYFILES: user_options->truecrypt_keyfiles = optarg; break; case IDX_VERACRYPT_KEYFILES: user_options->veracrypt_keyfiles = optarg; break; - case IDX_VERACRYPT_PIM: user_options->veracrypt_pim = hc_strtoul (optarg, NULL, 10); break; + case IDX_VERACRYPT_PIM_START: user_options->veracrypt_pim_start = hc_strtoul (optarg, NULL, 10); break; + case IDX_VERACRYPT_PIM_STOP: user_options->veracrypt_pim_stop = hc_strtoul (optarg, NULL, 10); break; case IDX_SEGMENT_SIZE: user_options->segment_size = hc_strtoul (optarg, NULL, 10); user_options->segment_size_chgd = true; break; case IDX_SCRYPT_TMTO: user_options->scrypt_tmto = hc_strtoul (optarg, NULL, 10); break; @@ -669,6 +673,27 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if ((user_options->veracrypt_pim_start != 0) && (user_options->veracrypt_pim_stop == 0)) + { + event_log_error (hashcat_ctx, "If --veracrypt-pim-start is specified then --veracrypt-pim-stop needs to be specified, too."); + + return -1; + } + + if ((user_options->veracrypt_pim_start == 0) && (user_options->veracrypt_pim_stop != 0)) + { + event_log_error (hashcat_ctx, "If --veracrypt-pim-stop is specified then --veracrypt-pim-start needs to be specified, too."); + + return -1; + } + + if (user_options->veracrypt_pim_start > user_options->veracrypt_pim_stop) + { + event_log_error (hashcat_ctx, "Invalid --veracrypt-pim-start value specified."); + + return -1; + } + if (user_options->increment_min > user_options->increment_max) { event_log_error (hashcat_ctx, "Invalid --increment-min value specified - must be >= --increment-max."); @@ -2769,7 +2794,8 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->stdout_flag); logfile_top_uint (user_options->usage); logfile_top_uint (user_options->username); - logfile_top_uint (user_options->veracrypt_pim); + logfile_top_uint (user_options->veracrypt_pim_start); + logfile_top_uint (user_options->veracrypt_pim_stop); logfile_top_uint (user_options->version); logfile_top_uint (user_options->workload_profile); #ifdef WITH_BRAIN diff --git a/tools/test.pl b/tools/test.pl index 353d584e3..5eb47e8d2 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -18,6 +18,11 @@ use lib "$FindBin::Bin/test_modules"; my $IS_OPTIMIZED = 1; +if (exists $ENV{"IS_OPTIMIZED"} && defined $ENV{"IS_OPTIMIZED"}) +{ + $IS_OPTIMIZED = $ENV{"IS_OPTIMIZED"}; +} + my $TYPES = [ 'single', 'passthrough', 'verify' ]; my $TYPE = shift @ARGV; diff --git a/tools/test.sh b/tools/test.sh index 3e39c31cf..b192df41e 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -5,7 +5,7 @@ ## License.....: MIT ## -OPTS="--quiet --potfile-disable --runtime 400 --hwmon-disable -O" +OPTS="--quiet --potfile-disable --runtime 400 --hwmon-disable" TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -2479,11 +2479,6 @@ OPTIONS: '8' => vector-width 8 'all' => test sequentially vector-width ${VECTOR_WIDTHS} - -T OpenCL device-types to use : - 'gpu' => gpu devices (default) - 'cpu' => cpu devices - 'all' => gpu and cpu devices - -t Select test mode : 'single' => single hash (default) 'multi' => multi hash @@ -2492,11 +2487,11 @@ OPTIONS: -m Select hash type : 'all' => all hash type supported (int) => hash type integer code (default : 0) + (int)-(int) => hash type integer range -a Select attack mode : 'all' => all attack modes (int) => attack mode integer code (default : 0) - (int)-(int) => attack mode integer range -x Select cpu architecture : '32' => 32 bit architecture @@ -2507,11 +2502,29 @@ OPTIONS: 'linux' => Linux operating system (use .bin file extension) 'macos' => macOS operating system (use .app file extension) + -d Select the OpenCL device : + (int)[,int] => comma separated list of devices (default : 1) + + -D Select the OpenCL device types : + '1' => CPU + '2' => GPU (default) + '3' => FPGA, DSP, Co-Processor + (int)[,int] => multiple comma separated device types from the list above + + -O Use optimized kernels (default : -O) + + -P Use pure kernels instead of optimized kernels (default : -O) + + -s Use this session name instead of the default one (default : "hashcat") + -c Disables markov-chains -p Package the tests into a .7z file - -d Use this folder as input/output folder for packaged tests + -F Use this folder as test folder instead of the default one + (string) => path to folder + + -I Use this folder as input/output folder for packaged tests (string) => path to folder -h Show this help @@ -2529,8 +2542,9 @@ TYPE="null" VECTOR="default" HT=0 PACKAGE=0 +OPTIMIZED=1 -while getopts "V:T:t:m:a:b:hcpd:x:o:" opt; do +while getopts "V:t:m:a:b:hcpd:x:o:d:D:F:POI:s:" opt; do case ${opt} in "V") @@ -2551,21 +2565,6 @@ while getopts "V:T:t:m:a:b:hcpd:x:o:" opt; do fi ;; - "T") - if [ ${OPTARG} == "gpu" ]; then - OPTS="${OPTS} --opencl-device-types 2" - TYPE="Gpu" - elif [ ${OPTARG} == "cpu" ]; then - OPTS="${OPTS} --opencl-device-types 1" - TYPE="Cpu" - elif [ ${OPTARG} == "all" ]; then - OPTS="${OPTS} --opencl-device-types 1,2" - TYPE="Cpu + Gpu" - else - usage - fi - ;; - "t") if [ ${OPTARG} == "single" ]; then MODE=0 @@ -2609,10 +2608,14 @@ while getopts "V:T:t:m:a:b:hcpd:x:o:" opt; do MARKOV="disabled" ;; - "d") + "I") PACKAGE_FOLDER=$( echo ${OPTARG} | sed 's!/$!!g' ) ;; + "s") + OPTS="${OPTS} --session \"${OPTARG}\"" + ;; + "p") PACKAGE=1 ;; @@ -2639,6 +2642,35 @@ while getopts "V:T:t:m:a:b:hcpd:x:o:" opt; do fi ;; + "O") + # optimized is already default, ignore it + ;; + + "d") + OPTS="${OPTS} -d ${OPTARG}" + ;; + + "D") + if [ ${OPTARG} == "1" ]; then + OPTS="${OPTS} -D 1" + TYPE="Cpu" + elif [ ${OPTARG} == "2" ]; then + OPTS="${OPTS} -D 2" + TYPE="Gpu" + else + OPTS="${OPTS} -D ${OPTARG}" + TYPE="Cpu + Gpu" + fi + ;; + + "F") + OUTD=$( echo ${OPTARG} | sed 's!/$!!g' ) + ;; + + "P") + OPTIMIZED=0 + ;; + \?) usage ;; @@ -2650,9 +2682,15 @@ while getopts "V:T:t:m:a:b:hcpd:x:o:" opt; do done +export IS_OPTIMIZED=${OPTIMIZED} + +if [ "${OPTIMIZED}" -eq 1 ]; then + OPTS="${OPTS} -O" +fi + if [ "${TYPE}" == "null" ]; then - TYPE="Gpu" - OPTS="${OPTS} --opencl-device-types 2" + OPTS="${OPTS} -D 2" + TYPE="Gpu" fi if [ -n "${ARCHITECTURE}" ]; then diff --git a/tools/test_modules/m19600.pm b/tools/test_modules/m19600.pm new file mode 100644 index 000000000..ed40c9b1d --- /dev/null +++ b/tools/test_modules/m19600.pm @@ -0,0 +1,219 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (hmac_sha1); +use Crypt::Mode::CBC; +use Crypt::PBKDF2; +use Encode; +use POSIX qw (strftime); + +sub byte2hex +{ + my $input = shift; + return unpack ("H*", $input); +} + +sub hex2byte +{ + my $input = shift; + return pack ("H*", $input); +} + +sub pad +{ + my $n = shift; + my $size = shift; + + return (~$n + 1) & ($size - 1); +} + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $user = shift // "user"; + my $realm = shift // "realm"; + my $checksum = shift; + my $edata2 = shift; + + my $mysalt = uc $realm; + $mysalt = $mysalt . $user; + + # first we generate the 'seed' + my $iter = 4096; + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => $iter, + output_len => 16 + ); + + my $b_seed = $pbkdf2->PBKDF2 ($mysalt, $word); + + # we can precompute this + my $b_kerberos_nfolded = hex2byte('6b65726265726f737b9b5b2b93132b93'); + + my $b_iv = hex2byte('0' x 32); + + # 'key_bytes' will be the AES key used to generate 'ki' (for final hmac-sha1) + # and 'ke' (AES key to decrypt/encrypt the ticket) + my $cbc = Crypt::Mode::CBC->new ('AES', 0); + my $b_key_bytes = $cbc->encrypt ($b_kerberos_nfolded, $b_seed, $b_iv); + + # precomputed stuff + my $b_nfolded1 = hex2byte('62dc6e371a63a80958ac562b15404ac5'); + my $b_nfolded2 = hex2byte('b5b0582c14b6500aad56ab55aa80556a'); + + my $b_ki = $cbc->encrypt ($b_nfolded1, $b_key_bytes, $b_iv); + my $b_ke = $cbc->encrypt ($b_nfolded2, $b_key_bytes, $b_iv); + + my $cleartext_ticket = '6381b03081ada00703050050a00000a11b3019a003020117a1'. + '12041058e0d77776e8b8e03991f2966939222aa2171b154d594b5242544553542e434f4e5'. + '44f534f2e434f4da3133011a003020102a10a30081b067472616e6365a40b3009a0030201'. + '01a1020400a511180f32303136303231353134343735305aa611180f32303136303231353'. + '134343735305aa711180f32303136303231363030343735305aa811180f32303136303232'. + '323134343735305a'; + + if (defined $edata2) + { + my $len_last_block = length($edata2) % 32; + + my $tmp = $len_last_block + 32; + + my $b_truncated_enc_ticket = hex2byte (substr $edata2, 0, -$tmp); + + my $b_last_block = hex2byte (substr $edata2, -$len_last_block); + + my $b_n_1_block = hex2byte (substr(substr($edata2, -$tmp), 0, 32)); + + my $b_truncated_ticket_decrypted = $cbc->decrypt ($b_truncated_enc_ticket, $b_ke, $b_iv); + + my $truncated_ticket_decrypted = byte2hex($b_truncated_ticket_decrypted); + + my $check_correct = ((substr ($truncated_ticket_decrypted, 32, 4) eq "6381" && substr ($truncated_ticket_decrypted, 38, 2) eq "30") || + (substr ($truncated_ticket_decrypted, 32, 4) eq "6382")) && + ((substr ($truncated_ticket_decrypted, 48, 6) eq "030500") || + (substr ($truncated_ticket_decrypted, 48, 8) eq "050307A0")); + + if ($check_correct == 1) + { + my $b_n_2 = substr $b_truncated_enc_ticket, -16; + + my $b_n_1_decrypted = $cbc->decrypt ($b_n_1_block, $b_ke, $b_iv); + + my $b_last_plain = substr $b_n_1_decrypted, 0, $len_last_block/2; + + $b_last_plain = $b_last_plain ^ $b_last_block; + + my $omitted = substr $b_n_1_decrypted, -(16 - $len_last_block/2); + + my $b_n_1 = $b_last_block . $omitted; + + $b_n_1 = $cbc->decrypt ($b_n_1, $b_ke, $b_iv); + + $b_n_1 = $b_n_1 ^ $b_n_2; + + my $b_cleartext_ticket = $b_truncated_ticket_decrypted . $b_n_1 . $b_last_plain; + + $cleartext_ticket = byte2hex($b_cleartext_ticket); + } + else # validation failed + { + # fake/wrong ticket (otherwise if we just decrypt/encrypt we end + #up with false positives all the time) + $cleartext_ticket = "0" x (length ($cleartext_ticket) + 32); + } + } + + if (defined $checksum) + { + $checksum = pack ("H*", $checksum); + } + else + { + if (!defined $edata2) + { + my $nonce = unpack ("H*", random_bytes (16)); + + $cleartext_ticket = $nonce . $cleartext_ticket; + } + # we have what is required to compute checksum + $checksum = hmac_sha1 (hex2byte($cleartext_ticket), $b_ki); + + $checksum = substr $checksum, 0, 12; + } + + my $len_cleartext_last_block = length($cleartext_ticket) % 32; + my $cleartext_last_block = substr $cleartext_ticket, -$len_cleartext_last_block; + + my $padding = pad(length($cleartext_ticket), 32); + + my $b_cleartext_last_block_padded = hex2byte($cleartext_last_block . '0' x $padding); + + # we will encrypt until n-1 block (included) + my $truncated_cleartext_ticket = substr $cleartext_ticket, 0, -$len_cleartext_last_block; + + my $b_truncated_enc_ticket = $cbc->encrypt (hex2byte($truncated_cleartext_ticket), $b_ke, $b_iv); + + my $b_enc_ticket_n_1_block= substr $b_truncated_enc_ticket, -16; + + my $b_enc_last_block = substr $b_enc_ticket_n_1_block, 0, $len_cleartext_last_block/2; + + # we now craft the new n-1 block + my $tmp = $b_enc_ticket_n_1_block ^ $b_cleartext_last_block_padded; + + $b_enc_ticket_n_1_block = $cbc->encrypt ($tmp, $b_ke, $b_iv); + + $tmp = substr $b_truncated_enc_ticket, 0, -16; + + $edata2 = $tmp . $b_enc_ticket_n_1_block . $b_enc_last_block; + + my $tmp_hash = sprintf ('$krb5tgs$17$%s$%s$%s$%s', $user, $realm, unpack ("H*", $checksum), unpack ("H*", $edata2)); + + return $tmp_hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my @data = split ('\$', $hash); + + return unless scalar @data == 7; + + shift @data; + + my $signature = shift @data; + my $algorithm = shift @data; + my $user = shift @data; + my $realm = shift @data; + my $checksum = shift @data; + my $edata2 = shift @data; + + return unless ($signature eq "krb5tgs"); + return unless ($algorithm eq "17"); + return unless (length ($checksum) == 24); + return unless (length ($edata2) >= 64); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, undef, $user, $realm, $checksum, $edata2); + + return ($new_hash, $word); +} + +1; \ No newline at end of file diff --git a/tools/test_modules/m19700.pm b/tools/test_modules/m19700.pm new file mode 100644 index 000000000..2510d14c3 --- /dev/null +++ b/tools/test_modules/m19700.pm @@ -0,0 +1,226 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (hmac_sha1); +use Crypt::Mode::CBC; +use Crypt::PBKDF2; +use Encode; +use POSIX qw (strftime); + +sub byte2hex +{ + my $input = shift; + return unpack ("H*", $input); +} + +sub hex2byte +{ + my $input = shift; + return pack ("H*", $input); +} + +sub pad +{ + my $n = shift; + my $size = shift; + + return (~$n + 1) & ($size - 1); +} + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $user = shift // "user"; + my $realm = shift // "realm"; + my $checksum = shift; + my $edata2 = shift; + + my $mysalt = uc $realm; + $mysalt = $mysalt . $user; + + # first we generate the 'seed' + my $iter = 4096; + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => $iter, + output_len => 32 + ); + + my $b_seed = $pbkdf2->PBKDF2 ($mysalt, $word); + + # we can precompute this + my $b_kerberos_nfolded = hex2byte('6b65726265726f737b9b5b2b93132b93'); + + my $b_iv = hex2byte('0' x 32); + + # 'key_bytes' will be the AES key used to generate 'ki' (for final hmac-sha1) + # and 'ke' (AES key to decrypt/encrypt the ticket) + my $cbc = Crypt::Mode::CBC->new ('AES', 0); + my $b_key_bytes = $cbc->encrypt ($b_kerberos_nfolded, $b_seed, $b_iv); + + $b_key_bytes = $b_key_bytes . $cbc->encrypt ($b_key_bytes, $b_seed, $b_iv); + + # precomputed stuff + my $b_nfolded1 = hex2byte('62dc6e371a63a80958ac562b15404ac5'); + my $b_nfolded2 = hex2byte('b5b0582c14b6500aad56ab55aa80556a'); + + my $b_ki = $cbc->encrypt ($b_nfolded1, $b_key_bytes, $b_iv); + + $b_ki = $b_ki . $cbc->encrypt ($b_ki, $b_key_bytes, $b_iv); + + my $b_ke = $cbc->encrypt ($b_nfolded2, $b_key_bytes, $b_iv); + + $b_ke = $b_ke . $cbc->encrypt ($b_ke, $b_key_bytes, $b_iv); + + my $cleartext_ticket = '6381b03081ada00703050050a00000a11b3019a003020117a1'. + '12041058e0d77776e8b8e03991f2966939222aa2171b154d594b5242544553542e434f4e5'. + '44f534f2e434f4da3133011a003020102a10a30081b067472616e6365a40b3009a0030201'. + '01a1020400a511180f32303136303231353134343735305aa611180f32303136303231353'. + '134343735305aa711180f32303136303231363030343735305aa811180f32303136303232'. + '323134343735305a'; + + if (defined $edata2) + { + my $len_last_block = length($edata2) % 32; + + my $tmp = $len_last_block + 32; + + my $b_truncated_enc_ticket = hex2byte (substr $edata2, 0, -$tmp); + + my $b_last_block = hex2byte (substr $edata2, -$len_last_block); + + my $b_n_1_block = hex2byte (substr(substr($edata2, -$tmp), 0, 32)); + + my $b_truncated_ticket_decrypted = $cbc->decrypt ($b_truncated_enc_ticket, $b_ke, $b_iv); + + my $truncated_ticket_decrypted = byte2hex($b_truncated_ticket_decrypted); + + my $check_correct = ((substr ($truncated_ticket_decrypted, 32, 4) eq "6381" && substr ($truncated_ticket_decrypted, 38, 2) eq "30") || + (substr ($truncated_ticket_decrypted, 32, 4) eq "6382")) && + ((substr ($truncated_ticket_decrypted, 48, 6) eq "030500") || + (substr ($truncated_ticket_decrypted, 48, 8) eq "050307A0")); + + if ($check_correct == 1) + { + my $b_n_2 = substr $b_truncated_enc_ticket, -16; + + my $b_n_1_decrypted = $cbc->decrypt ($b_n_1_block, $b_ke, $b_iv); + + my $b_last_plain = substr $b_n_1_decrypted, 0, $len_last_block/2; + + $b_last_plain = $b_last_plain ^ $b_last_block; + + my $omitted = substr $b_n_1_decrypted, -(16 - $len_last_block/2); + + my $b_n_1 = $b_last_block . $omitted; + + $b_n_1 = $cbc->decrypt ($b_n_1, $b_ke, $b_iv); + + $b_n_1 = $b_n_1 ^ $b_n_2; + + my $b_cleartext_ticket = $b_truncated_ticket_decrypted . $b_n_1 . $b_last_plain; + + $cleartext_ticket = byte2hex($b_cleartext_ticket); + } + else # validation failed + { + # fake/wrong ticket (otherwise if we just decrypt/encrypt we end + #up with false positives all the time) + $cleartext_ticket = "0" x (length ($cleartext_ticket) + 32); + } + } + + if (defined $checksum) + { + $checksum = pack ("H*", $checksum); + } + else + { + if (!defined $edata2) + { + my $nonce = unpack ("H*", random_bytes (16)); + + $cleartext_ticket = $nonce . $cleartext_ticket; + } + # we have what is required to compute checksum + $checksum = hmac_sha1 (hex2byte($cleartext_ticket), $b_ki); + + $checksum = substr $checksum, 0, 12; + } + + my $len_cleartext_last_block = length($cleartext_ticket)%32; + my $cleartext_last_block = substr $cleartext_ticket, -$len_cleartext_last_block; + + my $padding = pad(length($cleartext_ticket), 32); + + my $b_cleartext_last_block_padded = hex2byte($cleartext_last_block . '0' x $padding); + + # we will encrypt until n-1 block (included) + my $truncated_cleartext_ticket = substr $cleartext_ticket, 0, -$len_cleartext_last_block; + + my $b_truncated_enc_ticket = $cbc->encrypt (hex2byte($truncated_cleartext_ticket), $b_ke, $b_iv); + + my $b_enc_ticket_n_1_block= substr $b_truncated_enc_ticket, -16; + + my $b_enc_last_block = substr $b_enc_ticket_n_1_block, 0, $len_cleartext_last_block/2; + + # we now craft the new n-1 block + my $tmp = $b_enc_ticket_n_1_block ^ $b_cleartext_last_block_padded; + + $b_enc_ticket_n_1_block = $cbc->encrypt ($tmp, $b_ke, $b_iv); + + $tmp = substr $b_truncated_enc_ticket, 0, -16; + + $edata2 = $tmp . $b_enc_ticket_n_1_block . $b_enc_last_block; + + my $tmp_hash = sprintf ('$krb5tgs$18$%s$%s$%s$%s', $user, $realm, unpack ("H*", $checksum), unpack ("H*", $edata2)); + + return $tmp_hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my @data = split ('\$', $hash); + + return unless scalar @data == 7; + + shift @data; + + my $signature = shift @data; + my $algorithm = shift @data; + my $user = shift @data; + my $realm = shift @data; + my $checksum = shift @data; + my $edata2 = shift @data; + + return unless ($signature eq "krb5tgs"); + return unless ($algorithm eq "18"); + return unless (length ($checksum) == 24); + return unless (length ($edata2) >= 64); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, undef, $user, $realm, $checksum, $edata2); + + return ($new_hash, $word); +} + +1; \ No newline at end of file