summaryrefslogtreecommitdiff
path: root/passlib/utils
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-04-27 03:16:08 -0400
committerEli Collins <elic@assurancetechnologies.com>2012-04-27 03:16:08 -0400
commit332d8d949d27b4431ef4d7fb1044b8511a1188cb (patch)
tree14a967cb04b5d7f679b7962329e30f3cf68292c0 /passlib/utils
parent09aa392f4362ac7532184435f9f9f8cd15dc5aba (diff)
downloadpasslib-332d8d949d27b4431ef4d7fb1044b8511a1188cb.tar.gz
assorted small details that weren't covered in the last few merges
Diffstat (limited to 'passlib/utils')
-rw-r--r--passlib/utils/__init__.py4
-rw-r--r--passlib/utils/compat.py5
-rw-r--r--passlib/utils/pbkdf2.py8
3 files changed, 14 insertions, 3 deletions
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
index f2f08bd..450da38 100644
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -1595,16 +1595,18 @@ _handler_attrs = (
def is_crypt_handler(obj):
"check if object follows the :ref:`password-hash-api`"
+ # XXX: change to use isinstance(obj, PasswordHash) under py26+?
return all(hasattr(obj, name) for name in _handler_attrs)
_context_attrs = (
- "hash_needs_update",
+ "needs_update",
"genconfig", "genhash",
"verify", "encrypt", "identify",
)
def is_crypt_context(obj):
"check if object appears to be a :class:`~passlib.context.CryptContext` instance"
+ # XXX: change to use isinstance(obj, CryptContext)?
return all(hasattr(obj, name) for name in _context_attrs)
##def has_many_backends(handler):
diff --git a/passlib/utils/compat.py b/passlib/utils/compat.py
index 02c2de3..4f75c4a 100644
--- a/passlib/utils/compat.py
+++ b/passlib/utils/compat.py
@@ -212,6 +212,9 @@ if PY3:
return d.items()
def itervalues(d):
return d.values()
+
+ next_method_attr = "__next__"
+
else:
irange = xrange
##lrange = range
@@ -224,6 +227,8 @@ else:
def itervalues(d):
return d.itervalues()
+ next_method_attr = "next"
+
if PY_MAX_25:
_undef = object()
def next(itr, default=_undef):
diff --git a/passlib/utils/pbkdf2.py b/passlib/utils/pbkdf2.py
index 0c8a505..9c7be9e 100644
--- a/passlib/utils/pbkdf2.py
+++ b/passlib/utils/pbkdf2.py
@@ -335,8 +335,12 @@ def pbkdf1(secret, salt, rounds, keylen, hash="sha1"):
#=================================================================================
MAX_BLOCKS = 0xffffffff #2**32-1
MAX_HMAC_SHA1_KEYLEN = MAX_BLOCKS*20
+# NOTE: the pbkdf2 spec does not specify a maximum number of rounds.
+# however, many of the hashes in passlib are currently clamped
+# at the 32-bit limit, just for sanity. once realistic pbkdf2 rounds
+# start approaching 24 bits, this limit will be raised.
-def pbkdf2(secret, salt, rounds, keylen, prf="hmac-sha1"):
+def pbkdf2(secret, salt, rounds, keylen=-1, prf="hmac-sha1"):
"""pkcs#5 password-based key derivation v2.0
:arg secret: passphrase to use to generate key
@@ -344,7 +348,7 @@ def pbkdf2(secret, salt, rounds, keylen, prf="hmac-sha1"):
:param rounds: number of rounds to use to generate key
:arg keylen:
number of bytes to generate.
- if -1, will use digest size of prf.
+ if set to ``-1``, will use digest size of selected prf.
:param prf:
psuedo-random family to use for key strengthening.
this can be any string or callable accepted by :func:`get_prf`.