m2crypto/CVE-2020-25657-pre2.patch
starlet-dx 6cb405ce6f Fix CVE-2020-25657
(cherry picked from commit b32f1d4be1dc6c88e8c2ae083740acce38bf44c2)
2022-08-17 17:41:38 +08:00

43 lines
1.6 KiB
Diff

From 0b22d79082afd7c564b2ac07fb0ef5d76d692586 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu>
Date: Fri, 7 Jun 2019 11:43:03 +0200
Subject: [PATCH] Limit tests.test_rsa.RSATestCase.test_public_encrypt just to
OpenSSL which sustains it.
Fixes #258
---
M2Crypto-0.30.1/tests/test_rsa.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/M2Crypto-0.30.1/tests/test_rsa.py b/M2Crypto-0.30.1/tests/test_rsa.py
index 875b59c6..7028b608 100644
--- a/M2Crypto-0.30.1/tests/test_rsa.py
+++ b/M2Crypto-0.30.1/tests/test_rsa.py
@@ -113,6 +113,8 @@ class RSATestCase(unittest.TestCase):
with self.assertRaises(TypeError):
priv.private_encrypt(self.gen_callback, RSA.pkcs1_padding)
+ @unittest.skipIf(m2.OPENSSL_VERSION_NUMBER < 0x1010103f,
+ 'Relies on fix which happened only in OpenSSL 1.1.1c')
def test_public_encrypt(self):
priv = RSA.load_key(self.privkey)
# pkcs1_padding, pkcs1_oaep_padding
@@ -124,11 +126,11 @@ class RSATestCase(unittest.TestCase):
# sslv23_padding
ctxt = priv.public_encrypt(self.data, RSA.sslv23_padding)
- with self.assertRaises(RSA.RSAError):
- priv.private_decrypt(ctxt, RSA.sslv23_padding)
+ res = priv.private_decrypt(ctxt, RSA.sslv23_padding)
+ self.assertEqual(res, self.data)
# no_padding
- with self.assertRaises(RSA.RSAError):
+ with six.assertRaisesRegex(self, TypeError, 'data too small'):
priv.public_encrypt(self.data, RSA.no_padding)
# Type-check the data to be encrypted.
--
GitLab