summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2021-11-11 17:31:31 -0500
committerGitHub <noreply@github.com>2021-11-11 22:31:31 +0000
commitbf60d3ebba9817ed7a0f05c26f6f9a542bdd669e (patch)
tree94df4a4ab0e1628cd277be58b2d4e18969280a4a
parent8245d777ba58ac1da357b1a71cc8e33b229060ed (diff)
downloadcryptography-bf60d3ebba9817ed7a0f05c26f6f9a542bdd669e.tar.gz
Run tests/primitives/ (minus a few files) on BoringSSL (#6584)
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py9
-rw-r--r--tests/hazmat/primitives/test_rsa.py2
3 files changed, 9 insertions, 4 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5126f2ea1..cb76c351e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -42,7 +42,7 @@ jobs:
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "libressl", VERSION: "3.4.1"}}
- {VERSION: "3.10", TOXENV: "py310"}
# Latest commit on the main-with-bazel branch, as of November 8, 2021
- - {VERSION: "3.10", TOXENV: "py310", TOXARGS: "--ignore=tests/hazmat/backends/ --ignore=tests/hazmat/bindings/ --ignore=tests/hazmat/primitives/ --ignore=tests/x509/", OPENSSL: {TYPE: "boringssl", VERSION: "4fb158925f7753d80fb858cb0239dff893ef9f15"}}
+ - {VERSION: "3.10", TOXENV: "py310", TOXARGS: "--ignore=tests/hazmat/backends/ --ignore=tests/hazmat/bindings/ --ignore=tests/hazmat/primitives/test_dh.py --ignore=tests/hazmat/primitives/test_pkcs7.py --ignore=tests/hazmat/primitives/test_serialization.py --ignore=tests/x509/", OPENSSL: {TYPE: "boringssl", VERSION: "4fb158925f7753d80fb858cb0239dff893ef9f15"}}
RUST:
- stable
name: "${{ matrix.PYTHON.TOXENV }} ${{ matrix.PYTHON.OPENSSL.TYPE }} ${{ matrix.PYTHON.OPENSSL.VERSION }} ${{ matrix.PYTHON.TOXARGS }} ${{ matrix.PYTHON.OPENSSL.CONFIG_FLAGS }}"
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index fd5ad291d..2d75bf6ff 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -1187,7 +1187,9 @@ class Backend(BackendInterface):
self._int_to_bn(numbers.private_value), self._lib.BN_clear_free
)
res = self._lib.EC_KEY_set_private_key(ec_cdata, private_value)
- self.openssl_assert(res == 1)
+ if res != 1:
+ self._consume_errors()
+ raise ValueError("Invalid EC key.")
ec_cdata = self._ec_key_set_public_key_affine_coordinates(
ec_cdata, public.x, public.y
@@ -2043,7 +2045,10 @@ class Backend(BackendInterface):
# In OpenSSL < 3.0.0 PKCS12 parsing reverses the order of the
# certificates.
indices: typing.Iterable[int]
- if self._lib.CRYPTOGRAPHY_OPENSSL_300_OR_GREATER:
+ if (
+ self._lib.CRYPTOGRAPHY_OPENSSL_300_OR_GREATER
+ or self._lib.CRYPTOGRAPHY_IS_BORINGSSL
+ ):
indices = range(num)
else:
indices = reversed(range(num))
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 63fc215e1..4fb205db4 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -176,7 +176,7 @@ class TestRSA(object):
("public_exponent", "key_size"),
itertools.product(
(3, 65537),
- (1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1536, 2048),
+ (1024, 1536, 2048),
),
)
def test_generate_rsa_keys(self, backend, public_exponent, key_size):