summaryrefslogtreecommitdiff
path: root/passlib/handlers/scram.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/handlers/scram.py')
-rw-r--r--passlib/handlers/scram.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/passlib/handlers/scram.py b/passlib/handlers/scram.py
index 87bfabd..256de03 100644
--- a/passlib/handlers/scram.py
+++ b/passlib/handlers/scram.py
@@ -8,7 +8,7 @@ import logging; log = logging.getLogger(__name__)
# pkg
from passlib.utils import consteq, saslprep, to_native_str, splitcomma
from passlib.utils.binary import ab64_decode, ab64_encode
-from passlib.utils.compat import bascii_to_str, iteritems, u, native_string_types
+from passlib.utils.compat import bascii_to_str
from passlib.crypto.digest import pbkdf2_hmac, norm_hash_name
import passlib.utils.handlers as uh
# local
@@ -87,7 +87,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
#--GenericHandler--
name = "scram"
setting_kwds = ("salt", "salt_size", "rounds", "algs")
- ident = u("$scram$")
+ ident = u"$scram$"
#--HasSalt--
default_salt_size = 12
@@ -193,7 +193,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
SaltedPassword := Hi(Normalize(password), salt, i)
- :type password: unicode or utf-8 bytes
+ :type password: str or utf-8 bytes
:arg password: password to run through digest
:type salt: bytes
@@ -286,7 +286,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
default_algs = algs
# create subclass
- subcls = super(scram, cls).using(**kwds)
+ subcls = super().using(**kwds)
# fill in algs
if default_algs is not None:
@@ -297,7 +297,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
# init
#===================================================================
def __init__(self, algs=None, **kwds):
- super(scram, self).__init__(**kwds)
+ super().__init__(**kwds)
# init algs
digest_map = self.checksum
@@ -318,7 +318,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
def _norm_checksum(self, checksum, relaxed=False):
if not isinstance(checksum, dict):
raise uh.exc.ExpectedTypeError(checksum, "dict", "checksum")
- for alg, digest in iteritems(checksum):
+ for alg, digest in checksum.items():
if alg != norm_hash_name(alg, 'iana'):
raise ValueError("malformed algorithm name in scram hash: %r" %
(alg,))
@@ -336,7 +336,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
@classmethod
def _norm_algs(cls, algs):
"""normalize algs parameter"""
- if isinstance(algs, native_string_types):
+ if isinstance(algs, str):
algs = splitcomma(algs)
algs = sorted(norm_hash_name(alg, 'iana') for alg in algs)
if any(len(alg)>9 for alg in algs):
@@ -357,7 +357,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
return True
# hand off to base implementation
- return super(scram, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# digest methods
@@ -390,7 +390,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
# check entire hash for consistency.
if full:
correct = failed = False
- for alg, digest in iteritems(chkmap):
+ for alg, digest in chkmap.items():
other = self._calc_checksum(secret, alg)
# NOTE: could do this length check in norm_algs(),
# but don't need to be that strict, and want to be able
@@ -429,15 +429,14 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
##def _test_reference_scram():
## "quick hack testing scram reference vectors"
## # NOTE: "n,," is GS2 header - see https://tools.ietf.org/html/rfc5801
-## from passlib.utils.compat import print_
##
## engine = _scram_engine(
## alg="sha-1",
## salt='QSXCR+Q6sek8bf92'.decode("base64"),
## rounds=4096,
-## password=u("pencil"),
+## password=u"pencil",
## )
-## print_(engine.digest.encode("base64").rstrip())
+## print(engine.digest.encode("base64").rstrip())
##
## msg = engine.format_auth_msg(
## username="user",