aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-12-27 20:25:06 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-12-27 20:25:06 -0600
commitccd9c0069f6955e8325ec63853e4609241cbea06 (patch)
tree5e4967ac17585125a6b43b6c1d08355551ffc08a
parent28f10001a18c96649003c59beb458d8d865aac88 (diff)
downloadcryptography-ccd9c0069f6955e8325ec63853e4609241cbea06.tar.gz
cryptography-ccd9c0069f6955e8325ec63853e4609241cbea06.tar.bz2
cryptography-ccd9c0069f6955e8325ec63853e4609241cbea06.zip
Convert #defines to explicit type declaration for consistency
-rw-r--r--cryptography/hazmat/backends/openssl/bio.py85
-rw-r--r--cryptography/hazmat/backends/openssl/crypto.py8
-rw-r--r--cryptography/hazmat/backends/openssl/engine.py22
-rw-r--r--docs/contributing.rst17
4 files changed, 76 insertions, 56 deletions
diff --git a/cryptography/hazmat/backends/openssl/bio.py b/cryptography/hazmat/backends/openssl/bio.py
index 9af32b71..264a2410 100644
--- a/cryptography/hazmat/backends/openssl/bio.py
+++ b/cryptography/hazmat/backends/openssl/bio.py
@@ -50,6 +50,49 @@ struct bio_st {
...;
};
typedef ... BUF_MEM;
+
+static const int BIO_TYPE_MEM;
+static const int BIO_TYPE_FILE;
+static const int BIO_TYPE_FD;
+static const int BIO_TYPE_SOCKET;
+static const int BIO_TYPE_CONNECT;
+static const int BIO_TYPE_ACCEPT;
+static const int BIO_TYPE_NULL;
+static const int BIO_CLOSE;
+static const int BIO_NOCLOSE;
+static const int BIO_TYPE_SOURCE_SINK;
+static const int BIO_CTRL_RESET;
+static const int BIO_CTRL_EOF;
+static const int BIO_CTRL_SET;
+static const int BIO_CTRL_SET_CLOSE;
+static const int BIO_CTRL_FLUSH;
+static const int BIO_CTRL_DUP;
+static const int BIO_CTRL_GET_CLOSE;
+static const int BIO_CTRL_INFO;
+static const int BIO_CTRL_GET;
+static const int BIO_CTRL_PENDING;
+static const int BIO_CTRL_WPENDING;
+static const int BIO_C_FILE_SEEK;
+static const int BIO_C_FILE_TELL;
+static const int BIO_TYPE_NONE;
+static const int BIO_TYPE_PROXY_CLIENT;
+static const int BIO_TYPE_PROXY_SERVER;
+static const int BIO_TYPE_NBIO_TEST;
+static const int BIO_TYPE_BER;
+static const int BIO_TYPE_BIO;
+static const int BIO_TYPE_DESCRIPTOR;
+static const int BIO_FLAGS_READ;
+static const int BIO_FLAGS_WRITE;
+static const int BIO_FLAGS_IO_SPECIAL;
+static const int BIO_FLAGS_RWS;
+static const int BIO_FLAGS_SHOULD_RETRY;
+static const int BIO_TYPE_NULL_FILTER;
+static const int BIO_TYPE_SSL;
+static const int BIO_TYPE_MD;
+static const int BIO_TYPE_BUFFER;
+static const int BIO_TYPE_CIPHER;
+static const int BIO_TYPE_BASE64;
+static const int BIO_TYPE_FILTER;
"""
FUNCTIONS = """
@@ -125,48 +168,6 @@ long BIO_set_read_buffer_size(BIO *, long);
long BIO_set_write_buffer_size(BIO *, long);
long BIO_set_buffer_size(BIO *, long);
long BIO_set_buffer_read_data(BIO *, void *, long);
-#define BIO_TYPE_MEM ...
-#define BIO_TYPE_FILE ...
-#define BIO_TYPE_FD ...
-#define BIO_TYPE_SOCKET ...
-#define BIO_TYPE_CONNECT ...
-#define BIO_TYPE_ACCEPT ...
-#define BIO_TYPE_NULL ...
-#define BIO_CLOSE ...
-#define BIO_NOCLOSE ...
-#define BIO_TYPE_SOURCE_SINK ...
-#define BIO_CTRL_RESET ...
-#define BIO_CTRL_EOF ...
-#define BIO_CTRL_SET ...
-#define BIO_CTRL_SET_CLOSE ...
-#define BIO_CTRL_FLUSH ...
-#define BIO_CTRL_DUP ...
-#define BIO_CTRL_GET_CLOSE ...
-#define BIO_CTRL_INFO ...
-#define BIO_CTRL_GET ...
-#define BIO_CTRL_PENDING ...
-#define BIO_CTRL_WPENDING ...
-#define BIO_C_FILE_SEEK ...
-#define BIO_C_FILE_TELL ...
-#define BIO_TYPE_NONE ...
-#define BIO_TYPE_PROXY_CLIENT ...
-#define BIO_TYPE_PROXY_SERVER ...
-#define BIO_TYPE_NBIO_TEST ...
-#define BIO_TYPE_BER ...
-#define BIO_TYPE_BIO ...
-#define BIO_TYPE_DESCRIPTOR ...
-#define BIO_FLAGS_READ ...
-#define BIO_FLAGS_WRITE ...
-#define BIO_FLAGS_IO_SPECIAL ...
-#define BIO_FLAGS_RWS ...
-#define BIO_FLAGS_SHOULD_RETRY ...
-#define BIO_TYPE_NULL_FILTER ...
-#define BIO_TYPE_SSL ...
-#define BIO_TYPE_MD ...
-#define BIO_TYPE_BUFFER ...
-#define BIO_TYPE_CIPHER ...
-#define BIO_TYPE_BASE64 ...
-#define BIO_TYPE_FILTER ...
"""
CUSTOMIZATIONS = """
diff --git a/cryptography/hazmat/backends/openssl/crypto.py b/cryptography/hazmat/backends/openssl/crypto.py
index 5e995023..8749e2e1 100644
--- a/cryptography/hazmat/backends/openssl/crypto.py
+++ b/cryptography/hazmat/backends/openssl/crypto.py
@@ -21,6 +21,10 @@ static const int SSLEAY_CFLAGS;
static const int SSLEAY_PLATFORM;
static const int SSLEAY_DIR;
static const int SSLEAY_BUILT_ON;
+static const int CRYPTO_MEM_CHECK_ON;
+static const int CRYPTO_MEM_CHECK_OFF;
+static const int CRYPTO_MEM_CHECK_ENABLE;
+static const int CRYPTO_MEM_CHECK_DISABLE;
"""
FUNCTIONS = """
@@ -38,10 +42,6 @@ void CRYPTO_add(int *, int, int);
void CRYPTO_malloc_init(void);
void CRYPTO_malloc_debug_init(void);
-#define CRYPTO_MEM_CHECK_ON ...
-#define CRYPTO_MEM_CHECK_OFF ...
-#define CRYPTO_MEM_CHECK_ENABLE ...
-#define CRYPTO_MEM_CHECK_DISABLE ...
"""
CUSTOMIZATIONS = """
diff --git a/cryptography/hazmat/backends/openssl/engine.py b/cryptography/hazmat/backends/openssl/engine.py
index 640ef18c..acd92eee 100644
--- a/cryptography/hazmat/backends/openssl/engine.py
+++ b/cryptography/hazmat/backends/openssl/engine.py
@@ -17,6 +17,17 @@ INCLUDES = """
TYPES = """
typedef ... ENGINE;
+
+static const unsigned int ENGINE_METHOD_RSA;
+static const unsigned int ENGINE_METHOD_DSA;
+static const unsigned int ENGINE_METHOD_RAND;
+static const unsigned int ENGINE_METHOD_ECDH;
+static const unsigned int ENGINE_METHOD_ECDSA;
+static const unsigned int ENGINE_METHOD_CIPHERS;
+static const unsigned int ENGINE_METHOD_DIGESTS;
+static const unsigned int ENGINE_METHOD_STORE;
+static const unsigned int ENGINE_METHOD_ALL;
+static const unsigned int ENGINE_METHOD_NONE;
"""
FUNCTIONS = """
@@ -46,19 +57,10 @@ int ENGINE_set_default_DH(ENGINE *);
int ENGINE_set_default_RAND(ENGINE *);
int ENGINE_set_default_ciphers(ENGINE *);
int ENGINE_set_default_digests(ENGINE *);
+
"""
MACROS = """
-#define ENGINE_METHOD_RSA ...
-#define ENGINE_METHOD_DSA ...
-#define ENGINE_METHOD_RAND ...
-#define ENGINE_METHOD_ECDH ...
-#define ENGINE_METHOD_ECDSA ...
-#define ENGINE_METHOD_CIPHERS ...
-#define ENGINE_METHOD_DIGESTS ...
-#define ENGINE_METHOD_STORE ...
-#define ENGINE_METHOD_ALL ...
-#define ENGINE_METHOD_NONE ...
"""
CUSTOMIZATIONS = """
diff --git a/docs/contributing.rst b/docs/contributing.rst
index 139f7f3b..336d2acb 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -136,6 +136,23 @@ Include a space after commas between parameters:
// Bad
long f(int,char *)
+Values set by #define should be assigned the appropriate type. If you see
+this:
+
+.. code-block:: c
+
+ #define SOME_INTEGER 0x0;
+ #define SOME_UINTEGER (unsigned int)0x0001;
+ #define SOME_STRING "hello";
+
+...it should be added to the bindings like so:
+
+.. code-block:: c
+
+ static const int SOME_INTEGER;
+ static const unsigned int SOME_UINTEGER;
+ static char *const SOME_STRING;
+
Documentation
-------------