aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2013-11-12 10:51:40 -0800
committerDavid Reid <dreid@dreid.org>2013-11-12 10:51:40 -0800
commit4e065de9a34a91b71b1740c244372bba8d37ec16 (patch)
treefa2ded8ae0ffb59c10c6a63d711d2ae06ba0d92e
parent1d75bfa060ff55c4e415a8d34f8e55025fed9a86 (diff)
parent217e3b55bf91c4c633a7b79f1b7f8bf2e3e6be31 (diff)
downloadcryptography-4e065de9a34a91b71b1740c244372bba8d37ec16.tar.gz
cryptography-4e065de9a34a91b71b1740c244372bba8d37ec16.tar.bz2
cryptography-4e065de9a34a91b71b1740c244372bba8d37ec16.zip
Merge pull request #247 from alex/fix-hash-copy
Fixed using copied hashes
-rw-r--r--cryptography/hazmat/primitives/hashes.py2
-rw-r--r--tests/hazmat/primitives/utils.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py
index bdad5e16..c7748118 100644
--- a/cryptography/hazmat/primitives/hashes.py
+++ b/cryptography/hazmat/primitives/hashes.py
@@ -34,7 +34,7 @@ class Hash(object):
if ctx is None:
self._ctx = self._backend.hashes.create_ctx(self.algorithm)
else:
- self._ctx = None
+ self._ctx = ctx
def update(self, data):
if isinstance(data, six.text_type):
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index 0f975950..9327b0eb 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -155,6 +155,12 @@ def base_hash_test(backend, algorithm, digest_size, block_size, only_if,
assert m != m_copy
assert m._ctx != m_copy._ctx
+ m.update(b"abc")
+ copy = m.copy()
+ copy.update(b"123")
+ m.update(b"123")
+ assert copy.finalize() == m.finalize()
+
def generate_long_string_hash_test(hash_factory, md, only_if=None,
skip_message=None):