What is this random number generation algorithm?

I have the inverse algorithm of the subsequent random number generation algorithm,

int __cdecl sub_40BB60()
{
  char v0; // si@1
  int v1; // edx@1
  int v2; // ecx@1
  unsigned int v3; // eax@1
  int v4; // edi@1
  int v5; // esi@1
  int result; // eax@1

  v0 = random_state;
  v1 = dword_685440[((_BYTE)random_state - 3) & 0xF];
  v2 = dword_685440[random_state] ^ v1 ^ ((v1 ^ 2 * dword_685440[random_state]) << 15);
  v3 = ((unsigned int)dword_685440[((_BYTE)random_state - 7) & 0xF] >> 11) ^ dword_685440[((_BYTE)random_state - 7) & 0xF];
  v4 = v3 ^ dword_685440[random_state] ^ v1 ^ ((v1 ^ 2 * dword_685440[random_state]) << 15);
  dword_685440[random_state] = v4;
  v5 = (v0 - 1) & 0xF;
  result = dword_685440[v5] ^ v2 ^ v4 ^ 32 * (v4 & 0xFED22169) ^ 4 * (dword_685440[v5] ^ ((v2 ^ (v3 << 10)) << 16));
  random_state = v5;
  dword_685440[v5] = result;
  return result;
}

dword_685440is int[16], but random_statemutates, as you can see.

I thought it could be a twister. Does anyone know this algorithm?

+4
source share
1 answer

It looks like it could be a linear shift shift register algorithm . They can be implemented at the word level using a combination of bit offset and XOR operations, which seems to be consistent.

+3
source

All Articles