diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-09-27 20:56:15 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-09-27 20:56:15 -0400 |
commit | 5a4773856cd5d482009d855780189df87793bab4 (patch) | |
tree | 81fb9b4cbc0fb25a1bc031345fee05dc3bd954ba /tests/hazmat/primitives/test_ec.py | |
parent | 774b77f75a88735395b075f97f99ea577e1affa2 (diff) | |
parent | 7ee7d5ba847b0e1c6db4afc02fa858ac8734ba6b (diff) | |
download | cryptography-5a4773856cd5d482009d855780189df87793bab4.tar.gz cryptography-5a4773856cd5d482009d855780189df87793bab4.tar.bz2 cryptography-5a4773856cd5d482009d855780189df87793bab4.zip |
Merge pull request #1345 from reaperhulk/ec-withnumbers
Elliptic Curve WithNumbers Support
Diffstat (limited to 'tests/hazmat/primitives/test_ec.py')
-rw-r--r-- | tests/hazmat/primitives/test_ec.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index 35505820..c53a0cb6 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -139,6 +139,42 @@ def test_ec_numbers(): @pytest.mark.elliptic +class TestECWithNumbers(object): + @pytest.mark.parametrize( + ("vector", "hash_type"), + list(itertools.product( + load_vectors_from_file( + os.path.join( + "asymmetric", "ECDSA", "FIPS_186-3", "KeyPair.rsp"), + load_fips_ecdsa_key_pair_vectors + ), + _HASH_TYPES.values() + )) + ) + def test_with_numbers(self, backend, vector, hash_type): + curve_type = ec._CURVE_TYPES[vector['curve']] + + _skip_ecdsa_vector(backend, curve_type, hash_type) + + key = ec.EllipticCurvePrivateNumbers( + vector['d'], + ec.EllipticCurvePublicNumbers( + vector['x'], + vector['y'], + curve_type() + ) + ).private_key(backend) + assert key + + if isinstance(key, interfaces.EllipticCurvePrivateKeyWithNumbers): + priv_num = key.private_numbers() + assert priv_num.private_value == vector['d'] + assert priv_num.public_numbers.x == vector['x'] + assert priv_num.public_numbers.y == vector['y'] + assert curve_type().name == priv_num.public_numbers.curve.name + + +@pytest.mark.elliptic class TestECDSAVectors(object): @pytest.mark.parametrize( ("vector", "hash_type"), |