aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-29 10:53:57 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-29 10:53:57 -0700
commit89546af52b8f8a6fc2fba520377906b4010c9037 (patch)
tree5bb161d84c93e16db187b18f5d60e651198f7185 /tests/utils.py
parent3944a8ce014f9f665a2300e1fa994b872cffa92b (diff)
parenta9d9922f82d4e7b940679c4b548a4b14d0958ed9 (diff)
downloadcryptography-89546af52b8f8a6fc2fba520377906b4010c9037.tar.gz
cryptography-89546af52b8f8a6fc2fba520377906b4010c9037.tar.bz2
cryptography-89546af52b8f8a6fc2fba520377906b4010c9037.zip
Merge branch 'master' into pkcs7-padding
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 9d01746a..ad676c04 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -127,6 +127,9 @@ def load_openssl_vectors(vector_data):
def load_hash_vectors(vector_data):
vectors = []
+ key = None
+ msg = None
+ md = None
for line in vector_data:
line = line.strip()
@@ -136,6 +139,11 @@ def load_hash_vectors(vector_data):
if line.startswith("Len"):
length = int(line.split(" = ")[1])
+ elif line.startswith("Key"):
+ """
+ HMAC vectors contain a key attribute. Hash vectors do not.
+ """
+ key = line.split(" = ")[1].encode("ascii")
elif line.startswith("Msg"):
"""
In the NIST vectors they have chosen to represent an empty
@@ -145,8 +153,16 @@ def load_hash_vectors(vector_data):
msg = line.split(" = ")[1].encode("ascii") if length > 0 else b""
elif line.startswith("MD"):
md = line.split(" = ")[1]
- # after MD is found the Msg+MD tuple is complete
- vectors.append((msg, md))
+ # after MD is found the Msg+MD (+ potential key) tuple is complete
+ if key is not None:
+ vectors.append((msg, md, key))
+ key = None
+ msg = None
+ md = None
+ else:
+ vectors.append((msg, md))
+ msg = None
+ md = None
else:
raise ValueError("Unknown line in hash vector")
return vectors