diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-12-10 16:37:26 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-12-10 16:37:26 +0100 |
| commit | 7be6c07647afbc27bc7402efb23c1178affa2ec9 (patch) | |
| tree | 0e269d3e3d7e8556549538c673bc75c7bdab2da4 /src/cipher.c | |
| parent | 8eed9390de14c810d9242277e275c6e783f86261 (diff) | |
| download | lilliput-ae-implem-7be6c07647afbc27bc7402efb23c1178affa2ec9.tar.xz | |
Mise à jour de l'implémentation du key schedule
Pour le moment, Mⁱ (resp. MRⁱ) sont implémentées en appliquant i fois
M (resp. MR) ; à voir si on préfère les pré-calculer.
Diffstat (limited to 'src/cipher.c')
| -rw-r--r-- | src/cipher.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/cipher.c b/src/cipher.c index 4190359..bb2d46a 100644 --- a/src/cipher.c +++ b/src/cipher.c @@ -2,7 +2,6 @@ #include <string.h> #include "cipher.h" -#include "constants.h" #include "parameters.h" #include "tweakey.h" @@ -16,7 +15,7 @@ enum permutation typedef enum permutation permutation; -const uint8_t PERMUTATIONS[2][BLOCK_BYTES] = { +static const uint8_t PERMUTATIONS[2][BLOCK_BYTES] = { /* PI(i) */ [0] = { 13, 9, 14, 8, 10, 11, 12, 15, 4, 5, 3, 1, 2, 6, 0, 7 }, @@ -25,6 +24,41 @@ const uint8_t PERMUTATIONS[2][BLOCK_BYTES] = { 3, 1, 4, 5, 6, 0, 2, 7 } }; +static const uint8_t S[256] = { + 32, 0, 178, 133, 59, 53, 166, 164, + 48, 228, 106, 44, 255, 89, 226, 14, + 248, 30, 122, 128, 21, 189, 62, 177, + 232, 243, 162, 194, 218, 81, 42, 16, + 33, 1, 35, 120, 92, 36, 39, 181, + 55, 199, 43, 31, 174, 10, 119, 95, + 111, 9, 157, 129, 4, 90, 41, 220, + 57, 156, 5, 87, 151, 116, 121, 23, + 68, 198, 230, 233, 221, 65, 242, 138, + 84, 202, 110, 74, 225, 173, 182, 136, + 28, 152, 126, 206, 99, 73, 58, 93, + 12, 239, 246, 52, 86, 37, 46, 214, + 103, 117, 85, 118, 184, 210, 97, 217, + 113, 139, 205, 11, 114, 108, 49, 75, + 105, 253, 123, 109, 96, 60, 47, 98, + 63, 34, 115, 19, 201, 130, 127, 83, + 50, 18, 160, 124, 2, 135, 132, 134, + 147, 78, 104, 70, 141, 195, 219, 236, + 155, 183, 137, 146, 167, 190, 61, 216, + 234, 80, 145, 241, 51, 56, 224, 169, + 163, 131, 161, 27, 207, 6, 149, 7, + 158, 237, 185, 245, 76, 192, 244, 45, + 22, 250, 180, 3, 38, 179, 144, 79, + 171, 101, 252, 254, 20, 247, 227, 148, + 238, 172, 140, 26, 222, 203, 40, 64, + 125, 200, 196, 72, 107, 223, 165, 82, + 229, 251, 215, 100, 249, 240, 211, 94, + 102, 150, 143, 29, 69, 54, 204, 197, + 77, 159, 191, 15, 209, 8, 235, 67, + 66, 25, 231, 153, 168, 142, 88, 193, + 154, 212, 24, 71, 170, 175, 188, 91, + 213, 17, 208, 176, 112, 187, 13, 186 +}; + static void _state_init(uint8_t X[BLOCK_BYTES], const uint8_t message[BLOCK_BYTES]) { |
