aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-05-29 22:37:33 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2016-05-29 23:37:33 -0400
commitcb0fa2e323fde10d5fa61bcc32d87a567690e34a (patch)
treea95dbfaf1d559021ad350b0eff39bb4b139b0d02
parent6d7fe00c7066d8d474981b21cdadb16f021d3e6a (diff)
downloadcryptography-cb0fa2e323fde10d5fa61bcc32d87a567690e34a.tar.gz
cryptography-cb0fa2e323fde10d5fa61bcc32d87a567690e34a.tar.bz2
cryptography-cb0fa2e323fde10d5fa61bcc32d87a567690e34a.zip
KBKDF cleanup (#2929)
* unicode characters make everything angry * changelog entry and make skip msgs more informative * typo fix
-rw-r--r--CHANGELOG.rst1
-rw-r--r--src/cryptography/hazmat/primitives/kdf/kbkdf.py2
-rw-r--r--tests/hazmat/primitives/utils.py12
3 files changed, 9 insertions, 6 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 1ac12976..00a0a012 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -8,6 +8,7 @@ Changelog
* Support for OpenSSL 0.9.8 has been removed. Users on older version of OpenSSL
will need to upgrade.
+* Added :class:`~cryptography.hazmat.primitives.kdf.kbkdf.KBKDFHMAC`.
1.3.2 - 2016-05-04
~~~~~~~~~~~~~~~~~~
diff --git a/src/cryptography/hazmat/primitives/kdf/kbkdf.py b/src/cryptography/hazmat/primitives/kdf/kbkdf.py
index 70a0fdc6..29ac0fad 100644
--- a/src/cryptography/hazmat/primitives/kdf/kbkdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/kbkdf.py
@@ -112,7 +112,7 @@ class KBKDFHMAC(object):
output = [b'']
# For counter mode, the number of iterations shall not be
- # larger than 2^r-1, where r ≤ 32 is the binary length of the counter
+ # larger than 2^r-1, where r <= 32 is the binary length of the counter
# This ensures that the counter values used as an input to the
# PRF will not repeat during a particular call to the KDF function.
r_bin = utils.int_to_bytes(1, self._rlen)
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index e45466d8..8705cdc4 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -391,19 +391,21 @@ def kbkdf_counter_mode_test(backend, params):
'hmac_sha512': hashes.SHA512,
}
- supportd_counter_locations = {
+ supported_counter_locations = {
"before_fixed": CounterLocation.BeforeFixed,
"after_fixed": CounterLocation.AfterFixed,
}
algorithm = supported_algorithms.get(params.get('prf'))
if algorithm is None or not backend.hmac_supported(algorithm()):
- pytest.skip('Does not support algorithm')
+ pytest.skip("KBKDF does not support algorithm: {0}".format(
+ params.get('prf')
+ ))
- ctr_loc = supportd_counter_locations.get(params.get("ctrlocation"))
+ ctr_loc = supported_counter_locations.get(params.get("ctrlocation"))
if ctr_loc is None or not isinstance(ctr_loc, CounterLocation):
- pytest.skip("Does not support counter location".format(
- location=params.get('ctrlocation')
+ pytest.skip("Does not support counter location: {0}".format(
+ params.get('ctrlocation')
))
ctrkdf = KBKDFHMAC(