diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2019-02-03 19:01:09 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2019-02-03 19:01:33 +0100 |
| commit | fca886ea9494d7ae6178004d0080ed1a09f03cc9 (patch) | |
| tree | 5a640435b9c592a7015518b5e9b59c434d739981 /test | |
| parent | fc5be3360d6e9dda65166a518479f31df9be6148 (diff) | |
| download | lilliput-ae-implem-fca886ea9494d7ae6178004d0080ed1a09f03cc9.tar.xz | |
[WIP] Ajout d'un script de comparaison d'implémentations
Bricolé pendant la réunion SP3 du 1er février, inachevé.
Je me suis rendu compte que les "tests", en dehors des tests de
Lilliput-Ⅰ-128, se contentent de vérifier que D(E(plaintext)) =
plaintext, ce qui ne suffit pas pour s'assurer qu'une nouvelle
implémentation est conforme à l'ancienne.
Plutôt que de copier-coller-adapter les tests de Lilliput-Ⅰ-128, il me
semble qu'une approche plus simple serait de comparer les vecteurs
générés par une implémentation à ceux produits par l'implémentation de
référence.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/check-implementation.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/check-implementation.sh b/test/check-implementation.sh new file mode 100755 index 0000000..985ff04 --- /dev/null +++ b/test/check-implementation.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +set -eu + +# Run NIST's genkat_aead.c against the reference implementation as +# well as another one, and compare vectors. + +TEST_DIR=$(dirname $0) +ROOT=${TEST_DIR}/.. + +implem=$1 + + +run-genkat () +{ + local tmp_dir=$1 + local implem=$2 + local mode=$3 + local keylen=$4 + + local src_dir=${ROOT}/src/ + + local source_files=( + ae-common.h + cipher.{c,h} + lilliput-ae{.h,-${mode}.c} + parameters.h + tweakey.{c,h} + ) + + local f + for f in ${source_files[@]} + do + cp ${src_dir}/${implem}/${f} ${tmp_dir} + done + + cp ${src_dir}/${mode}-${keylen}/_parameters.h ${tmp_dir} + cp ${ROOT_DIR}/nist/{api.h,encrypt.c} ${tmp_dir} + + local nist_flags=(-std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2) + + gcc ${nist_flags[@]} -Werror -I${tmp_dir} -o ${tmp_dir}/genkat + ( + cd ${tmp_dir} + ./genkat + cat LWC_AEAD_KAT*.txt + ) +} + + +test-implem () +{ + local implem=$1 + local tmp_dir=$(mktemp -d) + + local mode + local keylen + + for mode in i ii + do + for keylen in 128 192 256 + do + run-genkat ${tmp_dir} ${implem} ${mode} ${keylen} + done + done + + rm -r ${tmp_dir} +} + + +diff -u <(test-implem ref) <(test-implem ${implem}) |
