summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch b/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch
new file mode 100644
index 0000000000..c0acb9066b
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch
@@ -0,0 +1,66 @@
1From 97d231672763cdb5959a3b191e692a362f1b9e55 Mon Sep 17 00:00:00 2001
2From: Alex Gaynor <alex.gaynor@gmail.com>
3Date: Mon, 19 Feb 2024 11:50:28 -0500
4Subject: [PATCH] Fixes #10422 -- don't crash when a PKCS#12 key and cert don't
5match (#10423)
6
7Upstream-Status: Backport [https://github.com/pyca/cryptography/commit/97d231672763cdb5959a3b191e692a362f1b9e55]
8CVE: CVE-2024-26130
9Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
10---
11 .../hazmat/backends/openssl/backend.py | 9 +++++++++
12 tests/hazmat/primitives/test_pkcs12.py | 18 ++++++++++++++++++
13 2 files changed, 27 insertions(+)
14
15diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
16index 7e9fa20..ce3fc8c 100644
17--- a/src/cryptography/hazmat/backends/openssl/backend.py
18+++ b/src/cryptography/hazmat/backends/openssl/backend.py
19@@ -1046,6 +1046,15 @@ class Backend(object):
20 raise NotImplementedError(
21 'Extension not supported: {}'.format(extension.oid)
22 )
23+ if p12 == self._ffi.NULL:
24+ errors = self._consume_errors()
25+ raise ValueError(
26+ (
27+ "Failed to create PKCS12 (does the key match the "
28+ "certificate?)"
29+ ),
30+ errors,
31+ )
32
33 ext_struct = encode(self, extension.value)
34 nid = self._lib.OBJ_txt2nid(
35diff --git a/tests/hazmat/primitives/test_pkcs12.py b/tests/hazmat/primitives/test_pkcs12.py
36index f084d57..c4160b0 100644
37--- a/tests/hazmat/primitives/test_pkcs12.py
38+++ b/tests/hazmat/primitives/test_pkcs12.py
39@@ -17,6 +17,24 @@ from cryptography.hazmat.primitives.serialization.pkcs12 import (
40
41 from .utils import load_vectors_from_file
42
43+ @pytest.mark.supported(
44+ only_if=lambda backend: backend._lib.Cryptography_HAS_PKCS12_SET_MAC,
45+ skip_message="Requires OpenSSL with PKCS12_set_mac",
46+ )
47+ def test_set_mac_key_certificate_mismatch(self, backend):
48+ cacert, _ = _load_ca(backend)
49+ key = ec.generate_private_key(ec.SECP256R1())
50+ encryption = (
51+ serialization.PrivateFormat.PKCS12.encryption_builder()
52+ .hmac_hash(hashes.SHA256())
53+ .build(b"password")
54+ )
55+
56+ with pytest.raises(ValueError):
57+ serialize_key_and_certificates(
58+ b"name", key, cacert, [], encryption
59+ )
60+
61
62 @pytest.mark.requires_backend_interface(interface=DERSerializationBackend)
63 class TestPKCS12(object):
64--
652.25.1
66