aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-03-07 22:49:43 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-03-07 22:49:43 -0400
commitd76bd668dc4b59c037771ed5619f939d65ca9905 (patch)
tree41ab4fac4ba90fef0602255c62d05ee8877936db /tests/hazmat
parent290272717c6d5fbdf074e72b9a444f7862c75f76 (diff)
downloadcryptography-d76bd668dc4b59c037771ed5619f939d65ca9905.tar.gz
cryptography-d76bd668dc4b59c037771ed5619f939d65ca9905.tar.bz2
cryptography-d76bd668dc4b59c037771ed5619f939d65ca9905.zip
only call ERR_error_string if we're going to raise InternalError
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/bindings/test_openssl.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
index 76a9218b..73f61257 100644
--- a/tests/hazmat/bindings/test_openssl.py
+++ b/tests/hazmat/bindings/test_openssl.py
@@ -6,7 +6,10 @@ from __future__ import absolute_import, division, print_function
import pytest
-from cryptography.hazmat.bindings.openssl.binding import Binding
+from cryptography.exceptions import InternalError
+from cryptography.hazmat.bindings.openssl.binding import (
+ Binding, _OpenSSLErrorText, _openssl_assert
+)
class TestOpenSSL(object):
@@ -149,3 +152,20 @@ class TestOpenSSL(object):
else:
with pytest.raises(AttributeError):
b.lib.CMAC_Init
+
+ def test_openssl_assert_error_on_stack(self):
+ b = Binding()
+ b.lib.ERR_put_error(4, 160, 110, b"", -1)
+ with pytest.raises(InternalError) as exc_info:
+ _openssl_assert(b.lib, False)
+
+ exc_info.value.err_code == _OpenSSLErrorText(
+ code=67764334,
+ lib=4,
+ func=160,
+ reason=110,
+ reason_text=(
+ b'error:040A006E:rsa routines:RSA_padding_add_PKCS1_OAEP_mgf1'
+ b':data too large for key size'
+ )
+ )