aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2014-01-22 17:18:49 -0800
committerDavid Reid <dreid@dreid.org>2014-02-03 10:05:26 -0800
commit5443e9d949a1b720642ac25c2a2eb712515e77b0 (patch)
tree66d6d720ab303661fc47292d92ee0338301bfbb5 /tests/utils.py
parenta187836004cd5e4bdc7d15fe54f1be91043110a6 (diff)
downloadcryptography-5443e9d949a1b720642ac25c2a2eb712515e77b0.tar.gz
cryptography-5443e9d949a1b720642ac25c2a2eb712515e77b0.tar.bz2
cryptography-5443e9d949a1b720642ac25c2a2eb712515e77b0.zip
Break up hkdf_derive into hkdf_extract and hkdf_expand.
Testing each individually against all the vectors and actually asserting about the intermediate state. hkdf_derive is now just a helper function which copes with the default arguments.
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 5f2c6ff6..850d436f 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -196,11 +196,7 @@ def load_hash_vectors(vector_data):
def load_hkdf_vectors(vector_data):
vectors = []
- ikm = None
- salt = None
- info = None
- length = None
- okm = None
+ ikm = salt = info = length = prk = okm = None
for line in vector_data:
line = line.strip()
@@ -211,27 +207,17 @@ def load_hkdf_vectors(vector_data):
elif line.startswith("IKM"):
ikm = line.split(" = ")[1].encode("ascii")
elif line.startswith("salt"):
- l = line.split(" =")
- if len(l) == 1:
- salt = b""
- else:
- salt = l[1].strip().encode("ascii")
+ salt = line.split(" =")[1].strip().encode("ascii")
elif line.startswith("info"):
- l = line.split(" =")
- if len(l) == 1:
- info = b""
- else:
- info = l[1].strip().encode("ascii")
+ info = line.split(" =")[1].strip().encode("ascii")
elif line.startswith("L"):
length = int(line.split(" = ")[1])
+ elif line.startswith("PRK"):
+ prk = line.split(" = ")[1].encode("ascii")
elif line.startswith("OKM"):
okm = line.split(" = ")[1].encode("ascii")
- vectors.append((ikm, salt, info, length, okm))
- ikm = None
- salt = None
- info = None
- length = None
- okm = None
+ vectors.append((ikm, salt, info, length, prk, okm))
+ ikm = salt = info = length = prk = okm = None
return vectors