From 7f63e5b65d14dca6c4783d62fa5937a5a5c705e7 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 17 Jan 2019 15:52:36 -0600 Subject: support bytes-like for X25519PrivateKey.from_private_bytes (#4698) yuck. --- tests/hazmat/primitives/test_x25519.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/hazmat/primitives') diff --git a/tests/hazmat/primitives/test_x25519.py b/tests/hazmat/primitives/test_x25519.py index f412f2e88..17a911548 100644 --- a/tests/hazmat/primitives/test_x25519.py +++ b/tests/hazmat/primitives/test_x25519.py @@ -258,3 +258,12 @@ class TestX25519Exchange(object): serialized = key.private_bytes(encoding, fmt, encryption) loaded_key = load_func(serialized, passwd, backend) assert isinstance(loaded_key, X25519PrivateKey) + + def test_buffer_protocol(self, backend): + private_bytes = bytearray(os.urandom(32)) + key = X25519PrivateKey.from_private_bytes(private_bytes) + assert key.private_bytes( + serialization.Encoding.Raw, + serialization.PrivateFormat.Raw, + serialization.NoEncryption() + ) == private_bytes -- cgit v1.2.3