diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-01-17 15:55:33 -0600 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-01-17 16:55:33 -0500 |
commit | 2b40f493bf6f9eb131b46d7ab582b89033bcda64 (patch) | |
tree | 64c0bcb76bb8081714ecde50937673ac3d3dab57 /tests/hazmat/primitives | |
parent | 27585690ac8379b711391eb24c466d6ea1786609 (diff) | |
download | cryptography-2b40f493bf6f9eb131b46d7ab582b89033bcda64.tar.gz cryptography-2b40f493bf6f9eb131b46d7ab582b89033bcda64.tar.bz2 cryptography-2b40f493bf6f9eb131b46d7ab582b89033bcda64.zip |
support byteslike for OTP (#4710)
Diffstat (limited to 'tests/hazmat/primitives')
-rw-r--r-- | tests/hazmat/primitives/twofactor/test_hotp.py | 5 | ||||
-rw-r--r-- | tests/hazmat/primitives/twofactor/test_totp.py | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/twofactor/test_hotp.py b/tests/hazmat/primitives/twofactor/test_hotp.py index 4c561f70..14cb08a8 100644 --- a/tests/hazmat/primitives/twofactor/test_hotp.py +++ b/tests/hazmat/primitives/twofactor/test_hotp.py @@ -109,6 +109,11 @@ class TestHOTP(object): "GNBVGY3TQOJQGEZDGNBVGY3TQOJQ&algorithm=SHA1&issuer=Foo" "&counter=1") + def test_buffer_protocol(self, backend): + key = bytearray(b"a long key with lots of entropy goes here") + hotp = HOTP(key, 6, SHA1(), backend) + assert hotp.generate(10) == b"559978" + def test_invalid_backend(): secret = b"12345678901234567890" diff --git a/tests/hazmat/primitives/twofactor/test_totp.py b/tests/hazmat/primitives/twofactor/test_totp.py index 95829713..59d875af 100644 --- a/tests/hazmat/primitives/twofactor/test_totp.py +++ b/tests/hazmat/primitives/twofactor/test_totp.py @@ -139,6 +139,12 @@ class TestTOTP(object): "DGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&algorithm=SHA1&issuer=World" "&period=30") + def test_buffer_protocol(self, backend): + key = bytearray(b"a long key with lots of entropy goes here") + totp = TOTP(key, 8, hashes.SHA512(), 30, backend) + time = 60 + assert totp.generate(time) == b"53049576" + def test_invalid_backend(): secret = b"12345678901234567890" |