Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
unsigned long long CHK0(unsigned long long x) {
return !x ? 0x10000 : x;
}
void initial_fw(unsigned long long mem[4], unsigned long long n1, unsigned long long n2, unsigned long long n3, unsigned long long n4) {
mem[0] = ((CHK0(mem[0]) * n1) %0x10001) & 0xFFFF;
mem[1] = (mem[1] + n2) & 0xFFFF;
mem[2] = (mem[2] + n3) & 0xFFFF;
mem[3] = ((CHK0(mem[3]) * n4) %0x10001) & 0xFFFF;
}
void block_fw(unsigned long long mem[4], unsigned long long $num1, unsigned long long $num2, unsigned long long $num3, unsigned long long $num4, unsigned long long $num5, unsigned long long $num6) {
initial_fw(mem, $num1, $num2, $num3, $num4);
unsigned long long mem4 = mem[0] ^ mem[2];
unsigned long long mem5 = mem[1] ^ mem[3];
mem4 = ((CHK0(mem4) * $num5) %0x10001) & 0xFFFF;
mem5 = (mem4 + mem5) & 0xFFFF;
mem5 = ((CHK0(mem5) * $num6) %0x10001) & 0xFFFF;
mem4 = (mem4 + mem5) & 0xFFFF;
mem[0] = mem[0] ^ mem5;
mem[1] = mem[1] ^ mem4;
mem[2] = mem[2] ^ mem5;
mem[3] = mem[3] ^ mem4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.