diff options
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 10 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/interfaces.py | 4 | ||||
-rw-r--r-- | docs/hazmat/primitives/interfaces.rst | 4 | ||||
-rw-r--r-- | docs/installation.rst | 7 | ||||
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 17 |
5 files changed, 33 insertions, 9 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index e842f078..67b365fa 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -177,6 +177,11 @@ class Backend(object): return self._ffi.buffer(buf)[:] + def _err_string(self, code): + err_buf = self._ffi.new("char[]", 256) + self._lib.ERR_error_string_n(code, err_buf, 256) + return self._ffi.string(err_buf, 256)[:] + def _handle_error(self, mode): code = self._lib.ERR_get_error() if not code and isinstance(mode, GCM): @@ -211,7 +216,10 @@ class Backend(object): ) raise InternalError( - "Unknown error code from OpenSSL, you should probably file a bug." + "Unknown error code {0} from OpenSSL, " + "you should probably file a bug. {1}".format( + code, self._err_string(code) + ) ) diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py index 1a27644f..4fa24570 100644 --- a/cryptography/hazmat/primitives/interfaces.py +++ b/cryptography/hazmat/primitives/interfaces.py @@ -185,7 +185,7 @@ class RSAPrivateKey(six.with_metaclass(abc.ABCMeta)): """ @abc.abstractproperty - def key_length(self): + def key_size(self): """ The bit length of the public modulus. """ @@ -241,7 +241,7 @@ class RSAPublicKey(six.with_metaclass(abc.ABCMeta)): """ @abc.abstractproperty - def key_length(self): + def key_size(self): """ The bit length of the public modulus. """ diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst index 09a5a4ce..7fef1c13 100644 --- a/docs/hazmat/primitives/interfaces.rst +++ b/docs/hazmat/primitives/interfaces.rst @@ -130,7 +130,7 @@ Asymmetric Interfaces The public exponent. - .. attribute:: key_length + .. attribute:: key_size :type: int @@ -179,7 +179,7 @@ Asymmetric Interfaces The public modulus. - .. attribute:: key_length + .. attribute:: key_size :type: int diff --git a/docs/installation.rst b/docs/installation.rst index 2206107e..7e7348e2 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,5 +1,5 @@ -Installing -========== +Installation +============ You can install ``cryptography`` with ``pip``: @@ -7,10 +7,9 @@ You can install ``cryptography`` with ``pip``: $ pip install cryptography -Installation Notes -================== On Windows ---------- + If you're on Windows you'll need to make sure you have OpenSSL installed. There are `pre-compiled binaries`_ available. If your installation is in an unusual location set the ``LIB`` and ``INCLUDE`` environment variables diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index b0a58c41..1e35322a 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -116,6 +116,23 @@ class TestOpenSSL(object): assert backend._lib.ERR_peek_error() == 0 + def test_openssl_error_string(self): + backend._lib.ERR_put_error( + backend._lib.ERR_LIB_EVP, + backend._lib.EVP_F_EVP_DECRYPTFINAL_EX, + 0, + b"test_openssl.py", + -1 + ) + + with pytest.raises(InternalError) as exc: + backend._handle_error(None) + + assert ( + "digital envelope routines:" + "EVP_DecryptFinal_ex:digital envelope routines" in str(exc) + ) + def test_ssl_ciphers_registered(self): meth = backend._lib.TLSv1_method() ctx = backend._lib.SSL_CTX_new(meth) |