lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

commit c766de8194c31b97173ba3f207c794a91f49c365
parent b16148d754f1f09586afd76e4f23c90d00c06320
Author: Kévin Le Gouguec <kevin.legouguec@airbus.com>
Date:   Tue,  2 Jul 2019 16:09:07 +0200

Parallélisation de la génération des vecteurs Python

Diffstat:
Mtest/python/compare.sh | 2+-
Mtest/python/generate-vectors.sh | 23+++++++++++++++--------
Mtest/python/genkat_aead.py | 17++++++++++++++---
3 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/test/python/compare.sh b/test/python/compare.sh @@ -1,7 +1,7 @@ #!/bin/bash PYTHON_DIR=$(dirname $0) -ROOT_DIR=${PYTHON_DIR}/../../ +ROOT_DIR=${PYTHON_DIR}/../.. RESULTS_DIR=${ROOT_DIR}/results CRYPTO_AEAD=${ROOT_DIR}/crypto_aead diff --git a/test/python/generate-vectors.sh b/test/python/generate-vectors.sh @@ -3,7 +3,7 @@ set -eu PYTHON_DIR=$(dirname $0) -ROOT_DIR=${PYTHON_DIR}/../../ +ROOT_DIR=${PYTHON_DIR}/../.. SRC_DIR=${ROOT_DIR}/src/add_python RESULTS_DIR=${ROOT_DIR}/results CRYPTO_AEAD=${RESULTS_DIR}/crypto_aead_py @@ -17,18 +17,20 @@ generate () { local mode=$1 local keylen=$2 + local dest_dir=${CRYPTO_AEAD}/${NAMES[${mode}]}${keylen}v1 + local param_dir=${RESULTS_DIR}/python-${mode}-${keylen} - echo generating for ${mode} ${keylen} - - cat <<EOF > ${RESULTS_DIR}/parameters.py + mkdir -p ${param_dir} + cat <<EOF > ${param_dir}/parameters.py MODE = ${mode} KEYBYTES = $((keylen/8)) EOF - PYTHONPATH=${RESULTS_DIR}:${SRC_DIR} ${PYTHON_DIR}/genkat_aead.py + echo ${mode} ${keylen}: starting + + PYTHONPATH=${param_dir}:${SRC_DIR} ${PYTHON_DIR}/genkat_aead.py ${dest_dir} - dest=${CRYPTO_AEAD}/${NAMES[${mode}]}${keylen}v1 - mv LWC_AEAD_KAT_${keylen}_120.txt ${dest} + echo ${mode} ${keylen}: finished } @@ -36,6 +38,11 @@ for mode in 1 2 do for keylen in 128 192 256 do - generate ${mode} ${keylen} + generate ${mode} ${keylen} & done done + +for ((i=0; i<6; i++)) +do + wait -n +done diff --git a/test/python/genkat_aead.py b/test/python/genkat_aead.py @@ -15,6 +15,9 @@ """Python port of the genkat_aead.c program.""" +from os import path +from sys import argv + import crypto_aead @@ -31,7 +34,7 @@ def print_bstr(output, label, buf): print('{l} = {b}'.format(l=label, b=buf.hex().upper()), file=output) -def generate_test_vectors(): +def generate_test_vectors(output_dir): count = 1 filename = 'LWC_AEAD_KAT_{key}_{npub}.txt'.format( key=crypto_aead.KEYBYTES*8, npub=crypto_aead.NPUBBYTES*8 @@ -40,7 +43,7 @@ def generate_test_vectors(): npub = bytes(range(crypto_aead.NPUBBYTES)) key = bytes(range(crypto_aead.KEYBYTES)) - with open(filename, 'w') as output: + with open(path.join(output_dir, filename), 'w') as output: for mlen in range(MAX_MESSAGE_LENGTH+1): for adlen in range(MAX_ASSOCIATED_DATA_LENGTH+1): @@ -68,5 +71,13 @@ def generate_test_vectors(): print(file=output) +def main(argv): + output_dir = path.curdir + if len(argv) > 1: + output_dir = argv[1] + + generate_test_vectors(output_dir) + + if __name__ == '__main__': - generate_test_vectors() + main(argv)