diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2020-04-12 11:02:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-12 10:02:02 -0500 |
commit | 37e11ccb998781928bea5b17b13266005261c15f (patch) | |
tree | baf23bbf9a7f4af84fe427cb51da447e7482a96a /tests/wycheproof/test_eddsa.py | |
parent | ebb04592d2286118d3368d939d8a53a4a42be59d (diff) | |
download | cryptography-37e11ccb998781928bea5b17b13266005261c15f.tar.gz cryptography-37e11ccb998781928bea5b17b13266005261c15f.tar.bz2 cryptography-37e11ccb998781928bea5b17b13266005261c15f.zip |
Refs #5075 -- use ed448_test.json from wycheproof (#5191)
Diffstat (limited to 'tests/wycheproof/test_eddsa.py')
-rw-r--r-- | tests/wycheproof/test_eddsa.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/wycheproof/test_eddsa.py b/tests/wycheproof/test_eddsa.py index 5ae87e09..5beca130 100644 --- a/tests/wycheproof/test_eddsa.py +++ b/tests/wycheproof/test_eddsa.py @@ -9,9 +9,8 @@ import binascii import pytest from cryptography.exceptions import InvalidSignature -from cryptography.hazmat.primitives.asymmetric.ed25519 import ( - Ed25519PublicKey -) +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey +from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PublicKey @pytest.mark.supported( @@ -41,3 +40,28 @@ def test_ed25519_signature(backend, wycheproof): binascii.unhexlify(wycheproof.testcase["sig"]), binascii.unhexlify(wycheproof.testcase["msg"]), ) + + +@pytest.mark.supported( + only_if=lambda backend: backend.ed448_supported(), + skip_message="Requires OpenSSL with Ed448 support" +) +@pytest.mark.wycheproof_tests( + "ed448_test.json", +) +def test_ed448_signature(backend, wycheproof): + key = Ed448PublicKey.from_public_bytes( + binascii.unhexlify(wycheproof.testgroup["key"]["pk"]) + ) + + if wycheproof.valid or wycheproof.acceptable: + key.verify( + binascii.unhexlify(wycheproof.testcase["sig"]), + binascii.unhexlify(wycheproof.testcase["msg"]), + ) + else: + with pytest.raises(InvalidSignature): + key.verify( + binascii.unhexlify(wycheproof.testcase["sig"]), + binascii.unhexlify(wycheproof.testcase["msg"]), + ) |