diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-09-26 17:46:22 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-09-26 17:46:22 -0400 |
commit | 95063f861bdc1e02bb1fbed966b44c25a9fe4533 (patch) | |
tree | 13f8357bda8949d130defefc75025ac886d12fb9 /src/cryptography/hazmat/backends/openssl/ciphers.py | |
parent | 6efcd60f319920e5b4eae971c1ddf704e56d866d (diff) | |
download | cryptography-95063f861bdc1e02bb1fbed966b44c25a9fe4533.tar.gz cryptography-95063f861bdc1e02bb1fbed966b44c25a9fe4533.tar.bz2 cryptography-95063f861bdc1e02bb1fbed966b44c25a9fe4533.zip |
Use InternalError for stuff
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/ciphers.py')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/ciphers.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py index 4c1c7bc9..a80708aa 100644 --- a/src/cryptography/hazmat/backends/openssl/ciphers.py +++ b/src/cryptography/hazmat/backends/openssl/ciphers.py @@ -136,23 +136,21 @@ class _CipherContext(object): if not errors and isinstance(self._mode, modes.GCM): raise InvalidTag - assert errors - - if errors[0][1:] == ( - self._backend._lib.ERR_LIB_EVP, - self._backend._lib.EVP_F_EVP_ENCRYPTFINAL_EX, - self._backend._lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH - ) or errors[0][1:] == ( - self._backend._lib.ERR_LIB_EVP, - self._backend._lib.EVP_F_EVP_DECRYPTFINAL_EX, - self._backend._lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH - ): - raise ValueError( - "The length of the provided data is not a multiple of " - "the block length." + self._backend.openssl_assert( + errors[0][1:] == ( + self._backend._lib.ERR_LIB_EVP, + self._backend._lib.EVP_F_EVP_ENCRYPTFINAL_EX, + self._backend._lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH + ) or errors[0][1:] == ( + self._backend._lib.ERR_LIB_EVP, + self._backend._lib.EVP_F_EVP_DECRYPTFINAL_EX, + self._backend._lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH ) - else: - raise self._backend._unknown_error(errors[0]) + ) + raise ValueError( + "The length of the provided data is not a multiple of " + "the block length." + ) if (isinstance(self._mode, modes.GCM) and self._operation == self._ENCRYPT): |