diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-02 10:52:21 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-02 10:52:21 -0700 |
| commit | 5d082009a1636d833e414585344eb1fba3545c7f (patch) | |
| tree | 984ac15e12492cf36daa9de949cf977cdff818f3 /cryptography | |
| parent | bc77663c0b937b05ca18269ffdb6e26f3c32d530 (diff) | |
| parent | 640fb6ce669e8921efb31502512445144662021b (diff) | |
| download | cryptography-5d082009a1636d833e414585344eb1fba3545c7f.tar.gz cryptography-5d082009a1636d833e414585344eb1fba3545c7f.tar.bz2 cryptography-5d082009a1636d833e414585344eb1fba3545c7f.zip | |
Merge branch 'master' into bind-bignum
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/bindings/openssl/api.py | 18 | ||||
| -rw-r--r-- | cryptography/bindings/openssl/evp.py | 8 | ||||
| -rw-r--r-- | cryptography/bindings/openssl/opensslv.py | 3 |
3 files changed, 25 insertions, 4 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 0270f9b6..6c7462cf 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -33,16 +33,28 @@ class API(object): def __init__(self): self.ffi = cffi.FFI() includes = [] + functions = [] for name in self._modules: __import__("cryptography.bindings.openssl." + name) module = sys.modules["cryptography.bindings.openssl." + name] self.ffi.cdef(module.TYPES) self.ffi.cdef(module.FUNCTIONS) + self.ffi.cdef(module.MACROS) + + functions.append(module.FUNCTIONS) includes.append(module.INCLUDES) + # We include functions here so that if we got any of their definitions + # wrong, the underlying C compiler will explode. In C you are allowed + # to re-declare a function if it has the same signature. That is: + # int foo(int); + # int foo(int); + # is legal, but the following will fail to compile: + # int foo(int); + # int foo(short); self.lib = self.ffi.verify( - source="\n".join(includes), - libraries=["crypto"] + source="\n".join(includes + functions), + libraries=["crypto"], ) self.lib.OpenSSL_add_all_algorithms() @@ -57,6 +69,8 @@ class API(object): def create_block_cipher_context(self, cipher, mode): ctx = self.ffi.new("EVP_CIPHER_CTX *") + res = self.lib.EVP_CIPHER_CTX_init(ctx) + assert res != 0 ctx = self.ffi.gc(ctx, self.lib.EVP_CIPHER_CTX_cleanup) # TODO: compute name using a better algorithm ciphername = "{0}-{1}-{2}".format( diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/bindings/openssl/evp.py index 8d2230fd..8afaf342 100644 --- a/cryptography/bindings/openssl/evp.py +++ b/cryptography/bindings/openssl/evp.py @@ -27,12 +27,16 @@ FUNCTIONS = """ void OpenSSL_add_all_algorithms(); const EVP_CIPHER *EVP_get_cipherbyname(const char *); int EVP_EncryptInit_ex(EVP_CIPHER_CTX *, const EVP_CIPHER *, ENGINE *, - unsigned char *, unsigned char *); + const unsigned char *, const unsigned char *); int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *, int); int EVP_EncryptUpdate(EVP_CIPHER_CTX *, unsigned char *, int *, - unsigned char *, int); + const unsigned char *, int); int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *, unsigned char *, int *); int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *); int EVP_CIPHER_block_size(const EVP_CIPHER *); +void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *); +""" + +MACROS = """ """ diff --git a/cryptography/bindings/openssl/opensslv.py b/cryptography/bindings/openssl/opensslv.py index 9b2db270..d1a1b3e6 100644 --- a/cryptography/bindings/openssl/opensslv.py +++ b/cryptography/bindings/openssl/opensslv.py @@ -21,3 +21,6 @@ static char *const OPENSSL_VERSION_TEXT; FUNCTIONS = """ """ + +MACROS = """ +""" |
