diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-07-05 16:49:05 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-07-05 17:14:31 +0200 |
| commit | 9e859f32720ee9d242863678ba7e1d88543e6a7a (patch) | |
| tree | e33050c82ae7d0c7c9758ae37a6af30295cc7d56 /src/ref | |
| parent | 09602fcb6e50fda8245213ac66a340510f21a12f (diff) | |
| download | lilliput-ae-implem-9e859f32720ee9d242863678ba7e1d88543e6a7a.tar.xz | |
Renommage des variables intermédiaires du tweakey schedule
x_{M^2,i} me semble moins lisible que b_i, et pas forcément plus
facile à traduire en (M²·x)[i].
Diffstat (limited to 'src/ref')
| -rw-r--r-- | src/ref/multiplications.h | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/ref/multiplications.h b/src/ref/multiplications.h index c0645b9..ba68ad0 100644 --- a/src/ref/multiplications.h +++ b/src/ref/multiplications.h @@ -41,54 +41,53 @@ static void _multiply_M(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) static void _multiply_M2(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) { - uint8_t x_M_5 = x[5]<<3 ^ x[4]; - uint8_t x_M_4 = x[4]>>3 ^ x[3]; + uint8_t a5 = x[5]<<3 ^ x[4]; + uint8_t a4 = x[4]>>3 ^ x[3]; y[7] = x[5]; - y[6] = x_M_5; - y[5] = x_M_5<<3 ^ x_M_4; - y[4] = x_M_4>>3 ^ x[2]; - y[3] = x[6]<<2 ^ x[1]; - y[2] = x[5]<<2 ^ x[0]; + y[6] = a5; + y[5] = a5<<3 ^ a4; + y[4] = a4>>3 ^ x[2]; + y[3] = x[6]<<2 ^ x[1]; + y[2] = x[5]<<2 ^ x[0]; y[1] = x[7]; y[0] = x[6]; } static void _multiply_M3(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) { - uint8_t x_M_5 = x[5]<<3 ^ x[4]; - uint8_t x_M_4 = x[4]>>3 ^ x[3]; - uint8_t x_M2_5 = x_M_5<<3 ^ x_M_4; - uint8_t x_M2_4 = x_M_4>>3 ^ x[2]; - - y[7] = x_M_5; - y[6] = x_M2_5; - y[5] = x_M2_5<<3 ^ x_M2_4; - y[4] = x_M2_4>>3 ^ x[6]<<2 ^ x[1]; - y[3] = x[5]<<2 ^ x[0]; - y[2] = x_M_5<<2 ^ x[7]; + uint8_t a5 = x[5]<<3 ^ x[4]; + uint8_t a4 = x[4]>>3 ^ x[3]; + uint8_t b5 = a5<<3 ^ a4; + uint8_t b4 = a4>>3 ^ x[2]; + + y[7] = a5; + y[6] = b5; + y[5] = b5<<3 ^ b4; + y[4] = b4>>3 ^ x[6]<<2 ^ x[1]; + y[3] = x[5]<<2 ^ x[0]; + y[2] = a5<<2 ^ x[7]; y[1] = x[6]; y[0] = x[5]; } static void _multiply_M4(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) { - uint8_t a_5 = x[5]<<3 ^ x[4]; - uint8_t a_4 = x[4]>>3 ^ x[3]; - uint8_t b_5 = a_5<<3 ^ a_4; - uint8_t b_4 = a_4>>3 ^ x[2]; - - uint8_t c_4 = b_4>>3 ^ x[6]<<2 ^ x[1]; - uint8_t c_5 = b_5<<3 ^ b_4; - - y[7] = b_5; - y[6] = c_5; - y[5] = c_5<<3 ^ c_4; - y[4] = c_4>>3 ^ x[5]<<2 ^ x[0]; - y[3] = a_5<<2 ^ x[7]; - y[2] = b_5<<2 ^ x[6]; + uint8_t a5 = x[5]<<3 ^ x[4]; + uint8_t a4 = x[4]>>3 ^ x[3]; + uint8_t b5 = a5<<3 ^ a4; + uint8_t b4 = a4>>3 ^ x[2]; + uint8_t c4 = b4>>3 ^ x[6]<<2 ^ x[1]; + uint8_t c5 = b5<<3 ^ b4; + + y[7] = b5; + y[6] = c5; + y[5] = c5<<3 ^ c4; + y[4] = c4>>3 ^ x[5]<<2 ^ x[0]; + y[3] = a5<<2 ^ x[7]; + y[2] = b5<<2 ^ x[6]; y[1] = x[5]; - y[0] = a_5; + y[0] = a5; } static void _multiply_MR(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) @@ -105,13 +104,13 @@ static void _multiply_MR(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) static void _multiply_MR2(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) { - uint8_t x_MR_4 = x[5] ^ x[6]<<3; + uint8_t a4 = x[5] ^ x[6]<<3; y[0] = x[2]; y[1] = x[3] ^ x[4]>>3; - y[2] = x[4] ^ x_MR_4>>3; - y[3] = x_MR_4; - y[4] = x[3]<<2 ^ x[6] ^ x[7]<<3; + y[2] = x[4] ^ a4>>3; + y[3] = a4; + y[4] = x[3]<<2 ^ x[6] ^ x[7]<<3; y[5] = x[4]<<2 ^ x[7]; y[6] = x[0]; y[7] = x[1]; @@ -119,15 +118,15 @@ static void _multiply_MR2(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) static void _multiply_MR3(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]) { - uint8_t x_MR_4 = x[5] ^ x[6]<<3; - uint8_t x_MR2_4 = x[3]<<2 ^ x[6] ^ x[7]<<3; - - y[0] = x[3] ^ x[4]>>3; - y[1] = x[4] ^ x_MR_4>>3; - y[2] = x_MR_4 ^ x_MR2_4>>3; - y[3] = x_MR2_4; - y[4] = x[0]<<3 ^ x[4]<<2 ^ x[7]; - y[5] = x_MR_4<<2 ^ x[0]; + uint8_t a4 = x[5] ^ x[6]<<3; + uint8_t b4 = x[3]<<2 ^ x[6] ^ x[7]<<3; + + y[0] = x[3] ^ x[4]>>3; + y[1] = x[4] ^ a4>>3; + y[2] = a4 ^ b4>>3; + y[3] = b4; + y[4] = x[0]<<3 ^ x[4]<<2 ^ x[7]; + y[5] = a4<<2 ^ x[0]; y[6] = x[1]; y[7] = x[2]; } |
