aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-02 10:52:21 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-02 10:52:21 -0700
commit5d082009a1636d833e414585344eb1fba3545c7f (patch)
tree984ac15e12492cf36daa9de949cf977cdff818f3
parentbc77663c0b937b05ca18269ffdb6e26f3c32d530 (diff)
parent640fb6ce669e8921efb31502512445144662021b (diff)
downloadcryptography-5d082009a1636d833e414585344eb1fba3545c7f.tar.gz
cryptography-5d082009a1636d833e414585344eb1fba3545c7f.tar.bz2
cryptography-5d082009a1636d833e414585344eb1fba3545c7f.zip
Merge branch 'master' into bind-bignum
-rw-r--r--cryptography/bindings/openssl/api.py18
-rw-r--r--cryptography/bindings/openssl/evp.py8
-rw-r--r--cryptography/bindings/openssl/opensslv.py3
-rw-r--r--dev-requirements.txt5
-rw-r--r--docs/contributing.rst73
5 files changed, 103 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 = """
+"""
diff --git a/dev-requirements.txt b/dev-requirements.txt
new file mode 100644
index 00000000..01030e87
--- /dev/null
+++ b/dev-requirements.txt
@@ -0,0 +1,5 @@
+flake8
+pretend
+pytest-cov
+sphinx
+tox
diff --git a/docs/contributing.rst b/docs/contributing.rst
index b4c72ba4..9dd14c23 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -73,8 +73,81 @@ So, specifically:
- No blank line at the end.
- Use Sphinx parameter/attribute documentation `syntax`_.
+Development Environment
+-----------------------
+
+Working on ``cryptography`` requires the installation of a small number of
+development dependencies. These are listed in ``dev-requirements.txt`` and they
+can be installed in a `virtualenv`_ using `pip`_. Once you've installed the
+dependencies, install ``cryptography`` in ``editable`` mode. For example:
+
+.. code-block:: sh
+
+ # Create a virtualenv and activate it
+ $ pip install --requirement dev-requirements.txt
+ $ pip install --editable .
+
+You are now ready to run the tests and build the documentation.
+
+Running Tests
+-------------
+
+``cryptography`` unit tests are found in the ``tests/`` directory and are
+designed to be run using `pytest`_. `pytest`_ will discover the tests
+automatically, so all you have to do is:
+
+.. code-block:: sh
+
+ $ py.test
+ ...
+ 4294 passed in 15.24 seconds
+
+This runs the tests with the default Python interpreter.
+
+You can also verify that the tests pass on other supported Python interpreters.
+For this we use `tox`_, which will automatically create a `virtualenv`_ for
+each supported Python version and run the tests. For example:
+
+.. code-block:: sh
+
+ $ tox
+ ...
+ ERROR: py26: InterpreterNotFound: python2.6
+ py27: commands succeeded
+ ERROR: pypy: InterpreterNotFound: pypy
+ ERROR: py32: InterpreterNotFound: python3.2
+ py33: commands succeeded
+ docs: commands succeeded
+ pep8: commands succeeded
+
+You may not have all the required Python versions installed, in which case you
+will see one or more ``InterpreterNotFound`` errors.
+
+Building Documentation
+----------------------
+
+``cryptography`` documentation is stored in the ``docs/`` directory. It is
+written in `reStructured Text`_ and rendered using `Sphinx`_.
+
+Use `tox`_ to build the documentation. For example:
+
+.. code-block:: sh
+
+ $ tox -e docs
+ ...
+ docs: commands succeeded
+ congratulations :)
+
+The HTML documentation index can now be found at ``docs/_build/html/index.html``
+
.. _`GitHub`: https://github.com/alex/cryptography
.. _`our mailing list`: https://mail.python.org/mailman/listinfo/cryptography-dev
.. _`PEP 8`: http://www.peps.io/8/
.. _`syntax`: http://sphinx-doc.org/domains.html#info-field-lists
+.. _`pytest`: https://pypi.python.org/pypi/pytest
+.. _`tox`: https://pypi.python.org/pypi/tox
+.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
+.. _`pip`: https://pypi.python.org/pypi/pip
+.. _`sphinx`: https://pypi.python.org/pypi/sphinx
+.. _`reStructured Text`: http://docutils.sourceforge.net/rst.html