diff options
Diffstat (limited to 'test')
| -rwxr-xr-x | test/check-implementation.sh | 28 | ||||
| -rw-r--r-- | test/common.mk | 47 |
2 files changed, 25 insertions, 50 deletions
diff --git a/test/check-implementation.sh b/test/check-implementation.sh index 0750d1b..5f46606 100755 --- a/test/check-implementation.sh +++ b/test/check-implementation.sh @@ -1,6 +1,7 @@ #!/bin/bash set -eu +shopt -s extglob # Run NIST's genkat_aead.c against the reference implementation as # well as another one, and compare vectors. @@ -11,6 +12,24 @@ ROOT_DIR=${TEST_DIR}/.. implem=$1 +list-implementation-files () +{ + local mode=$1 + local key_length=$2 + local src_dir=${ROOT_DIR}/src + + # src/${implem} can contain arbitrary files; we need to copy + # everything save for the unused AE mode. + + for f in ${src_dir}/${implem}/!(lilliput-i|lilliput-ii).[ch] + do + echo ${f} + done + + echo ${src_dir}/${implem}/lilliput-${mode}.c + echo ${src_dir}/${mode}-${key_length}/parameters.h +} + run-genkat () { local tmp_dir=$1 @@ -32,15 +51,10 @@ run-genkat () tweakey.{c,h} ) - mkdir -p ${genkat_dir} # "-p" to allow comparing ref against ref. + mkdir -p ${genkat_dir} # "-p" allows comparing ref against ref. - local f - for f in ${source_files[@]} - do - cp ${src_dir}/${implem}/${f} ${genkat_dir} - done + list-implementation-files ${mode} ${keylen} | xargs cp -t ${genkat_dir} - cp ${src_dir}/${mode}-${keylen}/parameters.h ${genkat_dir} cp ${ROOT_DIR}/nist/{api.h,encrypt.c} ${genkat_dir} cp ${ROOT_DIR}/nist/TestVectorGen/* ${genkat_dir} diff --git a/test/common.mk b/test/common.mk index c978c2d..31e84b0 100644 --- a/test/common.mk +++ b/test/common.mk @@ -10,19 +10,7 @@ endif # Use "make IMPLEMENTATION=..." to compile against other versions. IMPLEMENTATION = ref - -ifeq "$(IMPLEMENTATION)" "add_threshold" -# Filter out tests on tweakey schedule, as the thresholded API differs. -tests = $(filter-out test-tweakey,$(basename $(wildcard test-*.c))) -# Don't trigger warnings for "a&b ^ c". -CFLAGS += -Wno-parentheses -else -tests = $(basename $(wildcard test-*.c)) -endif - -traces = $(basename $(wildcard traces-*.c)) - -test_dir = $(dir $(lastword $(MAKEFILE_LIST))) +test_dir := $(dir $(lastword $(MAKEFILE_LIST))) root_dir = $(test_dir).. results_dir = $(root_dir)/results/$(mode)-$(keylen) src_dir = $(root_dir)/src/$(IMPLEMENTATION) @@ -34,6 +22,9 @@ CFLAGS += -I$(src_dir) -I$(variant_dir) -I$(test_dir) $(nist_flags) -Werror LDFLAGS += $(nist_flags) +include $(src_dir)/implem.mk + + .PHONY: clean test $(tests) traces $(traces) @@ -71,35 +62,5 @@ $(results_dir)/src/%.o: $(src_dir)/%.c | $(results_dir)/src $(Q) gcc -c $< $(CFLAGS) -o $@ -# Program => additional objects dependencies - -$(results_dir)/test-tbc-decrypt $(results_dir)/test-tbc-encrypt $(results_dir)/traces-tbc: \ -$(results_dir)/src/cipher.o $(results_dir)/src/tweakey.o - -$(results_dir)/test-ae-decrypt $(results_dir)/test-ae-encrypt $(results_dir)/test-ae-roundtrip $(results_dir)/traces-ae: \ -$(results_dir)/src/lilliput-$(mode).o $(results_dir)/src/cipher.o \ -$(results_dir)/src/tweakey.o - -$(results_dir)/test-tweakey: $(results_dir)/src/tweakey.o - -# Object => headers dependencies - -$(results_dir)/$(src_dir)/cipher.o: $(src_dir)/cipher.h \ -$(src_dir)/tweakey.h $(variant_dir)/parameters.h - -$(results_dir)/$(src_dir)/lilliput-i.o $(results_dir)/$(src_dir)/lilliput-ii.o: \ -$(src_dir)/lilliput-ae.h $(src_dir)/cipher.h $(src_dir)/constants.h \ -$(variant_dir)/parameters.h - -$(results_dir)/$(src_dir)/tweakey.o: $(src_dir)/tweakey.h \ -$(src_dir)/constants.h $(variant_dir)/parameters.h - -$(results_dir)/test/test-tbc-encrypt.o $(results_dir)/test/test-tbc-decrypt.o $(results_dir)/test/traces-tbc.o: \ -$(src_dir)/cipher.h - -$(results_dir)/test/test-ae-encrypt.o $(results_dir)/test/test-ae-decrypt.o $(results_dir)/test/test-ae-roundtrip.o $(results_dir)/test/traces-ae.o: \ -$(src_dir)/lilliput-ae.h - - # TODO: add valgrind, although it does not seem to play well with ASAN # TODO: use gcc -M... to generate .o -> .h dependencies |
