diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-07-02 16:09:07 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-07-02 17:11:13 +0200 |
| commit | 53229fa55e46f4d474cd38f31185aa8dcb83c701 (patch) | |
| tree | fcd91a27df9f1f0c03950a8046b5022746128db8 /test | |
| parent | 401fd928088f51e90e391377c9d696b162d1878f (diff) | |
| download | lilliput-ae-implem-53229fa55e46f4d474cd38f31185aa8dcb83c701.tar.xz | |
Parallélisation de la génération des vecteurs Python
Diffstat (limited to 'test')
| -rwxr-xr-x | test/python/compare.sh | 2 | ||||
| -rwxr-xr-x | test/python/generate-vectors.sh | 23 | ||||
| -rwxr-xr-x | test/python/genkat_aead.py | 17 |
3 files changed, 30 insertions, 12 deletions
diff --git a/test/python/compare.sh b/test/python/compare.sh index 414eb1e..c5c5eeb 100755 --- 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 index d37f15f..3f68d6c 100755 --- 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 index db3a89c..846155f 100755 --- 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) |
