2015-12-04 14:47:52 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2015-12-04 14:47:52 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-01-23 14:32:31 +00:00
|
|
|
#define MD4_F_S(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
|
|
|
#define MD4_G_S(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
|
|
|
#define MD4_H_S(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2015-12-04 14:47:52 +00:00
|
|
|
#define MD4_F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
|
|
|
#define MD4_G(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
|
|
|
#define MD4_H(x,y,z) ((x) ^ (y) ^ (z))
|
2016-11-27 12:47:52 +00:00
|
|
|
#define MD4_Fo(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define MD4_Go(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
2015-12-16 10:11:31 +00:00
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#ifdef IS_AMD
|
2015-12-16 10:11:31 +00:00
|
|
|
#define MD4_F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
|
|
|
#define MD4_G(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
|
|
|
#define MD4_H(x,y,z) ((x) ^ (y) ^ (z))
|
2015-12-04 14:47:52 +00:00
|
|
|
#define MD4_Fo(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define MD4_Go(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#define MD4_F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
|
|
|
#define MD4_G(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
|
|
|
#define MD4_H(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define MD4_Fo(x,y,z) (MD4_F((x), (y), (z)))
|
|
|
|
#define MD4_Go(x,y,z) (MD4_G((x), (y), (z)))
|
|
|
|
#endif
|
|
|
|
|
2016-05-14 23:13:09 +00:00
|
|
|
#define MD4_STEP_S(f,a,b,c,d,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32_S (a, s); \
|
|
|
|
}
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define MD4_STEP(f,a,b,c,d,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32 (a, s); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MD4_STEP0(f,a,b,c,d,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32 (a, s); \
|
|
|
|
}
|
|
|
|
|
2016-01-23 14:32:31 +00:00
|
|
|
#define MD5_F_S(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
|
|
#define MD5_G_S(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
|
|
|
|
#define MD5_H_S(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define MD5_I_S(x,y,z) ((y) ^ ((x) | ~(z)))
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2015-12-04 14:47:52 +00:00
|
|
|
#define MD5_F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
|
|
#define MD5_G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
|
|
|
|
#define MD5_H(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z)))
|
2015-12-16 10:11:31 +00:00
|
|
|
#define MD5_Fo(x,y,z) (MD5_F((x), (y), (z)))
|
|
|
|
#define MD5_Go(x,y,z) (MD5_G((x), (y), (z)))
|
2015-12-04 14:47:52 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IS_AMD
|
2015-12-16 10:11:31 +00:00
|
|
|
#define MD5_F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
|
|
#define MD5_G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
|
|
|
|
#define MD5_H(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define MD5_I(x,y,z) (bitselect (0xffffffffU, (x), (z)) ^ (y))
|
2015-12-04 14:47:52 +00:00
|
|
|
#define MD5_Fo(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define MD5_Go(x,y,z) (bitselect ((y), (x), (z)))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#define MD5_F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
|
|
#define MD5_G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
|
|
|
|
#define MD5_H(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z)))
|
|
|
|
#define MD5_Fo(x,y,z) (MD5_F((x), (y), (z)))
|
|
|
|
#define MD5_Go(x,y,z) (MD5_G((x), (y), (z)))
|
|
|
|
#endif
|
|
|
|
|
2016-05-01 16:34:59 +00:00
|
|
|
#define MD5_STEP_S(f,a,b,c,d,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32_S (a, s); \
|
|
|
|
a += b; \
|
|
|
|
}
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define MD5_STEP(f,a,b,c,d,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32 (a, s); \
|
|
|
|
a += b; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MD5_STEP0(f,a,b,c,d,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32 (a, s); \
|
|
|
|
a += b; \
|
|
|
|
}
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2015-12-04 14:47:52 +00:00
|
|
|
#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))))
|
2016-11-27 12:47:52 +00:00
|
|
|
#define SHA1_F0o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define SHA1_F2o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
2015-12-16 10:11:31 +00:00
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#ifdef IS_AMD
|
2015-12-16 10:11:31 +00:00
|
|
|
#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))))
|
2015-12-04 14:47:52 +00:00
|
|
|
#define SHA1_F0o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define SHA1_F2o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#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))))
|
2016-01-07 19:14:34 +00:00
|
|
|
#define SHA1_F0o(x,y,z) (SHA1_F0 ((x), (y), (z)))
|
|
|
|
#define SHA1_F2o(x,y,z) (SHA1_F2 ((x), (y), (z)))
|
2016-01-04 12:17:20 +00:00
|
|
|
#endif
|
|
|
|
|
2016-05-14 17:45:51 +00:00
|
|
|
#define SHA1_STEP_S(f,a,b,c,d,e,x) \
|
|
|
|
{ \
|
|
|
|
e += K; \
|
|
|
|
e += x; \
|
|
|
|
e += f (b, c, d); \
|
|
|
|
e += rotl32_S (a, 5u); \
|
|
|
|
b = rotl32_S (b, 30u); \
|
|
|
|
}
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#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); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA1_STEP0(f,a,b,c,d,e,x) \
|
|
|
|
{ \
|
|
|
|
e += K; \
|
|
|
|
e += f (b, c, d); \
|
|
|
|
e += rotl32 (a, 5u); \
|
|
|
|
b = rotl32 (b, 30u); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA1_STEPX(f,a,b,c,d,e,x) \
|
|
|
|
{ \
|
|
|
|
e += x; \
|
|
|
|
e += f (b, c, d); \
|
|
|
|
e += rotl32 (a, 5u); \
|
|
|
|
b = rotl32 (b, 30u); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA1_STEP_PE(f,a,b,c,d,e,x) \
|
|
|
|
{ \
|
|
|
|
e += x; \
|
|
|
|
e += f (b, c, d); \
|
|
|
|
e += rotl32 (a, 5u); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA1_STEP_PB(f,a,b,c,d,e,x) \
|
|
|
|
{ \
|
|
|
|
e += K; \
|
|
|
|
b = rotl32 (b, 30u); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHIFT_RIGHT_32(x,n) ((x) >> (n))
|
|
|
|
|
2016-05-15 17:54:56 +00:00
|
|
|
#define SHA256_S0_S(x) (rotl32_S ((x), 25u) ^ rotl32_S ((x), 14u) ^ SHIFT_RIGHT_32 ((x), 3u))
|
|
|
|
#define SHA256_S1_S(x) (rotl32_S ((x), 15u) ^ rotl32_S ((x), 13u) ^ SHIFT_RIGHT_32 ((x), 10u))
|
|
|
|
#define SHA256_S2_S(x) (rotl32_S ((x), 30u) ^ rotl32_S ((x), 19u) ^ rotl32_S ((x), 10u))
|
|
|
|
#define SHA256_S3_S(x) (rotl32_S ((x), 26u) ^ rotl32_S ((x), 21u) ^ rotl32_S ((x), 7u))
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#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))
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2015-12-04 14:47:52 +00:00
|
|
|
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
|
|
|
|
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
2016-11-27 12:47:52 +00:00
|
|
|
#define SHA256_F0o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
|
|
|
#define SHA256_F1o(x,y,z) (bitselect ((z), (y), (x)))
|
2015-12-16 10:11:31 +00:00
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#ifdef IS_AMD
|
2015-12-16 10:11:31 +00:00
|
|
|
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
|
|
|
|
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
2015-12-04 14:47:52 +00:00
|
|
|
#define SHA256_F0o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
|
|
|
#define SHA256_F1o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#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)))
|
|
|
|
#endif
|
|
|
|
|
2016-05-15 17:54:56 +00:00
|
|
|
#define SHA256_STEP_S(F0,F1,a,b,c,d,e,f,g,h,x,K) \
|
|
|
|
{ \
|
|
|
|
h += K; \
|
|
|
|
h += x; \
|
|
|
|
h += SHA256_S3_S (e); \
|
|
|
|
h += F1 (e,f,g); \
|
|
|
|
d += h; \
|
|
|
|
h += SHA256_S2_S (a); \
|
|
|
|
h += F0 (a,b,c); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA256_EXPAND_S(x,y,z,w) (SHA256_S1_S (x) + y + SHA256_S0_S (z) + w)
|
|
|
|
|
|
|
|
#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); \
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA256_EXPAND(x,y,z,w) (SHA256_S1 (x) + y + SHA256_S0 (z) + w)
|
|
|
|
|
|
|
|
#define SHIFT_RIGHT_64(x,n) ((x) >> (n))
|
|
|
|
|
|
|
|
#define SHA384_S0(x) (rotr64 ((x), 28) ^ rotr64 ((x), 34) ^ rotr64 ((x), 39))
|
|
|
|
#define SHA384_S1(x) (rotr64 ((x), 14) ^ rotr64 ((x), 18) ^ rotr64 ((x), 41))
|
|
|
|
#define SHA384_S2(x) (rotr64 ((x), 1) ^ rotr64 ((x), 8) ^ SHIFT_RIGHT_64 ((x), 7))
|
|
|
|
#define SHA384_S3(x) (rotr64 ((x), 19) ^ rotr64 ((x), 61) ^ SHIFT_RIGHT_64 ((x), 6))
|
|
|
|
|
|
|
|
#define SHA384_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
|
|
#define SHA384_F1(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2016-11-27 12:47:52 +00:00
|
|
|
#define SHA384_F0o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define SHA384_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
2015-12-16 10:11:31 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#ifdef IS_AMD
|
|
|
|
#define SHA384_F0o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define SHA384_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#define SHA384_F0o(x,y,z) (SHA384_F0 ((x), (y), (z)))
|
|
|
|
#define SHA384_F1o(x,y,z) (SHA384_F1 ((x), (y), (z)))
|
|
|
|
#endif
|
|
|
|
|
2017-07-07 10:48:35 +00:00
|
|
|
#define SHA384_STEP_S(F0,F1,a,b,c,d,e,f,g,h,x,K) \
|
|
|
|
{ \
|
|
|
|
h += K; \
|
|
|
|
h += x; \
|
|
|
|
h += SHA384_S1_S (e); \
|
|
|
|
h += F0 (e, f, g); \
|
|
|
|
d += h; \
|
|
|
|
h += SHA384_S0_S (a); \
|
|
|
|
h += F1 (a, b, c); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA384_EXPAND_S(x,y,z,w) (SHA384_S3_S (x) + y + SHA384_S2_S (z) + w)
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define SHA384_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
|
|
|
|
{ \
|
2016-01-31 16:24:12 +00:00
|
|
|
h += K; \
|
|
|
|
h += x; \
|
|
|
|
h += SHA384_S1 (e); \
|
|
|
|
h += F0 (e, f, g); \
|
|
|
|
d += h; \
|
|
|
|
h += SHA384_S0 (a); \
|
|
|
|
h += F1 (a, b, c); \
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA384_EXPAND(x,y,z,w) (SHA384_S3 (x) + y + SHA384_S2 (z) + w)
|
|
|
|
|
|
|
|
#define SHIFT_RIGHT_64(x,n) ((x) >> (n))
|
|
|
|
|
2016-05-15 17:54:56 +00:00
|
|
|
#define SHA512_S0_S(x) (rotr64_S ((x), 28) ^ rotr64_S ((x), 34) ^ rotr64_S ((x), 39))
|
|
|
|
#define SHA512_S1_S(x) (rotr64_S ((x), 14) ^ rotr64_S ((x), 18) ^ rotr64_S ((x), 41))
|
|
|
|
#define SHA512_S2_S(x) (rotr64_S ((x), 1) ^ rotr64_S ((x), 8) ^ SHIFT_RIGHT_64 ((x), 7))
|
|
|
|
#define SHA512_S3_S(x) (rotr64_S ((x), 19) ^ rotr64_S ((x), 61) ^ SHIFT_RIGHT_64 ((x), 6))
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define SHA512_S0(x) (rotr64 ((x), 28) ^ rotr64 ((x), 34) ^ rotr64 ((x), 39))
|
|
|
|
#define SHA512_S1(x) (rotr64 ((x), 14) ^ rotr64 ((x), 18) ^ rotr64 ((x), 41))
|
|
|
|
#define SHA512_S2(x) (rotr64 ((x), 1) ^ rotr64 ((x), 8) ^ SHIFT_RIGHT_64 ((x), 7))
|
|
|
|
#define SHA512_S3(x) (rotr64 ((x), 19) ^ rotr64 ((x), 61) ^ SHIFT_RIGHT_64 ((x), 6))
|
|
|
|
|
|
|
|
#define SHA512_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
|
|
#define SHA512_F1(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2016-11-27 12:47:52 +00:00
|
|
|
#define SHA512_F0o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define SHA512_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
2015-12-16 10:11:31 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#ifdef IS_AMD
|
|
|
|
#define SHA512_F0o(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define SHA512_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z))))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#define SHA512_F0o(x,y,z) (SHA512_F0 ((x), (y), (z)))
|
|
|
|
#define SHA512_F1o(x,y,z) (SHA512_F1 ((x), (y), (z)))
|
|
|
|
#endif
|
|
|
|
|
2016-05-15 17:54:56 +00:00
|
|
|
#define SHA512_STEP_S(F0,F1,a,b,c,d,e,f,g,h,x,K) \
|
|
|
|
{ \
|
|
|
|
h += K; \
|
|
|
|
h += x; \
|
|
|
|
h += SHA512_S1_S (e); \
|
|
|
|
h += F0 (e, f, g); \
|
|
|
|
d += h; \
|
|
|
|
h += SHA512_S0_S (a); \
|
|
|
|
h += F1 (a, b, c); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA512_EXPAND_S(x,y,z,w) (SHA512_S3_S (x) + y + SHA512_S2_S (z) + w)
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define SHA512_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
|
|
|
|
{ \
|
2016-01-31 16:24:12 +00:00
|
|
|
h += K; \
|
|
|
|
h += x; \
|
|
|
|
h += SHA512_S1 (e); \
|
|
|
|
h += F0 (e, f, g); \
|
|
|
|
d += h; \
|
|
|
|
h += SHA512_S0 (a); \
|
|
|
|
h += F1 (a, b, c); \
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SHA512_EXPAND(x,y,z,w) (SHA512_S3 (x) + y + SHA512_S2 (z) + w)
|
|
|
|
|
2015-12-16 10:11:31 +00:00
|
|
|
#ifdef IS_NV
|
2015-12-04 14:47:52 +00:00
|
|
|
#define RIPEMD160_F(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define RIPEMD160_G(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) /* x ? y : z */
|
|
|
|
#define RIPEMD160_H(x,y,z) (((x) | ~(y)) ^ (z))
|
|
|
|
#define RIPEMD160_I(x,y,z) ((y) ^ ((z) & ((x) ^ (y)))) /* z ? x : y */
|
|
|
|
#define RIPEMD160_J(x,y,z) ((x) ^ ((y) | ~(z)))
|
2016-11-27 12:47:52 +00:00
|
|
|
#define RIPEMD160_Go(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define RIPEMD160_Io(x,y,z) (bitselect ((y), (x), (z)))
|
2015-12-16 10:11:31 +00:00
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#ifdef IS_AMD
|
2015-12-16 10:11:31 +00:00
|
|
|
#define RIPEMD160_F(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define RIPEMD160_G(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) /* x ? y : z */
|
|
|
|
#define RIPEMD160_H(x,y,z) (((x) | ~(y)) ^ (z))
|
|
|
|
#define RIPEMD160_I(x,y,z) ((y) ^ ((z) & ((x) ^ (y)))) /* z ? x : y */
|
|
|
|
#define RIPEMD160_J(x,y,z) ((x) ^ ((y) | ~(z)))
|
2015-12-04 14:47:52 +00:00
|
|
|
#define RIPEMD160_Go(x,y,z) (bitselect ((z), (y), (x)))
|
|
|
|
#define RIPEMD160_Io(x,y,z) (bitselect ((y), (x), (z)))
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 19:14:34 +00:00
|
|
|
#ifdef IS_GENERIC
|
2016-01-04 12:17:20 +00:00
|
|
|
#define RIPEMD160_F(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define RIPEMD160_G(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) /* x ? y : z */
|
|
|
|
#define RIPEMD160_H(x,y,z) (((x) | ~(y)) ^ (z))
|
|
|
|
#define RIPEMD160_I(x,y,z) ((y) ^ ((z) & ((x) ^ (y)))) /* z ? x : y */
|
|
|
|
#define RIPEMD160_J(x,y,z) ((x) ^ ((y) | ~(z)))
|
|
|
|
#define RIPEMD160_Go(x,y,z) (RIPEMD160_G ((x), (y), (z)))
|
|
|
|
#define RIPEMD160_Io(x,y,z) (RIPEMD160_I ((x), (y), (z)))
|
|
|
|
#endif
|
|
|
|
|
2017-01-21 14:37:44 +00:00
|
|
|
#define RIPEMD160_STEP_S(f,a,b,c,d,e,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32_S (a, s); \
|
|
|
|
a += e; \
|
|
|
|
c = rotl32_S (c, 10u); \
|
|
|
|
}
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define RIPEMD160_STEP(f,a,b,c,d,e,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = rotl32 (a, s); \
|
|
|
|
a += e; \
|
|
|
|
c = rotl32 (c, 10u); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ROTATE_LEFT_WORKAROUND_BUG(a,n) ((a << n) | (a >> (32 - n)))
|
|
|
|
|
2017-01-21 14:37:44 +00:00
|
|
|
#define RIPEMD160_STEP_S_WORKAROUND_BUG(f,a,b,c,d,e,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = ROTATE_LEFT_WORKAROUND_BUG (a, s); \
|
|
|
|
a += e; \
|
|
|
|
c = rotl32_S (c, 10u); \
|
|
|
|
}
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#define RIPEMD160_STEP_WORKAROUND_BUG(f,a,b,c,d,e,x,K,s) \
|
|
|
|
{ \
|
|
|
|
a += K; \
|
|
|
|
a += x; \
|
|
|
|
a += f (b, c, d); \
|
|
|
|
a = ROTATE_LEFT_WORKAROUND_BUG (a, s); \
|
|
|
|
a += e; \
|
|
|
|
c = rotl32 (c, 10u); \
|
|
|
|
}
|