aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_hmac.py
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2013-11-13 13:49:41 -0800
committerDavid Reid <dreid@dreid.org>2013-11-13 13:49:41 -0800
commit2cce618311c892aa5a1be2ef899e8ff7a08ae5ef (patch)
treee664e84cc5e3ee9f70a6f8ae9bb9ccf3d73fae26 /tests/hazmat/primitives/test_hmac.py
parentc2cddd2b1f0bd935ed53ee49446e268d9bf874e7 (diff)
downloadcryptography-2cce618311c892aa5a1be2ef899e8ff7a08ae5ef.tar.gz
cryptography-2cce618311c892aa5a1be2ef899e8ff7a08ae5ef.tar.bz2
cryptography-2cce618311c892aa5a1be2ef899e8ff7a08ae5ef.zip
Make HMAC methods raise AlreadyFinalized.
Diffstat (limited to 'tests/hazmat/primitives/test_hmac.py')
-rw-r--r--tests/hazmat/primitives/test_hmac.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py
index 4186967a..d17049e3 100644
--- a/tests/hazmat/primitives/test_hmac.py
+++ b/tests/hazmat/primitives/test_hmac.py
@@ -19,6 +19,7 @@ import pytest
import six
+from cryptography.exceptions import AlreadyFinalized
from cryptography.hazmat.primitives import hashes, hmac
from .utils import generate_base_hmac_test
@@ -49,3 +50,16 @@ class TestHMAC(object):
def test_hmac_algorithm_instance(self):
with pytest.raises(TypeError):
hmac.HMAC(b"key", hashes.SHA1)
+
+ def test_raises_after_finalize(self):
+ h = hmac.HMAC(b"key", hashes.SHA1())
+ h.finalize()
+
+ with pytest.raises(AlreadyFinalized):
+ h.update(b"foo")
+
+ with pytest.raises(AlreadyFinalized):
+ h.copy()
+
+ with pytest.raises(AlreadyFinalized):
+ h.finalize()