Skip to content

Instantly share code, notes, and snippets.

@vanhoavn
Created November 6, 2017 15:11
Show Gist options
  • Save vanhoavn/625d1bb49cc2b639a67c08e4a4900386 to your computer and use it in GitHub Desktop.
Save vanhoavn/625d1bb49cc2b639a67c08e4a4900386 to your computer and use it in GitHub Desktop.
void initial_bw(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]) * invMod[n1]) %0x10001) & 0xFFFF;
mem[1] = (mem[1] - n2) & 0xFFFF;
mem[2] = (mem[2] - n3) & 0xFFFF;
mem[3] = ((CHK0(mem[3]) * invMod[n4]) %0x10001) & 0xFFFF;
}
void block_bw(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) {
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;
initial_bw(mem, $num1, $num2, $num3, $num4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment