summaryrefslogtreecommitdiff
path: root/crypto_aead/lilliputaeii128v1/ref/test/helpers.h
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-27 09:44:28 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-27 09:44:28 +0100
commit0034747fd91b5d1b5d6375eb295a79f5221de84a (patch)
tree7f894d5932ec2283d0184fe8c5dc8f054d4ac54b /crypto_aead/lilliputaeii128v1/ref/test/helpers.h
parentd14739644394986cb584acb45ed9b214dff1c501 (diff)
downloadlilliput-ae-implem-0034747fd91b5d1b5d6375eb295a79f5221de84a.tar.xz
Ajout de tests chiffrement/déchiffrement pour SCT-2
Diffstat (limited to 'crypto_aead/lilliputaeii128v1/ref/test/helpers.h')
-rw-r--r--crypto_aead/lilliputaeii128v1/ref/test/helpers.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/crypto_aead/lilliputaeii128v1/ref/test/helpers.h b/crypto_aead/lilliputaeii128v1/ref/test/helpers.h
new file mode 100644
index 0000000..0e1b3c2
--- /dev/null
+++ b/crypto_aead/lilliputaeii128v1/ref/test/helpers.h
@@ -0,0 +1,33 @@
+#ifndef HELPERS_H
+#define HELPERS_H
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "parameters.h"
+
+
+#define ARRAY_NB(A) (sizeof(A)/sizeof(A[0]))
+#define ARRAY_END(A) (A+ARRAY_NB(A))
+
+#define REPORT_DIFFERENCE(VECTOR, ELEMENT) do { \
+ fprintf(stderr, "%s: vector %s: %s differs from expected\n", \
+ __FILE__, (VECTOR), (ELEMENT)); \
+ } while (0)
+
+#define REPORT_INVALID(VECTOR) do { \
+ fprintf(stderr, "%s: vector %s: ciphertext/tag invalid\n", \
+ __FILE__, (VECTOR)); \
+ } while (0)
+
+
+static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name)
+{
+ 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");
+}
+
+
+#endif /* HELPERS_H */