diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-12-05 13:40:41 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-12-05 13:44:54 +0100 |
| commit | 7cef7206f7f4ec6afe54b710826e5c869be71df7 (patch) | |
| tree | b7d99a49eadeef7aad789a7b7cf23b1cc6a92ac9 /test/test-helpers.h | |
| parent | 52c0e83053a4a7326da6436f9ef29b7dcc64db41 (diff) | |
| download | lilliput-ae-implem-7cef7206f7f4ec6afe54b710826e5c869be71df7.tar.xz | |
Mise à jour de la permutation du key schedule dans le code
Ajout d'une fonction pour récupérer facilement la nouvelle valeur des
vecteurs.
Diffstat (limited to 'test/test-helpers.h')
| -rw-r--r-- | test/test-helpers.h | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/test/test-helpers.h b/test/test-helpers.h index 1991542..67b15a1 100644 --- a/test/test-helpers.h +++ b/test/test-helpers.h @@ -1,7 +1,7 @@ #ifndef TEST_HELPERS_H #define TEST_HELPERS_H -#include <stdint.h> +#include <inttypes.h> #include <stdio.h> #include "parameters.h" @@ -21,13 +21,34 @@ } while (0) -static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) +/* Used to update vectors when constants change. */ +static inline void dump_c_initializer(size_t len, uint8_t buf[len]) { - size_t filename_len = snprintf(NULL, 0, "%s/%s_%s.txt", folder, vector, name); - char filename[filename_len+1]; - snprintf(filename, sizeof(filename), "%s/%s_%s.txt", folder, vector, name); - return fopen(filename, "w"); + printf("{\n"); + + const size_t columns = 8; + + for (size_t i=0; i<len; i++) + { + printf("0x%02"PRIx8, buf[i]); + + if (i == len-1) + { + printf("\n"); + } + else if (i%columns == columns-1) + { + printf(",\n"); + } + else + { + printf(", "); + } + } + + printf("}\n"); } + #endif /* TEST_HELPERS_H */ |
