aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/bindings/openssl/evp.py4
-rw-r--r--cryptography/primitives/hashes.py2
-rw-r--r--docs/conf.py4
-rw-r--r--docs/primitives/cryptographic-hashes.rst2
-rw-r--r--tests/primitives/test_hashes.py22
5 files changed, 32 insertions, 2 deletions
diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/bindings/openssl/evp.py
index 41df1056..80980c6e 100644
--- a/cryptography/bindings/openssl/evp.py
+++ b/cryptography/bindings/openssl/evp.py
@@ -29,6 +29,9 @@ typedef struct evp_pkey_st {
} EVP_PKEY;
static const int EVP_PKEY_RSA;
static const int EVP_PKEY_DSA;
+static const int EVP_CTRL_GCM_SET_IVLEN;
+static const int EVP_CTRL_GCM_GET_TAG;
+static const int EVP_CTRL_GCM_SET_TAG;
"""
FUNCTIONS = """
@@ -84,4 +87,5 @@ MACROS = """
int EVP_PKEY_assign_RSA(EVP_PKEY *, RSA *);
int EVP_PKEY_assign_DSA(EVP_PKEY *, DSA *);
int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *);
+int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *, int, int, void *);
"""
diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py
index 7133a916..3aa52462 100644
--- a/cryptography/primitives/hashes.py
+++ b/cryptography/primitives/hashes.py
@@ -37,7 +37,7 @@ class BaseHash(six.with_metaclass(abc.ABCMeta)):
self._api.update_hash_context(self._ctx, data)
def copy(self):
- return self.__class__(ctx=self._copy_ctx())
+ return self.__class__(api=self._api, ctx=self._copy_ctx())
def digest(self):
return self._api.finalize_hash_context(self._copy_ctx(),
diff --git a/docs/conf.py b/docs/conf.py
index 16b1109e..a368ac70 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -248,3 +248,7 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}
+
+
+# Enable the new ReadTheDocs theme
+RTD_NEW_THEME = True
diff --git a/docs/primitives/cryptographic-hashes.rst b/docs/primitives/cryptographic-hashes.rst
index f917ab45..dcf21250 100644
--- a/docs/primitives/cryptographic-hashes.rst
+++ b/docs/primitives/cryptographic-hashes.rst
@@ -88,5 +88,5 @@ MD5
.. class:: MD5()
- MD5 is a deprecated cryptographic hash function. It has a 160-bit message
+ MD5 is a deprecated cryptographic hash function. It has a 128-bit message
digest and has practical known collision attacks.
diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py
index 03de8916..46517701 100644
--- a/tests/primitives/test_hashes.py
+++ b/tests/primitives/test_hashes.py
@@ -13,10 +13,14 @@
from __future__ import absolute_import, division, print_function
+import pretend
+
import pytest
import six
+from cryptography.bindings import _default_api
+
from cryptography.primitives import hashes
from .utils import generate_base_hash_test
@@ -33,6 +37,24 @@ class TestBaseHash(object):
assert isinstance(m.hexdigest(), str)
+class TestCopyHash(object):
+ def test_copy_api_object(self):
+ pretend_api = pretend.stub(copy_hash_context=lambda a: "copiedctx")
+ pretend_ctx = pretend.stub()
+ h = hashes.SHA1(api=pretend_api, ctx=pretend_ctx)
+ assert h._api is pretend_api
+ assert h.copy()._api is h._api
+
+
+class TestDefaultAPISHA1(object):
+ def test_default_api_creation(self):
+ """
+ This test assumes the presence of SHA1 in the default API.
+ """
+ h = hashes.SHA1()
+ assert h._api is _default_api
+
+
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(
hashes.SHA1,