Skip to content

Commit

Permalink
better CI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
bhess committed Jan 24, 2024
1 parent 7653559 commit b810cc5
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 53 deletions.
1 change: 1 addition & 0 deletions tests/test_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import helpers
import os
import pytest
import re
import sys

@helpers.filtered_test
Expand Down
21 changes: 16 additions & 5 deletions tests/test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@

@helpers.filtered_test
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not needed on Windows")
def test_vectors():

@pytest.mark.parametrize('kem_name', helpers.available_kems_by_name())
def test_vectors_kem(kem_name):
if not(helpers.is_kem_enabled_by_name(kem_name)): pytest.skip('Not enabled')
result = helpers.run_subprocess(
['tests/test_vectors.sh']
['tests/test_vectors.sh', kem_name],
)
if kem_name + " not supported" in result:
pytest.skip("Not supported")

print("Test vectors mismatch.")
print(result)
@helpers.filtered_test
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not needed on Windows")
@pytest.mark.parametrize('sig_name', helpers.available_sigs_by_name())
def test_vectors_sig(sig_name):
if not(helpers.is_sig_enabled_by_name(sig_name)): pytest.skip('Not enabled')
result = helpers.run_subprocess(
['tests/test_vectors.sh', sig_name],
)
if sig_name + " not supported" in result:
pytest.skip("Not supported")

if __name__ == "__main__":
import sys
Expand Down
112 changes: 64 additions & 48 deletions tests/test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,78 @@ else
build_dir="${OQS_BUILD_DIR}"
fi

file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-DSA-44.txt
file_signature=tests/PQC\ Intermediate\ Values/Signature\ Generation\ --\ ML-DSA-44.txt
file_verification=tests/PQC\ Intermediate\ Values/Signature\ Verification\ --\ ML-DSA-44.txt
scheme_name=ML-DSA-44-ipd
if [ "$1" = "ML-DSA-44-ipd" ]; then

sh tests/test_sig_vectors.sh "$scheme_name" "$file_keygen" "$file_signature" "$file_verification" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi
scheme_name=ML-DSA-44-ipd
file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-DSA-44.txt
file_signature=tests/PQC\ Intermediate\ Values/Signature\ Generation\ --\ ML-DSA-44.txt
file_verification=tests/PQC\ Intermediate\ Values/Signature\ Verification\ --\ ML-DSA-44.txt

sh tests/test_sig_vectors.sh "$scheme_name" "$file_keygen" "$file_signature" "$file_verification" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi

file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-DSA-65.txt
file_signature=tests/PQC\ Intermediate\ Values/Signature\ Generation\ --\ ML-DSA-65.txt
file_verification=tests/PQC\ Intermediate\ Values/Signature\ Verification\ --\ ML-DSA-65.txt
scheme_name=ML-DSA-65-ipd
elif [ "$1" = "ML-DSA-65-ipd" ]; then

sh tests/test_sig_vectors.sh "$scheme_name" "$file_keygen" "$file_signature" "$file_verification" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi
file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-DSA-65.txt
file_signature=tests/PQC\ Intermediate\ Values/Signature\ Generation\ --\ ML-DSA-65.txt
file_verification=tests/PQC\ Intermediate\ Values/Signature\ Verification\ --\ ML-DSA-65.txt
scheme_name=ML-DSA-65-ipd

sh tests/test_sig_vectors.sh "$scheme_name" "$file_keygen" "$file_signature" "$file_verification" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi

file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-DSA-87.txt
file_signature=tests/PQC\ Intermediate\ Values/Signature\ Generation\ --\ ML-DSA-87.txt
file_verification=tests/PQC\ Intermediate\ Values/Signature\ Verification\ --\ ML-DSA-87.txt
scheme_name=ML-DSA-87-ipd
elif [ "$1" = "ML-DSA-87-ipd" ]; then

sh tests/test_sig_vectors.sh "$scheme_name" "$file_keygen" "$file_signature" "$file_verification" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi
file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-DSA-87.txt
file_signature=tests/PQC\ Intermediate\ Values/Signature\ Generation\ --\ ML-DSA-87.txt
file_verification=tests/PQC\ Intermediate\ Values/Signature\ Verification\ --\ ML-DSA-87.txt
scheme_name=ML-DSA-87-ipd

sh tests/test_sig_vectors.sh "$scheme_name" "$file_keygen" "$file_signature" "$file_verification" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi

file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-KEM-512.txt
file_encaps=tests/PQC\ Intermediate\ Values/Encapsulation\ --\ ML-KEM-512.txt
file_decaps=tests/PQC\ Intermediate\ Values/Decapsulation\ --\ ML-KEM-512.txt
scheme_name=ML-KEM-512-ipd
elif [ "$1" = "ML-KEM-512-ipd" ]; then

sh tests/test_kem_vectors.sh "$scheme_name" "$file_keygen" "$file_encaps" "$file_decaps" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi
file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-KEM-512.txt
file_encaps=tests/PQC\ Intermediate\ Values/Encapsulation\ --\ ML-KEM-512.txt
file_decaps=tests/PQC\ Intermediate\ Values/Decapsulation\ --\ ML-KEM-512.txt
scheme_name=ML-KEM-512-ipd

sh tests/test_kem_vectors.sh "$scheme_name" "$file_keygen" "$file_encaps" "$file_decaps" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi

file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-KEM-768.txt
file_encaps=tests/PQC\ Intermediate\ Values/Encapsulation\ --\ ML-KEM-768.txt
file_decaps=tests/PQC\ Intermediate\ Values/Decapsulation\ --\ ML-KEM-768.txt
scheme_name=ML-KEM-768-ipd
elif [ "$1" = "ML-KEM-768-ipd" ]; then

sh tests/test_kem_vectors.sh "$scheme_name" "$file_keygen" "$file_encaps" "$file_decaps" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi
file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-KEM-768.txt
file_encaps=tests/PQC\ Intermediate\ Values/Encapsulation\ --\ ML-KEM-768.txt
file_decaps=tests/PQC\ Intermediate\ Values/Decapsulation\ --\ ML-KEM-768.txt
scheme_name=ML-KEM-768-ipd

sh tests/test_kem_vectors.sh "$scheme_name" "$file_keygen" "$file_encaps" "$file_decaps" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi

elif [ "$1" = "ML-KEM-1024-ipd" ]; then

file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-KEM-1024.txt
file_encaps=tests/PQC\ Intermediate\ Values/Encapsulation\ --\ ML-KEM-1024.txt
file_decaps=tests/PQC\ Intermediate\ Values/Decapsulation\ --\ ML-KEM-1024.txt
scheme_name=ML-KEM-1024-ipd
file_keygen=tests/PQC\ Intermediate\ Values/Key\ Generation\ --\ ML-KEM-1024.txt
file_encaps=tests/PQC\ Intermediate\ Values/Encapsulation\ --\ ML-KEM-1024.txt
file_decaps=tests/PQC\ Intermediate\ Values/Decapsulation\ --\ ML-KEM-1024.txt
scheme_name=ML-KEM-1024-ipd

sh tests/test_kem_vectors.sh "$scheme_name" "$file_keygen" "$file_encaps" "$file_decaps" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi

sh tests/test_kem_vectors.sh "$scheme_name" "$file_keygen" "$file_encaps" "$file_decaps" "$build_dir"
if [ $? != 0 ]; then
exit 1
fi
else
echo "$1 not supported"
fi

0 comments on commit b810cc5

Please sign in to comment.