aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography/primitives/block/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'cryptography/primitives/block/base.py')
-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