aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorunknown <mrh2@MRH2W7D.uk.cambridgeconsultants.com>2014-09-12 10:03:56 +0100
committerunknown <mrh2@MRH2W7D.uk.cambridgeconsultants.com>2014-09-12 10:03:56 +0100
commit84005936bc02bc928fc7901e08b7866bf808da6b (patch)
treedb92951aa57b7c6b99c07f01102bd78c8092d9b3
parent04e783f5610d3983bb3cbdf82720d17a97c779a7 (diff)
downloadcryptography-84005936bc02bc928fc7901e08b7866bf808da6b.tar.gz
cryptography-84005936bc02bc928fc7901e08b7866bf808da6b.tar.bz2
cryptography-84005936bc02bc928fc7901e08b7866bf808da6b.zip
Adjusted formatting and added EC check
Due to the code failing the PEP-8 test, the test code has been reformatted so that there are two blank lines between the function and the next class, and the overlong line has been adjusted. Also added a check to the private key loading function to check for the Cryptography_HAS_EC field. This has been tested on Windows only.
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py2
-rw-r--r--tests/hazmat/primitives/test_serialization.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index b59b2391..c04c6603 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -473,7 +473,7 @@ class Backend(object):
assert dsa_cdata != self._ffi.NULL
dsa_cdata = self._ffi.gc(dsa_cdata, self._lib.DSA_free)
return _DSAPrivateKey(self, dsa_cdata)
- elif type == self._lib.EVP_PKEY_EC:
+ elif self._lib.Cryptography_HAS_EC == 1 and type == self._lib.EVP_PKEY_EC:
ec_cdata = self._lib.EVP_PKEY_get1_EC_KEY(evp_pkey)
assert ec_cdata != self._ffi.NULL
ec_cdata = self._ffi.gc(ec_cdata, self._lib.EC_KEY_free)
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py
index 4d32fba2..77d748b3 100644
--- a/tests/hazmat/primitives/test_serialization.py
+++ b/tests/hazmat/primitives/test_serialization.py
@@ -61,7 +61,8 @@ class TestPEMSerialization(object):
def test_load_pem_ec_private_key_encrypted(self, backend):
key = load_vectors_from_file(
os.path.join(
- "asymmetric", "PEM_Serialization", "ec_private_key_encrypted.pem"),
+ "asymmetric", "PEM_Serialization",
+ "ec_private_key_encrypted.pem"),
lambda pemfile: load_pem_private_key(
pemfile.read().encode(), b"123456", backend
)
@@ -70,6 +71,7 @@ class TestPEMSerialization(object):
assert key
assert isinstance(key, interfaces.EllipticCurvePrivateKey)
+
@pytest.mark.traditional_openssl_serialization
class TestTraditionalOpenSSLSerialization(object):
@pytest.mark.parametrize(