aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorJared <jamessenger@gmail.com>2016-04-13 14:03:52 -0700
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-04-13 16:03:52 -0500
commitcd258d531c93c51772fa5e52658f47912aff4fbd (patch)
treecfbd313d1c76e81e4ee236eac634cd0af1843183 /tests/utils.py
parent43774546263812c965ec3040632f36d43889084d (diff)
downloadcryptography-cd258d531c93c51772fa5e52658f47912aff4fbd.tar.gz
cryptography-cd258d531c93c51772fa5e52658f47912aff4fbd.tar.bz2
cryptography-cd258d531c93c51772fa5e52658f47912aff4fbd.zip
Adding CAVP vector parsing for NIST SP 800-108 KDF vectors. (#2865)
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