diff options
| author | Alex Stapleton <alexs@prol.etari.at> | 2014-01-14 22:47:54 +0000 |
|---|---|---|
| committer | Alex Stapleton <alexs@prol.etari.at> | 2014-02-01 17:22:08 +0000 |
| commit | 7581866c0c3a33698767c2b2adc2eee3bf525fe0 (patch) | |
| tree | 5450cbf73630701a214c3a6591331799e693c4a1 /cryptography | |
| parent | 719c8970188a354a466c0464ad0445e1b4ce2d6d (diff) | |
| download | cryptography-7581866c0c3a33698767c2b2adc2eee3bf525fe0.tar.gz cryptography-7581866c0c3a33698767c2b2adc2eee3bf525fe0.tar.bz2 cryptography-7581866c0c3a33698767c2b2adc2eee3bf525fe0.zip | |
Handle multiple errors on the stack
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index cf931dab..e842f078 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -182,12 +182,20 @@ class Backend(object): if not code and isinstance(mode, GCM): raise InvalidTag assert code != 0 + + # consume any remaining errors on the stack + ignored_code = None + while ignored_code != 0: + ignored_code = self._lib.ERR_get_error() + + # raise the first error we found + return self._handle_error_code(code) + + def _handle_error_code(self, code): lib = self._lib.ERR_GET_LIB(code) func = self._lib.ERR_GET_FUNC(code) reason = self._lib.ERR_GET_REASON(code) - return self._handle_error_code(lib, func, reason) - def _handle_error_code(self, lib, func, reason): if lib == self._lib.ERR_LIB_EVP: if func == self._lib.EVP_F_EVP_ENCRYPTFINAL_EX: if reason == self._lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH: |
