From ec4155a4035736011d8e3857965c60a766dd48f3 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 28 Jan 2014 14:51:25 -0800 Subject: Aggressively type-check for text. --- tests/hazmat/primitives/test_hkdf.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') 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') -- cgit v1.2.3