aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2014-01-28 14:51:25 -0800
committerDavid Reid <dreid@dreid.org>2014-02-03 10:05:27 -0800
commitec4155a4035736011d8e3857965c60a766dd48f3 (patch)
tree77e3d262a964a4061582202072c20d282e2d587e /tests
parentfec6d147eef3ada5b8d3c11714216f9438db58e3 (diff)
downloadcryptography-ec4155a4035736011d8e3857965c60a766dd48f3.tar.gz
cryptography-ec4155a4035736011d8e3857965c60a766dd48f3.tar.bz2
cryptography-ec4155a4035736011d8e3857965c60a766dd48f3.zip
Aggressively type-check for text.
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_hkdf.py40
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')