2019-02-18 15:07:01 +00:00
|
|
|
"""
|
|
|
|
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:
|
2019-03-01 12:18:41 +00:00
|
|
|
yield check_vectors, implementation
|
2019-02-18 15:07:01 +00:00
|
|
|
|
2019-03-01 12:18:41 +00:00
|
|
|
|
|
|
|
def check_vectors(implementation):
|
|
|
|
helpers.make(TYPE=implementation.scheme.type,
|
|
|
|
SCHEME=implementation.scheme.name,
|
|
|
|
IMPLEMENTATION=implementation.name,
|
|
|
|
working_dir=os.path.join('..', 'test'))
|
2019-02-18 15:07:01 +00:00
|
|
|
out = helpers.run_subprocess(
|
2019-03-01 12:18:41 +00:00
|
|
|
['./testvectors_{}_{}'.format(implementation.scheme.name,
|
|
|
|
implementation.name)],
|
2019-02-18 15:07:01 +00:00
|
|
|
os.path.join('..', 'bin'),
|
|
|
|
)
|
2019-03-01 12:18:41 +00:00
|
|
|
assert(implementation.scheme.metadata()['testvectors-sha256'].lower()
|
|
|
|
== hashlib.sha256(out.encode('utf-8')).hexdigest().lower())
|
2019-02-18 15:07:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
try:
|
|
|
|
import nose2
|
|
|
|
nose2.main()
|
|
|
|
except ImportError:
|
|
|
|
import nose
|
|
|
|
nose.runmodule()
|