From cf77d3ad5390e6e00bbb38f379effe8df401fabb Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 10 Jan 2014 12:13:05 -0600 Subject: add tests to the openssl backend to verify that we've registered evp ciphers and ssl ciphers --- tests/hazmat/backends/test_openssl.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index ad399594..71250592 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -95,3 +95,11 @@ class TestOpenSSL(object): backend._lib.EVP_F_EVP_DECRYPTFINAL_EX, 0 ) + + def test_ssl_ciphers_registered(self): + meth = backend._lib.TLSv1_method() + assert backend._lib.SSL_CTX_new(meth) != backend._ffi.NULL + + def test_evp_ciphers_registered(self): + cipher = backend._lib.EVP_get_cipherbyname("aes-256-cbc") + assert cipher != backend._ffi.NULL -- cgit v1.2.3 From 82128826bb0a92779a9029645525a7dc280671be Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 10 Jan 2014 12:27:14 -0600 Subject: don't leak a context in the test --- tests/hazmat/backends/test_openssl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 71250592..a212df4a 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -98,7 +98,9 @@ class TestOpenSSL(object): def test_ssl_ciphers_registered(self): meth = backend._lib.TLSv1_method() - assert backend._lib.SSL_CTX_new(meth) != backend._ffi.NULL + ctx = backend._lib.SSL_CTX_new(meth) + assert ctx != backend._ffi.NULL + backend._lib.SSL_CTX_free(ctx) def test_evp_ciphers_registered(self): cipher = backend._lib.EVP_get_cipherbyname("aes-256-cbc") -- cgit v1.2.3 From 44957cde537a85ad8dba524cb352f784b07fc307 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 10 Jan 2014 12:36:14 -0600 Subject: oops, bytes plz --- tests/hazmat/backends/test_openssl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index a212df4a..c70446b0 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -103,5 +103,5 @@ class TestOpenSSL(object): backend._lib.SSL_CTX_free(ctx) def test_evp_ciphers_registered(self): - cipher = backend._lib.EVP_get_cipherbyname("aes-256-cbc") + cipher = backend._lib.EVP_get_cipherbyname(b"aes-256-cbc") assert cipher != backend._ffi.NULL -- cgit v1.2.3 From ab2cfc70a63e49ed385f9bb9c4e44bc86025c3a5 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 10 Jan 2014 21:44:05 -0600 Subject: add check to confirm we've loaded error strings --- tests/hazmat/backends/test_openssl.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index c70446b0..421bb530 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -105,3 +105,10 @@ class TestOpenSSL(object): def test_evp_ciphers_registered(self): cipher = backend._lib.EVP_get_cipherbyname(b"aes-256-cbc") assert cipher != backend._ffi.NULL + + def test_error_strings_loaded(self): + err = backend._lib.ERR_error_string(101183626, backend._ffi.NULL) + assert backend._ffi.string(err) == ( + "error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:" + "data not multiple of block length" + ) -- cgit v1.2.3 From 985d99d2934befe8bcf6257cbd9036dee1934ed9 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 10 Jan 2014 22:01:04 -0600 Subject: bytes byte back --- tests/hazmat/backends/test_openssl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 421bb530..2a329920 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -107,8 +107,9 @@ class TestOpenSSL(object): assert cipher != backend._ffi.NULL def test_error_strings_loaded(self): + # returns a value in a static buffer err = backend._lib.ERR_error_string(101183626, backend._ffi.NULL) assert backend._ffi.string(err) == ( - "error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:" - "data not multiple of block length" + b"error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:" + b"data not multiple of block length" ) -- cgit v1.2.3