diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2018-12-10 12:13:31 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2018-12-09 23:13:31 -0500 |
commit | 3c68250ad9bfb275c760fcce4c72c78c99b57c34 (patch) | |
tree | 06c6f5b1e513d9d16ec25ab25ae927b47172a7ca /tests/hazmat/primitives/test_chacha20.py | |
parent | c2d16370f00e42fae13e492c0b1c7b3a83a5e495 (diff) | |
download | cryptography-3c68250ad9bfb275c760fcce4c72c78c99b57c34.tar.gz cryptography-3c68250ad9bfb275c760fcce4c72c78c99b57c34.tar.bz2 cryptography-3c68250ad9bfb275c760fcce4c72c78c99b57c34.zip |
allow bytes-like for key/iv/data for symmetric encryption (#4621)
* allow bytearrays for key/iv for symmetric encryption
* bump pypy/cffi requirements
* update docs, fix some tests
* old openssl is naught but pain
* revert a typo
* use trusty for old pypy
* better error msg again
* restore match
Diffstat (limited to 'tests/hazmat/primitives/test_chacha20.py')
-rw-r--r-- | tests/hazmat/primitives/test_chacha20.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_chacha20.py b/tests/hazmat/primitives/test_chacha20.py index 33730d91..7c475c0f 100644 --- a/tests/hazmat/primitives/test_chacha20.py +++ b/tests/hazmat/primitives/test_chacha20.py @@ -44,6 +44,18 @@ class TestChaCha20(object): computed_ct = encryptor.update(pt) + encryptor.finalize() assert binascii.hexlify(computed_ct) == vector["ciphertext"] + def test_buffer_protocol(self, backend): + key = bytearray(os.urandom(32)) + nonce = bytearray(os.urandom(16)) + cipher = Cipher( + algorithms.ChaCha20(key, nonce), None, backend + ) + enc = cipher.encryptor() + ct = enc.update(bytearray(b"hello")) + enc.finalize() + dec = cipher.decryptor() + pt = dec.update(ct) + dec.finalize() + assert pt == b"hello" + def test_key_size(self): chacha = algorithms.ChaCha20(b"0" * 32, b"0" * 16) assert chacha.key_size == 256 |