From 2d0afd3485a6349924f921d12dc94a302999ae20 Mon Sep 17 00:00:00 2001 From: Vladyslav Moisieienkov Date: Wed, 20 Jun 2018 14:21:33 +0200 Subject: 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 --- tests/hazmat/primitives/test_chacha20.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/hazmat/primitives/test_chacha20.py') diff --git a/tests/hazmat/primitives/test_chacha20.py b/tests/hazmat/primitives/test_chacha20.py index 16ef97ed..33730d91 100644 --- a/tests/hazmat/primitives/test_chacha20.py +++ b/tests/hazmat/primitives/test_chacha20.py @@ -58,3 +58,7 @@ class TestChaCha20(object): with pytest.raises(TypeError): algorithms.ChaCha20(b"0" * 32, object()) + + def test_invalid_key_type(self): + with pytest.raises(TypeError, match="key must be bytes"): + algorithms.ChaCha20(u"0" * 32, b"0" * 16) -- cgit v1.2.3