From 84c53958def0f510e92119fca14d74f94215827a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Tue, 28 Jun 2022 21:17:01 +0200 Subject: Mitigate the Bleichenbacher timing attacks in the RSA decryption API (CVE-2020-25657) Fixes #282 --- tests/test_rsa.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tests/test_rsa.py') diff --git a/tests/test_rsa.py b/tests/test_rsa.py index 7bb3af7..5e75d68 100644 --- a/tests/test_rsa.py +++ b/tests/test_rsa.py @@ -109,8 +109,9 @@ class RSATestCase(unittest.TestCase): # The other paddings. for padding in self.s_padding_nok: p = getattr(RSA, padding) - with self.assertRaises(RSA.RSAError): - priv.private_encrypt(self.data, p) + # Exception disabled as a part of mitigation against CVE-2020-25657 + # with self.assertRaises(RSA.RSAError): + priv.private_encrypt(self.data, p) # Type-check the data to be encrypted. with self.assertRaises(TypeError): priv.private_encrypt(self.gen_callback, RSA.pkcs1_padding) @@ -127,10 +128,12 @@ class RSATestCase(unittest.TestCase): self.assertEqual(ptxt, self.data) # no_padding - with six.assertRaisesRegex(self, RSA.RSAError, 'data too small'): - priv.public_encrypt(self.data, RSA.no_padding) + # Exception disabled as a part of mitigation against CVE-2020-25657 + # with six.assertRaisesRegex(self, RSA.RSAError, 'data too small'): + priv.public_encrypt(self.data, RSA.no_padding) # Type-check the data to be encrypted. + # Exception disabled as a part of mitigation against CVE-2020-25657 with self.assertRaises(TypeError): priv.public_encrypt(self.gen_callback, RSA.pkcs1_padding) @@ -146,10 +149,6 @@ class RSATestCase(unittest.TestCase): b'\000\000\000\003\001\000\001') # aka 65537 aka 0xf4 with self.assertRaises(RSA.RSAError): setattr(rsa, 'e', '\000\000\000\003\001\000\001') - with self.assertRaises(RSA.RSAError): - rsa.private_encrypt(1) - with self.assertRaises(RSA.RSAError): - rsa.private_decrypt(1) assert rsa.check_key() def test_loadpub_bad(self): -- cgit v1.2.1