aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-09-24 16:24:21 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-09-26 16:02:36 -0500
commit84fc4e01afaae95d5a92703b045a37183be27988 (patch)
treec5c73b7078e9431120264e6ace63d375c3435c44 /tests
parent58f63ed781b73478ee3fe60ebe1cfdfd85df5186 (diff)
downloadcryptography-84fc4e01afaae95d5a92703b045a37183be27988.tar.gz
cryptography-84fc4e01afaae95d5a92703b045a37183be27988.tar.bz2
cryptography-84fc4e01afaae95d5a92703b045a37183be27988.zip
Process curve name when loading EC keys. Fixes #1336
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/backends/test_openssl.py5
-rw-r--r--tests/hazmat/primitives/test_ec.py28
-rw-r--r--tests/hazmat/primitives/test_serialization.py2
3 files changed, 10 insertions, 25 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index d4c5e2e7..d2620060 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -493,7 +493,7 @@ class TestOpenSSLSerialisationWithOpenSSL(object):
)
-class TestOpenSSLNoEllipticCurve(object):
+class TestOpenSSLEllipticCurve(object):
def test_elliptic_curve_supported(self, monkeypatch):
monkeypatch.setattr(backend._lib, "Cryptography_HAS_EC", 0)
@@ -506,6 +506,9 @@ class TestOpenSSLNoEllipticCurve(object):
None, None
) is False
+ def test_sn_to_elliptic_curve_not_supported(self):
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE):
+ backend._sn_to_elliptic_curve(b"fake")
class TestDeprecatedRSABackendMethods(object):
def test_create_rsa_signature_ctx(self):
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py
index 2690e794..84a25868 100644
--- a/tests/hazmat/primitives/test_ec.py
+++ b/tests/hazmat/primitives/test_ec.py
@@ -29,26 +29,6 @@ from ...utils import (
raises_unsupported_algorithm
)
-_CURVE_TYPES = {
- "secp192r1": ec.SECP192R1,
- "secp224r1": ec.SECP224R1,
- "secp256r1": ec.SECP256R1,
- "secp384r1": ec.SECP384R1,
- "secp521r1": ec.SECP521R1,
-
- "sect163k1": ec.SECT163K1,
- "sect233k1": ec.SECT233K1,
- "sect283k1": ec.SECT283K1,
- "sect409k1": ec.SECT409K1,
- "sect571k1": ec.SECT571K1,
-
- "sect163r2": ec.SECT163R2,
- "sect233r1": ec.SECT233R1,
- "sect283r1": ec.SECT283R1,
- "sect409r1": ec.SECT409R1,
- "sect571r1": ec.SECT571R1,
-}
-
_HASH_TYPES = {
"SHA-1": hashes.SHA1,
"SHA-224": hashes.SHA224,
@@ -162,7 +142,7 @@ class TestECDSAVectors(object):
))
)
def test_signing_with_example_keys(self, backend, vector, hash_type):
- curve_type = _CURVE_TYPES[vector['curve']]
+ curve_type = ec.CURVE_TYPES[vector['curve']]
_skip_ecdsa_vector(backend, curve_type, hash_type)
@@ -188,7 +168,7 @@ class TestECDSAVectors(object):
verifier.verify()
@pytest.mark.parametrize(
- "curve", _CURVE_TYPES.values()
+ "curve", ec.CURVE_TYPES.values()
)
def test_generate_vector_curves(self, backend, curve):
_skip_curve_unsupported(backend, curve())
@@ -244,7 +224,7 @@ class TestECDSAVectors(object):
)
def test_signatures(self, backend, vector):
hash_type = _HASH_TYPES[vector['digest_algorithm']]
- curve_type = _CURVE_TYPES[vector['curve']]
+ curve_type = ec.CURVE_TYPES[vector['curve']]
_skip_ecdsa_vector(backend, curve_type, hash_type)
@@ -276,7 +256,7 @@ class TestECDSAVectors(object):
)
def test_signature_failures(self, backend, vector):
hash_type = _HASH_TYPES[vector['digest_algorithm']]
- curve_type = _CURVE_TYPES[vector['curve']]
+ curve_type = ec.CURVE_TYPES[vector['curve']]
_skip_ecdsa_vector(backend, curve_type, hash_type)
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py
index 8405f4b2..06997491 100644
--- a/tests/hazmat/primitives/test_serialization.py
+++ b/tests/hazmat/primitives/test_serialization.py
@@ -412,6 +412,8 @@ class TestPKCS8Serialization(object):
)
assert key
assert isinstance(key, interfaces.EllipticCurvePrivateKey)
+ assert key.curve.name == "secp256r1"
+ assert key.curve.key_size == 256
def test_unused_password(self, backend):
key_file = os.path.join(