aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-11-22 16:24:06 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-11-22 16:24:06 -0800
commite247d0be584c52e25694918ad2345dadde3fefa9 (patch)
tree4de14a0fefd1e1f783b9c2d0b00823089ebf722d
parent3edffe25ab91702842a7553b028d50086c58eef1 (diff)
downloadcryptography-e247d0be584c52e25694918ad2345dadde3fefa9.tar.gz
cryptography-e247d0be584c52e25694918ad2345dadde3fefa9.tar.bz2
cryptography-e247d0be584c52e25694918ad2345dadde3fefa9.zip
Coverage
-rw-r--r--cryptography/hazmat/bindings/openssl/backend.py6
-rw-r--r--tests/hazmat/bindings/test_openssl.py4
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)