aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/utils.py
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2014-01-27 17:05:49 -0800
committerDavid Reid <dreid@dreid.org>2014-02-03 10:05:27 -0800
commit0d492db1be3e287b5f49a5ce408196401bdd0a2b (patch)
tree8c9cbc30464819cfd173d751600d92e21fb7a836 /tests/hazmat/primitives/utils.py
parent14367303f16bc271f4a8f11f09b02342f44c3a7e (diff)
downloadcryptography-0d492db1be3e287b5f49a5ce408196401bdd0a2b.tar.gz
cryptography-0d492db1be3e287b5f49a5ce408196401bdd0a2b.tar.bz2
cryptography-0d492db1be3e287b5f49a5ce408196401bdd0a2b.zip
Closer to proposed interface in #513.
Diffstat (limited to 'tests/hazmat/primitives/utils.py')
-rw-r--r--tests/hazmat/primitives/utils.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index 9e9088a3..2584272a 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -8,9 +8,7 @@ import pytest
from cryptography.hazmat.primitives import hashes, hmac
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives.ciphers import Cipher
-from cryptography.hazmat.primitives.kdf.hkdf import (
- hkdf_derive, hkdf_extract, hkdf_expand
-)
+from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.exceptions import (
AlreadyFinalized, NotYetFinalized, AlreadyUpdated, InvalidTag,
@@ -306,38 +304,44 @@ def aead_tag_exception_test(backend, cipher_factory, mode_factory):
def hkdf_derive_test(backend, algorithm, params):
- okm = hkdf_derive(
- binascii.unhexlify(params["ikm"]),
- int(params["l"]),
- binascii.unhexlify(params["salt"]),
- binascii.unhexlify(params["info"]),
+ hkdf = HKDF(
algorithm,
+ int(params["l"]),
+ salt=binascii.unhexlify(params["salt"]) or None,
+ info=binascii.unhexlify(params["info"]) or None,
backend=backend
)
+ okm = hkdf.derive(binascii.unhexlify(params["ikm"]))
+
assert okm == binascii.unhexlify(params["okm"])
def hkdf_extract_test(backend, algorithm, params):
- prk = hkdf_extract(
+ hkdf = HKDF(
algorithm,
- binascii.unhexlify(params["ikm"]),
- binascii.unhexlify(params["salt"]),
+ int(params["l"]),
+ salt=binascii.unhexlify(params["salt"]) or None,
+ info=binascii.unhexlify(params["info"]) or None,
backend=backend
)
+ prk = hkdf.extract(binascii.unhexlify(params["ikm"]))
+
assert prk == binascii.unhexlify(params["prk"])
def hkdf_expand_test(backend, algorithm, params):
- okm = hkdf_expand(
+ hkdf = HKDF(
algorithm,
- binascii.unhexlify(params["prk"]),
- binascii.unhexlify(params["info"]),
int(params["l"]),
+ salt=binascii.unhexlify(params["salt"]) or None,
+ info=binascii.unhexlify(params["info"]) or None,
backend=backend
)
+ okm = hkdf.expand(binascii.unhexlify(params["prk"]))
+
assert okm == binascii.unhexlify(params["okm"])