summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2016-07-03 10:48:32 -0400
committerCory Benfield <lukasaoz@gmail.com>2016-07-03 15:48:32 +0100
commit5bb2bd19dcb015bf7f2bfb8817da86fd0dc94672 (patch)
tree55762c693c33f50f7042d1a6c1e057ec9c89ea76 /src
parent09f19f5ab29d7545b962c921d350b9d4320b448e (diff)
downloadpyopenssl-5bb2bd19dcb015bf7f2bfb8817da86fd0dc94672.tar.gz
Simplify a few more branches to improve coverage (#500)
Diffstat (limited to 'src')
-rw-r--r--src/OpenSSL/SSL.py10
-rw-r--r--src/OpenSSL/crypto.py20
2 files changed, 6 insertions, 24 deletions
diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py
index 5eea271..3f97ccb 100644
--- a/src/OpenSSL/SSL.py
+++ b/src/OpenSSL/SSL.py
@@ -71,10 +71,7 @@ OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = (
)
OP_SSLREF2_REUSE_CERT_TYPE_BUG = _lib.SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
OP_MICROSOFT_BIG_SSLV3_BUFFER = _lib.SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
-try:
- OP_MSIE_SSLV2_RSA_PADDING = _lib.SSL_OP_MSIE_SSLV2_RSA_PADDING
-except AttributeError:
- pass
+OP_MSIE_SSLV2_RSA_PADDING = _lib.SSL_OP_MSIE_SSLV2_RSA_PADDING
OP_SSLEAY_080_CLIENT_DH_BUG = _lib.SSL_OP_SSLEAY_080_CLIENT_DH_BUG
OP_TLS_D5_BUG = _lib.SSL_OP_TLS_D5_BUG
OP_TLS_BLOCK_PADDING_BUG = _lib.SSL_OP_TLS_BLOCK_PADDING_BUG
@@ -91,10 +88,7 @@ OP_NO_COMPRESSION = _lib.SSL_OP_NO_COMPRESSION
OP_NO_QUERY_MTU = _lib.SSL_OP_NO_QUERY_MTU
OP_COOKIE_EXCHANGE = _lib.SSL_OP_COOKIE_EXCHANGE
-try:
- OP_NO_TICKET = _lib.SSL_OP_NO_TICKET
-except AttributeError:
- pass
+OP_NO_TICKET = _lib.SSL_OP_NO_TICKET
OP_ALL = _lib.SSL_OP_ALL
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index 70ae3d2..869bbb4 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -201,20 +201,10 @@ class PKey(object):
rsa = _lib.RSA_new()
result = _lib.RSA_generate_key_ex(rsa, bits, exponent, _ffi.NULL)
- if result == 0:
- # TODO: The test for this case is commented out. Different
- # builds of OpenSSL appear to have different failure modes that
- # make it hard to test. Visual inspection of the OpenSSL
- # source reveals that a return value of 0 signals an error.
- # Manual testing on a particular build of OpenSSL suggests that
- # this is probably the appropriate way to handle those errors.
- _raise_current_error()
+ _openssl_assert(result == 1)
result = _lib.EVP_PKEY_assign_RSA(self._pkey, rsa)
- if not result:
- # TODO: It appears as though this can fail if an engine is in
- # use which does not support RSA.
- _raise_current_error()
+ _openssl_assert(result == 1)
elif type == TYPE_DSA:
dsa = _lib.DSA_new()
@@ -824,8 +814,7 @@ class X509Req(object):
:return: ``None``
"""
set_result = _lib.X509_REQ_set_version(self._req, version)
- if not set_result:
- _raise_current_error()
+ _openssl_assert(set_result == 1)
def get_version(self):
"""
@@ -1037,8 +1026,7 @@ class X509(object):
raise ValueError("No such digest method")
sign_result = _lib.X509_sign(self._x509, pkey._pkey, evp_md)
- if not sign_result:
- _raise_current_error()
+ _openssl_assert(sign_result > 0)
def get_signature_algorithm(self):
"""