Name: Anonymous 2016-05-27 7:25
What does this number stands for? I've stumbled upon it during reverse engineering a simple encryption scheme.
how does your crypto work btw? is it a stream cipher or a block cipher? is it similar to any popular algorithms?It works like following (decrypt_init uses random number fill in the table with 1234567890u being the both the seed and the password)
uint32_t GDecryptPRNG_State;
uint32_t GDecryptMap[256];
uint32_t decrypt_sub(uint32_t *table) {
uint32_t a, b, c;
a = table[0];
table[a] = GDecryptMap[a];
b = table[1];
table[1] = GDecryptMap[b];
c = table[b + 2] ^ table[a + 2];
table[a + 2] = c;
return c;
}
void decrypt_init(uint32_t *table, uint32_t seed) {
int i;
uint32_t *p;
int count;
uint64_t t;
unsigned int a;
uint32_t k;
uint32_t *q;
int b;
for (i = 0; i < 256; i++) GDecryptMap[i] = i+1;
GDecryptPRNG_State = seed;
table[0] = 0;
table[1] = 103;
p = table + 251;
count = 250;
do
{
t = 0x41C64E6DULL * GDecryptPRNG_State;
HIDWORD(t) <<= 16;
t += 0xFFFF00003039ULL;
GDecryptPRNG_State = t;
*p = HIDWORD(t) & 0xFFFF0000 | ((uint32_t)t >> 16);
--p;
--count;
} while ( count );
a = 0xFFFFFFFF;
k = 0x80000000;
q = table + 5;
do {
b = *q;
q += 7;
*(q - 7) = k | a & b;
k >>= 1;
a >>= 1;
} while ( k );
}
int decrypt(uint32_t *data, int datasize) {
signed int result;
uint32_t *p;
uint32_t a, b, c, d, e;
uint32_t table[256];
memset(table, 0, 256*sizeof(uint32_t));
decrypt_init(table, 1234567890u);
if (datasize <= 12) return 0;
p = data + 1;
decrypt_init(table, *data);
e = datasize - 4;
if ( (datasize - 4) / 4 > 0 )
{
a = e / 4;
do
{
b = decrypt_sub(table);
c = *p;
++p;
--a;
*(p - 1) = b ^ c;
}
while ( a );
}
d = e % 4;
if ( d > 0 )
{
do
{
--d;
*(uint8_t*)p ^= decrypt_sub(table);
} while ( d );
}
return 1;
}