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

Prepare fix for datatypes, not final

This commit is contained in:
Jens Steube 2016-01-15 17:16:43 +01:00
parent 2e61685f48
commit 63e06f582b
15 changed files with 2367 additions and 2372 deletions

View File

@ -76,6 +76,13 @@ typedef HINSTANCE HM_LIB;
#endif #endif
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
#define SPEED_CACHE 128 #define SPEED_CACHE 128
#define SPEED_MAXAGE 4096 #define SPEED_MAXAGE 4096
@ -94,7 +101,7 @@ void log_out (FILE *fp, const char *fmt, ...);
void log_info (const char *fmt, ...); void log_info (const char *fmt, ...);
void log_error (const char *fmt, ...); void log_error (const char *fmt, ...);
typedef uint32_t uint; // we should rename to u32, sooner or later, for consistency #define MIN(a,b) (((a) < (b)) ? (a) : (b))
typedef uint64_t u64; #define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif #endif

View File

@ -3,7 +3,7 @@
* License.....: MIT * License.....: MIT
*/ */
static const uint te0[256] = static const u32 te0[256] =
{ {
0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d,
0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
@ -71,7 +71,7 @@ static const uint te0[256] =
0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a,
}; };
static const uint te1[256] = static const u32 te1[256] =
{ {
0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b,
0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5,
@ -139,7 +139,7 @@ static const uint te1[256] =
0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616,
}; };
static const uint te2[256] = static const u32 te2[256] =
{ {
0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b,
0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5,
@ -207,7 +207,7 @@ static const uint te2[256] =
0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16,
}; };
static const uint te3[256] = static const u32 te3[256] =
{ {
0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6,
0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491,
@ -275,7 +275,7 @@ static const uint te3[256] =
0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c,
}; };
static const uint te4[256] = static const u32 te4[256] =
{ {
0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b, 0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b,
0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5, 0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5,
@ -343,7 +343,7 @@ static const uint te4[256] =
0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616, 0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616,
}; };
static const uint td0[256] = static const u32 td0[256] =
{ {
0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96,
0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
@ -411,7 +411,7 @@ static const uint td0[256] =
0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742,
}; };
static const uint td1[256] = static const u32 td1[256] =
{ {
0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e,
0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303,
@ -479,7 +479,7 @@ static const uint td1[256] =
0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857,
}; };
static const uint td2[256] = static const u32 td2[256] =
{ {
0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27,
0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3,
@ -547,7 +547,7 @@ static const uint td2[256] =
0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8,
}; };
static const uint td3[256] = static const u32 td3[256] =
{ {
0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a,
0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b,
@ -615,7 +615,7 @@ static const uint td3[256] =
0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0,
}; };
static const uint td4[256] = static const u32 td4[256] =
{ {
0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5, 0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5,
0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838, 0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838,
@ -683,7 +683,7 @@ static const uint td4[256] =
0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d, 0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d,
}; };
static const uint rcon[] = static const u32 rcon[] =
{ {
0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000,
@ -692,9 +692,9 @@ static const uint rcon[] =
// 128 bit // 128 bit
static void AES128_ExpandKey (const uint *userkey, uint *rek) static void AES128_ExpandKey (const u32 *userkey, u32 *rek)
{ {
uint userkey_s[4]; u32 userkey_s[4];
userkey_s[0] = byte_swap_32 (userkey[0]); userkey_s[0] = byte_swap_32 (userkey[0]);
userkey_s[1] = byte_swap_32 (userkey[1]); userkey_s[1] = byte_swap_32 (userkey[1]);
@ -711,7 +711,7 @@ static void AES128_ExpandKey (const uint *userkey, uint *rek)
for (i = 0, j = 0; i < 10; i += 1, j += 4) for (i = 0, j = 0; i < 10; i += 1, j += 4)
{ {
uint temp = rek[j + 3]; u32 temp = rek[j + 3];
temp = (te2[(temp >> 16) & 0xff] & 0xff000000) temp = (te2[(temp >> 16) & 0xff] & 0xff000000)
^ (te3[(temp >> 8) & 0xff] & 0x00ff0000) ^ (te3[(temp >> 8) & 0xff] & 0x00ff0000)
@ -728,14 +728,14 @@ static void AES128_ExpandKey (const uint *userkey, uint *rek)
} }
} }
static void AES128_InvertKey (uint *rdk) static void AES128_InvertKey (u32 *rdk)
{ {
int i; int i;
int j; int j;
for (i = 0, j = 40; i < j; i += 4, j -= 4) for (i = 0, j = 40; i < j; i += 4, j -= 4)
{ {
uint temp; u32 temp;
temp = rdk[i + 0]; rdk[i + 0] = rdk[j + 0]; rdk[j + 0] = temp; temp = rdk[i + 0]; rdk[i + 0] = rdk[j + 0]; rdk[j + 0] = temp;
temp = rdk[i + 1]; rdk[i + 1] = rdk[j + 1]; rdk[j + 1] = temp; temp = rdk[i + 1]; rdk[i + 1] = rdk[j + 1]; rdk[j + 1] = temp;
@ -771,24 +771,24 @@ static void AES128_InvertKey (uint *rdk)
} }
} }
static void AES128_encrypt (const uint *in, uint *out, const uint *rek) static void AES128_encrypt (const u32 *in, u32 *out, const u32 *rek)
{ {
uint in_s[4]; u32 in_s[4];
in_s[0] = byte_swap_32 (in[0]); in_s[0] = byte_swap_32 (in[0]);
in_s[1] = byte_swap_32 (in[1]); in_s[1] = byte_swap_32 (in[1]);
in_s[2] = byte_swap_32 (in[2]); in_s[2] = byte_swap_32 (in[2]);
in_s[3] = byte_swap_32 (in[3]); in_s[3] = byte_swap_32 (in[3]);
uint s0 = in_s[0] ^ rek[0]; u32 s0 = in_s[0] ^ rek[0];
uint s1 = in_s[1] ^ rek[1]; u32 s1 = in_s[1] ^ rek[1];
uint s2 = in_s[2] ^ rek[2]; u32 s2 = in_s[2] ^ rek[2];
uint s3 = in_s[3] ^ rek[3]; u32 s3 = in_s[3] ^ rek[3];
uint t0; u32 t0;
uint t1; u32 t1;
uint t2; u32 t2;
uint t3; u32 t3;
t0 = te0[s0 >> 24] ^ te1[(s1 >> 16) & 0xff] ^ te2[(s2 >> 8) & 0xff] ^ te3[s3 & 0xff] ^ rek[ 4]; t0 = te0[s0 >> 24] ^ te1[(s1 >> 16) & 0xff] ^ te2[(s2 >> 8) & 0xff] ^ te3[s3 & 0xff] ^ rek[ 4];
t1 = te0[s1 >> 24] ^ te1[(s2 >> 16) & 0xff] ^ te2[(s3 >> 8) & 0xff] ^ te3[s0 & 0xff] ^ rek[ 5]; t1 = te0[s1 >> 24] ^ te1[(s2 >> 16) & 0xff] ^ te2[(s3 >> 8) & 0xff] ^ te3[s0 & 0xff] ^ rek[ 5];
@ -857,24 +857,24 @@ static void AES128_encrypt (const uint *in, uint *out, const uint *rek)
out[3] = byte_swap_32 (out[3]); out[3] = byte_swap_32 (out[3]);
} }
static void AES128_decrypt (const uint *in, uint *out, const uint *rdk) static void AES128_decrypt (const u32 *in, u32 *out, const u32 *rdk)
{ {
uint in_s[4]; u32 in_s[4];
in_s[0] = byte_swap_32 (in[0]); in_s[0] = byte_swap_32 (in[0]);
in_s[1] = byte_swap_32 (in[1]); in_s[1] = byte_swap_32 (in[1]);
in_s[2] = byte_swap_32 (in[2]); in_s[2] = byte_swap_32 (in[2]);
in_s[3] = byte_swap_32 (in[3]); in_s[3] = byte_swap_32 (in[3]);
uint s0 = in_s[0] ^ rdk[0]; u32 s0 = in_s[0] ^ rdk[0];
uint s1 = in_s[1] ^ rdk[1]; u32 s1 = in_s[1] ^ rdk[1];
uint s2 = in_s[2] ^ rdk[2]; u32 s2 = in_s[2] ^ rdk[2];
uint s3 = in_s[3] ^ rdk[3]; u32 s3 = in_s[3] ^ rdk[3];
uint t0; u32 t0;
uint t1; u32 t1;
uint t2; u32 t2;
uint t3; u32 t3;
t0 = td0[s0 >> 24] ^ td1[(s3 >> 16) & 0xff] ^ td2[(s2 >> 8) & 0xff] ^ td3[s1 & 0xff] ^ rdk[ 4]; t0 = td0[s0 >> 24] ^ td1[(s3 >> 16) & 0xff] ^ td2[(s2 >> 8) & 0xff] ^ td3[s1 & 0xff] ^ rdk[ 4];
t1 = td0[s1 >> 24] ^ td1[(s0 >> 16) & 0xff] ^ td2[(s3 >> 8) & 0xff] ^ td3[s2 & 0xff] ^ rdk[ 5]; t1 = td0[s1 >> 24] ^ td1[(s0 >> 16) & 0xff] ^ td2[(s3 >> 8) & 0xff] ^ td3[s2 & 0xff] ^ rdk[ 5];
@ -945,9 +945,9 @@ static void AES128_decrypt (const uint *in, uint *out, const uint *rdk)
// 256 bit // 256 bit
static void AES256_ExpandKey (const uint *userkey, uint *rek) static void AES256_ExpandKey (const u32 *userkey, u32 *rek)
{ {
uint userkey_s[8]; u32 userkey_s[8];
userkey_s[0] = byte_swap_32 (userkey[0]); userkey_s[0] = byte_swap_32 (userkey[0]);
userkey_s[1] = byte_swap_32 (userkey[1]); userkey_s[1] = byte_swap_32 (userkey[1]);
@ -975,7 +975,7 @@ static void AES256_ExpandKey (const uint *userkey, uint *rek)
while (1) while (1)
{ {
uint temp = rek[j + 7]; u32 temp = rek[j + 7];
rek[j + 8] = rek[j + 0] rek[j + 8] = rek[j + 0]
^ (te2[(temp >> 16) & 0xff] & 0xff000000) ^ (te2[(temp >> 16) & 0xff] & 0xff000000)
@ -1006,11 +1006,11 @@ static void AES256_ExpandKey (const uint *userkey, uint *rek)
} }
} }
static void AES256_InvertKey (uint *rdk) static void AES256_InvertKey (u32 *rdk)
{ {
for (uint i = 0, j = 56; i < j; i += 4, j -= 4) for (u32 i = 0, j = 56; i < j; i += 4, j -= 4)
{ {
uint temp; u32 temp;
temp = rdk[i + 0]; rdk[i + 0] = rdk[j + 0]; rdk[j + 0] = temp; temp = rdk[i + 0]; rdk[i + 0] = rdk[j + 0]; rdk[j + 0] = temp;
temp = rdk[i + 1]; rdk[i + 1] = rdk[j + 1]; rdk[j + 1] = temp; temp = rdk[i + 1]; rdk[i + 1] = rdk[j + 1]; rdk[j + 1] = temp;
@ -1018,7 +1018,7 @@ static void AES256_InvertKey (uint *rdk)
temp = rdk[i + 3]; rdk[i + 3] = rdk[j + 3]; rdk[j + 3] = temp; temp = rdk[i + 3]; rdk[i + 3] = rdk[j + 3]; rdk[j + 3] = temp;
} }
for (uint i = 1, j = 4; i < 14; i += 1, j += 4) for (u32 i = 1, j = 4; i < 14; i += 1, j += 4)
{ {
rdk[j + 0] = rdk[j + 0] =
td0[te1[(rdk[j + 0] >> 24) & 0xff] & 0xff] ^ td0[te1[(rdk[j + 0] >> 24) & 0xff] & 0xff] ^
@ -1046,24 +1046,24 @@ static void AES256_InvertKey (uint *rdk)
} }
} }
static void AES256_encrypt (const uint *in, uint *out, const uint *rek) static void AES256_encrypt (const u32 *in, u32 *out, const u32 *rek)
{ {
uint in_s[4]; u32 in_s[4];
in_s[0] = byte_swap_32 (in[0]); in_s[0] = byte_swap_32 (in[0]);
in_s[1] = byte_swap_32 (in[1]); in_s[1] = byte_swap_32 (in[1]);
in_s[2] = byte_swap_32 (in[2]); in_s[2] = byte_swap_32 (in[2]);
in_s[3] = byte_swap_32 (in[3]); in_s[3] = byte_swap_32 (in[3]);
uint s0 = in_s[0] ^ rek[0]; u32 s0 = in_s[0] ^ rek[0];
uint s1 = in_s[1] ^ rek[1]; u32 s1 = in_s[1] ^ rek[1];
uint s2 = in_s[2] ^ rek[2]; u32 s2 = in_s[2] ^ rek[2];
uint s3 = in_s[3] ^ rek[3]; u32 s3 = in_s[3] ^ rek[3];
uint t0; u32 t0;
uint t1; u32 t1;
uint t2; u32 t2;
uint t3; u32 t3;
t0 = te0[s0 >> 24] ^ te1[(s1 >> 16) & 0xff] ^ te2[(s2 >> 8) & 0xff] ^ te3[s3 & 0xff] ^ rek[ 4]; t0 = te0[s0 >> 24] ^ te1[(s1 >> 16) & 0xff] ^ te2[(s2 >> 8) & 0xff] ^ te3[s3 & 0xff] ^ rek[ 4];
t1 = te0[s1 >> 24] ^ te1[(s2 >> 16) & 0xff] ^ te2[(s3 >> 8) & 0xff] ^ te3[s0 & 0xff] ^ rek[ 5]; t1 = te0[s1 >> 24] ^ te1[(s2 >> 16) & 0xff] ^ te2[(s3 >> 8) & 0xff] ^ te3[s0 & 0xff] ^ rek[ 5];
@ -1148,24 +1148,24 @@ static void AES256_encrypt (const uint *in, uint *out, const uint *rek)
out[3] = byte_swap_32 (out[3]); out[3] = byte_swap_32 (out[3]);
} }
static void AES256_decrypt (const uint *in, uint *out, const uint *rdk) static void AES256_decrypt (const u32 *in, u32 *out, const u32 *rdk)
{ {
uint in_s[4]; u32 in_s[4];
in_s[0] = byte_swap_32 (in[0]); in_s[0] = byte_swap_32 (in[0]);
in_s[1] = byte_swap_32 (in[1]); in_s[1] = byte_swap_32 (in[1]);
in_s[2] = byte_swap_32 (in[2]); in_s[2] = byte_swap_32 (in[2]);
in_s[3] = byte_swap_32 (in[3]); in_s[3] = byte_swap_32 (in[3]);
uint s0 = in_s[0] ^ rdk[0]; u32 s0 = in_s[0] ^ rdk[0];
uint s1 = in_s[1] ^ rdk[1]; u32 s1 = in_s[1] ^ rdk[1];
uint s2 = in_s[2] ^ rdk[2]; u32 s2 = in_s[2] ^ rdk[2];
uint s3 = in_s[3] ^ rdk[3]; u32 s3 = in_s[3] ^ rdk[3];
uint t0; u32 t0;
uint t1; u32 t1;
uint t2; u32 t2;
uint t3; u32 t3;
t0 = td0[s0 >> 24] ^ td1[(s3 >> 16) & 0xff] ^ td2[(s2 >> 8) & 0xff] ^ td3[s1 & 0xff] ^ rdk[ 4]; t0 = td0[s0 >> 24] ^ td1[(s3 >> 16) & 0xff] ^ td2[(s2 >> 8) & 0xff] ^ td3[s1 & 0xff] ^ rdk[ 4];
t1 = td0[s1 >> 24] ^ td1[(s0 >> 16) & 0xff] ^ td2[(s3 >> 8) & 0xff] ^ td3[s2 & 0xff] ^ rdk[ 5]; t1 = td0[s1 >> 24] ^ td1[(s0 >> 16) & 0xff] ^ td2[(s3 >> 8) & 0xff] ^ td3[s2 & 0xff] ^ rdk[ 5];
@ -1252,58 +1252,58 @@ static void AES256_decrypt (const uint *in, uint *out, const uint *rdk)
// wrappers // wrappers
void AES_set_encrypt_key (unsigned char *key, int keysize, AES_KEY *aes_key) void AES_set_encrypt_key (const u8 *key, int keysize, AES_KEY *aes_key)
{ {
aes_key->bits = keysize; aes_key->bits = keysize;
if (aes_key->bits == 128) if (aes_key->bits == 128)
{ {
AES128_ExpandKey ((const uint *) key, aes_key->rek); AES128_ExpandKey ((const u32 *) key, aes_key->rek);
} }
else if (aes_key->bits == 256) else if (aes_key->bits == 256)
{ {
AES256_ExpandKey ((const uint *) key, aes_key->rek); AES256_ExpandKey ((const u32 *) key, aes_key->rek);
} }
} }
void AES_set_decrypt_key (unsigned char *key, int keysize, AES_KEY *aes_key) void AES_set_decrypt_key (const u8 *key, int keysize, AES_KEY *aes_key)
{ {
aes_key->bits = keysize; aes_key->bits = keysize;
if (aes_key->bits == 128) if (aes_key->bits == 128)
{ {
AES128_ExpandKey ((const uint *) key, aes_key->rdk); AES128_ExpandKey ((const u32 *) key, aes_key->rdk);
AES128_InvertKey (aes_key->rdk); AES128_InvertKey (aes_key->rdk);
} }
else if (aes_key->bits == 256) else if (aes_key->bits == 256)
{ {
AES256_ExpandKey ((const uint *) key, aes_key->rdk); AES256_ExpandKey ((const u32 *) key, aes_key->rdk);
AES256_InvertKey (aes_key->rdk); AES256_InvertKey (aes_key->rdk);
} }
} }
void AES_encrypt (AES_KEY *aes_key, char *input, char *output) void AES_encrypt (AES_KEY *aes_key, const u8 *input, u8 *output)
{ {
if (aes_key->bits == 128) if (aes_key->bits == 128)
{ {
AES128_encrypt ((const uint *) input, (uint *) output, aes_key->rek); AES128_encrypt ((const u32 *) input, (u32 *) output, aes_key->rek);
} }
else if (aes_key->bits == 256) else if (aes_key->bits == 256)
{ {
AES256_encrypt ((const uint *) input, (uint *) output, aes_key->rek); AES256_encrypt ((const u32 *) input, (u32 *) output, aes_key->rek);
} }
} }
void AES_decrypt (AES_KEY *aes_key, char *input, char *output) void AES_decrypt (AES_KEY *aes_key, const u8 *input, u8 *output)
{ {
if (aes_key->bits == 128) if (aes_key->bits == 128)
{ {
AES128_decrypt ((const uint *) input, (uint *) output, aes_key->rdk); AES128_decrypt ((const u32 *) input, (u32 *) output, aes_key->rdk);
} }
else if (aes_key->bits == 256) else if (aes_key->bits == 256)
{ {
AES256_decrypt ((const uint *) input, (uint *) output, aes_key->rdk); AES256_decrypt ((const u32 *) input, (u32 *) output, aes_key->rdk);
} }
} }

View File

@ -9,19 +9,19 @@
/* AES context. */ /* AES context. */
typedef struct aes_context typedef struct aes_context
{ {
uint bits; u32 bits;
uint rek[60]; u32 rek[60];
uint rdk[60]; u32 rdk[60];
} aes_context_t; } aes_context_t;
typedef aes_context_t aes_ctx; typedef aes_context_t aes_ctx;
#define AES_KEY aes_ctx #define AES_KEY aes_ctx
void AES_set_encrypt_key (unsigned char *key, int keysize, AES_KEY *aes_key); void AES_set_encrypt_key (const u8 *key, int keysize, AES_KEY *aes_key);
void AES_set_decrypt_key (unsigned char *key, int keysize, AES_KEY *aes_key); void AES_set_decrypt_key (const u8 *key, int keysize, AES_KEY *aes_key);
void AES_encrypt (AES_KEY *aes_key, char *input, char *output); void AES_encrypt (AES_KEY *aes_key, const u8 *input, u8 *output);
void AES_decrypt (AES_KEY *aes_key, char *input, char *output); void AES_decrypt (AES_KEY *aes_key, const u8 *input, u8 *output);
#endif #endif

View File

@ -3,7 +3,7 @@
* License.....: MIT * License.....: MIT
*/ */
static const uint c_SPtrans[8][64] = static const u32 c_SPtrans[8][64] =
{ {
{ {
/* nibble 0 */ /* nibble 0 */
@ -159,7 +159,7 @@ static const uint c_SPtrans[8][64] =
}, },
}; };
static const uint c_skb[8][64] = static const u32 c_skb[8][64] =
{ {
{ {
/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
@ -353,12 +353,12 @@ static const uint c_skb[8][64] =
PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \ PERM_OP (l, r, tt, 4, 0x0f0f0f0f); \
} }
void _des_keysetup (uint data[2], uint Kc[16], uint Kd[16], const uint s_skb[8][64]) void _des_keysetup (u32 data[2], u32 Kc[16], u32 Kd[16], const u32 s_skb[8][64])
{ {
uint c = data[0]; u32 c = data[0];
uint d = data[1]; u32 d = data[1];
uint tt; u32 tt;
PERM_OP (d, c, tt, 4, 0x0f0f0f0f); PERM_OP (d, c, tt, 4, 0x0f0f0f0f);
HPERM_OP (c, tt, 2, 0xcccc0000); HPERM_OP (c, tt, 2, 0xcccc0000);
@ -378,8 +378,8 @@ void _des_keysetup (uint data[2], uint Kc[16], uint Kd[16], const uint s_skb[8][
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
const uint shifts3s0[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; const u32 shifts3s0[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
const uint shifts3s1[16] = { 27, 27, 26, 26, 26, 26, 26, 26, 27, 26, 26, 26, 26, 26, 26, 27 }; const u32 shifts3s1[16] = { 27, 27, 26, 26, 26, 26, 26, 26, 27, 26, 26, 26, 26, 26, 26, 27 };
c = c >> shifts3s0[i] | c << shifts3s1[i]; c = c >> shifts3s0[i] | c << shifts3s1[i];
d = d >> shifts3s0[i] | d << shifts3s1[i]; d = d >> shifts3s0[i] | d << shifts3s1[i];
@ -389,7 +389,7 @@ void _des_keysetup (uint data[2], uint Kc[16], uint Kd[16], const uint s_skb[8][
#define BOX(v,i,S) (S)[(i)][(v)] #define BOX(v,i,S) (S)[(i)][(v)]
uint s = BOX ((( c >> 0) & 0x3f), 0, s_skb) u32 s = BOX ((( c >> 0) & 0x3f), 0, s_skb)
| BOX ((((c >> 6) & 0x03) | BOX ((((c >> 6) & 0x03)
| ((c >> 7) & 0x3c)), 1, s_skb) | ((c >> 7) & 0x3c)), 1, s_skb)
| BOX ((((c >> 13) & 0x0f) | BOX ((((c >> 13) & 0x0f)
@ -398,7 +398,7 @@ void _des_keysetup (uint data[2], uint Kc[16], uint Kd[16], const uint s_skb[8][
| ((c >> 21) & 0x06) | ((c >> 21) & 0x06)
| ((c >> 22) & 0x38)), 3, s_skb); | ((c >> 22) & 0x38)), 3, s_skb);
uint t = BOX ((( d >> 0) & 0x3f), 4, s_skb) u32 t = BOX ((( d >> 0) & 0x3f), 4, s_skb)
| BOX ((((d >> 7) & 0x03) | BOX ((((d >> 7) & 0x03)
| ((d >> 8) & 0x3c)), 5, s_skb) | ((d >> 8) & 0x3c)), 5, s_skb)
| BOX ((((d >> 15) & 0x3f)), 6, s_skb) | BOX ((((d >> 15) & 0x3f)), 6, s_skb)
@ -408,29 +408,29 @@ void _des_keysetup (uint data[2], uint Kc[16], uint Kd[16], const uint s_skb[8][
Kc[i] = ((t << 16) | (s & 0x0000ffff)); Kc[i] = ((t << 16) | (s & 0x0000ffff));
Kd[i] = ((s >> 16) | (t & 0xffff0000)); Kd[i] = ((s >> 16) | (t & 0xffff0000));
Kc[i] = ROTATE_LEFT (Kc[i], 2u); Kc[i] = rotl32 (Kc[i], 2u);
Kd[i] = ROTATE_LEFT (Kd[i], 2u); Kd[i] = rotl32 (Kd[i], 2u);
} }
} }
void _des_encrypt (uint data[2], uint Kc[16], uint Kd[16], const uint s_SPtrans[8][64]) void _des_encrypt (u32 data[2], u32 Kc[16], u32 Kd[16], const u32 s_SPtrans[8][64])
{ {
uint r = data[0]; u32 r = data[0];
uint l = data[1]; u32 l = data[1];
uint tt; u32 tt;
IP (r, l, tt); IP (r, l, tt);
r = ROTATE_LEFT (r, 3u); r = rotl32 (r, 3u);
l = ROTATE_LEFT (l, 3u); l = rotl32 (l, 3u);
int i; int i;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
uint u = Kc[i] ^ r; u32 u = Kc[i] ^ r;
uint t = Kd[i] ^ ROTATE_LEFT (r, 28u); u32 t = Kd[i] ^ rotl32 (r, 28u);
l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans) l ^= BOX (((u >> 2) & 0x3f), 0, s_SPtrans)
| BOX (((u >> 10) & 0x3f), 2, s_SPtrans) | BOX (((u >> 10) & 0x3f), 2, s_SPtrans)
@ -446,8 +446,8 @@ void _des_encrypt (uint data[2], uint Kc[16], uint Kd[16], const uint s_SPtrans[
r = tt; r = tt;
} }
l = ROTATE_LEFT (l, 29u); l = rotl32 (l, 29u);
r = ROTATE_LEFT (r, 29u); r = rotl32 (r, 29u);
FP (r, l, tt); FP (r, l, tt);

View File

@ -11,7 +11,7 @@
#include "common.h" #include "common.h"
#include "rp_kernel.h" #include "rp_kernel.h"
uint apply_rule (const uint name, const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len); u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len);
uint apply_rules (uint *cmds, uint32_t buf0[4], uint32_t buf1[4], const uint len); u32 apply_rules (u32 *cmds, u32 buf0[4], u32 buf1[4], const u32 len);
#endif #endif

View File

@ -137,7 +137,6 @@ extern const char *VERSION_TXT;
extern const uint VERSION_BIN; extern const uint VERSION_BIN;
extern const uint RESTORE_MIN; extern const uint RESTORE_MIN;
extern const char *EULA_TXT[];
extern const char *USAGE_MINI[]; extern const char *USAGE_MINI[];
extern const char *USAGE_BIG[]; extern const char *USAGE_BIG[];
@ -1480,9 +1479,9 @@ extern hc_thread_mutex_t mux_display;
#define DGST_SIZE_4_16 (16 * sizeof (uint)) // 64 !!! #define DGST_SIZE_4_16 (16 * sizeof (uint)) // 64 !!!
#define DGST_SIZE_4_32 (32 * sizeof (uint)) // 128 !!! #define DGST_SIZE_4_32 (32 * sizeof (uint)) // 128 !!!
#define DGST_SIZE_4_64 (64 * sizeof (uint)) // 256 #define DGST_SIZE_4_64 (64 * sizeof (uint)) // 256
#define DGST_SIZE_8_8 (8 * sizeof (uint64_t)) // 64 !!! #define DGST_SIZE_8_8 (8 * sizeof (u64)) // 64 !!!
#define DGST_SIZE_8_16 (16 * sizeof (uint64_t)) // 128 !!! #define DGST_SIZE_8_16 (16 * sizeof (u64)) // 128 !!!
#define DGST_SIZE_8_25 (25 * sizeof (uint64_t)) // 200 #define DGST_SIZE_8_25 (25 * sizeof (u64)) // 200
/** /**
* parser * parser
@ -1570,26 +1569,28 @@ extern hc_thread_mutex_t mux_display;
* functions * functions
*/ */
#define ROTATE_LEFT(a,n) rotl32 ((a), (n)) u32 rotl32 (const u32 a, const u32 n);
#define ROTATE_RIGHT(a,n) rotr32 ((a), (n)) u32 rotr32 (const u32 a, const u32 n);
u64 rotl64 (const u64 a, const u64 n);
u64 rotr64 (const u64 a, const u64 n);
uint32_t rotl32 (const uint32_t a, const uint n); u32 byte_swap_32 (const u32 n);
uint32_t rotr32 (const uint32_t a, const uint n); u64 byte_swap_64 (const u64 n);
uint64_t rotl64 (const uint64_t a, const uint n);
uint64_t rotr64 (const uint64_t a, const uint n);
void dump_hex (const char *s, size_t size); u8 hex_convert (const u8 c);
u8 hex_to_u8 (const u8 hex[2]);
u32 hex_to_u32 (const u8 hex[8]);
u64 hex_to_u64 (const u8 hex[16]);
void truecrypt_crc32 (char *file, unsigned char keytab[64]); void dump_hex (const u8 *s, const int sz);
void truecrypt_crc32 (const char *filename, u8 keytab[64]);
char *get_exec_path (); char *get_exec_path ();
char *get_install_dir (const char *progname); char *get_install_dir (const char *progname);
char *get_profile_dir (const char *homedir); char *get_profile_dir (const char *homedir);
char *get_session_dir (const char *profile_dir); char *get_session_dir (const char *profile_dir);
uint get_vliw_by_compute_capability (const uint major, const uint minor);
uint get_vliw_by_device_name (const char *device_name);
void *rulefind (const void *key, void *base, int nmemb, size_t size, int (*compar) (const void *, const void *)); void *rulefind (const void *key, void *base, int nmemb, size_t size, int (*compar) (const void *, const void *));
int sort_by_mtime (const void *p1, const void *p2); int sort_by_mtime (const void *p1, const void *p2);
@ -1621,14 +1622,9 @@ int sort_by_digest_p0p1 (const void *v1, const void *v2);
// special version for hccap (last 2 uints should be skipped where the digest is located) // special version for hccap (last 2 uints should be skipped where the digest is located)
int sort_by_hash_t_salt_hccap (const void *v1, const void *v2); int sort_by_hash_t_salt_hccap (const void *v1, const void *v2);
char hex_convert (const char c);
char hex_to_char (const char hex[2]);
uint hex_to_uint (const char hex[8]);
uint64_t hex_to_uint64_t (const char hex[16]);
void format_debug (char * debug_file, uint debug_mode, unsigned char *orig_plain_ptr, uint orig_plain_len, unsigned char *mod_plain_ptr, uint mod_plain_len, char *rule_buf, int rule_len); void format_debug (char * debug_file, uint debug_mode, unsigned char *orig_plain_ptr, uint orig_plain_len, unsigned char *mod_plain_ptr, uint mod_plain_len, char *rule_buf, int rule_len);
void format_plain (FILE *fp, unsigned char *plain_ptr, uint plain_len, uint outfile_autohex); void format_plain (FILE *fp, unsigned char *plain_ptr, uint plain_len, uint outfile_autohex);
void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const uint plain_len, const uint64_t crackpos, unsigned char *username, const uint user_len); void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const uint plain_len, const u64 crackpos, unsigned char *username, const uint user_len);
void handle_show_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp); void handle_show_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
void handle_left_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp); void handle_left_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
void handle_show_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp); void handle_show_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
@ -1638,18 +1634,18 @@ uint setup_opencl_platforms_filter (char *opencl_platforms);
uint devices_to_devicemask (char *opencl_devices); uint devices_to_devicemask (char *opencl_devices);
cl_device_type setup_device_types_filter (char *opencl_device_types); cl_device_type setup_device_types_filter (char *opencl_device_types);
uint get_random_num (uint min, uint max); u32 get_random_num (const u32 min, const u32 max);
uint32_t mydivc32 (const uint32_t dividend, const uint32_t divisor); u32 mydivc32 (const u32 dividend, const u32 divisor);
uint64_t mydivc64 (const uint64_t dividend, const uint64_t divisor); u64 mydivc64 (const u64 dividend, const u64 divisor);
void ascii_digest (char out_buf[1024], uint salt_pos, uint digest_pos); void ascii_digest (char out_buf[1024], uint salt_pos, uint digest_pos);
void to_hccap_t (hccap_t *hccap, uint salt_pos, uint digest_pos); void to_hccap_t (hccap_t *hccap, uint salt_pos, uint digest_pos);
void format_speed_display (float val, char *buf, size_t len); void format_speed_display (float val, char *buf, size_t len);
void format_timer_display (struct tm *tm, char *buf, size_t len); void format_timer_display (struct tm *tm, char *buf, size_t len);
void lowercase (char *buf, int len); void lowercase (u8 *buf, int len);
void uppercase (char *buf, int len); void uppercase (u8 *buf, int len);
int fgetl (FILE *fp, char *line_buf); int fgetl (FILE *fp, char *line_buf);
int in_superchop (char *buf); int in_superchop (char *buf);
char **scan_directory (const char *path); char **scan_directory (const char *path);
@ -1682,14 +1678,14 @@ int hm_get_device_num (HM_LIB hm_dll_amd, HM_ADAPTER_AMD hm_adapter_index, int *
// void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices); // void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
int hm_get_adapter_index_amd (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll_amd, int iNumberAdapters); LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll_amd, int iNumberAdapters);
uint32_t *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo); u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo);
int hm_get_overdrive_version (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); int hm_get_overdrive_version (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
void hm_close (HM_LIB hm_dll); void hm_close (HM_LIB hm_dll);
@ -1710,33 +1706,27 @@ uint set_kernel_accel (uint hash_mode);
uint set_kernel_loops (uint hash_mode); uint set_kernel_loops (uint hash_mode);
void set_cpu_affinity (char *cpu_affinity); void set_cpu_affinity (char *cpu_affinity);
void eula_print (const char *progname);
void usage_mini_print (const char *progname); void usage_mini_print (const char *progname);
void usage_big_print (const char *progname); void usage_big_print (const char *progname);
void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHARSIZ]); void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHARSIZ]);
void mp_cut_at (char *mask, uint max); void mp_cut_at (char *mask, uint max);
void mp_exec (uint64_t val, char *buf, cs_t *css, int css_cnt); void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt);
cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, uint *css_cnt); cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, uint *css_cnt);
uint64_t mp_get_sum (uint css_cnt, cs_t *css); u64 mp_get_sum (uint css_cnt, cs_t *css);
void mp_setup_sys (cs_t *mp_sys); void mp_setup_sys (cs_t *mp_sys);
void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index); void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index);
void mp_reset_usr (cs_t *mp_usr, uint index); void mp_reset_usr (cs_t *mp_usr, uint index);
char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len); char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len);
uint64_t sp_get_sum (uint start, uint stop, cs_t *root_css_buf); u64 sp_get_sum (uint start, uint stop, cs_t *root_css_buf);
void sp_exec (uint64_t ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint start, uint stop); void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint start, uint stop);
int sp_comp_val (const void *p1, const void *p2); int sp_comp_val (const void *p1, const void *p2);
void sp_setup_tbl (const char *install_dir, char *hcstat, uint disable, uint classic, hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf); void sp_setup_tbl (const char *install_dir, char *hcstat, uint disable, uint classic, hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf);
void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint threshold, uint uniq_tbls[SP_PW_MAX][CHARSIZ]); void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint threshold, uint uniq_tbls[SP_PW_MAX][CHARSIZ]);
void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out); void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out);
void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out); void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out);
uint byte_swap_32 (const uint n);
uint64_t byte_swap_64 (const uint64_t n);
char hex_convert (const char c);
int bcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf); int bcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf);
int cisco4_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf); int cisco4_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf);
int dcc_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf); int dcc_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf);
@ -1881,10 +1871,10 @@ int mywallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf);
int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf); int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf);
int androidfde_samsung_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf); int androidfde_samsung_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf);
void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const unsigned char **kernel_sources); void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources);
void writeProgramBin (char *dst, unsigned char *binary, size_t binary_size); void writeProgramBin (char *dst, u8 *binary, size_t binary_size);
uint64_t get_lowest_words_done (); u64 get_lowest_words_done ();
restore_data_t *init_restore (int argc, char **argv); restore_data_t *init_restore (int argc, char **argv);
void read_restore (const char *eff_restore_file, restore_data_t *rd); void read_restore (const char *eff_restore_file, restore_data_t *rd);
@ -1906,10 +1896,10 @@ void hc_signal (void c (int));
#endif #endif
bool class_num (char c); bool class_num (u8 c);
bool class_lower (char c); bool class_lower (u8 c);
bool class_upper (char c); bool class_upper (u8 c);
bool class_alpha (char c); bool class_alpha (u8 c);
int mangle_lrest (char arr[BLOCK_SIZE], int arr_len); int mangle_lrest (char arr[BLOCK_SIZE], int arr_len);
int mangle_urest (char arr[BLOCK_SIZE], int arr_len); int mangle_urest (char arr[BLOCK_SIZE], int arr_len);
@ -1936,13 +1926,13 @@ int mangle_dupechar_at (char arr[BLOCK_SIZE], int arr_len, int upos, int
int mangle_dupechar (char arr[BLOCK_SIZE], int arr_len); int mangle_dupechar (char arr[BLOCK_SIZE], int arr_len);
int mangle_switch_at_check (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2); int mangle_switch_at_check (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2);
int mangle_switch_at (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2); int mangle_switch_at (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2);
int mangle_chr_shiftl (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_shiftl (char arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_chr_shiftr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_shiftr (char arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_chr_incr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_incr (char arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_chr_decr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_decr (char arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_title (char arr[BLOCK_SIZE], int arr_len); int mangle_title (char arr[BLOCK_SIZE], int arr_len);
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], uint32_t rp_gen_func_min, uint32_t rp_gen_func_max); int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max);
int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]); int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]);
int cpu_rule_to_kernel_rule (char rule_buf[BUFSIZ], uint rule_len, kernel_rule_t *rule); int cpu_rule_to_kernel_rule (char rule_buf[BUFSIZ], uint rule_len, kernel_rule_t *rule);

View File

@ -161,7 +161,7 @@ typedef struct
typedef struct typedef struct
{ {
uint8_t cipher[1040]; u8 cipher[1040];
} agilekey_t; } agilekey_t;
@ -260,10 +260,10 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t l_alt_result[8]; u64 l_alt_result[8];
uint64_t l_p_bytes[2]; u64 l_p_bytes[2];
uint64_t l_s_bytes[2]; u64 l_s_bytes[2];
} sha512crypt_tmp_t; } sha512crypt_tmp_t;
@ -288,7 +288,7 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t dgst[8]; u64 dgst[8];
} bitcoin_wallet_tmp_t; } bitcoin_wallet_tmp_t;
@ -362,11 +362,11 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t ipad[8]; u64 ipad[8];
uint64_t opad[8]; u64 opad[8];
uint64_t dgst[32]; u64 dgst[32];
uint64_t out[32]; u64 out[32];
} tc64_tmp_t; } tc64_tmp_t;
@ -415,11 +415,11 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t ipad[8]; u64 ipad[8];
uint64_t opad[8]; u64 opad[8];
uint64_t dgst[8]; u64 dgst[8];
uint64_t out[8]; u64 out[8];
} sha512aix_tmp_t; } sha512aix_tmp_t;
@ -435,7 +435,7 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t digest_buf[8]; u64 digest_buf[8];
} drupal7_tmp_t; } drupal7_tmp_t;
@ -463,7 +463,7 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t out[8]; u64 out[8];
} office2013_tmp_t; } office2013_tmp_t;
@ -475,57 +475,57 @@ typedef struct
typedef struct typedef struct
{ {
uint32_t ipad[4]; u32 ipad[4];
uint32_t opad[4]; u32 opad[4];
uint32_t dgst[32]; u32 dgst[32];
uint32_t out[32]; u32 out[32];
} pbkdf2_md5_tmp_t; } pbkdf2_md5_tmp_t;
typedef struct typedef struct
{ {
uint32_t ipad[5]; u32 ipad[5];
uint32_t opad[5]; u32 opad[5];
uint32_t dgst[32]; u32 dgst[32];
uint32_t out[32]; u32 out[32];
} pbkdf2_sha1_tmp_t; } pbkdf2_sha1_tmp_t;
typedef struct typedef struct
{ {
uint32_t ipad[8]; u32 ipad[8];
uint32_t opad[8]; u32 opad[8];
uint32_t dgst[32]; u32 dgst[32];
uint32_t out[32]; u32 out[32];
} pbkdf2_sha256_tmp_t; } pbkdf2_sha256_tmp_t;
typedef struct typedef struct
{ {
uint64_t ipad[8]; u64 ipad[8];
uint64_t opad[8]; u64 opad[8];
uint64_t dgst[16]; u64 dgst[16];
uint64_t out[16]; u64 out[16];
} pbkdf2_sha512_tmp_t; } pbkdf2_sha512_tmp_t;
typedef struct typedef struct
{ {
uint64_t out[8]; u64 out[8];
} ecryptfs_tmp_t; } ecryptfs_tmp_t;
typedef struct typedef struct
{ {
uint64_t ipad[8]; u64 ipad[8];
uint64_t opad[8]; u64 opad[8];
uint64_t dgst[16]; u64 dgst[16];
uint64_t out[16]; u64 out[16];
} oraclet_tmp_t; } oraclet_tmp_t;
@ -605,7 +605,7 @@ typedef struct
typedef struct typedef struct
{ {
uint key; uint key;
uint64_t val; u64 val;
} hcstat_table_t; } hcstat_table_t;
@ -636,9 +636,9 @@ typedef struct
typedef struct typedef struct
{ {
char signature[4]; char signature[4];
uint32_t salt_buf[8]; u32 salt_buf[8];
uint32_t iterations; u32 iterations;
uint32_t hash_buf[8]; u32 hash_buf[8];
} psafe3_t; } psafe3_t;
@ -653,7 +653,7 @@ typedef struct
typedef struct typedef struct
{ {
uint64_t cnt; u64 cnt;
#ifdef _POSIX #ifdef _POSIX
struct stat stat; struct stat stat;
@ -683,17 +683,17 @@ typedef struct
{ {
union union
{ {
uint8_t hc4[4][ 64]; u8 hc4[4][ 64];
uint32_t hi4[4][ 16]; u32 hi4[4][ 16];
uint64_t hl4[4][ 8]; u64 hl4[4][ 8];
uint8_t hc2[2][128]; u8 hc2[2][128];
uint32_t hi2[2][ 32]; u32 hi2[2][ 32];
uint64_t hl2[2][ 16]; u64 hl2[2][ 16];
uint8_t hc1[1][256]; u8 hc1[1][256];
uint32_t hi1[1][ 64]; u32 hi1[1][ 64];
uint64_t hl1[1][ 32]; u64 hl1[1][ 32];
}; };
uint pw_len; uint pw_len;
@ -733,16 +733,16 @@ typedef struct
typedef struct typedef struct
{ {
uint32_t version_bin; u32 version_bin;
char cwd[256]; char cwd[256];
uint32_t pid; u32 pid;
uint32_t dictpos; u32 dictpos;
uint32_t maskpos; u32 maskpos;
uint64_t words_cur; u64 words_cur;
uint32_t argc; u32 argc;
char **argv; char **argv;
} restore_data_t; } restore_data_t;
@ -758,10 +758,10 @@ typedef struct
typedef struct typedef struct
{ {
char *buf; char *buf;
uint32_t incr; u32 incr;
uint32_t avail; u32 avail;
uint32_t cnt; u32 cnt;
uint32_t pos; u32 pos;
} wl_data_t; } wl_data_t;
@ -826,7 +826,7 @@ struct __hc_device_param
uint device_processors; uint device_processors;
uint device_processor_cores; uint device_processor_cores;
uint64_t device_maxmem_alloc; u64 device_maxmem_alloc;
uint kernel_threads; uint kernel_threads;
uint kernel_accel; uint kernel_accel;
@ -846,7 +846,7 @@ struct __hc_device_param
uint size_results; uint size_results;
uint size_plains; uint size_plains;
uint (*pw_add) (struct __hc_device_param *, const uint8_t *, const uint); uint (*pw_add) (struct __hc_device_param *, const u8 *, const uint);
void (*pw_transpose) (const pw_t *, pw_t *); void (*pw_transpose) (const pw_t *, pw_t *);
@ -859,10 +859,10 @@ struct __hc_device_param
pw_t *pws_buf; pw_t *pws_buf;
uint pws_cnt; uint pws_cnt;
uint64_t pw_cnt; u64 pw_cnt;
uint64_t words_off; u64 words_off;
uint64_t words_done; u64 words_done;
uint *result; uint *result;
@ -873,7 +873,7 @@ struct __hc_device_param
uint innerloop_left; uint innerloop_left;
uint speed_pos; uint speed_pos;
uint64_t speed_cnt[SPEED_CACHE]; u64 speed_cnt[SPEED_CACHE];
float speed_ms[SPEED_CACHE]; float speed_ms[SPEED_CACHE];
hc_timer_t speed_rec[SPEED_CACHE]; hc_timer_t speed_rec[SPEED_CACHE];
@ -955,18 +955,18 @@ struct __hc_device_param
void *kernel_params_tb[PARAMCNT]; void *kernel_params_tb[PARAMCNT];
void *kernel_params_tm[PARAMCNT]; void *kernel_params_tm[PARAMCNT];
uint32_t kernel_params_buf32[PARAMCNT]; u32 kernel_params_buf32[PARAMCNT];
uint32_t kernel_params_mp_buf32[PARAMCNT]; u32 kernel_params_mp_buf32[PARAMCNT];
uint64_t kernel_params_mp_buf64[PARAMCNT]; u64 kernel_params_mp_buf64[PARAMCNT];
uint32_t kernel_params_mp_r_buf32[PARAMCNT]; u32 kernel_params_mp_r_buf32[PARAMCNT];
uint64_t kernel_params_mp_r_buf64[PARAMCNT]; u64 kernel_params_mp_r_buf64[PARAMCNT];
uint32_t kernel_params_mp_l_buf32[PARAMCNT]; u32 kernel_params_mp_l_buf32[PARAMCNT];
uint64_t kernel_params_mp_l_buf64[PARAMCNT]; u64 kernel_params_mp_l_buf64[PARAMCNT];
uint32_t kernel_params_amp_buf32[PARAMCNT]; u32 kernel_params_amp_buf32[PARAMCNT];
}; };
typedef struct __hc_device_param hc_device_param_t; typedef struct __hc_device_param hc_device_param_t;
@ -1076,7 +1076,7 @@ typedef struct
cpt_t cpt_buf[CPT_BUF]; cpt_t cpt_buf[CPT_BUF];
int cpt_pos; int cpt_pos;
time_t cpt_start; time_t cpt_start;
uint64_t cpt_total; u64 cpt_total;
/** /**
* user * user
@ -1161,12 +1161,12 @@ typedef struct
* used for restore * used for restore
*/ */
uint64_t skip; u64 skip;
uint64_t limit; u64 limit;
restore_data_t *rd; restore_data_t *rd;
uint64_t checkpoint_cur_words; // used for the "stop at next checkpoint" feature u64 checkpoint_cur_words; // used for the "stop at next checkpoint" feature
/** /**
* status, timer * status, timer
@ -1178,13 +1178,13 @@ typedef struct
time_t proc_start; time_t proc_start;
time_t proc_stop; time_t proc_stop;
uint64_t words_cnt; u64 words_cnt;
uint64_t words_cur; u64 words_cur;
uint64_t words_base; u64 words_base;
uint64_t *words_progress_done; // progress number of words done per salt u64 *words_progress_done; // progress number of words done per salt
uint64_t *words_progress_rejected; // progress number of words rejected per salt u64 *words_progress_rejected; // progress number of words rejected per salt
uint64_t *words_progress_restored; // progress number of words restored per salt u64 *words_progress_restored; // progress number of words restored per salt
hc_timer_t timer_running; // timer on current dict hc_timer_t timer_running; // timer on current dict
hc_timer_t timer_paused; // timer on current dict hc_timer_t timer_paused; // timer on current dict

View File

@ -51,7 +51,7 @@ CP := cp
RM := rm RM := rm
INSTALL := install INSTALL := install
CC_NATIVE := gcc CC_NATIVE := clang
## ##
## Cross compiler paths ## Cross compiler paths
@ -76,8 +76,8 @@ NOW := $(shell date +%s)
## Compiler flags ## Compiler flags
## ##
CFLAGS := -O2 -s -pipe -W -Wall -std=c99 -Iinclude/ #CFLAGS := -O2 -s -pipe -W -Wall -std=c99 -Iinclude/
#CFLAGS := -g -ggdb -pipe -W -Wall -std=c99 -Iinclude/ -fsanitize=address CFLAGS := -g -ggdb -pipe -W -Wall -std=c99 -Iinclude/ -fsanitize=undefined -fno-omit-frame-pointer
## ##
## Native compilation target ## Native compilation target

View File

@ -282,7 +282,7 @@ static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
* types * types
*/ */
static void (*get_next_word_func) (char *, uint32_t, uint32_t *, uint32_t *); static void (*get_next_word_func) (char *, u32, u32 *, u32 *);
/** /**
* globals * globals
@ -743,7 +743,7 @@ void status_display_automat ()
{ {
hc_device_param_t *device_param = &data.devices_param[device_id]; hc_device_param_t *device_param = &data.devices_param[device_id];
uint64_t speed_cnt = 0; u64 speed_cnt = 0;
float speed_ms = 0; float speed_ms = 0;
for (int i = 0; i < SPEED_CACHE; i++) for (int i = 0; i < SPEED_CACHE; i++)
@ -768,7 +768,7 @@ void status_display_automat ()
* words_cur * words_cur
*/ */
uint64_t words_cur = get_lowest_words_done (); u64 words_cur = get_lowest_words_done ();
fprintf (out, "CURKU\t%llu\t", (unsigned long long int) words_cur); fprintf (out, "CURKU\t%llu\t", (unsigned long long int) words_cur);
@ -780,11 +780,11 @@ void status_display_automat ()
if (salts_left == 0) salts_left = 1; if (salts_left == 0) salts_left = 1;
uint64_t progress_total = data.words_cnt * salts_left; u64 progress_total = data.words_cnt * salts_left;
uint64_t all_done = 0; u64 all_done = 0;
uint64_t all_rejected = 0; u64 all_rejected = 0;
uint64_t all_restored = 0; u64 all_restored = 0;
for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++) for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
{ {
@ -800,10 +800,10 @@ void status_display_automat ()
all_restored += data.words_progress_restored[salt_pos]; all_restored += data.words_progress_restored[salt_pos];
} }
uint64_t progress_cur = all_restored + all_done + all_rejected; u64 progress_cur = all_restored + all_done + all_rejected;
uint64_t progress_end = progress_total; u64 progress_end = progress_total;
uint64_t progress_skip = 0; u64 progress_skip = 0;
if (data.skip) if (data.skip)
{ {
@ -823,8 +823,8 @@ void status_display_automat ()
else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt; else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
} }
uint64_t progress_cur_relative_skip = progress_cur - progress_skip; u64 progress_cur_relative_skip = progress_cur - progress_skip;
uint64_t progress_end_relative_skip = progress_end - progress_skip; u64 progress_end_relative_skip = progress_end - progress_skip;
fprintf (out, "PROGRESS\t%llu\t%llu\t", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip); fprintf (out, "PROGRESS\t%llu\t%llu\t", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip);
@ -1082,7 +1082,7 @@ void status_display ()
* speed new * speed new
*/ */
uint64_t speed_cnt[DEVICES_MAX]; u64 speed_cnt[DEVICES_MAX];
float speed_ms[DEVICES_MAX]; float speed_ms[DEVICES_MAX];
for (uint device_id = 0; device_id < data.devices_cnt; device_id++) for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
@ -1208,11 +1208,11 @@ void status_display ()
if (salts_left == 0) salts_left = 1; if (salts_left == 0) salts_left = 1;
uint64_t progress_total = data.words_cnt * salts_left; u64 progress_total = data.words_cnt * salts_left;
uint64_t all_done = 0; u64 all_done = 0;
uint64_t all_rejected = 0; u64 all_rejected = 0;
uint64_t all_restored = 0; u64 all_restored = 0;
for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++) for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
{ {
@ -1228,10 +1228,10 @@ void status_display ()
all_restored += data.words_progress_restored[salt_pos]; all_restored += data.words_progress_restored[salt_pos];
} }
uint64_t progress_cur = all_restored + all_done + all_rejected; u64 progress_cur = all_restored + all_done + all_rejected;
uint64_t progress_end = progress_total; u64 progress_end = progress_total;
uint64_t progress_skip = 0; u64 progress_skip = 0;
if (data.skip) if (data.skip)
{ {
@ -1251,17 +1251,17 @@ void status_display ()
else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt; else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
} }
uint64_t progress_cur_relative_skip = progress_cur - progress_skip; u64 progress_cur_relative_skip = progress_cur - progress_skip;
uint64_t progress_end_relative_skip = progress_end - progress_skip; u64 progress_end_relative_skip = progress_end - progress_skip;
float speed_ms_real = ms_running - ms_paused; float speed_ms_real = ms_running - ms_paused;
uint64_t speed_plains_real = all_done; u64 speed_plains_real = all_done;
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK)) if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{ {
if (data.devices_status != STATUS_CRACKED) if (data.devices_status != STATUS_CRACKED)
{ {
uint64_t words_per_ms = 0; u64 words_per_ms = 0;
if (speed_plains_real && speed_ms_real) if (speed_plains_real && speed_ms_real)
{ {
@ -1276,9 +1276,9 @@ void status_display ()
if (words_per_ms) if (words_per_ms)
{ {
uint64_t progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip; u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip;
uint64_t ms_left = progress_left_relative_skip / words_per_ms; u64 ms_left = progress_left_relative_skip / words_per_ms;
sec_etc = ms_left / 1000; sec_etc = ms_left / 1000;
} }
@ -1287,7 +1287,7 @@ void status_display ()
{ {
log_info ("Time.Estimated.: 0 secs"); log_info ("Time.Estimated.: 0 secs");
} }
else if ((uint64_t) sec_etc > ETC_MAX) else if ((u64) sec_etc > ETC_MAX)
{ {
log_info ("Time.Estimated.: > 10 Years"); log_info ("Time.Estimated.: > 10 Years");
} }
@ -1435,9 +1435,9 @@ void status_display ()
// Restore point // Restore point
uint64_t restore_point = get_lowest_words_done (); u64 restore_point = get_lowest_words_done ();
uint64_t restore_total = data.words_base; u64 restore_total = data.words_base;
float percent_restore = 0; float percent_restore = 0;
@ -1471,12 +1471,12 @@ void status_display ()
{ {
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK)) if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{ {
log_info ("Progress.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100); log_info ("Progress.......: %llu/%llu (%.02f%%)", (u64) 0, (u64) 0, (float) 100);
log_info ("Rejected.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100); log_info ("Rejected.......: %llu/%llu (%.02f%%)", (u64) 0, (u64) 0, (float) 100);
if (data.restore_disable == 0) if (data.restore_disable == 0)
{ {
log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100); log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (u64) 0, (u64) 0, (float) 100);
} }
} }
else else
@ -1550,7 +1550,7 @@ static void status_benchmark ()
if (data.words_cnt == 0) return; if (data.words_cnt == 0) return;
uint64_t speed_cnt[DEVICES_MAX]; u64 speed_cnt[DEVICES_MAX];
float speed_ms[DEVICES_MAX]; float speed_ms[DEVICES_MAX];
uint device_id; uint device_id;
@ -1693,7 +1693,7 @@ static uint convert_from_hex (char *line_buf, const uint line_len)
for (i = 0, j = 0; j < line_len; i += 1, j += 2) for (i = 0, j = 0; j < line_len; i += 1, j += 2)
{ {
line_buf[i] = hex_to_char (&line_buf[j]); line_buf[i] = hex_to_u8 ((const u8 *) &line_buf[j]);
} }
memset (line_buf + i, 0, line_len - i); memset (line_buf + i, 0, line_len - i);
@ -1714,7 +1714,7 @@ static uint convert_from_hex (char *line_buf, const uint line_len)
for (i = 0, j = 5; j < line_len - 1; i += 1, j += 2) for (i = 0, j = 5; j < line_len - 1; i += 1, j += 2)
{ {
line_buf[i] = hex_to_char (&line_buf[j]); line_buf[i] = hex_to_u8 ((const u8 *) &line_buf[j]);
} }
memset (line_buf + i, 0, line_len - i); memset (line_buf + i, 0, line_len - i);
@ -1787,7 +1787,7 @@ static void clear_prompt ()
fflush (stdout); fflush (stdout);
} }
static void gidd_to_pw_t (hc_device_param_t *device_param, const uint64_t gidd, pw_t *pw) static void gidd_to_pw_t (hc_device_param_t *device_param, const u64 gidd, pw_t *pw)
{ {
hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL); hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL);
} }
@ -1824,7 +1824,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
uint gidvid = plain.gidvid; uint gidvid = plain.gidvid;
uint il_pos = plain.il_pos; uint il_pos = plain.il_pos;
uint64_t crackpos = device_param->words_off; u64 crackpos = device_param->words_off;
uint plain_buf[16]; uint plain_buf[16];
@ -1833,8 +1833,8 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
if (data.attack_mode == ATTACK_MODE_STRAIGHT) if (data.attack_mode == ATTACK_MODE_STRAIGHT)
{ {
uint64_t gidd = gidvid; u64 gidd = gidvid;
uint64_t gidm = 0; u64 gidm = 0;
pw_t pw; pw_t pw;
@ -1882,8 +1882,8 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
} }
else if (data.attack_mode == ATTACK_MODE_COMBI) else if (data.attack_mode == ATTACK_MODE_COMBI)
{ {
uint64_t gidd = gidvid; u64 gidd = gidvid;
uint64_t gidm = 0; u64 gidm = 0;
pw_t pw; pw_t pw;
@ -1923,8 +1923,8 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
} }
else if (data.attack_mode == ATTACK_MODE_BF) else if (data.attack_mode == ATTACK_MODE_BF)
{ {
uint64_t l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid; u64 l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid;
uint64_t r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos; u64 r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos;
uint l_start = device_param->kernel_params_mp_l_buf32[5]; uint l_start = device_param->kernel_params_mp_l_buf32[5];
uint r_start = device_param->kernel_params_mp_r_buf32[5]; uint r_start = device_param->kernel_params_mp_r_buf32[5];
@ -1943,8 +1943,8 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
} }
else if (data.attack_mode == ATTACK_MODE_HYBRID1) else if (data.attack_mode == ATTACK_MODE_HYBRID1)
{ {
uint64_t gidd = gidvid; u64 gidd = gidvid;
uint64_t gidm = 0; u64 gidm = 0;
pw_t pw; pw_t pw;
@ -1957,7 +1957,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
plain_len = pw.pw_len; plain_len = pw.pw_len;
uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos; u64 off = device_param->kernel_params_mp_buf64[3] + il_pos;
uint start = 0; uint start = 0;
uint stop = device_param->kernel_params_mp_buf32[4]; uint stop = device_param->kernel_params_mp_buf32[4];
@ -1977,8 +1977,8 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
} }
else if (data.attack_mode == ATTACK_MODE_HYBRID2) else if (data.attack_mode == ATTACK_MODE_HYBRID2)
{ {
uint64_t gidd = gidvid; u64 gidd = gidvid;
uint64_t gidm = 0; u64 gidm = 0;
pw_t pw; pw_t pw;
@ -1991,7 +1991,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
plain_len = pw.pw_len; plain_len = pw.pw_len;
uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos; u64 off = device_param->kernel_params_mp_buf64[3] + il_pos;
uint start = 0; uint start = 0;
uint stop = device_param->kernel_params_mp_buf32[4]; uint stop = device_param->kernel_params_mp_buf32[4];
@ -2307,7 +2307,7 @@ static void save_hash ()
unlink (old_hashfile); unlink (old_hashfile);
} }
static float find_kernel_blocks_div (const uint64_t total_left, const uint kernel_blocks_all) static float find_kernel_blocks_div (const u64 total_left, const uint kernel_blocks_all)
{ {
// function called only in case kernel_blocks_all > words_left) // function called only in case kernel_blocks_all > words_left)
@ -2315,13 +2315,13 @@ static float find_kernel_blocks_div (const uint64_t total_left, const uint kerne
kernel_blocks_div += kernel_blocks_div / 100; kernel_blocks_div += kernel_blocks_div / 100;
uint32_t kernel_blocks_new = (uint32_t) (kernel_blocks_all * kernel_blocks_div); u32 kernel_blocks_new = (u32) (kernel_blocks_all * kernel_blocks_div);
while (kernel_blocks_new < total_left) while (kernel_blocks_new < total_left)
{ {
kernel_blocks_div += kernel_blocks_div / 100; kernel_blocks_div += kernel_blocks_div / 100;
kernel_blocks_new = (uint32_t) (kernel_blocks_all * kernel_blocks_div); kernel_blocks_new = (u32) (kernel_blocks_all * kernel_blocks_div);
} }
if (data.quiet == 0) if (data.quiet == 0)
@ -2590,7 +2590,7 @@ static void run_copy (hc_device_param_t *device_param, const uint pws_cnt)
} }
else if (data.attack_kern == ATTACK_KERN_BF) else if (data.attack_kern == ATTACK_KERN_BF)
{ {
const uint64_t off = device_param->words_off; const u64 off = device_param->words_off;
device_param->kernel_params_mp_l_buf64[3] = off; device_param->kernel_params_mp_l_buf64[3] = off;
@ -2752,7 +2752,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
line_len = MIN (line_len, PW_DICTMAX); line_len = MIN (line_len, PW_DICTMAX);
char *ptr = (char *) device_param->combs_buf[i].i; u8 *ptr = (u8 *) device_param->combs_buf[i].i;
memcpy (ptr, line_buf_new, line_len); memcpy (ptr, line_buf_new, line_len);
@ -2799,7 +2799,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
} }
else if (data.attack_mode == ATTACK_MODE_BF) else if (data.attack_mode == ATTACK_MODE_BF)
{ {
uint64_t off = innerloop_pos; u64 off = innerloop_pos;
device_param->kernel_params_mp_r_buf64[3] = off; device_param->kernel_params_mp_r_buf64[3] = off;
@ -2807,7 +2807,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
} }
else if (data.attack_mode == ATTACK_MODE_HYBRID1) else if (data.attack_mode == ATTACK_MODE_HYBRID1)
{ {
uint64_t off = innerloop_pos; u64 off = innerloop_pos;
device_param->kernel_params_mp_buf64[3] = off; device_param->kernel_params_mp_buf64[3] = off;
@ -2815,7 +2815,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
} }
else if (data.attack_mode == ATTACK_MODE_HYBRID2) else if (data.attack_mode == ATTACK_MODE_HYBRID2)
{ {
uint64_t off = innerloop_pos; u64 off = innerloop_pos;
device_param->kernel_params_mp_buf64[3] = off; device_param->kernel_params_mp_buf64[3] = off;
@ -2939,7 +2939,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
* progress * progress
*/ */
uint64_t perf_sum_all = (uint64_t) pw_cnt * (uint64_t) innerloop_left; u64 perf_sum_all = (u64) pw_cnt * (u64) innerloop_left;
hc_thread_mutex_lock (mux_counter); hc_thread_mutex_lock (mux_counter);
@ -3025,11 +3025,11 @@ static void load_segment (wl_data_t *wl_data, FILE *fd)
return; return;
} }
static void get_next_word_lm (char *buf, uint32_t sz, uint32_t *len, uint32_t *off) static void get_next_word_lm (char *buf, u32 sz, u32 *len, u32 *off)
{ {
char *ptr = buf; char *ptr = buf;
for (uint32_t i = 0; i < sz; i++, ptr++) for (u32 i = 0; i < sz; i++, ptr++)
{ {
if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20; if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
@ -3056,11 +3056,11 @@ static void get_next_word_lm (char *buf, uint32_t sz, uint32_t *len, uint32_t *o
*len = sz; *len = sz;
} }
static void get_next_word_uc (char *buf, uint32_t sz, uint32_t *len, uint32_t *off) static void get_next_word_uc (char *buf, u32 sz, u32 *len, u32 *off)
{ {
char *ptr = buf; char *ptr = buf;
for (uint32_t i = 0; i < sz; i++, ptr++) for (u32 i = 0; i < sz; i++, ptr++)
{ {
if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20; if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
@ -3079,11 +3079,11 @@ static void get_next_word_uc (char *buf, uint32_t sz, uint32_t *len, uint32_t *o
*len = sz; *len = sz;
} }
static void get_next_word_std (char *buf, uint32_t sz, uint32_t *len, uint32_t *off) static void get_next_word_std (char *buf, u32 sz, u32 *len, u32 *off)
{ {
char *ptr = buf; char *ptr = buf;
for (uint32_t i = 0; i < sz; i++, ptr++) for (u32 i = 0; i < sz; i++, ptr++)
{ {
if (*ptr != '\n') continue; if (*ptr != '\n') continue;
@ -3163,11 +3163,11 @@ static void get_next_word (wl_data_t *wl_data, FILE *fd, char **out_buf, uint *o
} }
#ifdef _POSIX #ifdef _POSIX
static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, size_t *dictstat_nmemb) static u64 count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, size_t *dictstat_nmemb)
#endif #endif
#ifdef _WIN #ifdef _WIN
static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, uint *dictstat_nmemb) static u64 count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, uint *dictstat_nmemb)
#endif #endif
{ {
hc_signal (NULL); hc_signal (NULL);
@ -3204,9 +3204,9 @@ static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dicts
{ {
if (d_cache) if (d_cache)
{ {
uint64_t cnt = d_cache->cnt; u64 cnt = d_cache->cnt;
uint64_t keyspace = cnt; u64 keyspace = cnt;
if (data.attack_kern == ATTACK_KERN_STRAIGHT) if (data.attack_kern == ATTACK_KERN_STRAIGHT)
{ {
@ -3229,9 +3229,9 @@ static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dicts
time_t now = 0; time_t now = 0;
time_t prev = 0; time_t prev = 0;
uint64_t comp = 0; u64 comp = 0;
uint64_t cnt = 0; u64 cnt = 0;
uint64_t cnt2 = 0; u64 cnt2 = 0;
while (!feof (fd)) while (!feof (fd))
{ {
@ -3239,12 +3239,12 @@ static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dicts
comp += wl_data->cnt; comp += wl_data->cnt;
uint32_t i = 0; u32 i = 0;
while (i < wl_data->cnt) while (i < wl_data->cnt)
{ {
uint32_t len; u32 len;
uint32_t off; u32 off;
get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off); get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
@ -3316,7 +3316,7 @@ static void pw_transpose_to_hi1 (const pw_t *p1, pw_t *p2)
memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint)); memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint));
} }
static uint pw_add_to_hc1 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len) static uint pw_add_to_hc1 (hc_device_param_t *device_param, const u8 *pw_buf, const uint pw_len)
{ {
if (data.devices_status == STATUS_BYPASS) return 0; if (data.devices_status == STATUS_BYPASS) return 0;
@ -3324,7 +3324,7 @@ static uint pw_add_to_hc1 (hc_device_param_t *device_param, const uint8_t *pw_bu
uint cache_cnt = pw_cache->cnt; uint cache_cnt = pw_cache->cnt;
uint8_t *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt]; u8 *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt];
memcpy (pw_hc1, pw_buf, pw_len); memcpy (pw_hc1, pw_buf, pw_len);
@ -3807,7 +3807,7 @@ static void *thread_outfile_remove (void *p)
for (uint i = 0, j = 0; i < 6; i++, j += 2) for (uint i = 0, j = 0; i < 6; i++, j += 2)
{ {
if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j])) if (mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
{ {
cracked = 0; cracked = 0;
break; break;
@ -3819,7 +3819,7 @@ static void *thread_outfile_remove (void *p)
for (uint i = 0, j = 0; i < 6; i++, j += 2) for (uint i = 0, j = 0; i < 6; i++, j += 2)
{ {
if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j])) if (mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
{ {
cracked = 0; cracked = 0;
break; break;
@ -3900,16 +3900,16 @@ static void *thread_outfile_remove (void *p)
return (p); return (p);
} }
static uint get_work (hc_device_param_t *device_param, const uint64_t max) static uint get_work (hc_device_param_t *device_param, const u64 max)
{ {
hc_thread_mutex_lock (mux_dispatcher); hc_thread_mutex_lock (mux_dispatcher);
const uint64_t words_cur = data.words_cur; const u64 words_cur = data.words_cur;
const uint64_t words_base = (data.limit == 0) ? data.words_base : data.limit; const u64 words_base = (data.limit == 0) ? data.words_base : data.limit;
device_param->words_off = words_cur; device_param->words_off = words_cur;
const uint64_t words_left = words_base - words_cur; const u64 words_left = words_base - words_cur;
if (data.kernel_blocks_all > words_left) if (data.kernel_blocks_all > words_left)
{ {
@ -3923,8 +3923,8 @@ static uint get_work (hc_device_param_t *device_param, const uint64_t max)
{ {
if (device_param->kernel_blocks == device_param->kernel_blocks_user) if (device_param->kernel_blocks == device_param->kernel_blocks_user)
{ {
const uint32_t kernel_blocks_new = (float) device_param->kernel_blocks * data.kernel_blocks_div; const u32 kernel_blocks_new = (float) device_param->kernel_blocks * data.kernel_blocks_div;
const uint32_t kernel_power_new = kernel_blocks_new; const u32 kernel_power_new = kernel_blocks_new;
if (kernel_blocks_new < device_param->kernel_blocks) if (kernel_blocks_new < device_param->kernel_blocks)
{ {
@ -4042,7 +4042,7 @@ static void *thread_calc_stdin (void *p)
} }
} }
device_param->pw_add (device_param, (uint8_t *) line_buf, line_len); device_param->pw_add (device_param, (u8 *) line_buf, line_len);
words_cur++; words_cur++;
@ -4176,8 +4176,8 @@ static void *thread_calc (void *p)
if (work == 0) break; if (work == 0) break;
const uint64_t words_off = device_param->words_off; const u64 words_off = device_param->words_off;
const uint64_t words_fin = words_off + work; const u64 words_fin = words_off + work;
const uint pw_cnt = work; const uint pw_cnt = work;
const uint pws_cnt = work; const uint pws_cnt = work;
@ -4276,14 +4276,14 @@ static void *thread_calc (void *p)
wl_data->cnt = 0; wl_data->cnt = 0;
wl_data->pos = 0; wl_data->pos = 0;
uint64_t words_cur = 0; u64 words_cur = 0;
while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT)) while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
{ {
uint64_t words_off = 0; u64 words_off = 0;
uint64_t words_fin = 0; u64 words_fin = 0;
uint64_t max = -1; u64 max = -1;
while (max) while (max)
{ {
@ -4368,7 +4368,7 @@ static void *thread_calc (void *p)
} }
} }
device_param->pw_add (device_param, (uint8_t *) line_buf, line_len); device_param->pw_add (device_param, (u8 *) line_buf, line_len);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (); if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
@ -4942,9 +4942,9 @@ void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
return mymalloc (iSize); return mymalloc (iSize);
} }
static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint dgst_shifts, char *digests_buf_ptr, const uint bitmap_mask, const uint bitmap_size, uint *bitmap_a, uint *bitmap_b, uint *bitmap_c, uint *bitmap_d, const uint64_t collisions_max) static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint dgst_shifts, char *digests_buf_ptr, const uint bitmap_mask, const uint bitmap_size, uint *bitmap_a, uint *bitmap_b, uint *bitmap_c, uint *bitmap_d, const u64 collisions_max)
{ {
uint64_t collisions = 0; u64 collisions = 0;
const uint dgst_pos0 = data.dgst_pos0; const uint dgst_pos0 = data.dgst_pos0;
const uint dgst_pos1 = data.dgst_pos1; const uint dgst_pos1 = data.dgst_pos1;
@ -5056,8 +5056,8 @@ int main (int argc, char **argv)
uint username = USERNAME; uint username = USERNAME;
uint remove = REMOVE; uint remove = REMOVE;
uint remove_timer = REMOVE_TIMER; uint remove_timer = REMOVE_TIMER;
uint64_t skip = SKIP; u64 skip = SKIP;
uint64_t limit = LIMIT; u64 limit = LIMIT;
uint keyspace = KEYSPACE; uint keyspace = KEYSPACE;
uint potfile_disable = POTFILE_DISABLE; uint potfile_disable = POTFILE_DISABLE;
uint debug_mode = DEBUG_MODE; uint debug_mode = DEBUG_MODE;
@ -10520,7 +10520,7 @@ int main (int argc, char **argv)
if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY)) if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
{ {
uint32_t hash_pos; u32 hash_pos;
for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++) for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
{ {
@ -11756,7 +11756,7 @@ int main (int argc, char **argv)
for (uint i = 0, j = 0; i < 6; i++, j += 2) for (uint i = 0, j = 0; i < 6; i++, j += 2)
{ {
if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j])) if (mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
{ {
found = NULL; found = NULL;
break; break;
@ -11768,7 +11768,7 @@ int main (int argc, char **argv)
for (uint i = 0, j = 0; i < 6; i++, j += 2) for (uint i = 0, j = 0; i < 6; i++, j += 2)
{ {
if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j])) if (mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
{ {
found = NULL; found = NULL;
break; break;
@ -12944,7 +12944,7 @@ int main (int argc, char **argv)
int num_adl_adapters = 0; int num_adl_adapters = 0;
uint32_t *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo); u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
if (num_adl_adapters > 0) if (num_adl_adapters > 0)
{ {
@ -13218,7 +13218,7 @@ int main (int argc, char **argv)
uint size_bfs = KERNEL_BFS * sizeof (bf_t); uint size_bfs = KERNEL_BFS * sizeof (bf_t);
uint size_tm = 32 * sizeof (bs_word_t); uint size_tm = 32 * sizeof (bs_word_t);
uint64_t size_scryptV = 1; u64 size_scryptV = 1;
if ((hash_mode == 8900) || (hash_mode == 9300)) if ((hash_mode == 8900) || (hash_mode == 9300))
{ {
@ -14269,9 +14269,9 @@ int main (int argc, char **argv)
* keep track of the progress * keep track of the progress
*/ */
data.words_progress_done = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t)); data.words_progress_done = (u64 *) mycalloc (data.salts_cnt, sizeof (u64));
data.words_progress_rejected = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t)); data.words_progress_rejected = (u64 *) mycalloc (data.salts_cnt, sizeof (u64));
data.words_progress_restored = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t)); data.words_progress_restored = (u64 *) mycalloc (data.salts_cnt, sizeof (u64));
/** /**
* open filehandles * open filehandles
@ -14489,7 +14489,7 @@ int main (int argc, char **argv)
data.quiet = 1; data.quiet = 1;
const uint64_t words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb); const u64 words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb);
data.quiet = quiet; data.quiet = quiet;
@ -14507,7 +14507,7 @@ int main (int argc, char **argv)
data.quiet = 1; data.quiet = 1;
const uint64_t words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb); const u64 words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb);
data.quiet = quiet; data.quiet = quiet;
@ -15427,9 +15427,9 @@ int main (int argc, char **argv)
data.devices_status = STATUS_INIT; data.devices_status = STATUS_INIT;
memset (data.words_progress_done, 0, data.salts_cnt * sizeof (uint64_t)); memset (data.words_progress_done, 0, data.salts_cnt * sizeof (u64));
memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (uint64_t)); memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (u64));
memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (uint64_t)); memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (u64));
memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t)); memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t));
@ -15458,7 +15458,7 @@ int main (int argc, char **argv)
device_param->speed_pos = 0; device_param->speed_pos = 0;
memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (uint64_t)); memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64));
memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float)); memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t)); memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
@ -15861,7 +15861,7 @@ int main (int argc, char **argv)
} }
} }
uint64_t words_base = data.words_cnt; u64 words_base = data.words_cnt;
if (data.attack_kern == ATTACK_KERN_STRAIGHT) if (data.attack_kern == ATTACK_KERN_STRAIGHT)
{ {

View File

@ -8,20 +8,20 @@
#include <rp_kernel_on_cpu.h> #include <rp_kernel_on_cpu.h>
static uint32_t generate_cmask (uint32_t buf) static u32 generate_cmask (u32 buf)
{ {
const uint32_t rmask = ((buf & 0x40404040) >> 1) const u32 rmask = ((buf & 0x40404040) >> 1)
& ~((buf & 0x80808080) >> 2); & ~((buf & 0x80808080) >> 2);
const uint32_t hmask = (buf & 0x1f1f1f1f) + 0x05050505; const u32 hmask = (buf & 0x1f1f1f1f) + 0x05050505;
const uint32_t lmask = (buf & 0x1f1f1f1f) + 0x1f1f1f1f; const u32 lmask = (buf & 0x1f1f1f1f) + 0x1f1f1f1f;
return rmask & ~hmask & lmask; return rmask & ~hmask & lmask;
} }
static void truncate_right (uint32_t w0[4], uint32_t w1[4], const uint len) static void truncate_right (u32 w0[4], u32 w1[4], const u32 len)
{ {
const uint tmp = (1 << ((len % 4) * 8)) - 1; const u32 tmp = (1 << ((len % 4) * 8)) - 1;
switch (len / 4) switch (len / 4)
{ {
@ -72,9 +72,9 @@ static void truncate_right (uint32_t w0[4], uint32_t w1[4], const uint len)
} }
} }
static void truncate_left (uint32_t w0[4], uint32_t w1[4], const uint len) static void truncate_left (u32 w0[4], u32 w1[4], const u32 len)
{ {
const uint tmp = ~((1 << ((len % 4) * 8)) - 1); const u32 tmp = ~((1 << ((len % 4) * 8)) - 1);
switch (len / 4) switch (len / 4)
{ {
@ -125,7 +125,7 @@ static void truncate_left (uint32_t w0[4], uint32_t w1[4], const uint len)
} }
} }
static void lshift_block (const uint32_t in0[4], const uint32_t in1[4], uint32_t out0[4], uint32_t out1[4]) static void lshift_block (const u32 in0[4], const u32 in1[4], u32 out0[4], u32 out1[4])
{ {
out0[0] = in0[0] >> 8 | in0[1] << 24; out0[0] = in0[0] >> 8 | in0[1] << 24;
out0[1] = in0[1] >> 8 | in0[2] << 24; out0[1] = in0[1] >> 8 | in0[2] << 24;
@ -137,7 +137,7 @@ static void lshift_block (const uint32_t in0[4], const uint32_t in1[4], uint32_t
out1[3] = in1[3] >> 8; out1[3] = in1[3] >> 8;
} }
static void rshift_block (const uint32_t in0[4], const uint32_t in1[4], uint32_t out0[4], uint32_t out1[4]) static void rshift_block (const u32 in0[4], const u32 in1[4], u32 out0[4], u32 out1[4])
{ {
out1[3] = in1[3] << 8 | in1[2] >> 24; out1[3] = in1[3] << 8 | in1[2] >> 24;
out1[2] = in1[2] << 8 | in1[1] >> 24; out1[2] = in1[2] << 8 | in1[1] >> 24;
@ -149,7 +149,7 @@ static void rshift_block (const uint32_t in0[4], const uint32_t in1[4], uint32_t
out0[0] = in0[0] << 8; out0[0] = in0[0] << 8;
} }
static void rshift_block_N (const uint32_t in0[4], const uint32_t in1[4], uint32_t out0[4], uint32_t out1[4], const uint num) static void rshift_block_N (const u32 in0[4], const u32 in1[4], u32 out0[4], u32 out1[4], const u32 num)
{ {
switch (num) switch (num)
{ {
@ -444,7 +444,7 @@ static void rshift_block_N (const uint32_t in0[4], const uint32_t in1[4], uint32
} }
} }
static void lshift_block_N (const uint32_t in0[4], const uint32_t in1[4], uint32_t out0[4], uint32_t out1[4], const uint num) static void lshift_block_N (const u32 in0[4], const u32 in1[4], u32 out0[4], u32 out1[4], const u32 num)
{ {
switch (num) switch (num)
{ {
@ -740,9 +740,9 @@ static void lshift_block_N (const uint32_t in0[4], const uint32_t in1[4], uint32
} }
} }
static void append_block1 (const uint offset, uint32_t dst0[4], uint32_t dst1[4], const uint32_t src_r0) static void append_block1 (const u32 offset, u32 dst0[4], u32 dst1[4], const u32 src_r0)
{ {
uint32_t tmp[2]; u32 tmp[2];
switch (offset & 3) switch (offset & 3)
{ {
@ -788,7 +788,7 @@ static void append_block1 (const uint offset, uint32_t dst0[4], uint32_t dst1[4]
} }
} }
static void append_block8 (const uint offset, uint32_t dst0[4], uint32_t dst1[4], const uint32_t src_l0[4], const uint32_t src_l1[4], const uint32_t src_r0[4], const uint32_t src_r1[4]) static void append_block8 (const u32 offset, u32 dst0[4], u32 dst1[4], const u32 src_l0[4], const u32 src_l1[4], const u32 src_r0[4], const u32 src_r1[4])
{ {
switch (offset) switch (offset)
{ {
@ -1034,12 +1034,12 @@ static void append_block8 (const uint offset, uint32_t dst0[4], uint32_t dst1[4]
} }
} }
static void reverse_block (uint32_t in0[4], uint32_t in1[4], uint32_t out0[4], uint32_t out1[4], const uint len) static void reverse_block (u32 in0[4], u32 in1[4], u32 out0[4], u32 out1[4], const u32 len)
{ {
rshift_block_N (in0, in1, out0, out1, 32 - len); rshift_block_N (in0, in1, out0, out1, 32 - len);
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
tib40[0] = out1[3]; tib40[0] = out1[3];
tib40[1] = out1[2]; tib40[1] = out1[2];
@ -1060,7 +1060,7 @@ static void reverse_block (uint32_t in0[4], uint32_t in1[4], uint32_t out0[4], u
out1[3] = swap_workaround (tib41[3]); out1[3] = swap_workaround (tib41[3]);
} }
static uint rule_op_mangle_lrest (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_lrest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
buf0[0] |= (generate_cmask (buf0[0])); buf0[0] |= (generate_cmask (buf0[0]));
buf0[1] |= (generate_cmask (buf0[1])); buf0[1] |= (generate_cmask (buf0[1]));
@ -1074,7 +1074,7 @@ static uint rule_op_mangle_lrest (const uint p0, const uint p1, uint32_t buf0[4]
return in_len; return in_len;
} }
static uint rule_op_mangle_urest (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_urest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
buf0[0] &= ~(generate_cmask (buf0[0])); buf0[0] &= ~(generate_cmask (buf0[0]));
buf0[1] &= ~(generate_cmask (buf0[1])); buf0[1] &= ~(generate_cmask (buf0[1]));
@ -1088,7 +1088,7 @@ static uint rule_op_mangle_urest (const uint p0, const uint p1, uint32_t buf0[4]
return in_len; return in_len;
} }
static uint rule_op_mangle_lrest_ufirst (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_lrest_ufirst (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
rule_op_mangle_lrest (p0, p1, buf0, buf1, in_len); rule_op_mangle_lrest (p0, p1, buf0, buf1, in_len);
@ -1097,7 +1097,7 @@ static uint rule_op_mangle_lrest_ufirst (const uint p0, const uint p1, uint32_t
return in_len; return in_len;
} }
static uint rule_op_mangle_urest_lfirst (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_urest_lfirst (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
rule_op_mangle_urest (p0, p1, buf0, buf1, in_len); rule_op_mangle_urest (p0, p1, buf0, buf1, in_len);
@ -1106,7 +1106,7 @@ static uint rule_op_mangle_urest_lfirst (const uint p0, const uint p1, uint32_t
return in_len; return in_len;
} }
static uint rule_op_mangle_trest (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_trest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
buf0[0] ^= (generate_cmask (buf0[0])); buf0[0] ^= (generate_cmask (buf0[0]));
buf0[1] ^= (generate_cmask (buf0[1])); buf0[1] ^= (generate_cmask (buf0[1]));
@ -1120,11 +1120,11 @@ static uint rule_op_mangle_trest (const uint p0, const uint p1, uint32_t buf0[4]
return in_len; return in_len;
} }
static uint rule_op_mangle_toggle_at (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_toggle_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
const uint tmp = 0x20u << ((p0 & 3) * 8); const u32 tmp = 0x20u << ((p0 & 3) * 8);
switch (p0 / 4) switch (p0 / 4)
{ {
@ -1141,21 +1141,21 @@ static uint rule_op_mangle_toggle_at (const uint p0, const uint p1, uint32_t buf
return in_len; return in_len;
} }
static uint rule_op_mangle_reverse (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_reverse (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
reverse_block (buf0, buf1, buf0, buf1, in_len); reverse_block (buf0, buf1, buf0, buf1, in_len);
return in_len; return in_len;
} }
static uint rule_op_mangle_dupeword (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupeword (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ((in_len + in_len) >= 32) return (in_len); if ((in_len + in_len) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
tib40[0] = buf0[0]; tib40[0] = buf0[0];
tib40[1] = buf0[1]; tib40[1] = buf0[1];
@ -1173,14 +1173,14 @@ static uint rule_op_mangle_dupeword (const uint p0, const uint p1, uint32_t buf0
return out_len; return out_len;
} }
static uint rule_op_mangle_dupeword_times (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupeword_times (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (((in_len * p0) + in_len) >= 32) return (in_len); if (((in_len * p0) + in_len) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
tib40[0] = buf0[0]; tib40[0] = buf0[0];
tib40[1] = buf0[1]; tib40[1] = buf0[1];
@ -1191,7 +1191,7 @@ static uint rule_op_mangle_dupeword_times (const uint p0, const uint p1, uint32_
tib41[2] = buf1[2]; tib41[2] = buf1[2];
tib41[3] = buf1[3]; tib41[3] = buf1[3];
for (uint i = 0; i < p0; i++) for (u32 i = 0; i < p0; i++)
{ {
append_block8 (out_len, buf0, buf1, buf0, buf1, tib40, tib41); append_block8 (out_len, buf0, buf1, buf0, buf1, tib40, tib41);
@ -1201,14 +1201,14 @@ static uint rule_op_mangle_dupeword_times (const uint p0, const uint p1, uint32_
return out_len; return out_len;
} }
static uint rule_op_mangle_reflect (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_reflect (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ((in_len + in_len) >= 32) return (in_len); if ((in_len + in_len) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
reverse_block (buf0, buf1, tib40, tib41, out_len); reverse_block (buf0, buf1, tib40, tib41, out_len);
@ -1219,11 +1219,11 @@ static uint rule_op_mangle_reflect (const uint p0, const uint p1, uint32_t buf0[
return out_len; return out_len;
} }
static uint rule_op_mangle_append (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_append (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ((in_len + 1) >= 32) return (in_len); if ((in_len + 1) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
append_block1 (out_len, buf0, buf1, p0); append_block1 (out_len, buf0, buf1, p0);
@ -1232,11 +1232,11 @@ static uint rule_op_mangle_append (const uint p0, const uint p1, uint32_t buf0[4
return out_len; return out_len;
} }
static uint rule_op_mangle_prepend (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_prepend (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ((in_len + 1) >= 32) return (in_len); if ((in_len + 1) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
rshift_block (buf0, buf1, buf0, buf1); rshift_block (buf0, buf1, buf0, buf1);
@ -1247,15 +1247,15 @@ static uint rule_op_mangle_prepend (const uint p0, const uint p1, uint32_t buf0[
return out_len; return out_len;
} }
static uint rule_op_mangle_rotate_left (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_rotate_left (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (in_len == 0) return (in_len); if (in_len == 0) return (in_len);
const uint in_len1 = in_len - 1; const u32 in_len1 = in_len - 1;
const uint sh = (in_len1 & 3) * 8; const u32 sh = (in_len1 & 3) * 8;
const uint32_t tmp = (buf0[0] & 0xff) << sh; const u32 tmp = (buf0[0] & 0xff) << sh;
lshift_block (buf0, buf1, buf0, buf1); lshift_block (buf0, buf1, buf0, buf1);
@ -1274,15 +1274,15 @@ static uint rule_op_mangle_rotate_left (const uint p0, const uint p1, uint32_t b
return in_len; return in_len;
} }
static uint rule_op_mangle_rotate_right (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_rotate_right (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (in_len == 0) return (in_len); if (in_len == 0) return (in_len);
const uint in_len1 = in_len - 1; const u32 in_len1 = in_len - 1;
const uint sh = (in_len1 & 3) * 8; const u32 sh = (in_len1 & 3) * 8;
uint32_t tmp = 0; u32 tmp = 0;
switch (in_len1 / 4) switch (in_len1 / 4)
{ {
@ -1305,24 +1305,24 @@ static uint rule_op_mangle_rotate_right (const uint p0, const uint p1, uint32_t
return in_len; return in_len;
} }
static uint rule_op_mangle_delete_first (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_delete_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (in_len == 0) return (in_len); if (in_len == 0) return (in_len);
const uint in_len1 = in_len - 1; const u32 in_len1 = in_len - 1;
lshift_block (buf0, buf1, buf0, buf1); lshift_block (buf0, buf1, buf0, buf1);
return in_len1; return in_len1;
} }
static uint rule_op_mangle_delete_last (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_delete_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (in_len == 0) return (in_len); if (in_len == 0) return (in_len);
const uint in_len1 = in_len - 1; const u32 in_len1 = in_len - 1;
const uint tmp = (1 << ((in_len1 & 3) * 8)) - 1; const u32 tmp = (1 << ((in_len1 & 3) * 8)) - 1;
switch (in_len1 / 4) switch (in_len1 / 4)
{ {
@ -1339,19 +1339,19 @@ static uint rule_op_mangle_delete_last (const uint p0, const uint p1, uint32_t b
return in_len1; return in_len1;
} }
static uint rule_op_mangle_delete_at (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_delete_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
lshift_block (buf0, buf1, tib40, tib41); lshift_block (buf0, buf1, tib40, tib41);
const uint ml = (1 << ((p0 & 3) * 8)) - 1; const u32 ml = (1 << ((p0 & 3) * 8)) - 1;
const uint mr = ~ml; const u32 mr = ~ml;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -1414,13 +1414,13 @@ static uint rule_op_mangle_delete_at (const uint p0, const uint p1, uint32_t buf
return out_len; return out_len;
} }
static uint rule_op_mangle_extract (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_extract (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
if ((p0 + p1) > in_len) return (in_len); if ((p0 + p1) > in_len) return (in_len);
uint out_len = p1; u32 out_len = p1;
lshift_block_N (buf0, buf1, buf0, buf1, p0); lshift_block_N (buf0, buf1, buf0, buf1, p0);
@ -1429,16 +1429,16 @@ static uint rule_op_mangle_extract (const uint p0, const uint p1, uint32_t buf0[
return out_len; return out_len;
} }
static uint rule_op_mangle_omit (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_omit (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
if ((p0 + p1) > in_len) return (in_len); if ((p0 + p1) > in_len) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
tib40[0] = 0; tib40[0] = 0;
tib40[1] = 0; tib40[1] = 0;
@ -1451,8 +1451,8 @@ static uint rule_op_mangle_omit (const uint p0, const uint p1, uint32_t buf0[4],
lshift_block_N (buf0, buf1, tib40, tib41, p1); lshift_block_N (buf0, buf1, tib40, tib41, p1);
const uint ml = (1 << ((p0 & 3) * 8)) - 1; const u32 ml = (1 << ((p0 & 3) * 8)) - 1;
const uint mr = ~ml; const u32 mr = ~ml;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -1515,24 +1515,24 @@ static uint rule_op_mangle_omit (const uint p0, const uint p1, uint32_t buf0[4],
return out_len; return out_len;
} }
static uint rule_op_mangle_insert (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_insert (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 > in_len) return (in_len); if (p0 > in_len) return (in_len);
if ((in_len + 1) >= 32) return (in_len); if ((in_len + 1) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
rshift_block (buf0, buf1, tib40, tib41); rshift_block (buf0, buf1, tib40, tib41);
const uint p1n = p1 << ((p0 & 3) * 8); const u32 p1n = p1 << ((p0 & 3) * 8);
const uint ml = (1 << ((p0 & 3) * 8)) - 1; const u32 ml = (1 << ((p0 & 3) * 8)) - 1;
const uint mr = 0xffffff00 << ((p0 & 3) * 8); const u32 mr = 0xffffff00 << ((p0 & 3) * 8);
switch (p0 / 4) switch (p0 / 4)
{ {
@ -1587,13 +1587,13 @@ static uint rule_op_mangle_insert (const uint p0, const uint p1, uint32_t buf0[4
return out_len; return out_len;
} }
static uint rule_op_mangle_overstrike (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_overstrike (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
const uint p1n = p1 << ((p0 & 3) * 8); const u32 p1n = p1 << ((p0 & 3) * 8);
const uint m = ~(0xffu << ((p0 & 3) * 8)); const u32 m = ~(0xffu << ((p0 & 3) * 8));
switch (p0 / 4) switch (p0 / 4)
{ {
@ -1610,7 +1610,7 @@ static uint rule_op_mangle_overstrike (const uint p0, const uint p1, uint32_t bu
return in_len; return in_len;
} }
static uint rule_op_mangle_truncate_at (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_truncate_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
@ -1619,9 +1619,9 @@ static uint rule_op_mangle_truncate_at (const uint p0, const uint p1, uint32_t b
return p0; return p0;
} }
static uint rule_op_mangle_replace (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_replace (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
for (uint i = 0; i < in_len; i++) for (u32 i = 0; i < in_len; i++)
{ {
switch (i) switch (i)
{ {
@ -1663,26 +1663,26 @@ static uint rule_op_mangle_replace (const uint p0, const uint p1, uint32_t buf0[
return in_len; return in_len;
} }
static uint rule_op_mangle_purgechar (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_purgechar (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
// TODO // TODO
return in_len; return in_len;
} }
static uint rule_op_mangle_togglecase_rec (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_togglecase_rec (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
// TODO // TODO
return in_len; return in_len;
} }
static uint rule_op_mangle_dupechar_first (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupechar_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ( in_len == 0) return (in_len); if ( in_len == 0) return (in_len);
if ((in_len + p0) >= 32) return (in_len); if ((in_len + p0) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
const uint32_t tmp = buf0[0] & 0xFF; const u32 tmp = buf0[0] & 0xFF;
rshift_block_N (buf0, buf1, buf0, buf1, p0); rshift_block_N (buf0, buf1, buf0, buf1, p0);
@ -1862,16 +1862,16 @@ static uint rule_op_mangle_dupechar_first (const uint p0, const uint p1, uint32_
return out_len; return out_len;
} }
static uint rule_op_mangle_dupechar_last (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupechar_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ( in_len == 0) return (in_len); if ( in_len == 0) return (in_len);
if ((in_len + p0) >= 32) return (in_len); if ((in_len + p0) >= 32) return (in_len);
const uint in_len1 = in_len - 1; const u32 in_len1 = in_len - 1;
const uint sh = (in_len1 & 3) * 8; const u32 sh = (in_len1 & 3) * 8;
uint32_t tmp = 0; u32 tmp = 0;
switch (in_len1 / 4) switch (in_len1 / 4)
{ {
@ -1885,9 +1885,9 @@ static uint rule_op_mangle_dupechar_last (const uint p0, const uint p1, uint32_t
case 7: tmp = (buf1[3] >> sh) & 0xff; break; case 7: tmp = (buf1[3] >> sh) & 0xff; break;
} }
uint out_len = in_len; u32 out_len = in_len;
for (uint i = 0; i < p0; i++) for (u32 i = 0; i < p0; i++)
{ {
append_block1 (out_len, buf0, buf1, tmp); append_block1 (out_len, buf0, buf1, tmp);
@ -1897,15 +1897,15 @@ static uint rule_op_mangle_dupechar_last (const uint p0, const uint p1, uint32_t
return out_len; return out_len;
} }
static uint rule_op_mangle_dupechar_all (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupechar_all (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ( in_len == 0) return (in_len); if ( in_len == 0) return (in_len);
if ((in_len + in_len) >= 32) return (in_len); if ((in_len + in_len) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
tib40[0] = ((buf0[0] & 0x000000FF) << 0) | ((buf0[0] & 0x0000FF00) << 8); tib40[0] = ((buf0[0] & 0x000000FF) << 0) | ((buf0[0] & 0x0000FF00) << 8);
tib40[1] = ((buf0[0] & 0x00FF0000) >> 16) | ((buf0[0] & 0xFF000000) >> 8); tib40[1] = ((buf0[0] & 0x00FF0000) >> 16) | ((buf0[0] & 0xFF000000) >> 8);
@ -1930,7 +1930,7 @@ static uint rule_op_mangle_dupechar_all (const uint p0, const uint p1, uint32_t
return out_len; return out_len;
} }
static uint rule_op_mangle_switch_first (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_switch_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (in_len < 2) return (in_len); if (in_len < 2) return (in_len);
@ -1939,7 +1939,7 @@ static uint rule_op_mangle_switch_first (const uint p0, const uint p1, uint32_t
return in_len; return in_len;
} }
static uint rule_op_mangle_switch_last (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_switch_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (in_len < 2) return (in_len); if (in_len < 2) return (in_len);
@ -2024,13 +2024,13 @@ static uint rule_op_mangle_switch_last (const uint p0, const uint p1, uint32_t b
return in_len; return in_len;
} }
static uint rule_op_mangle_switch_at (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_switch_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
if (p1 >= in_len) return (in_len); if (p1 >= in_len) return (in_len);
uint32_t tmp0 = 0; u32 tmp0 = 0;
uint32_t tmp1 = 0; u32 tmp1 = 0;
switch (p0) switch (p0)
{ {
@ -2271,12 +2271,12 @@ static uint rule_op_mangle_switch_at (const uint p0, const uint p1, uint32_t buf
return in_len; return in_len;
} }
static uint rule_op_mangle_chr_shiftl (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_chr_shiftl (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
const uint mr = 0xffu << ((p0 & 3) * 8); const u32 mr = 0xffu << ((p0 & 3) * 8);
const uint ml = ~mr; const u32 ml = ~mr;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -2293,12 +2293,12 @@ static uint rule_op_mangle_chr_shiftl (const uint p0, const uint p1, uint32_t bu
return in_len; return in_len;
} }
static uint rule_op_mangle_chr_shiftr (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_chr_shiftr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
const uint mr = 0xffu << ((p0 & 3) * 8); const u32 mr = 0xffu << ((p0 & 3) * 8);
const uint ml = ~mr; const u32 ml = ~mr;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -2315,14 +2315,14 @@ static uint rule_op_mangle_chr_shiftr (const uint p0, const uint p1, uint32_t bu
return in_len; return in_len;
} }
static uint rule_op_mangle_chr_incr (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_chr_incr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
const uint mr = 0xffu << ((p0 & 3) * 8); const u32 mr = 0xffu << ((p0 & 3) * 8);
const uint ml = ~mr; const u32 ml = ~mr;
const uint n = 0x01010101 & mr; const u32 n = 0x01010101 & mr;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -2339,14 +2339,14 @@ static uint rule_op_mangle_chr_incr (const uint p0, const uint p1, uint32_t buf0
return in_len; return in_len;
} }
static uint rule_op_mangle_chr_decr (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_chr_decr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
const uint mr = 0xffu << ((p0 & 3) * 8); const u32 mr = 0xffu << ((p0 & 3) * 8);
const uint ml = ~mr; const u32 ml = ~mr;
const uint n = 0x01010101 & mr; const u32 n = 0x01010101 & mr;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -2363,17 +2363,17 @@ static uint rule_op_mangle_chr_decr (const uint p0, const uint p1, uint32_t buf0
return in_len; return in_len;
} }
static uint rule_op_mangle_replace_np1 (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_replace_np1 (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if ((p0 + 1) >= in_len) return (in_len); if ((p0 + 1) >= in_len) return (in_len);
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
lshift_block (buf0, buf1, tib40, tib41); lshift_block (buf0, buf1, tib40, tib41);
const uint mr = 0xffu << ((p0 & 3) * 8); const u32 mr = 0xffu << ((p0 & 3) * 8);
const uint ml = ~mr; const u32 ml = ~mr;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -2390,19 +2390,19 @@ static uint rule_op_mangle_replace_np1 (const uint p0, const uint p1, uint32_t b
return in_len; return in_len;
} }
static uint rule_op_mangle_replace_nm1 (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_replace_nm1 (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 == 0) return (in_len); if (p0 == 0) return (in_len);
if (p0 >= in_len) return (in_len); if (p0 >= in_len) return (in_len);
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
rshift_block (buf0, buf1, tib40, tib41); rshift_block (buf0, buf1, tib40, tib41);
const uint mr = 0xffu << ((p0 & 3) * 8); const u32 mr = 0xffu << ((p0 & 3) * 8);
const uint ml = ~mr; const u32 ml = ~mr;
switch (p0 / 4) switch (p0 / 4)
{ {
@ -2419,16 +2419,16 @@ static uint rule_op_mangle_replace_nm1 (const uint p0, const uint p1, uint32_t b
return in_len; return in_len;
} }
static uint rule_op_mangle_dupeblock_first (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupeblock_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 > in_len) return (in_len); if (p0 > in_len) return (in_len);
if ((in_len + p0) >= 32) return (in_len); if ((in_len + p0) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
tib40[0] = buf0[0]; tib40[0] = buf0[0];
tib40[1] = buf0[1]; tib40[1] = buf0[1];
@ -2457,16 +2457,16 @@ static uint rule_op_mangle_dupeblock_first (const uint p0, const uint p1, uint32
return out_len; return out_len;
} }
static uint rule_op_mangle_dupeblock_last (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_dupeblock_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
if (p0 > in_len) return (in_len); if (p0 > in_len) return (in_len);
if ((in_len + p0) >= 32) return (in_len); if ((in_len + p0) >= 32) return (in_len);
uint out_len = in_len; u32 out_len = in_len;
uint32_t tib40[4]; u32 tib40[4];
uint32_t tib41[4]; u32 tib41[4];
rshift_block_N (buf0, buf1, tib40, tib41, p0); rshift_block_N (buf0, buf1, tib40, tib41, p0);
@ -2486,7 +2486,7 @@ static uint rule_op_mangle_dupeblock_last (const uint p0, const uint p1, uint32_
return out_len; return out_len;
} }
static uint rule_op_mangle_title (const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) static u32 rule_op_mangle_title (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
buf0[0] |= (generate_cmask (buf0[0])); buf0[0] |= (generate_cmask (buf0[0]));
buf0[1] |= (generate_cmask (buf0[1])); buf0[1] |= (generate_cmask (buf0[1]));
@ -2499,10 +2499,10 @@ static uint rule_op_mangle_title (const uint p0, const uint p1, uint32_t buf0[4]
buf0[0] &= ~(0x00000020 & generate_cmask (buf0[0])); buf0[0] &= ~(0x00000020 & generate_cmask (buf0[0]));
for (uint i = 0; i < in_len; i++) for (u32 i = 0; i < in_len; i++)
{ {
uint32_t tmp0 = 0; u32 tmp0 = 0;
uint32_t tmp1 = 0; u32 tmp1 = 0;
switch (i) switch (i)
{ {
@ -2607,9 +2607,9 @@ static uint rule_op_mangle_title (const uint p0, const uint p1, uint32_t buf0[4]
return in_len; return in_len;
} }
uint apply_rule (const uint name, const uint p0, const uint p1, uint32_t buf0[4], uint32_t buf1[4], const uint in_len) u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
{ {
uint out_len = in_len; u32 out_len = in_len;
switch (name) switch (name)
{ {
@ -2658,15 +2658,17 @@ uint apply_rule (const uint name, const uint p0, const uint p1, uint32_t buf0[4]
return out_len; return out_len;
} }
uint apply_rules (uint *cmds, uint32_t buf0[4], uint32_t buf1[4], const uint len) u32 apply_rules (u32 *cmds, u32 buf0[4], u32 buf1[4], const u32 len)
{ {
uint out_len = len; u32 out_len = len;
for (; *cmds; cmds++) for (u32 i = 0; cmds[i] != 0; i++)
{ {
const uint name = (*cmds >> 0) & 0xff; const u32 cmd = cmds[i];
const uint p0 = (*cmds >> 8) & 0xff;
const uint p1 = (*cmds >> 16) & 0xff; const u32 name = (cmd >> 0) & 0xff;
const u32 p0 = (cmd >> 8) & 0xff;
const u32 p1 = (cmd >> 16) & 0xff;
out_len = apply_rule (name, p0, p1, buf0, buf1, out_len); out_len = apply_rule (name, p0, p1, buf0, buf1, out_len);
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,12 +3,12 @@
## License.....: MIT ## License.....: MIT
## ##
GCC := /usr/bin/x86_64-linux-gnu-gcc-4.6 GCC := gcc
ROOT := ../../ ROOT := ../..
CFLAGS := -O2 -s -ansi -pipe -W -Wall -std=c99 -I$(ROOT)include/ CFLAGS := -O2 -s -pipe -W -Wall -std=c99 -I$(ROOT)/include/
LIBS := LIBS :=
TARGET := gpu2cpu_rule_test TARGET := kernel2cpu_rule_test
INCLUDE := $(ROOT)src/rp_gpu_on_cpu.c cpu_rules.c INCLUDE := $(ROOT)/src/rp_kernel_on_cpu.c cpu_rules.c
all: ${TARGET}.c all: ${TARGET}.c
${GCC} ${CFLAGS} ${INCLUDE} $< -o ${TARGET}.bin ${LIBS} ${GCC} ${CFLAGS} ${INCLUDE} $< -o ${TARGET}.bin ${LIBS}

View File

@ -25,7 +25,7 @@ extern int max_len;
#define GET_P0_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 8) & 0xff) #define GET_P0_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 8) & 0xff)
#define GET_P1_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 16) & 0xff) #define GET_P1_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 16) & 0xff)
void gen_cmask (const uint8_t *word, uint8_t *cmask, const uint len) void gen_cmask (const u8 *word, u8 *cmask, const uint len)
{ {
uint i; uint i;
@ -420,7 +420,7 @@ int mangle_switch_at (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2)
return (arr_len); return (arr_len);
} }
int mangle_chr_shiftl (uint8_t arr[BLOCK_SIZE], int arr_len, int upos) int mangle_chr_shiftl (u8 arr[BLOCK_SIZE], int arr_len, int upos)
{ {
if (upos >= arr_len) return (arr_len); if (upos >= arr_len) return (arr_len);
@ -429,7 +429,7 @@ int mangle_chr_shiftl (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
return (arr_len); return (arr_len);
} }
int mangle_chr_shiftr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos) int mangle_chr_shiftr (u8 arr[BLOCK_SIZE], int arr_len, int upos)
{ {
if (upos >= arr_len) return (arr_len); if (upos >= arr_len) return (arr_len);
@ -438,7 +438,7 @@ int mangle_chr_shiftr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
return (arr_len); return (arr_len);
} }
int mangle_chr_incr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos) int mangle_chr_incr (u8 arr[BLOCK_SIZE], int arr_len, int upos)
{ {
if (upos >= arr_len) return (arr_len); if (upos >= arr_len) return (arr_len);
@ -447,7 +447,7 @@ int mangle_chr_incr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
return (arr_len); return (arr_len);
} }
int mangle_chr_decr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos) int mangle_chr_decr (u8 arr[BLOCK_SIZE], int arr_len, int upos)
{ {
if (upos >= arr_len) return (arr_len); if (upos >= arr_len) return (arr_len);
@ -486,20 +486,20 @@ int mangle_title (char arr[BLOCK_SIZE], int arr_len)
return (arr_len); return (arr_len);
} }
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], uint32_t rp_gen_func_min, uint32_t rp_gen_func_max) int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max)
{ {
uint32_t rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max); u32 rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
uint32_t j; u32 j;
uint32_t rule_pos = 0; u32 rule_pos = 0;
for (j = 0; j < rp_gen_num; j++) for (j = 0; j < rp_gen_num; j++)
{ {
uint32_t r = 0; u32 r = 0;
uint32_t p1 = 0; u32 p1 = 0;
uint32_t p2 = 0; u32 p2 = 0;
uint32_t p3 = 0; u32 p3 = 0;
switch ((char) get_random_num (0, 9)) switch ((char) get_random_num (0, 9))
{ {
@ -795,25 +795,25 @@ int apply_rule_cpu (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, c
case RULE_OP_MANGLE_CHR_SHIFTL: case RULE_OP_MANGLE_CHR_SHIFTL:
NEXT_RULEPOS (rule_pos); NEXT_RULEPOS (rule_pos);
NEXT_RPTOI (rule, rule_pos, upos); NEXT_RPTOI (rule, rule_pos, upos);
mangle_chr_shiftl ((uint8_t *) out, out_len, upos); mangle_chr_shiftl ((u8 *) out, out_len, upos);
break; break;
case RULE_OP_MANGLE_CHR_SHIFTR: case RULE_OP_MANGLE_CHR_SHIFTR:
NEXT_RULEPOS (rule_pos); NEXT_RULEPOS (rule_pos);
NEXT_RPTOI (rule, rule_pos, upos); NEXT_RPTOI (rule, rule_pos, upos);
mangle_chr_shiftr ((uint8_t *) out, out_len, upos); mangle_chr_shiftr ((u8 *) out, out_len, upos);
break; break;
case RULE_OP_MANGLE_CHR_INCR: case RULE_OP_MANGLE_CHR_INCR:
NEXT_RULEPOS (rule_pos); NEXT_RULEPOS (rule_pos);
NEXT_RPTOI (rule, rule_pos, upos); NEXT_RPTOI (rule, rule_pos, upos);
mangle_chr_incr ((uint8_t *) out, out_len, upos); mangle_chr_incr ((u8 *) out, out_len, upos);
break; break;
case RULE_OP_MANGLE_CHR_DECR: case RULE_OP_MANGLE_CHR_DECR:
NEXT_RULEPOS (rule_pos); NEXT_RULEPOS (rule_pos);
NEXT_RPTOI (rule, rule_pos, upos); NEXT_RPTOI (rule, rule_pos, upos);
mangle_chr_decr ((uint8_t *) out, out_len, upos); mangle_chr_decr ((u8 *) out, out_len, upos);
break; break;
case RULE_OP_MANGLE_REPLACE_NP1: case RULE_OP_MANGLE_REPLACE_NP1:
@ -929,7 +929,7 @@ int apply_rule_cpu (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, c
return (out_len); return (out_len);
} }
int cpu_rule_to_gpu_rule (char rule_buf[BUFSIZ], uint rule_len, gpu_rule_t *rule) int cpu_rule_to_kernel_rule (char rule_buf[BUFSIZ], uint rule_len, kernel_rule_t *rule)
{ {
uint rule_pos; uint rule_pos;
uint rule_cnt; uint rule_cnt;

View File

@ -6,10 +6,7 @@
#ifndef CPU_RULES_H #ifndef CPU_RULES_H
#define CPU_RULES_H #define CPU_RULES_H
#include <stdio.h> #include <common.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include "rp_cpu.h" #include "rp_cpu.h"
#define BLOCK_SIZE 64 #define BLOCK_SIZE 64
@ -17,13 +14,11 @@
#define RP_RULE_BUFSIZ 0x100 #define RP_RULE_BUFSIZ 0x100
#define RULE_RC_SYNTAX_ERROR -1 #define RULE_RC_SYNTAX_ERROR -1
typedef unsigned int uint;
typedef struct typedef struct
{ {
uint cmds[256]; uint cmds[256];
} gpu_rule_t; } kernel_rule_t;
int mangle_lrest (char arr[BLOCK_SIZE], int arr_len); int mangle_lrest (char arr[BLOCK_SIZE], int arr_len);
int mangle_urest (char arr[BLOCK_SIZE], int arr_len); int mangle_urest (char arr[BLOCK_SIZE], int arr_len);
@ -51,26 +46,25 @@ int mangle_dupechar_at (char arr[BLOCK_SIZE], int arr_len, int upos, int ulen);
int mangle_dupechar (char arr[BLOCK_SIZE], int arr_len); int mangle_dupechar (char arr[BLOCK_SIZE], int arr_len);
int mangle_switch_at_check (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2); int mangle_switch_at_check (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2);
int mangle_switch_at (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2); int mangle_switch_at (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2);
int mangle_chr_shiftl (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_shiftl (u8 arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_chr_shiftr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_shiftr (u8 arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_chr_incr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_incr (u8 arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_chr_decr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos); int mangle_chr_decr (u8 arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_title (char arr[BLOCK_SIZE], int arr_len); int mangle_title (char arr[BLOCK_SIZE], int arr_len);
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], uint32_t rp_gen_func_min, uint32_t rp_gen_func_max); int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max);
int apply_rule_cpu (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]); int apply_rule_cpu (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]);
int cpu_rule_to_gpu_rule (char rule_buf[BUFSIZ], uint rule_len, gpu_rule_t *rule); int cpu_rule_to_kernel_rule (char rule_buf[BUFSIZ], uint rule_len, kernel_rule_t *rule);
typedef int bool;
bool class_num (char c); bool class_num (char c);
bool class_lower (char c); bool class_lower (char c);
bool class_upper (char c); bool class_upper (char c);
bool class_alpha (char c); bool class_alpha (char c);
char conv_ctoi (char c); char conv_ctoi (char c);
char conv_itoc (char c); char conv_itoc (char c);
uint get_random_num (uint min, uint max); uint get_random_num (uint min, uint max);
void gen_cmask (const uint8_t *word, uint8_t *cmask, const uint len); void gen_cmask (const u8 *word, u8 *cmask, const uint len);
#endif #endif

View File

@ -3,10 +3,7 @@
* License.....: MIT * License.....: MIT
*/ */
#include <stdlib.h> #include <common.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#define RULES_PER_PLAIN_MIN 1 #define RULES_PER_PLAIN_MIN 1
#define RULES_PER_PLAIN_MAX 99 #define RULES_PER_PLAIN_MAX 99
@ -18,13 +15,13 @@
int max_len = 0; int max_len = 0;
#include "cpu_rules.h" #include "cpu_rules.h"
#include "rp_gpu_on_cpu.h" #include "rp_kernel_on_cpu.h"
void print_plain (char *plain, int plain_len) void print_plain (char *plain, int plain_len)
{ {
int need_hexifly = 0; int need_hexifly = 0;
unsigned char *plain_ptr = (unsigned char*) plain; u8 *plain_ptr = (u8*) plain;
int k; int k;
@ -124,11 +121,11 @@ int main (int argc, char **argv)
rule_len = strlen (rule_buf); rule_len = strlen (rule_buf);
} }
gpu_rule_t gpu_rule_buf; kernel_rule_t kernel_rule_buf;
memset (&gpu_rule_buf, 0, sizeof (gpu_rule_t)); memset (&kernel_rule_buf, 0, sizeof (kernel_rule_t));
if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rule_buf) == -1) continue; if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rule_buf) == -1) continue;
// cpu // cpu
char rule_buf_cpu[BLOCK_SIZE]; char rule_buf_cpu[BLOCK_SIZE];
@ -142,15 +139,15 @@ int main (int argc, char **argv)
if (max_len >= 32) continue; if (max_len >= 32) continue;
// gpu // gpu
char rule_buf_gpu[BLOCK_SIZE]; char rule_buf_kernel[BLOCK_SIZE];
memset (rule_buf_gpu, 0, sizeof (rule_buf_gpu)); memset (rule_buf_kernel, 0, sizeof (rule_buf_kernel));
memcpy (rule_buf_gpu, line_buf, line_len); memcpy (rule_buf_kernel, line_buf, line_len);
uint32_t *plain_ptr = (uint32_t *) rule_buf_gpu; u32 *plain_ptr = (u32 *) rule_buf_kernel;
int out_len_gpu = apply_rules (gpu_rule_buf.cmds, &plain_ptr[0], &plain_ptr[4], line_len); int out_len_kernel = apply_rules (kernel_rule_buf.cmds, &plain_ptr[0], &plain_ptr[4], line_len);
/* /*
* compare * compare
@ -160,9 +157,9 @@ int main (int argc, char **argv)
{ {
int failed = 1; int failed = 1;
if (out_len_gpu == out_len_cpu) if (out_len_kernel == out_len_cpu)
{ {
if (memcmp (rule_buf_gpu, rule_buf_cpu, out_len_gpu) == 0) if (memcmp (rule_buf_kernel, rule_buf_cpu, out_len_kernel) == 0)
{ {
failed = 0; failed = 0;
} }
@ -197,9 +194,9 @@ int main (int argc, char **argv)
printf (" %i vs ", out_len_cpu); printf (" %i vs ", out_len_cpu);
// modified by gpu // modified by gpu
print_plain (rule_buf_gpu, out_len_gpu); print_plain (rule_buf_kernel, out_len_kernel);
printf (" %i\n", out_len_gpu); printf (" %i\n", out_len_kernel);
} }
} }
} }