forked from open-quantum-safe/liboqs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_kat_all.py
40 lines (34 loc) · 1.16 KB
/
test_kat_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# SPDX-License-Identifier: MIT
import helpers
import os
import os.path
import pytest
import platform
from hashlib import sha256
@helpers.filtered_test
@pytest.mark.parametrize('kem_name', helpers.available_kems_by_name())
def test_kem(kem_name):
kats = helpers.get_kats("kem")
if not(helpers.is_kem_enabled_by_name(kem_name)): pytest.skip('Not enabled')
output = helpers.run_subprocess(
[helpers.path_to_executable('kat_kem'), kem_name, '--all'],
)
output = output.replace("\r\n", "\n")
h256 = sha256()
h256.update(output.encode())
assert(kats[kem_name]['all'] == h256.hexdigest())
@helpers.filtered_test
@pytest.mark.parametrize('sig_name', helpers.available_sigs_by_name())
def test_sig(sig_name):
kats = helpers.get_kats("sig")
if not(helpers.is_sig_enabled_by_name(sig_name)): pytest.skip('Not enabled')
output = helpers.run_subprocess(
[helpers.path_to_executable('kat_sig'), sig_name, '--all'],
)
output = output.replace("\r\n", "\n")
h256 = sha256()
h256.update(output.encode())
assert(kats[sig_name]['all'] == h256.hexdigest())
if __name__ == "__main__":
import sys
pytest.main(sys.argv)