From c0ce911b4e971f3090d406cb88dea532647eeac6 Mon Sep 17 00:00:00 2001 From: Ayrx Date: Wed, 7 May 2014 16:22:09 +0800 Subject: Renamed HKDFExpandOnly to HKDFExpand --- cryptography/hazmat/primitives/kdf/hkdf.py | 2 +- docs/hazmat/primitives/key-derivation-functions.rst | 10 +++++----- tests/hazmat/primitives/test_hkdf.py | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cryptography/hazmat/primitives/kdf/hkdf.py b/cryptography/hazmat/primitives/kdf/hkdf.py index 6d34a0f7..44e14817 100644 --- a/cryptography/hazmat/primitives/kdf/hkdf.py +++ b/cryptography/hazmat/primitives/kdf/hkdf.py @@ -103,7 +103,7 @@ class HKDF(object): @utils.register_interface(interfaces.KeyDerivationFunction) -class HKDFExpandOnly(HKDF): +class HKDFExpand(HKDF): def __init__(self, algorithm, length, info, backend): HKDF.__init__(self, algorithm, length, None, info, backend) diff --git a/docs/hazmat/primitives/key-derivation-functions.rst b/docs/hazmat/primitives/key-derivation-functions.rst index 9b76bf64..11fbd4e0 100644 --- a/docs/hazmat/primitives/key-derivation-functions.rst +++ b/docs/hazmat/primitives/key-derivation-functions.rst @@ -220,7 +220,7 @@ Different KDFs are suitable for different tasks such as: raises an exception if they do not match. -.. class:: HKDFExpandOnly(algorithm, length, info, backend) +.. class:: HKDFExpand(algorithm, length, info, backend) .. versionadded:: 0.5 @@ -230,7 +230,7 @@ Different KDFs are suitable for different tasks such as: .. warning:: - HKDFExpandOnly should only be used if the key material is + HKDFExpand should only be used if the key material is cryptographically strong. You should use :class:`~cryptography.hazmat.primitives.kdf.hkdf.HKDF` if you are unsure. @@ -239,19 +239,19 @@ Different KDFs are suitable for different tasks such as: >>> import os >>> from cryptography.hazmat.primitives import hashes - >>> from cryptography.hazmat.primitives.kdf.hkdf import HKDFExpandOnly + >>> from cryptography.hazmat.primitives.kdf.hkdf import HKDFExpand >>> from cryptography.hazmat.backends import default_backend >>> backend = default_backend() >>> info = b"hkdf-example" >>> key_material = os.urandom(16) - >>> hkdf = HKDFExpandOnly( + >>> hkdf = HKDFExpand( ... algorithm=hashes.SHA256(), ... length=32, ... info=info, ... backend=backend ... ) >>> key = hkdf.derive(key_material) - >>> hkdf = HKDFExpandOnly( + >>> hkdf = HKDFExpand( ... algorithm=hashes.SHA256(), ... length=32, ... info=info, diff --git a/tests/hazmat/primitives/test_hkdf.py b/tests/hazmat/primitives/test_hkdf.py index 904ed69c..bee42172 100644 --- a/tests/hazmat/primitives/test_hkdf.py +++ b/tests/hazmat/primitives/test_hkdf.py @@ -23,7 +23,7 @@ from cryptography.exceptions import ( AlreadyFinalized, InvalidKey, _Reasons ) from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpandOnly +from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpand from ...utils import raises_unsupported_algorithm @@ -154,7 +154,7 @@ class TestHKDF(object): @pytest.mark.hmac -class TestHKDFExpandOnly(object): +class TestHKDFExpand(object): def test_derive(self, backend): prk = binascii.unhexlify( b"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5" @@ -164,7 +164,7 @@ class TestHKDFExpandOnly(object): b"5bf34007208d5b887185865") info = binascii.unhexlify(b"f0f1f2f3f4f5f6f7f8f9") - hkdf = HKDFExpandOnly(hashes.SHA256(), 42, info, backend) + hkdf = HKDFExpand(hashes.SHA256(), 42, info, backend) assert binascii.hexlify(hkdf.derive(prk)) == okm @@ -177,7 +177,7 @@ class TestHKDFExpandOnly(object): b"5bf34007208d5b887185865") info = binascii.unhexlify(b"f0f1f2f3f4f5f6f7f8f9") - hkdf = HKDFExpandOnly(hashes.SHA256(), 42, info, backend) + hkdf = HKDFExpand(hashes.SHA256(), 42, info, backend) assert hkdf.verify(prk, binascii.unhexlify(okm)) is None @@ -187,14 +187,14 @@ class TestHKDFExpandOnly(object): ) info = binascii.unhexlify(b"f0f1f2f3f4f5f6f7f8f9") - hkdf = HKDFExpandOnly(hashes.SHA256(), 42, info, backend) + hkdf = HKDFExpand(hashes.SHA256(), 42, info, backend) with pytest.raises(InvalidKey): hkdf.verify(prk, b"wrong key") def test_already_finalized(self, backend): info = binascii.unhexlify(b"f0f1f2f3f4f5f6f7f8f9") - hkdf = HKDFExpandOnly(hashes.SHA256(), 42, info, backend) + hkdf = HKDFExpand(hashes.SHA256(), 42, info, backend) hkdf.derive(b"first") @@ -203,7 +203,7 @@ class TestHKDFExpandOnly(object): def test_unicode_error(self, backend): info = binascii.unhexlify(b"f0f1f2f3f4f5f6f7f8f9") - hkdf = HKDFExpandOnly(hashes.SHA256(), 42, info, backend) + hkdf = HKDFExpand(hashes.SHA256(), 42, info, backend) with pytest.raises(TypeError): hkdf.derive(six.u("first")) -- cgit v1.2.3