clean up loader and make docs default to hmac sha256

This commit is contained in:
Paul Kehrer 2013-10-27 17:00:14 -05:00
parent 00dd509f18
commit 1bb8b710d4
2 changed files with 9 additions and 2 deletions

View file

@ -27,7 +27,7 @@ message.
.. doctest::
>>> from cryptography.primitives import hashes, hmac
>>> h = hmac.HMAC(key, hashes.SHA1)
>>> h = hmac.HMAC(key, hashes.SHA256)
>>> h.update(b"message to hash")
>>> h.hexdigest()
'...'

View file

@ -127,7 +127,9 @@ def load_openssl_vectors(vector_data):
def load_hash_vectors(vector_data):
vectors = []
key, msg, md = None, None, None
key = None
msg = None
md = None
for line in vector_data:
line = line.strip()
@ -154,8 +156,13 @@ def load_hash_vectors(vector_data):
# 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