From d5c9f5ae0c83ad1c156476ea43bb72e0e1a1fa0e Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 15 Feb 2014 22:17:14 -0600 Subject: remove openssl vector loader that is no longer in use --- tests/utils.py | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 2bbecd7d..3c150a2e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -135,26 +135,6 @@ def load_cryptrec_vectors(vector_data): return cryptrec_list -def load_openssl_vectors(vector_data): - vectors = [] - - for line in vector_data: - line = line.strip() - - # Blank lines and comments are ignored - if not line or line.startswith("#"): - continue - - vector = line.split(":") - vectors.append({ - "key": vector[1].encode("ascii"), - "iv": vector[2].encode("ascii"), - "plaintext": vector[3].encode("ascii"), - "ciphertext": vector[4].encode("ascii"), - }) - return vectors - - def load_hash_vectors(vector_data): vectors = [] key = None -- cgit v1.2.3 From efca28007009163b29443c2f5558221f37002bf9 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 17 Feb 2014 20:55:13 -0600 Subject: expand pkcs1 loader to load PKCS1 v1.5 and PSS signature examples --- tests/utils.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 3c150a2e..bcd915be 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -177,15 +177,53 @@ def load_hash_vectors(vector_data): def load_pkcs1_vectors(vector_data): """ Loads data out of RSA PKCS #1 vector files. - - Currently only returns the key pairs. """ private_key_vector = None public_key_vector = None attr = None key = None + example_vector = None + examples = [] vectors = [] for line in vector_data: + if (line.startswith("# PSS Example") or + line.startswith("# PKCS#1 v1.5 Signature") + ): + if example_vector: + for key, value in six.iteritems(example_vector): + hex_str = "".join(value).replace(" ", "") + example_vector[key] = hex_str + examples.append(example_vector) + + attr = None + example_vector = collections.defaultdict(list) + + if line.startswith("# Message to be signed"): + attr = "msg" + continue + elif line.startswith("# Salt"): + attr = "salt" + continue + elif line.startswith("# Signature"): + attr = "signature" + continue + elif ( + example_vector and + line.startswith("# =============================================") + ): + for key, value in six.iteritems(example_vector): + hex_str = "".join(value).replace(" ", "") + example_vector[key] = hex_str + examples.append(example_vector) + example_vector = None + attr = None + elif example_vector and line.startswith("#"): + continue + else: + if attr is not None and example_vector is not None: + example_vector[attr].append(line.strip()) + continue + if ( line.startswith("# Example") or line.startswith("# =============================================") @@ -202,6 +240,9 @@ def load_pkcs1_vectors(vector_data): hex_str = "".join(value).replace(" ", "") private_key_vector[key] = int(hex_str, 16) + private_key_vector["examples"] = examples + examples = [] + assert ( private_key_vector['public_exponent'] == public_key_vector['public_exponent'] -- cgit v1.2.3 From 7774a0380b551266fc2c6440895c1f17a6e937ee Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 17 Feb 2014 22:56:55 -0600 Subject: fix pep8 --- tests/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index bcd915be..5262b733 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -186,9 +186,10 @@ def load_pkcs1_vectors(vector_data): examples = [] vectors = [] for line in vector_data: - if (line.startswith("# PSS Example") or - line.startswith("# PKCS#1 v1.5 Signature") - ): + if ( + line.startswith("# PSS Example") or + line.startswith("# PKCS#1 v1.5 Signature") + ): if example_vector: for key, value in six.iteritems(example_vector): hex_str = "".join(value).replace(" ", "") -- cgit v1.2.3 From 7d9c306cd6bd1a3250d7b85e812b9cb90aaa3fd3 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 18 Feb 2014 08:27:39 -0600 Subject: rename msg -> message in pkcs1 loader --- tests/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 5262b733..6679e907 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -200,7 +200,7 @@ def load_pkcs1_vectors(vector_data): example_vector = collections.defaultdict(list) if line.startswith("# Message to be signed"): - attr = "msg" + attr = "message" continue elif line.startswith("# Salt"): attr = "salt" -- cgit v1.2.3 From 26811800a7ef162b7e868ca50856fb1a243d5ed6 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 19 Feb 2014 16:32:11 -0600 Subject: these examples should be bytes to be consistent with other loaders --- tests/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 6679e907..0d9567f9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -192,7 +192,7 @@ def load_pkcs1_vectors(vector_data): ): if example_vector: for key, value in six.iteritems(example_vector): - hex_str = "".join(value).replace(" ", "") + hex_str = "".join(value).replace(" ", "").encode("ascii") example_vector[key] = hex_str examples.append(example_vector) @@ -213,7 +213,7 @@ def load_pkcs1_vectors(vector_data): line.startswith("# =============================================") ): for key, value in six.iteritems(example_vector): - hex_str = "".join(value).replace(" ", "") + hex_str = "".join(value).replace(" ", "").encode("ascii") example_vector[key] = hex_str examples.append(example_vector) example_vector = None -- cgit v1.2.3