diff options
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/tests/utils.py b/tests/utils.py index 720a9054..4d6882c2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -302,6 +302,8 @@ def load_pkcs1_vectors(vector_data): def load_rsa_nist_vectors(vector_data): test_data = None + p = None + salt_length = None data = [] for line in vector_data: @@ -322,17 +324,37 @@ def load_rsa_nist_vectors(vector_data): if name == "n": n = int(value, 16) - elif name == "e": + elif name == "e" and p is None: e = int(value, 16) + elif name == "p": + p = int(value, 16) + elif name == "q": + q = int(value, 16) elif name == "SHAAlg": - test_data = { - "modulus": n, - "public_exponent": e, - "salt_length": salt_length, - "algorithm": value.encode("ascii") - } + if p is None: + test_data = { + "modulus": n, + "public_exponent": e, + "salt_length": salt_length, + "algorithm": value, + "fail": False + } + else: + test_data = { + "modulus": n, + "p": p, + "q": q, + "algorithm": value + } + if salt_length is not None: + test_data["salt_length"] = salt_length data.append(test_data) - continue + elif name == "e" and p is not None: + test_data["public_exponent"] = int(value, 16) + elif name == "d": + test_data["private_exponent"] = int(value, 16) + elif name == "Result": + test_data["fail"] = value.startswith("F") # For all other tokens we simply want the name, value stored in # the dictionary else: |