diff options
author | David Reid <dreid@dreid.org> | 2014-01-28 14:51:25 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2014-02-03 10:05:27 -0800 |
commit | ec4155a4035736011d8e3857965c60a766dd48f3 (patch) | |
tree | 77e3d262a964a4061582202072c20d282e2d587e /tests/hazmat/primitives/test_hkdf.py | |
parent | fec6d147eef3ada5b8d3c11714216f9438db58e3 (diff) | |
download | cryptography-ec4155a4035736011d8e3857965c60a766dd48f3.tar.gz cryptography-ec4155a4035736011d8e3857965c60a766dd48f3.tar.bz2 cryptography-ec4155a4035736011d8e3857965c60a766dd48f3.zip |
Aggressively type-check for text.
Diffstat (limited to 'tests/hazmat/primitives/test_hkdf.py')
-rw-r--r-- | tests/hazmat/primitives/test_hkdf.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_hkdf.py b/tests/hazmat/primitives/test_hkdf.py index 53bc098d..bd896cef 100644 --- a/tests/hazmat/primitives/test_hkdf.py +++ b/tests/hazmat/primitives/test_hkdf.py @@ -83,3 +83,43 @@ class TestHKDF(object): with pytest.raises(exceptions.InvalidKey): hkdf.verify(b'\x02' * 16, b'gJ\xfb{\xb1Oi\xc5sMC\xb7\xe4@\xf7u') + + def test_unicode_typeerror(self, backend): + with pytest.raises(TypeError): + HKDF(hashes.SHA256(), 16, salt=u'foo', info=None, backend=backend) + + with pytest.raises(TypeError): + HKDF(hashes.SHA256(), 16, salt=None, info=u'foo', backend=backend) + + with pytest.raises(TypeError): + hkdf = HKDF( + hashes.SHA256(), + 16, + salt=None, + info=None, + backend=backend + ) + + hkdf.derive(u'foo') + + with pytest.raises(TypeError): + hkdf = HKDF( + hashes.SHA256(), + 16, + salt=None, + info=None, + backend=backend + ) + + hkdf.verify(u'foo', b'bar') + + with pytest.raises(TypeError): + hkdf = HKDF( + hashes.SHA256(), + 16, + salt=None, + info=None, + backend=backend + ) + + hkdf.verify(b'foo', u'bar') |