summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-01-18 15:51:31 -0500
committerEli Collins <elic@assurancetechnologies.com>2012-01-18 15:51:31 -0500
commitf77ddd297449870951cf4541f0ef042a17db616a (patch)
treed5334575b7b031eada2b7a58216e247d3aa61411
parentd4ebb05e010b435c62eeb425059bc9d78e090660 (diff)
downloadpasslib-f77ddd297449870951cf4541f0ef042a17db616a.tar.gz
renamed the utils.handlers.XX_CHARS constants to match utils.XX_CHARS (old aliases kept for now)
-rw-r--r--passlib/handlers/des_crypt.py16
-rw-r--r--passlib/handlers/django.py4
-rw-r--r--passlib/handlers/fshp.py2
-rw-r--r--passlib/handlers/ldap_digests.py4
-rw-r--r--passlib/handlers/md5_crypt.py4
-rw-r--r--passlib/handlers/nthash.py2
-rw-r--r--passlib/handlers/oracle.py4
-rw-r--r--passlib/handlers/pbkdf2.py4
-rw-r--r--passlib/handlers/phpass.py4
-rw-r--r--passlib/handlers/sha1_crypt.py4
-rw-r--r--passlib/handlers/sha2_crypt.py8
-rw-r--r--passlib/handlers/sun_md5_crypt.py4
-rw-r--r--passlib/tests/test_utils_handlers.py2
-rw-r--r--passlib/tests/utils.py4
-rw-r--r--passlib/utils/__init__.py9
-rw-r--r--passlib/utils/handlers.py27
16 files changed, 51 insertions, 51 deletions
diff --git a/passlib/handlers/des_crypt.py b/passlib/handlers/des_crypt.py
index cdde60a..1669ac8 100644
--- a/passlib/handlers/des_crypt.py
+++ b/passlib/handlers/des_crypt.py
@@ -164,11 +164,11 @@ class des_crypt(uh.HasManyBackends, uh.HasSalt, uh.GenericHandler):
#--GenericHandler--
name = "des_crypt"
setting_kwds = ("salt",)
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
min_salt_size = max_salt_size = 2
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#=========================================================
#formatting
@@ -275,11 +275,11 @@ class bsdi_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
name = "bsdi_crypt"
setting_kwds = ("salt", "rounds")
checksum_size = 11
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
min_salt_size = max_salt_size = 4
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#--HasRounds--
default_rounds = 5001
@@ -376,12 +376,12 @@ class bigcrypt(uh.HasSalt, uh.GenericHandler):
#--GenericHandler--
name = "bigcrypt"
setting_kwds = ("salt",)
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#NOTE: checksum chars must be multiple of 11
#--HasSalt--
min_salt_size = max_salt_size = 2
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#=========================================================
#internal helpers
@@ -469,11 +469,11 @@ class crypt16(uh.HasSalt, uh.GenericHandler):
name = "crypt16"
setting_kwds = ("salt",)
checksum_size = 22
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
min_salt_size = max_salt_size = 2
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#=========================================================
#internal helpers
diff --git a/passlib/handlers/django.py b/passlib/handlers/django.py
index a86c51a..e407814 100644
--- a/passlib/handlers/django.py
+++ b/passlib/handlers/django.py
@@ -44,7 +44,7 @@ class DjangoSaltedHash(uh.HasStubChecksum, uh.HasSalt, uh.GenericHandler):
min_salt_size = 0
default_salt_size = 5
max_salt_size = None
- salt_chars = checksum_chars = uh.LC_HEX_CHARS
+ salt_chars = checksum_chars = uh.LOWER_HEX_CHARS
@classmethod
def identify(cls, hash):
@@ -144,7 +144,7 @@ class django_des_crypt(DjangoSaltedHash):
name = "django_des_crypt"
ident = "crypt$"
- checksum_chars = salt_chars = uh.H64_CHARS
+ checksum_chars = salt_chars = uh.HASH64_CHARS
checksum_size = 13
min_salt_size = 2
diff --git a/passlib/handlers/fshp.py b/passlib/handlers/fshp.py
index d199357..67c4ee1 100644
--- a/passlib/handlers/fshp.py
+++ b/passlib/handlers/fshp.py
@@ -57,7 +57,7 @@ class fshp(uh.HasStubChecksum, uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, u
#--GenericHandler--
name = "fshp"
setting_kwds = ("salt", "salt_size", "rounds", "variant")
- checksum_chars = uh.PADDED_B64_CHARS
+ checksum_chars = uh.PADDED_BASE64_CHARS
#--HasRawSalt--
default_salt_size = 16 #current passlib default, FSHP uses 8
diff --git a/passlib/handlers/ldap_digests.py b/passlib/handlers/ldap_digests.py
index e9cc02a..2f6606d 100644
--- a/passlib/handlers/ldap_digests.py
+++ b/passlib/handlers/ldap_digests.py
@@ -44,7 +44,7 @@ class _Base64DigestHelper(uh.StaticHandler):
ident = None #required - prefix identifier
_hash_func = None #required - hash function
_pat = None #required - regexp to recognize hash
- checksum_chars = uh.PADDED_B64_CHARS
+ checksum_chars = uh.PADDED_BASE64_CHARS
@classmethod
def identify(cls, hash):
@@ -65,7 +65,7 @@ class _Base64DigestHelper(uh.StaticHandler):
class _SaltedBase64DigestHelper(uh.HasStubChecksum, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
"helper for ldap_salted_md5 / ldap_salted_sha1"
setting_kwds = ("salt",)
- checksum_chars = uh.PADDED_B64_CHARS
+ checksum_chars = uh.PADDED_BASE64_CHARS
ident = None #required - prefix identifier
_hash_func = None #required - hash function
diff --git a/passlib/handlers/md5_crypt.py b/passlib/handlers/md5_crypt.py
index c06d14b..66641f7 100644
--- a/passlib/handlers/md5_crypt.py
+++ b/passlib/handlers/md5_crypt.py
@@ -159,12 +159,12 @@ class _Md5Common(uh.HasSalt, uh.GenericHandler):
setting_kwds = ("salt", "salt_size")
#ident in subclass
checksum_size = 22
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
min_salt_size = 0
max_salt_size = 8
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#=========================================================
#internal helpers
diff --git a/passlib/handlers/nthash.py b/passlib/handlers/nthash.py
index 66e9b2f..03340a9 100644
--- a/passlib/handlers/nthash.py
+++ b/passlib/handlers/nthash.py
@@ -40,7 +40,7 @@ class nthash(uh.HasStubChecksum, uh.HasManyIdents, uh.GenericHandler):
#--GenericHandler--
name = "nthash"
setting_kwds = ("ident",)
- checksum_chars = uh.LC_HEX_CHARS
+ checksum_chars = uh.LOWER_HEX_CHARS
_stub_checksum = u("0") * 32
diff --git a/passlib/handlers/oracle.py b/passlib/handlers/oracle.py
index 7fc3747..f8fdc25 100644
--- a/passlib/handlers/oracle.py
+++ b/passlib/handlers/oracle.py
@@ -149,13 +149,13 @@ class oracle11(uh.HasStubChecksum, uh.HasSalt, uh.GenericHandler):
name = "oracle11"
setting_kwds = ("salt",)
checksum_size = 40
- checksum_chars = uh.UC_HEX_CHARS
+ checksum_chars = uh.UPPER_HEX_CHARS
_stub_checksum = u('0') * 40
#--HasSalt--
min_salt_size = max_salt_size = 20
- salt_chars = uh.UC_HEX_CHARS
+ salt_chars = uh.UPPER_HEX_CHARS
#=========================================================
diff --git a/passlib/handlers/pbkdf2.py b/passlib/handlers/pbkdf2.py
index 3fbf1dc..889f511 100644
--- a/passlib/handlers/pbkdf2.py
+++ b/passlib/handlers/pbkdf2.py
@@ -37,7 +37,7 @@ class Pbkdf2DigestHandler(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.Gen
#--GenericHandler--
setting_kwds = ("salt", "salt_size", "rounds")
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
default_salt_size = 16
@@ -280,7 +280,7 @@ class dlitz_pbkdf2_sha1(uh.HasRounds, uh.HasSalt, uh.GenericHandler):
default_salt_size = 16
min_salt_size = 0
max_salt_size = 1024
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#--HasROunds--
default_rounds = 10000
diff --git a/passlib/handlers/phpass.py b/passlib/handlers/phpass.py
index ea6ddfc..d83df21 100644
--- a/passlib/handlers/phpass.py
+++ b/passlib/handlers/phpass.py
@@ -56,11 +56,11 @@ class phpass(uh.HasManyIdents, uh.HasRounds, uh.HasSalt, uh.GenericHandler):
#--GenericHandler--
name = "phpass"
setting_kwds = ("salt", "rounds", "ident")
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
min_salt_size = max_salt_size = 8
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#--HasRounds--
default_rounds = 9
diff --git a/passlib/handlers/sha1_crypt.py b/passlib/handlers/sha1_crypt.py
index dc58901..a23202e 100644
--- a/passlib/handlers/sha1_crypt.py
+++ b/passlib/handlers/sha1_crypt.py
@@ -61,13 +61,13 @@ class sha1_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
setting_kwds = ("salt", "salt_size", "rounds")
ident = u("$sha1$")
checksum_size = 28
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
default_salt_size = 8
min_salt_size = 0
max_salt_size = 64
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#--HasRounds--
default_rounds = 40000 #current passlib default
diff --git a/passlib/handlers/sha2_crypt.py b/passlib/handlers/sha2_crypt.py
index 6bc486f..7b00aad 100644
--- a/passlib/handlers/sha2_crypt.py
+++ b/passlib/handlers/sha2_crypt.py
@@ -250,13 +250,13 @@ class sha256_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandl
name = "sha256_crypt"
setting_kwds = ("salt", "rounds", "implicit_rounds", "salt_size")
ident = u("$5$")
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#--HasSalt--
min_salt_size = 0
max_salt_size = 16
#TODO: allow salt charset 0-255 except for "\x00\n:$"
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
#--HasRounds--
default_rounds = 40000 #current passlib default
@@ -400,14 +400,14 @@ class sha512_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandl
#=========================================================
name = "sha512_crypt"
ident = u("$6$")
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
setting_kwds = ("salt", "rounds", "implicit_rounds", "salt_size")
min_salt_size = 0
max_salt_size = 16
#TODO: allow salt charset 0-255 except for "\x00\n:$"
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
default_rounds = 40000 #current passlib default
min_rounds = 1000
diff --git a/passlib/handlers/sun_md5_crypt.py b/passlib/handlers/sun_md5_crypt.py
index 386224a..3bc5f0d 100644
--- a/passlib/handlers/sun_md5_crypt.py
+++ b/passlib/handlers/sun_md5_crypt.py
@@ -195,7 +195,7 @@ class sun_md5_crypt(uh.HasRounds, uh.HasSalt, uh.GenericHandler):
#=========================================================
name = "sun_md5_crypt"
setting_kwds = ("salt", "rounds", "bare_salt", "salt_size")
- checksum_chars = uh.H64_CHARS
+ checksum_chars = uh.HASH64_CHARS
#NOTE: docs say max password length is 255.
#release 9u2
@@ -205,7 +205,7 @@ class sun_md5_crypt(uh.HasRounds, uh.HasSalt, uh.GenericHandler):
default_salt_size = 8
min_salt_size = 0
max_salt_size = None
- salt_chars = uh.H64_CHARS
+ salt_chars = uh.HASH64_CHARS
default_rounds = 5000 #current passlib default
min_rounds = 0
diff --git a/passlib/tests/test_utils_handlers.py b/passlib/tests/test_utils_handlers.py
index d2e262e..3f4fb60 100644
--- a/passlib/tests/test_utils_handlers.py
+++ b/passlib/tests/test_utils_handlers.py
@@ -421,7 +421,7 @@ class SaltedHash(uh.HasSalt, uh.GenericHandler):
min_salt_size = 2
max_salt_size = 4
checksum_size = 40
- salt_chars = checksum_chars = uh.LC_HEX_CHARS
+ salt_chars = checksum_chars = uh.LOWER_HEX_CHARS
@classmethod
def identify(cls, hash):
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index 4d51e47..c9a5aff 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -33,7 +33,7 @@ if ut_version < 2:
from passlib import registry, utils
from passlib.utils import classproperty, handlers as uh, \
has_rounds_info, has_salt_info, MissingBackendError, \
- rounds_cost_values, b, bytes, NoneType
+ rounds_cost_values, b, bytes
from passlib.utils.compat import iteritems, irange, callable, sb_types, \
exc_err, unicode
#local
@@ -821,7 +821,7 @@ class HandlerCase(TestCase):
cs = self.do_genconfig()
if self.genconfig_uses_hash:
# unix fallback handler returns "!" as cs,
- # which verify() accepts quite readily.
+ # which verify() accepts quite readily.
self.assertFalse(self.do_verify(u(""), cs))
self.assertFalse(self.do_verify(u("stub"), cs))
else:
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
index d2bb85c..eb10873 100644
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -80,15 +80,6 @@ unix_crypt_schemes = [
#: list of rounds_cost constants
rounds_cost_values = [ "linear", "log2" ]
-#: special byte string containing all possible byte values, used in a few places.
-#XXX: treated as singleton by some of the code for efficiency.
-if PY3:
- ALL_BYTE_VALUES = bytes(irange(256))
-else:
- ALL_BYTE_VALUES = ''.join(chr(x) for x in irange(256))
-
-NoneType = type(None)
-
class MissingBackendError(RuntimeError):
"""Error raised if multi-backend handler has no available backends;
or if specifically requested backend is not available.
diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py
index 26d0708..fb93e1c 100644
--- a/passlib/utils/handlers.py
+++ b/passlib/utils/handlers.py
@@ -15,9 +15,9 @@ from warnings import warn
#libs
from passlib.registry import get_crypt_handler
from passlib.utils import to_native_str, bytes, b, consteq, \
- classproperty, h64, getrandstr, getrandbytes, \
+ classproperty, h64, getrandstr, getrandbytes, bjoin_ints, \
rng, is_crypt_handler, ALL_BYTE_VALUES, MissingBackendError
-from passlib.utils.compat import unicode, u
+from passlib.utils.compat import unicode, u, irange
#pkg
#local
__all__ = [
@@ -38,14 +38,23 @@ __all__ = [
#constants
#=========================================================
-#common salt_chars & checksum_chars values
-H64_CHARS = h64.CHARS
-B64_CHARS = u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
-PADDED_B64_CHARS = B64_CHARS + u("=")
-U64_CHARS = u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")
+# common salt_chars & checksum_chars values
+# (BASE64_CHARS, HASH64_CHARS imported above)
+PADDED_BASE64_CHARS = BASE64_CHARS + u("=")
HEX_CHARS = u("0123456789abcdefABCDEF")
-UC_HEX_CHARS = u("0123456789ABCDEF")
-LC_HEX_CHARS = u("0123456789abcdef")
+UPPER_HEX_CHARS = u("0123456789ABCDEF")
+LOWER_HEX_CHARS = u("0123456789abcdef")
+
+#: special byte string containing all possible byte values
+# XXX: treated as singleton by some of the code for efficiency.
+ALL_BYTE_VALUES = bjoin_ints(irange(256))
+
+# deprecated aliases - will be removed after passlib 1.8
+H64_CHARS = HASH64_CHARS
+B64_CHARS = BASE64_CHARS
+PADDED_B64_CHARS = PADDED_BASE64_CHARS
+UC_HEX_CHARS = UPPER_HEX_CHARS
+LC_HEX_CHARS = LOWER_HEX_CHARS
#=========================================================
#identify helpers