From cd258d531c93c51772fa5e52658f47912aff4fbd Mon Sep 17 00:00:00 2001 From: Jared Date: Wed, 13 Apr 2016 14:03:52 -0700 Subject: Adding CAVP vector parsing for NIST SP 800-108 KDF vectors. (#2865) --- tests/utils.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 3970109e..dc7377ae 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -809,3 +809,40 @@ def load_x963_vectors(vector_data): vector = {} return vectors + + +def load_nist_kbkdf_vectors(vector_data): + """ + Load NIST SP 800-108 KDF Vectors + """ + vectors = [] + test_data = None + tag = {} + + for line in vector_data: + line = line.strip() + + if not line or line.startswith("#"): + continue + + if line.startswith("[") and line.endswith("]"): + tag_data = line[1:-1] + name, value = [c.strip() for c in tag_data.split("=")] + if value.endswith('_BITS'): + value = int(value.split('_')[0]) + tag.update({name.lower(): value}) + continue + + tag.update({name.lower(): value.lower()}) + elif line.startswith("COUNT="): + test_data = dict() + test_data.update(tag) + vectors.append(test_data) + elif line.startswith("L"): + name, value = [c.strip() for c in line.split("=")] + test_data[name.lower()] = int(value) + else: + name, value = [c.strip() for c in line.split("=")] + test_data[name.lower()] = value.encode("ascii") + + return vectors -- cgit v1.2.3