aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-08-09 12:12:30 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-08-09 12:12:30 -0700
commit250903aa4c1776a1859bbb41b9e19953e0733206 (patch)
tree03f5af319475080420822f8bc1d4f70ace4ba8e4 /cryptography
parent0b26f787601acedf80d8fad5c71bf60c907b5201 (diff)
downloadcryptography-250903aa4c1776a1859bbb41b9e19953e0733206.tar.gz
cryptography-250903aa4c1776a1859bbb41b9e19953e0733206.tar.bz2
cryptography-250903aa4c1776a1859bbb41b9e19953e0733206.zip
Removed duplicate tests, added tests + fix for use after finalize
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/primitives/block/base.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/cryptography/primitives/block/base.py b/cryptography/primitives/block/base.py
index 6e3565a3..d52fa73e 100644
--- a/cryptography/primitives/block/base.py
+++ b/cryptography/primitives/block/base.py
@@ -10,9 +10,13 @@ class BlockCipher(object):
self._ctx = api.create_block_cipher_context(cipher, mode)
def encrypt(self, plaintext):
+ if self._ctx is None:
+ raise ValueError("BlockCipher was already finalized")
return api.update_encrypt_context(self._ctx, plaintext)
def finalize(self):
+ if self._ctx is None:
+ raise ValueError("BlockCipher was already finalized")
# TODO: this might be a decrypt context
result = api.finalize_encrypt_context(self._ctx)
self._ctx = None