1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-30 03:48:17 +00:00

moving macros out of function in cpu-*.c

based on 58b728230b
This commit is contained in:
jsteube 2016-09-05 10:27:32 +02:00
parent 4366afecee
commit d24c200dfe
4 changed files with 58 additions and 81 deletions

View File

@ -353,6 +353,8 @@ static const u32 c_skb[8][64] =
PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \
}
#define BOX(v,i,S) (S)[(i)][(v)]
void _des_keysetup (u32 data[2], u32 Kc[16], u32 Kd[16], const u32 s_skb[8][64])
{
u32 c = data[0];
@ -387,8 +389,6 @@ void _des_keysetup (u32 data[2], u32 Kc[16], u32 Kd[16], const u32 s_skb[8][64])
c = c & 0x0fffffff;
d = d & 0x0fffffff;
#define BOX(v,i,S) (S)[(i)][(v)]
u32 s = BOX ((( c >> 0) & 0x3f), 0, s_skb)
| BOX ((((c >> 6) & 0x03)
| ((c >> 7) & 0x3c)), 1, s_skb)

View File

@ -29,6 +29,23 @@
(a) += (b); \
}
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
void md5_64 (uint block[16], uint digest[4])
{
uint a = digest[0];
@ -36,11 +53,6 @@ void md5_64 (uint block[16], uint digest[4])
uint c = digest[2];
uint d = digest[3];
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF ( a, b, c, d, block[ 0], S11, 0xd76aa478);
FF ( d, a, b, c, block[ 1], S12, 0xe8c7b756);
FF ( c, d, a, b, block[ 2], S13, 0x242070db);
@ -58,11 +70,6 @@ void md5_64 (uint block[16], uint digest[4])
FF ( c, d, a, b, block[14], S13, 0xa679438e);
FF ( b, c, d, a, block[15], S14, 0x49b40821);
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG ( a, b, c, d, block[ 1], S21, 0xf61e2562);
GG ( d, a, b, c, block[ 6], S22, 0xc040b340);
GG ( c, d, a, b, block[11], S23, 0x265e5a51);
@ -80,11 +87,6 @@ void md5_64 (uint block[16], uint digest[4])
GG ( c, d, a, b, block[ 7], S23, 0x676f02d9);
GG ( b, c, d, a, block[12], S24, 0x8d2a4c8a);
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH ( a, b, c, d, block[ 5], S31, 0xfffa3942);
HH ( d, a, b, c, block[ 8], S32, 0x8771f681);
HH ( c, d, a, b, block[11], S33, 0x6d9d6122);
@ -102,11 +104,6 @@ void md5_64 (uint block[16], uint digest[4])
HH ( c, d, a, b, block[15], S33, 0x1fa27cf8);
HH ( b, c, d, a, block[ 2], S34, 0xc4ac5665);
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II ( a, b, c, d, block[ 0], S41, 0xf4292244);
II ( d, a, b, c, block[ 7], S42, 0x432aff97);
II ( c, d, a, b, block[14], S43, 0xab9423a7);
@ -198,11 +195,6 @@ void md5_complete_no_limit (uint digest[4], uint *plain, uint plain_len)
* md5 ()
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF ( a, b, c, d, block[ 0], S11, 0xd76aa478);
FF ( d, a, b, c, block[ 1], S12, 0xe8c7b756);
FF ( c, d, a, b, block[ 2], S13, 0x242070db);
@ -220,11 +212,6 @@ void md5_complete_no_limit (uint digest[4], uint *plain, uint plain_len)
FF ( c, d, a, b, block[14], S13, 0xa679438e);
FF ( b, c, d, a, block[15], S14, 0x49b40821);
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG ( a, b, c, d, block[ 1], S21, 0xf61e2562);
GG ( d, a, b, c, block[ 6], S22, 0xc040b340);
GG ( c, d, a, b, block[11], S23, 0x265e5a51);
@ -242,11 +229,6 @@ void md5_complete_no_limit (uint digest[4], uint *plain, uint plain_len)
GG ( c, d, a, b, block[ 7], S23, 0x676f02d9);
GG ( b, c, d, a, block[12], S24, 0x8d2a4c8a);
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH ( a, b, c, d, block[ 5], S31, 0xfffa3942);
HH ( d, a, b, c, block[ 8], S32, 0x8771f681);
HH ( c, d, a, b, block[11], S33, 0x6d9d6122);
@ -264,11 +246,6 @@ void md5_complete_no_limit (uint digest[4], uint *plain, uint plain_len)
HH ( c, d, a, b, block[15], S33, 0x1fa27cf8);
HH ( b, c, d, a, block[ 2], S34, 0xc4ac5665);
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II ( a, b, c, d, block[ 0], S41, 0xf4292244);
II ( d, a, b, c, block[ 7], S42, 0x432aff97);
II ( c, d, a, b, block[14], S43, 0xab9423a7);

View File

@ -3,6 +3,19 @@
* License.....: MIT
*/
#define SHA1_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA1_F1(x,y,z) ((x) ^ (y) ^ (z))
#define SHA1_F2(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA1_STEP(f,a,b,c,d,e,x) \
{ \
e += K; \
e += x; \
e += f (b, c, d); \
e += rotl32 (a, 5u); \
b = rotl32 (b, 30u); \
}
void sha1_64 (uint block[16], uint digest[5])
{
u32 A = digest[0];
@ -28,19 +41,6 @@ void sha1_64 (uint block[16], uint digest[5])
u32 we_t = block[14];
u32 wf_t = block[15];
#define SHA1_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA1_F1(x,y,z) ((x) ^ (y) ^ (z))
#define SHA1_F2(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA1_STEP(f,a,b,c,d,e,x) \
{ \
e += K; \
e += x; \
e += f (b, c, d); \
e += rotl32 (a, 5u); \
b = rotl32 (b, 30u); \
}
#undef K
#define K SHA1C00

View File

@ -3,34 +3,34 @@
* License.....: MIT
*/
#define SHIFT_RIGHT_32(x,n) ((x) >> (n))
#define SHA256_S0(x) (rotl32 ((x), 25u) ^ rotl32 ((x), 14u) ^ SHIFT_RIGHT_32 ((x), 3u))
#define SHA256_S1(x) (rotl32 ((x), 15u) ^ rotl32 ((x), 13u) ^ SHIFT_RIGHT_32 ((x), 10u))
#define SHA256_S2(x) (rotl32 ((x), 30u) ^ rotl32 ((x), 19u) ^ rotl32 ((x), 10u))
#define SHA256_S3(x) (rotl32 ((x), 26u) ^ rotl32 ((x), 21u) ^ rotl32 ((x), 7u))
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA256_F0o(x,y,z) (SHA256_F0 ((x), (y), (z)))
#define SHA256_F1o(x,y,z) (SHA256_F1 ((x), (y), (z)))
#define SHA256_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
h += K; \
h += x; \
h += SHA256_S3 (e); \
h += F1 (e,f,g); \
d += h; \
h += SHA256_S2 (a); \
h += F0 (a,b,c); \
}
#define SHA256_EXPAND(x,y,z,w) (SHA256_S1 (x) + y + SHA256_S0 (z) + w)
void sha256_64 (uint block[16], uint digest[8])
{
#define SHIFT_RIGHT_32(x,n) ((x) >> (n))
#define SHA256_S0(x) (rotl32 ((x), 25u) ^ rotl32 ((x), 14u) ^ SHIFT_RIGHT_32 ((x), 3u))
#define SHA256_S1(x) (rotl32 ((x), 15u) ^ rotl32 ((x), 13u) ^ SHIFT_RIGHT_32 ((x), 10u))
#define SHA256_S2(x) (rotl32 ((x), 30u) ^ rotl32 ((x), 19u) ^ rotl32 ((x), 10u))
#define SHA256_S3(x) (rotl32 ((x), 26u) ^ rotl32 ((x), 21u) ^ rotl32 ((x), 7u))
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA256_F0o(x,y,z) (SHA256_F0 ((x), (y), (z)))
#define SHA256_F1o(x,y,z) (SHA256_F1 ((x), (y), (z)))
#define SHA256_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
h += K; \
h += x; \
h += SHA256_S3 (e); \
h += F1 (e,f,g); \
d += h; \
h += SHA256_S2 (a); \
h += F0 (a,b,c); \
}
#define SHA256_EXPAND(x,y,z,w) (SHA256_S1 (x) + y + SHA256_S0 (z) + w)
uint w0_t = block[ 0];
uint w1_t = block[ 1];
uint w2_t = block[ 2];