Upgrade cryptography from 2.5 to 3.3
Source code is from https://github.com/pyca/cryptography/tree/3.3.x
Run setup.py locally and rename _openssl.so/_padding.so
Bug: 205265538
Test: None
Change-Id: If031739ef5830ba2fb177add74515e4660e2906e
diff --git a/tests/conftest.py b/tests/conftest.py
index d858b4f..ece7a11 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -9,12 +9,18 @@
from cryptography.hazmat.backends.openssl import backend as openssl_backend
from .utils import (
- check_backend_support, load_wycheproof_tests, skip_if_wycheproof_none
+ check_backend_support,
+ load_wycheproof_tests,
)
def pytest_report_header(config):
- return "OpenSSL: {0}".format(openssl_backend.openssl_version_text())
+ return "\n".join(
+ [
+ "OpenSSL: {}".format(openssl_backend.openssl_version_text()),
+ "FIPS Enabled: {}".format(openssl_backend._fips_enabled),
+ ]
+ )
def pytest_addoption(parser):
@@ -23,8 +29,7 @@
def pytest_generate_tests(metafunc):
if "wycheproof" in metafunc.fixturenames:
- wycheproof = metafunc.config.getoption("--wycheproof-root")
- skip_if_wycheproof_none(wycheproof)
+ wycheproof = metafunc.config.getoption("--wycheproof-root", skip=True)
testcases = []
marker = metafunc.definition.get_closest_marker("wycheproof_tests")
@@ -33,6 +38,12 @@
metafunc.parametrize("wycheproof", testcases)
+def pytest_runtest_setup(item):
+ if openssl_backend._fips_enabled:
+ for marker in item.iter_markers(name="skip_fips"):
+ pytest.skip(marker.kwargs["reason"])
+
+
@pytest.fixture()
def backend(request):
required_interfaces = [
@@ -43,7 +54,7 @@
isinstance(openssl_backend, iface) for iface in required_interfaces
):
pytest.skip(
- "OpenSSL doesn't implement required interfaces: {0}".format(
+ "OpenSSL doesn't implement required interfaces: {}".format(
required_interfaces
)
)