summaryrefslogtreecommitdiff
path: root/nist/make-package.sh
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-29 14:48:22 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-29 14:49:27 +0100
commitffd17baa2f156d90f854e72eee374f0bc5abc99e (patch)
tree61d3cd9c94520be4c34261f11912fcf805a05d84 /nist/make-package.sh
parent65a052061b6621ef77b90b3e1ed7f85356f1d0bb (diff)
downloadlilliput-ae-implem-ffd17baa2f156d90f854e72eee374f0bc5abc99e.tar.xz
Ajout d'un script de génération de livraison pour le NIST
Diffstat (limited to 'nist/make-package.sh')
-rwxr-xr-xnist/make-package.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/nist/make-package.sh b/nist/make-package.sh
new file mode 100755
index 0000000..009d997
--- /dev/null
+++ b/nist/make-package.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+set -Eeu
+
+# Generate NIST's expected tree:
+#
+# crypto_aead
+# │
+# └── lilliputae${mode}${keylen}v1
+# │
+# ├── add_${someimplementation}
+# │ ├── api.h
+# │ └── encrypt.c
+# │
+# ├── add_${someplatform}
+# │ ├── api.h
+# │ └── encrypt.c
+# │
+# ├── ref
+# │ ├── api.h
+# │ └── encrypt.c
+# │
+# └── LWC_AEAD_KAT_${keylen}_120.txt
+
+NIST_DIR=$(dirname $0)
+ROOT=${NIST_DIR}/..
+TMP_DIR=$(mktemp -d)
+
+cleanup ()
+{
+ rm -r ${TMP_DIR}
+}
+
+trap cleanup ERR
+
+
+add-variant ()
+{
+ mode=$1
+ key_length=$2
+ variant=lilliputae${mode}${key_length}v1
+ dest=${TMP_DIR}/crypto_aead/${variant}/ref
+
+ mkdir -p ${dest}
+ cp ${ROOT}/crypto_aead/${variant}/ref/_parameters.h ${dest}
+ cp ${NIST_DIR}/{api.h,encrypt.c} ${dest}
+
+ source_files=(
+ ae-common.h
+ cipher.{c,h}
+ constants.{c,h}
+ lilliput-ae{.h,-${mode}.c}
+ parameters.h
+ tweakey.{c,h}
+ )
+
+ for f in ${source_files[@]}
+ do
+ cp ${ROOT}/src/${f} ${dest}
+ done
+}
+
+test-variant ()
+{
+ mode=$1
+ key_length=$2
+ variant=lilliputae${mode}${key_length}v1
+ dest=${TMP_DIR}/crypto_aead/${variant}
+ src=${dest}/ref
+
+ genkat=${TMP_DIR}/${variant}
+
+ nist_flags=(-std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2)
+
+ gcc ${nist_flags[@]} -Werror -I${src} -I${TMP_DIR} \
+ ${src}/*.c ${TMP_DIR}/genkat_aead.c -o ${genkat}
+
+ ${genkat}
+
+ mv LWC_AEAD_KAT_${key_length}_120.txt ${dest}
+}
+
+
+unzip ${NIST_DIR}/TestVectorGen.zip -d ${TMP_DIR}
+
+for mode in i ii
+do
+ for key_length in 128 192 256
+ do
+ add-variant ${mode} ${key_length}
+ test-variant ${mode} ${key_length}
+ done
+done
+
+tar czf lilliput-ae.tgz -C ${TMP_DIR} crypto_aead
+
+cleanup