diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-06 14:26:08 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-06 14:26:08 -0800 |
commit | b5c4891e0c2e30118641092aff975e8d0e63cbab (patch) | |
tree | b6209797e16ed81a5021fa6172e47ce2ebd94e1d /cryptography | |
parent | 07c36baec6ee7d4a89b3cbe18a37b9e5cbe48f64 (diff) | |
parent | a07925a154e2b28db30499c5a3cf40fedc451d10 (diff) | |
download | cryptography-b5c4891e0c2e30118641092aff975e8d0e63cbab.tar.gz cryptography-b5c4891e0c2e30118641092aff975e8d0e63cbab.tar.bz2 cryptography-b5c4891e0c2e30118641092aff975e8d0e63cbab.zip |
Merge pull request #285 from reaperhulk/fix-282
raise ValueErrors when supplying/not supplying tags for GCM
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/bindings/openssl/backend.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index 1b19ddaa..6ab4dc26 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -289,12 +289,18 @@ class _CipherContext(object): ) assert res != 0 if operation == self._DECRYPT: - assert mode.tag is not None + if not mode.tag: + raise ValueError("Authentication tag must be supplied " + "when decrypting") res = self._backend.lib.EVP_CIPHER_CTX_ctrl( ctx, self._backend.lib.Cryptography_EVP_CTRL_GCM_SET_TAG, len(mode.tag), mode.tag ) assert res != 0 + else: + if mode.tag: + raise ValueError("Authentication tag must be None when " + "encrypting") # pass key/iv res = self._backend.lib.EVP_CipherInit_ex(ctx, self._backend.ffi.NULL, |