diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2019-02-01 14:22:00 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2019-02-01 14:22:00 +0100 |
| commit | bbc9f0fcb03183c9f8cff2bf8a5c5a34607fa126 (patch) | |
| tree | 1cf83c74f8d4a788e21718946ef9da212b26fe82 /src | |
| parent | ae461f64bd249f959411b8b7cf56e549bb2ecb5c (diff) | |
| download | lilliput-ae-implem-bbc9f0fcb03183c9f8cff2bf8a5c5a34607fa126.tar.xz | |
Implémentation de M₂
Diffstat (limited to 'src')
| -rw-r--r-- | src/add_developedtweakey/tweakey.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/add_developedtweakey/tweakey.c b/src/add_developedtweakey/tweakey.c index cbda1cf..98484bc 100644 --- a/src/add_developedtweakey/tweakey.c +++ b/src/add_developedtweakey/tweakey.c @@ -48,6 +48,11 @@ static uint8_t _M1(uint8_t x) return x<<3 ^ x>>3; } +static uint8_t _M2(uint8_t x) +{ + return x<<6 ^ (x & 0xf8) ^ x>>6; +} + static void _multiply_M(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) { Y[7] = X[6]; @@ -74,11 +79,14 @@ static void _multiply_M2(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) static void _multiply_M3(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) { - uint8_t M_X[LANE_BYTES]; - uint8_t M2_X[LANE_BYTES]; - _multiply_M(X, M_X); - _multiply_M(M_X, M2_X); - _multiply_M(M2_X, Y); + Y[7] = X[5]<<3 ^ X[4]; + Y[6] = X[5]<<6 ^ _M1(X[4]) ^ X[3]; + Y[5] = _M2(X[4]) ^ _M1(X[3]) ^ X[2]; + Y[4] = X[6]<<2 ^ X[3]>>6 ^ X[2]>>3 ^ X[1]; + Y[3] = X[5]<<2 ^ X[0]; + Y[2] = X[7] ^ X[5]<<5 ^ X[4]<<2; + Y[1] = X[6]; + Y[0] = X[5]; } static void _multiply_MR(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) |
