mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-26 17:31:38 +00:00
75be658074
Modify the tests to no longer construct the classes multiple times and to have them make use of the new helpers.make() function.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""
|
|
Checks that (hash of the) test vectors produced on this platform matches
|
|
the one provided in the META file for every scheme/implementation.
|
|
"""
|
|
|
|
import hashlib
|
|
import os
|
|
import pqclean
|
|
import helpers
|
|
|
|
|
|
def test_testvectors():
|
|
for scheme in pqclean.Scheme.all_schemes():
|
|
for implementation in scheme.implementations:
|
|
yield check_vectors, implementation
|
|
|
|
|
|
def check_vectors(implementation):
|
|
helpers.make(TYPE=implementation.scheme.type,
|
|
SCHEME=implementation.scheme.name,
|
|
IMPLEMENTATION=implementation.name,
|
|
working_dir=os.path.join('..', 'test'))
|
|
out = helpers.run_subprocess(
|
|
['./testvectors_{}_{}'.format(implementation.scheme.name,
|
|
implementation.name)],
|
|
os.path.join('..', 'bin'),
|
|
)
|
|
assert(implementation.scheme.metadata()['testvectors-sha256'].lower()
|
|
== hashlib.sha256(out.encode('utf-8')).hexdigest().lower())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
import nose2
|
|
nose2.main()
|
|
except ImportError:
|
|
import nose
|
|
nose.runmodule()
|