mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-07 00:10:54 -04:00
* Add SPDX-License-Identifier in src/common * Add SPDX-License-Identifier in FrodoKEM * Add SPDX-License-Identifier in SIKE * Add SPDX-License-Identifier in BIKE * Add SPDX-License-Identifier in OQS headers * Add SPDX-License-Identifier in files generated during copy-from-pqclean * Add SPDX-License-Identifier in Picnic * Add SPDX-License-Identifier in qTesla * Add SPDX-License-Identifier in CMake files * Update license info in README * Add SPDX-License-Identifier in scripts * Add SPDX-License-Info to CMakeLists * Add SPDX-License-Info in tests * Add SPDX-License-Info to various files * Prettyprint * Add test for SPDX-License-Identifier headers * Updated license identifiers for CPU extension detection code. * Use conjunction for SPDX in file with two licenses Co-authored-by: xvzcf <xvzcf@users.noreply.github.com>
71 lines
2.5 KiB
Python
71 lines
2.5 KiB
Python
# SPDX-License-Identifier: MIT
|
|
|
|
import hashlib
|
|
import helpers
|
|
import pytest
|
|
import sys
|
|
|
|
@helpers.filtered_test
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
|
def test_aes():
|
|
helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_aes')],
|
|
)
|
|
|
|
@helpers.filtered_test
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
|
def test_sha3():
|
|
helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_sha3')],
|
|
)
|
|
|
|
@helpers.filtered_test
|
|
@pytest.mark.parametrize('msg', ['', 'a', 'abc', '1234567890123456789012345678901678901567890'])
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
|
def test_sha256(msg):
|
|
output = helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_hash'), 'sha256'],
|
|
input = msg.encode(),
|
|
)
|
|
assert(output.rstrip() == hashlib.sha256(msg.encode()).hexdigest())
|
|
output = helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_hash'), 'sha256inc'],
|
|
input = msg.encode(),
|
|
)
|
|
assert(output.rstrip() == hashlib.sha256(msg.encode()).hexdigest())
|
|
|
|
@helpers.filtered_test
|
|
@pytest.mark.parametrize('msg', ['', 'a', 'abc', '1234567890123456789012345678901678901567890'])
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
|
def test_sha384(msg):
|
|
output = helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_hash'), 'sha384'],
|
|
input = msg.encode(),
|
|
)
|
|
assert(output.rstrip() == hashlib.sha384(msg.encode()).hexdigest())
|
|
output = helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_hash'), 'sha384inc'],
|
|
input = msg.encode(),
|
|
)
|
|
assert(output.rstrip() == hashlib.sha384(msg.encode()).hexdigest())
|
|
|
|
@helpers.filtered_test
|
|
@pytest.mark.parametrize('msg', ['', 'a', 'abc', '1234567890123456789012345678901678901567890'])
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
|
def test_sha512(msg):
|
|
output = helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_hash'), 'sha512'],
|
|
input = msg.encode(),
|
|
)
|
|
assert(output.rstrip() == hashlib.sha512(msg.encode()).hexdigest())
|
|
output = helpers.run_subprocess(
|
|
[helpers.path_to_executable('test_hash'), 'sha512inc'],
|
|
input = msg.encode(),
|
|
)
|
|
assert(output.rstrip() == hashlib.sha512(msg.encode()).hexdigest())
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
pytest.main(sys.argv)
|
|
|