aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-09-09 15:26:26 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-09-09 15:30:13 -0500
commit733404a826678538f0b67d666d4c303b1ccc2204 (patch)
treeee1313a24db0a878bc6809bb1384aa457be835ef
parentd55920576d288e9cb703337c6183cfe071d274ce (diff)
downloadcryptography-733404a826678538f0b67d666d4c303b1ccc2204.tar.gz
cryptography-733404a826678538f0b67d666d4c303b1ccc2204.tar.bz2
cryptography-733404a826678538f0b67d666d4c303b1ccc2204.zip
Add method to bindings to get OPENSSL_VERSION_TEXT
* This allows you to check that you're binding against the expected version of OpenSSL * Test is pretty basic (just checks to see that the string starts with OpenSSL)
-rw-r--r--cryptography/bindings/openssl/api.py7
-rw-r--r--tests/bindings/test_openssl.py3
2 files changed, 10 insertions, 0 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py
index 202595bf..87ed38fa 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -27,6 +27,7 @@ class API(object):
self._ffi = ffi
self._lib = ffi.verify("""
#include <openssl/evp.h>
+ #include <openssl/opensslv.h>
""")
self._lib.OpenSSL_add_all_algorithms()
@@ -38,6 +39,8 @@ class API(object):
typedef ... EVP_CIPHER;
typedef ... ENGINE;
+ static char *const OPENSSL_VERSION_TEXT;
+
void OpenSSL_add_all_algorithms();
const EVP_CIPHER *EVP_get_cipherbyname(const char *);
@@ -52,6 +55,10 @@ class API(object):
int EVP_CIPHER_block_size(const EVP_CIPHER *);
""")
+ """ Friendly string name of linked OpenSSL. """
+ def openssl_version_text(self):
+ return self._ffi.string(api._lib.OPENSSL_VERSION_TEXT)
+
def create_block_cipher_context(self, cipher, mode):
ctx = self._ffi.new("EVP_CIPHER_CTX *")
ctx = self._ffi.gc(ctx, self._lib.EVP_CIPHER_CTX_cleanup)
diff --git a/tests/bindings/test_openssl.py b/tests/bindings/test_openssl.py
index 9d637222..8704d933 100644
--- a/tests/bindings/test_openssl.py
+++ b/tests/bindings/test_openssl.py
@@ -17,3 +17,6 @@ from cryptography.bindings.openssl import api
class TestOpenSSL(object):
def test_api_exists(self):
assert api
+
+ def test_openssl_version_text(self):
+ assert api.openssl_version_text().find("OpenSSL") == 0