Merge pull request #2660 from reaperhulk/move-decode-functions

move openssl asn1 decode functions to a new module
diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py
index d1f8f34..fcfda61 100644
--- a/tests/hazmat/primitives/test_dsa.py
+++ b/tests/hazmat/primitives/test_dsa.py
@@ -35,6 +35,29 @@
     pass
 
 
+@utils.register_interface(hashes.HashAlgorithm)
+class DummyHashAlgorithm(object):
+    name = "dummy"
+    digest_size = 32
+    block_size = 64
+
+
+def _skip_if_dsa_not_supported(backend, algorithm, p, q, g):
+    if (
+        not backend.dsa_parameters_supported(p, q, g) or
+        not backend.dsa_hash_supported(algorithm)
+    ):
+        pytest.skip(
+            "{0} does not support the provided parameters".format(backend)
+        )
+
+
+@pytest.mark.requires_backend_interface(interface=DSABackend)
+def test_skip_if_dsa_not_supported(backend):
+    with pytest.raises(pytest.skip.Exception):
+        _skip_if_dsa_not_supported(backend, DummyHashAlgorithm(), 1, 1, 1)
+
+
 @pytest.mark.requires_backend_interface(interface=DSABackend)
 class TestDSA(object):
     def test_generate_dsa_parameters(self, backend):
@@ -552,14 +575,10 @@
     def test_dsa_verification(self, vector, backend):
         digest_algorithm = vector['digest_algorithm'].replace("-", "")
         algorithm = self._algorithms_dict[digest_algorithm]
-        if (
-            not backend.dsa_parameters_supported(
-                vector['p'], vector['q'], vector['g']
-            ) or not backend.dsa_hash_supported(algorithm)
-        ):
-            pytest.skip(
-                "{0} does not support the provided parameters".format(backend)
-            )
+
+        _skip_if_dsa_not_supported(
+            backend, algorithm, vector['p'], vector['q'], vector['g']
+        )
 
         public_key = dsa.DSAPublicNumbers(
             parameter_numbers=dsa.DSAParameterNumbers(
@@ -620,14 +639,10 @@
     def test_dsa_signing(self, vector, backend):
         digest_algorithm = vector['digest_algorithm'].replace("-", "")
         algorithm = self._algorithms_dict[digest_algorithm]
-        if (
-            not backend.dsa_parameters_supported(
-                vector['p'], vector['q'], vector['g']
-            ) or not backend.dsa_hash_supported(algorithm)
-        ):
-            pytest.skip(
-                "{0} does not support the provided parameters".format(backend)
-            )
+
+        _skip_if_dsa_not_supported(
+            backend, algorithm, vector['p'], vector['q'], vector['g']
+        )
 
         private_key = dsa.DSAPrivateNumbers(
             public_numbers=dsa.DSAPublicNumbers(
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py
index 8613267..600ea27 100644
--- a/tests/hazmat/primitives/test_ec.py
+++ b/tests/hazmat/primitives/test_ec.py
@@ -98,6 +98,12 @@
         _skip_exchange_algorithm_unsupported(backend, ec.ECDH(), DummyCurve())
 
 
+@pytest.mark.requires_backend_interface(interface=EllipticCurveBackend)
+def test_skip_ecdsa_vector(backend):
+    with pytest.raises(pytest.skip.Exception):
+        _skip_ecdsa_vector(backend, DummyCurve, hashes.SHA256)
+
+
 def test_ec_numbers():
     numbers = ec.EllipticCurvePrivateNumbers(
         1,
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index b6213d6..c432db8 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -53,6 +53,13 @@
     pass
 
 
+@utils.register_interface(hashes.HashAlgorithm)
+class DummyHashAlgorithm(object):
+    name = "dummy-hash"
+    digest_size = 32
+    block_size = 64
+
+
 def _flatten_pkcs1_examples(vectors):
     flattened_vectors = []
     for vector in vectors:
@@ -64,6 +71,24 @@
     return flattened_vectors
 
 
+def _skip_pss_hash_algorithm_unsupported(backend, hash_alg):
+    if not backend.rsa_padding_supported(
+        padding.PSS(
+            mgf=padding.MGF1(hash_alg),
+            salt_length=padding.PSS.MAX_LENGTH
+        )
+    ):
+        pytest.skip(
+            "Does not support {0} in MGF1 using PSS.".format(hash_alg.name)
+        )
+
+
+@pytest.mark.requires_backend_interface(interface=RSABackend)
+def test_skip_pss_hash_algorithm_unsupported(backend):
+    with pytest.raises(pytest.skip.Exception):
+        _skip_pss_hash_algorithm_unsupported(backend, DummyHashAlgorithm())
+
+
 def test_modular_inverse():
     p = int(
         "d1f9f6c09fd3d38987f7970247b85a6da84907753d42ec52bc23b745093f4fff5cff3"
@@ -268,15 +293,7 @@
         [hashes.SHA224(), hashes.SHA256(), hashes.SHA384(), hashes.SHA512()]
     )
     def test_pss_signing_sha2(self, hash_alg, backend):
-        if not backend.rsa_padding_supported(
-            padding.PSS(
-                mgf=padding.MGF1(hash_alg),
-                salt_length=padding.PSS.MAX_LENGTH
-            )
-        ):
-            pytest.skip(
-                "Does not support {0} in MGF1 using PSS.".format(hash_alg.name)
-            )
+        _skip_pss_hash_algorithm_unsupported(backend, hash_alg)
         private_key = RSA_KEY_768.private_key(backend)
         public_key = private_key.public_key()
         pss = padding.PSS(