diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-04-25 22:31:44 +0100 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-04-25 22:31:44 +0100 |
commit | 575a7f5f93828c1dd133b420490be2183d71fe9c (patch) | |
tree | 23f0fdfc53b4d5edf2dccd0188276ddac1533046 /cryptography | |
parent | 75db7f4902ffd756f06c14e4328ebeda6a527800 (diff) | |
download | cryptography-575a7f5f93828c1dd133b420490be2183d71fe9c.tar.gz cryptography-575a7f5f93828c1dd133b420490be2183d71fe9c.tar.bz2 cryptography-575a7f5f93828c1dd133b420490be2183d71fe9c.zip |
Use AlreadyFinalized not ValueError
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/primitives/padding.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py index d78c6a5b..c1a763b5 100644 --- a/cryptography/hazmat/primitives/padding.py +++ b/cryptography/hazmat/primitives/padding.py @@ -20,6 +20,7 @@ import cffi import six from cryptography import utils +from cryptography.exceptions import AlreadyFinalized from cryptography.hazmat.bindings.utils import _create_modulename from cryptography.hazmat.primitives import interfaces @@ -101,7 +102,7 @@ class _PKCS7PaddingContext(object): def update(self, data): if self._buffer is None: - raise ValueError("Context was already finalized") + raise AlreadyFinalized("Context was already finalized") if isinstance(data, six.text_type): raise TypeError("Unicode-objects must be encoded before padding") @@ -117,7 +118,7 @@ class _PKCS7PaddingContext(object): def finalize(self): if self._buffer is None: - raise ValueError("Context was already finalized") + raise AlreadyFinalized("Context was already finalized") pad_size = self.block_size // 8 - len(self._buffer) result = self._buffer + six.int2byte(pad_size) * pad_size @@ -134,7 +135,7 @@ class _PKCS7UnpaddingContext(object): def update(self, data): if self._buffer is None: - raise ValueError("Context was already finalized") + raise AlreadyFinalized("Context was already finalized") if isinstance(data, six.text_type): raise TypeError("Unicode-objects must be encoded before unpadding") @@ -153,7 +154,7 @@ class _PKCS7UnpaddingContext(object): def finalize(self): if self._buffer is None: - raise ValueError("Context was already finalized") + raise AlreadyFinalized("Context was already finalized") if len(self._buffer) != self.block_size // 8: raise ValueError("Invalid padding bytes") |