From d76bd668dc4b59c037771ed5619f939d65ca9905 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 7 Mar 2016 22:49:43 -0400 Subject: only call ERR_error_string if we're going to raise InternalError --- tests/hazmat/bindings/test_openssl.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests') 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' + ) + ) -- cgit v1.2.3