diff options
-rw-r--r-- | cryptography/hazmat/bindings/openssl/backend.py | 6 | ||||
-rw-r--r-- | tests/hazmat/bindings/test_openssl.py | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index ae951717..77ecf277 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -199,7 +199,9 @@ class Backend(object): lib = self.lib.ERR_GET_LIB(code) func = self.lib.ERR_GET_FUNC(code) reason = self.lib.ERR_GET_REASON(code) + return self._handle_error_code(lib, func, reason) + def _handle_error_code(self, lib, func, reason): if lib == self.lib.ERR_LIB_EVP: if func == self.lib.EVP_F_EVP_ENCRYPTFINAL_EX: if reason == self.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH: @@ -208,10 +210,8 @@ class Backend(object): if reason == self.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH: raise IncorrectPadding - message = self.ffi.string(self.lib.ERR_reason_error_string(code)) raise SystemError( - "Unknown error code from OpenSSL, you should probably file a bug. " - "Cause: %s" % message + "Unknown error code from OpenSSL, you should probably file a bug." ) diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index 9f27aab7..7ad1ea75 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -70,3 +70,7 @@ class TestOpenSSL(object): ) with pytest.raises(UnsupportedAlgorithm): cipher.encryptor() + + def test_handle_unknown_error(self): + with pytest.raises(SystemError): + backend._handle_error_code(0, 0, 0) |