aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py37
1 files changed, 37 insertions, 0 deletions
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