testkat.sh 1.21 KB
Newer Older
lwc-tester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#!/bin/bash

SNEIK=`pwd`
WORKD=`mktemp -d`
echo "Work directory =" $WORKD
AEADMAIN=$SNEIK/common/nist/genkat_aead.c
HASHMAIN=$SNEIK/common/nist/genkat_hash.c
CC=gcc
CFLAGS="-std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2"
TARGETS="ref opt"

# The following works if you have the cross-compiler and QEMU binfmt support
# CC=arm-linux-gnueabihf-gcc
# CFLAGS="-std=c99 -Wall -static -O2"
# TARGETS="ref opt arm"

echo "Compiler = " $CC $CFLAGS

for algpath in $SNEIK/crypto_aead/*
do
	echo
	algname=`basename $algpath`
	cd $algpath
	KAT=`echo *.txt`
	echo -n $algname "kat  "
	sha256sum $KAT

	for targ in $TARGETS
	do
		cd $algpath/$targ
		sources=`ls *.* | grep -v '\.h'`
		$CC $CFLAGS -I. -o $WORKD/$targ.$algname $sources $AEADMAIN
		cd $WORKD
		./$targ.$algname
		echo -n $algname $targ " "
		sha256sum *.txt
		rm -f *
	done
done

for algpath in $SNEIK/crypto_hash/*
do
	echo
	algname=`basename $algpath`
	cd $algpath
	KAT=`echo *.txt`
	echo -n $algname "kat  "
	sha256sum $KAT

	for targ in $TARGETS
	do
		cd $algpath/$targ
		sources=`ls *.* | grep -v '\.h'`
		$CC $CFLAGS -I. -o $WORKD/$targ.$algname $sources $HASHMAIN
		cd $WORKD
		./$targ.$algname
		echo -n $algname $targ " "
		sha256sum *.txt
		rm -f *
	done
done