aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2024-05-02 00:55:41 -0400
committerGitHub <noreply@github.com>2024-05-01 21:55:41 -0700
commitb4ca965b0f8186b95e7c3f1389205628a0cf2502 (patch)
tree2c68e4bb30bc16260c3b87978c604cd826c19019 /tests
parent05d44a8d9d8eedf4d1278cdff67ddc32b2af45c0 (diff)
downloadpyca-cryptography-b4ca965b0f8186b95e7c3f1389205628a0cf2502.zip
pyca-cryptography-b4ca965b0f8186b95e7c3f1389205628a0cf2502.tar.gz
pyca-cryptography-b4ca965b0f8186b95e7c3f1389205628a0cf2502.tar.bz2
Ensure curves are supported in determinisic ECDSA tests (#10917)
* Ensure curves are supported in determinisic ECDSA tests * x25519/x448 isnt fips anymore i guess
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_ec.py20
-rw-r--r--tests/utils.py1
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py
index b0e29b3..08178c2 100644
--- a/tests/hazmat/primitives/test_ec.py
+++ b/tests/hazmat/primitives/test_ec.py
@@ -535,6 +535,23 @@ class TestECDSAVectors:
"SHA384": hashes.SHA384(),
"SHA512": hashes.SHA512(),
}
+ curves = {
+ "B-163": ec.SECT163R2(),
+ "B-233": ec.SECT233R1(),
+ "B-283": ec.SECT283R1(),
+ "B-409": ec.SECT409R1(),
+ "B-571": ec.SECT571R1(),
+ "K-163": ec.SECT163K1(),
+ "K-233": ec.SECT233K1(),
+ "K-283": ec.SECT283K1(),
+ "K-409": ec.SECT409K1(),
+ "K-571": ec.SECT571K1(),
+ "P-192": ec.SECP192R1(),
+ "P-224": ec.SECP224R1(),
+ "P-256": ec.SECP256R1(),
+ "P-384": ec.SECP384R1(),
+ "P-521": ec.SECP521R1(),
+ }
vectors = load_vectors_from_file(
os.path.join(
"asymmetric", "ECDSA", "RFC6979", "evppkey_ecdsa_rfc6979.txt"
@@ -547,6 +564,9 @@ class TestECDSAVectors:
input = bytes(vector["input"], "utf-8")
output = bytes.fromhex(vector["output"])
key = bytes("\n".join(vector["key"]), "utf-8")
+ curve = curves[vector["key_name"].split("_")[0]]
+ _skip_curve_unsupported(backend, curve)
+
if "digest_sign" in vector:
algorithm = vector["digest_sign"]
hash_algorithm = supported_hash_algorithms[algorithm]
diff --git a/tests/utils.py b/tests/utils.py
index 3a8a768..b9734a6 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -734,6 +734,7 @@ def load_rfc6979_vectors(vector_data):
key_name = line.split("=")[1].strip()
assert key_name in keys
data["key"] = keys[key_name]
+ data["key_name"] = key_name
elif line.startswith("NonceType = "):
nonce_type = line.split("=")[1].strip()
data["deterministic_nonce"] = nonce_type == "deterministic"