diff options
author | Vladyslav Moisieienkov <vladyslav.moisieienkov@gmail.com> | 2018-06-20 14:21:33 +0200 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2018-06-20 05:21:33 -0700 |
commit | 2d0afd3485a6349924f921d12dc94a302999ae20 (patch) | |
tree | 43ef9d2396ba5ffdbe33cc0903fd4546b7f7fe6c /src | |
parent | d88d721343828accacefca701a3d542365cd6d59 (diff) | |
download | cryptography-2d0afd3485a6349924f921d12dc94a302999ae20.tar.gz cryptography-2d0afd3485a6349924f921d12dc94a302999ae20.tar.bz2 cryptography-2d0afd3485a6349924f921d12dc94a302999ae20.zip |
Add clearer message when key type is not bytes (#4289)
* Add clearer message in Cipher when key is not bytes
* Change location of key type check to verify_key_size function
* Replace formated error message with static
* Add key type check tests to all ciphers constructors
* Change key type error message to lowercase
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/primitives/ciphers/algorithms.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/primitives/ciphers/algorithms.py b/src/cryptography/hazmat/primitives/ciphers/algorithms.py index 99a837e4..68a9e330 100644 --- a/src/cryptography/hazmat/primitives/ciphers/algorithms.py +++ b/src/cryptography/hazmat/primitives/ciphers/algorithms.py @@ -12,6 +12,9 @@ from cryptography.hazmat.primitives.ciphers.modes import ModeWithNonce def _verify_key_size(algorithm, key): + # Verify that the key is instance of bytes + utils._check_bytes("key", key) + # Verify that the key size matches the expected key size if len(key) * 8 not in algorithm.key_sizes: raise ValueError("Invalid key size ({0}) for {1}.".format( |