From e1f7e0978231f73382f95b864200fdeca7d37bb7 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 21 Feb 2019 12:53:45 +0800 Subject: add an EC OID to curve dictionary mapping (#4759) * add an EC OID to curve dictionary mapping * oid_to_curve function * changelog and docs fix * rename to get_curve_for_oid --- tests/hazmat/primitives/test_ec.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index 1f3a67d3..cd30223c 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -11,7 +11,7 @@ from binascii import hexlify import pytest -from cryptography import exceptions, utils +from cryptography import exceptions, utils, x509 from cryptography.hazmat.backends.interfaces import ( EllipticCurveBackend, PEMSerializationBackend ) @@ -71,6 +71,12 @@ def _skip_exchange_algorithm_unsupported(backend, algorithm, curve): ) +def test_get_curve_for_oid(): + assert ec.get_curve_for_oid(ec.EllipticCurveOID.SECP256R1) == ec.SECP256R1 + with pytest.raises(LookupError): + ec.get_curve_for_oid(x509.ObjectIdentifier("1.1.1.1")) + + @utils.register_interface(ec.EllipticCurve) class DummyCurve(object): name = "dummy-curve" -- cgit v1.2.3