diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-27 14:31:08 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-27 14:31:08 -0800 |
commit | 64db0292ac574cb1c965585439b3155199ada414 (patch) | |
tree | 78b71d87ce2d21448dfeecd277f4e26a487636e3 | |
parent | 0ed17826ede036e0c24aa5c061dbb3132e8a330b (diff) | |
parent | 03c9ef407d9b58ac5cfc692ac4a92662dfda4421 (diff) | |
download | cryptography-64db0292ac574cb1c965585439b3155199ada414.tar.gz cryptography-64db0292ac574cb1c965585439b3155199ada414.tar.bz2 cryptography-64db0292ac574cb1c965585439b3155199ada414.zip |
Merge pull request #337 from exarkun/some-typedef-fixes
Switch two types which were declared as opaque but are actually integers...
-rw-r--r-- | cryptography/hazmat/backends/openssl/asn1.py | 19 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/bignum.py | 19 |
2 files changed, 36 insertions, 2 deletions
diff --git a/cryptography/hazmat/backends/openssl/asn1.py b/cryptography/hazmat/backends/openssl/asn1.py index 07bb32f9..6a309ee1 100644 --- a/cryptography/hazmat/backends/openssl/asn1.py +++ b/cryptography/hazmat/backends/openssl/asn1.py @@ -16,7 +16,24 @@ INCLUDES = """ """ TYPES = """ -typedef ... time_t; +/* + * TODO: This typedef is wrong. + * + * This is due to limitations of cffi. + * See https://bitbucket.org/cffi/cffi/issue/69 + * + * For another possible work-around (not used here because it involves more + * complicated use of the cffi API which falls outside the general pattern used + * by this package), see + * http://paste.pound-python.org/show/iJcTUMkKeBeS6yXpZWUU/ + * + * The work-around used here is to just be sure to declare a type that is at + * least as large as the real type. Maciej explains: + * + * <fijal> I think you want to declare your value too large (e.g. long) + * <fijal> that way you'll never pass garbage + */ +typedef uintptr_t time_t; typedef int ASN1_BOOLEAN; typedef ... ASN1_INTEGER; diff --git a/cryptography/hazmat/backends/openssl/bignum.py b/cryptography/hazmat/backends/openssl/bignum.py index 68d0c3a2..599eadc8 100644 --- a/cryptography/hazmat/backends/openssl/bignum.py +++ b/cryptography/hazmat/backends/openssl/bignum.py @@ -17,7 +17,24 @@ INCLUDES = """ TYPES = """ typedef ... BIGNUM; -typedef ... BN_ULONG; +/* + * TODO: This typedef is wrong. + * + * This is due to limitations of cffi. + * See https://bitbucket.org/cffi/cffi/issue/69 + * + * For another possible work-around (not used here because it involves more + * complicated use of the cffi API which falls outside the general pattern used + * by this package), see + * http://paste.pound-python.org/show/iJcTUMkKeBeS6yXpZWUU/ + * + * The work-around used here is to just be sure to declare a type that is at + * least as large as the real type. Maciej explains: + * + * <fijal> I think you want to declare your value too large (e.g. long) + * <fijal> that way you'll never pass garbage + */ +typedef uintptr_t BN_ULONG; """ FUNCTIONS = """ |