diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-10-19 08:04:17 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-10-19 08:04:17 -0400 |
commit | 7c60ffc621320349f88cf36b12cd087d8bd9b6a3 (patch) | |
tree | b2f58e22274b9d7cba4b206a9c5a40830f592650 | |
parent | 799b33f69a8bfd1aaf7f90a81b6ee3fdebc777a1 (diff) | |
download | cryptography-7c60ffc621320349f88cf36b12cd087d8bd9b6a3.tar.gz cryptography-7c60ffc621320349f88cf36b12cd087d8bd9b6a3.tar.bz2 cryptography-7c60ffc621320349f88cf36b12cd087d8bd9b6a3.zip |
removed unused code, and added a test
-rw-r--r-- | tests/hazmat/primitives/test_ec.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index a634afe8..6c184522 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -90,6 +90,12 @@ def test_skip_curve_unsupported(backend): _skip_curve_unsupported(backend, DummyCurve()) +@pytest.mark.requires_backend_interface(interface=EllipticCurveBackend) +def test_skip_exchange_algorithm_unsupported(backend): + with pytest.raises(pytest.skip.Exception): + _skip_exchange_algorithm_unsupported(backend, ec.ECDH(), DummyCurve()) + + def test_ec_numbers(): numbers = ec.EllipticCurvePrivateNumbers( 1, @@ -814,16 +820,11 @@ class TestECDHVectors(object): else: peer_pubkey = public_numbers.public_key(backend) - if vector['fail'] and vector['errno'] not in [7, 8]: - with pytest.raises(ValueError): - private_key.exchange(ec.ECDH(), peer_pubkey) + z = private_key.exchange(ec.ECDH(), peer_pubkey) + z = int(hexlify(z).decode('ascii'), 16) + # At this point fail indicates that one of the underlying keys was + # changed. This results in a non-matching derived key. + if vector['fail']: + assert z != vector['Z'] else: - z = private_key.exchange(ec.ECDH(), peer_pubkey) - z = int(hexlify(z).decode('ascii'), 16) - # Errno 7 denotes a changed private key. Errno 8 denotes a changed - # shared key. Both these errors will not cause a failure in the - # exchange but should lead to a non-matching derived shared key. - if vector['errno'] in [7, 8]: - assert z != vector['Z'] - else: - assert z == vector['Z'] + assert z == vector['Z'] |