cryptography/tests/wycheproof/utils.py
Paul Kehrer 01687d63a5
add unsafe_skip_rsa_key_validation (#7667)
* add unsafe_skip_rsa_key_validation

This allows users to skip RSA key validation when calling
load_pem_private_key, load_der_private_key, and
RSAPrivateNumbers.private_key. This is a significant performance
improvement but is **only safe if you know the key is valid**. If you
use this when the key is invalid OpenSSL makes no guarantees about what
might happen. Infinite loops, crashes, and all manner of terrible things
become possible if that occurs. Beware, beware, beware.

* Apply suggestions from code review

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>

* remove unneeded variable

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-10-03 14:29:45 +00:00

17 lines
515 B
Python

from ..utils import load_wycheproof_tests
def wycheproof_tests(*paths):
def wrapper(func):
def run_wycheproof(backend, subtests, pytestconfig):
wycheproof_root = pytestconfig.getoption(
"--wycheproof-root", skip=True
)
for path in paths:
for test in load_wycheproof_tests(wycheproof_root, path):
with subtests.test():
func(backend, test)
return run_wycheproof
return wrapper