diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-28 11:06:55 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-28 17:36:50 -0500 |
commit | 2824ab72d30e8423d17496e2c3baa47106505c8c (patch) | |
tree | 49f1e87ceb6d3f8a387231cf1a81cb444ee94ee6 /tests/hazmat/primitives/test_hmac.py | |
parent | 1bb8b710d444012b7218a08f098a85c4a31ca1bc (diff) | |
download | cryptography-2824ab72d30e8423d17496e2c3baa47106505c8c.tar.gz cryptography-2824ab72d30e8423d17496e2c3baa47106505c8c.tar.bz2 cryptography-2824ab72d30e8423d17496e2c3baa47106505c8c.zip |
make hmac (mostly) compatible with stdlib hmac
Diffstat (limited to 'tests/hazmat/primitives/test_hmac.py')
-rw-r--r-- | tests/hazmat/primitives/test_hmac.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index e2b517ae..81d9ac86 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -32,22 +32,26 @@ class TestHMAC(object): ) def test_hmac_reject_unicode(self, backend): - h = hmac.HMAC(key=b"mykey", hash_cls=hashes.SHA1, backend=backend) + h = hmac.HMAC(key=b"mykey", digestmod=hashes.SHA1, backend=backend) with pytest.raises(TypeError): h.update(six.u("\u00FC")) def test_base_hash_hexdigest_string_type(self, backend): - h = hmac.HMAC(key=b"mykey", hash_cls=hashes.SHA1, backend=backend, - data=b"") + h = hmac.HMAC(key=b"mykey", digestmod=hashes.SHA1, backend=backend, + msg=b"") assert isinstance(h.hexdigest(), str) + def test_hmac_no_digestmod(self): + with pytest.raises(ValueError): + hmac.HMAC(key=b"shortkey") + class TestCopyHMAC(object): def test_copy_backend_object(self): pretend_hmac = pretend.stub(copy_ctx=lambda a: True) pretend_backend = pretend.stub(hmacs=pretend_hmac) pretend_ctx = pretend.stub() - h = hmac.HMAC(b"key", hashes.SHA1, backend=pretend_backend, + h = hmac.HMAC(b"key", digestmod=hashes.SHA1, backend=pretend_backend, ctx=pretend_ctx) assert h._backend is pretend_backend assert h.copy()._backend is pretend_backend |