From a2bc7064a1d88681d5482a1920468f1ae37caf2f Mon Sep 17 00:00:00 2001 From: Tiago Oliveira Date: Mon, 11 Mar 2024 23:03:50 +0000 Subject: [PATCH] mlkem768 delete file (was moved) --- .../mlkem768/amd64/avx2/keccakf1600.jinc | 230 ------------------ 1 file changed, 230 deletions(-) delete mode 100644 src/crypto_kem/mlkem/mlkem768/amd64/avx2/keccakf1600.jinc diff --git a/src/crypto_kem/mlkem/mlkem768/amd64/avx2/keccakf1600.jinc b/src/crypto_kem/mlkem/mlkem768/amd64/avx2/keccakf1600.jinc deleted file mode 100644 index 9a056e20..00000000 --- a/src/crypto_kem/mlkem/mlkem768/amd64/avx2/keccakf1600.jinc +++ /dev/null @@ -1,230 +0,0 @@ -param int KECCAK_ROUNDS = 24; - -u64[24] KECCAK1600_RC = -{ 0x0000000000000001 - ,0x0000000000008082 - ,0x800000000000808a - ,0x8000000080008000 - ,0x000000000000808b - ,0x0000000080000001 - ,0x8000000080008081 - ,0x8000000000008009 - ,0x000000000000008a - ,0x0000000000000088 - ,0x0000000080008009 - ,0x000000008000000a - ,0x000000008000808b - ,0x800000000000008b - ,0x8000000000008089 - ,0x8000000000008003 - ,0x8000000000008002 - ,0x8000000000000080 - ,0x000000000000800a - ,0x800000008000000a - ,0x8000000080008081 - ,0x8000000000008080 - ,0x0000000080000001 - ,0x8000000080008008 -}; - -inline fn keccakf1600_index(inline int x y) -> inline int -{ - inline int r; - r = (x % 5) + 5 * (y % 5); - return r; -} - -inline fn keccakf1600_rho_offsets(inline int i) -> inline int -{ - inline int r x y z t; - - r = 0; - x = 1; - y = 0; - - for t = 0 to 24 - { if (i == x + 5 * y) - { r = ((t + 1) * (t + 2) / 2) % 64; } - z = (2 * x + 3 * y) % 5; - x = y; - y = z; - } - - return r; -} - -inline fn keccakf1600_rhotates(inline int x y) -> inline int -{ - inline int i r; - i = keccakf1600_index(x, y); - r = keccakf1600_rho_offsets(i); - return r; -} - -// C[x] = A[x,0] ^ A[x,1] ^ A[x,2] ^ A[x,3] ^ A[x,4] -inline fn keccakf1600_theta_sum(reg ptr u64[25] a) -> reg u64[5] -{ - inline int x y; - reg u64[5] c; - - // C[x] = A[x, 0] - for x=0 to 5 - { c[x] = a[x + 0]; } - - // C[x] ^= A[x,1] ^ A[x,2] ^ A[x,3] ^ A[x,4] - for y=1 to 5 - { for x=0 to 5 - { c[x] ^= a[x + y*5]; } - } - - return c; -} - -// D[x] = C[x-1] ^ ROT(C[x+1], 1) -inline fn keccakf1600_theta_rol(reg u64[5] c) -> reg u64[5] -{ - inline int x; - reg u64[5] d; - - for x = 0 to 5 - { // D[x] = C[x + 1] - d[x] = c[(x + 1) % 5]; - - // D[x] = ROT(D[x], 1) - _, _, d[x] = #ROL_64(d[x], 1); - - // D[x] ^= C[x-1] - d[x] ^= c[(x - 1 + 5) % 5]; - } - - return d; -} - -// B[x] = ROT( (A[x',y'] ^ D[x']), r[x',y'] ) with (x',y') = M^-1 (x,y) -// -// M = (0 1) M^-1 = (1 3) x' = 1x + 3y -// (2 3) (1 0) y' = 1x + 0y -// -inline fn keccakf1600_rol_sum( - reg ptr u64[25] a, - reg u64[5] d, - inline int y) - -> - reg u64[5] -{ - inline int r x x_ y_; - reg u64[5] b; - - for x = 0 to 5 - { - x_ = (x + 3*y) % 5; - y_ = x; - r = keccakf1600_rhotates(x_, y_); - - // B[x] = A[x',y'] - b[x] = a[x_ + y_*5]; - - // B[x] ^= D[x']; - b[x] ^= d[x_]; - - // B[x] = ROT( B[x], r[x',y'] ); - if(r != 0) - { _, _, b[x] = #ROL_64(b[x], r); } - - } - - return b; -} - -// E[x, y] = B[x] ^ ( (!B[x+1]) & B[x+2] ) -// -- when x and y are 0: E[0,0] ^= RC[i]; -inline fn keccakf1600_set_row( - reg ptr u64[25] e, - reg u64[5] b, - inline int y, - stack u64 s_rc) - -> - reg ptr u64[25] -{ - inline int x x1 x2; - reg u64 t; - - for x=0 to 5 - { - x1 = (x + 1) % 5; - x2 = (x + 2) % 5; - - t = !b[x1] & b[x2]; // bmi1 - //t = b[x1]; t = !t; t &= b[x2]; - - t ^= b[x]; - if( x==0 && y==0 ){ t ^= s_rc; } - e[x + y*5] = t; - } - - return e; -} - -inline fn keccakf1600_round( - reg ptr u64[25] e, - reg ptr u64[25] a, - reg u64 rc) - -> - reg ptr u64[25] -{ - inline int y; - reg u64[5] b c d; - stack u64 s_rc; - - s_rc = rc; - - c = keccakf1600_theta_sum(a); - d = keccakf1600_theta_rol(c); - - for y = 0 to 5 - { b = keccakf1600_rol_sum(a, d, y); - e = keccakf1600_set_row(e, b, y, s_rc); - } - - return e; -} - -inline fn __keccakf1600(reg ptr u64[25] a) -> reg ptr u64[25] -{ - reg ptr u64[24] RC; - stack u64[25] s_e; - reg ptr u64[25] e; - - reg u64 c rc; - - RC = KECCAK1600_RC; - e = s_e; - - c = 0; - while (c < KECCAK_ROUNDS - 1) - { - rc = RC[(int) c]; - e = keccakf1600_round(e, a, rc); - - rc = RC[(int) c + 1]; - a = keccakf1600_round(a, e, rc); - - c += 2; - } - - return a; -} - -fn _keccakf1600(reg ptr u64[25] a) -> reg ptr u64[25] -{ - a = __keccakf1600(a); - return a; -} - -inline fn _keccakf1600_(reg ptr u64[25] a) -> reg ptr u64[25] -{ - a = a; - a = _keccakf1600(a); - a = a; - return a; -}