diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-02-04 10:57:14 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-02-04 10:57:14 +0100 |
| commit | e5a9fe49462ad0ede700041f4ae5c8c430cefe34 (patch) | |
| tree | 22f5aa957787fe1bbf9a55cdc92a51a7d95dbaa9 /src/add_developedtweakey | |
| parent | 89d08745d767ef36ac1694ba80403dabdf6ee9cb (diff) | |
| download | lilliput-ae-implem-e5a9fe49462ad0ede700041f4ae5c8c430cefe34.tar.xz | |
Implémentation de M₄
Diffstat (limited to 'src/add_developedtweakey')
| -rw-r--r-- | src/add_developedtweakey/tweakey.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/add_developedtweakey/tweakey.c b/src/add_developedtweakey/tweakey.c index a602191..605098b 100644 --- a/src/add_developedtweakey/tweakey.c +++ b/src/add_developedtweakey/tweakey.c @@ -58,6 +58,14 @@ static uint8_t _M3(uint8_t x) return x & 0x1f; } +static uint8_t _M4(uint8_t x) +{ + /* (x<<2)>>3 would keep bit x6 due to integer promotion. + * Side-step this by writing each shift on its own statement. */ + x <<= 2; + return x>>3; +} + static void _multiply_M(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) { Y[7] = X[6]; @@ -120,11 +128,14 @@ 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 MR_X[LANE_BYTES]; - uint8_t MR2_X[LANE_BYTES]; - _multiply_MR(X, MR_X); - _multiply_MR(MR_X, MR2_X); - _multiply_MR(MR2_X, Y); + Y[0] = X[3] ^ X[4]>>3; + Y[1] = X[4] ^ X[5]>>3 ^ _M3(X[6]); + Y[2] = _M4(X[3]) ^ X[5] ^ _M1(X[6]) ^ _M3(X[7]); + Y[3] = X[3]<<2 ^ X[6] ^ X[7]<<3; + Y[4] = X[0]<<3 ^ X[4]<<2 ^ X[7]; + Y[5] = X[0] ^ X[5]<<2 ^ X[6]<<5; + Y[6] = X[1]; + Y[7] = X[2]; } typedef void (*matrix_multiplication)(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]); |
