diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2012-02-08 22:38:25 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2012-02-08 22:38:25 -0500 |
commit | 86a2dc3ed68fcdf7853f5e219541a19b5fcacfff (patch) | |
tree | 8319e8704f04a23faab1eedfad383d50ff6d3671 /passlib/handlers/pbkdf2.py | |
parent | 4c4615329b64287dabd729e3078ab03cb2bb7442 (diff) | |
download | passlib-86a2dc3ed68fcdf7853f5e219541a19b5fcacfff.tar.gz |
large refactor of GenericHandler internals
strict keyword
--------------
* GenericHandler's "strict" keyword had poorly defined semantics;
replaced this with "use_defaults" and "relaxed" keywords.
Most handlers' from_string() method specified strict=True.
This is now the default behavior, use_defaults=True is enabled
only for encrypt() and genconfig(). relaxed=True is enabled
only for specific handlers (and unittests) whose code requires it.
This *does* break backward compat with passlib 1.5 handlers,
but this is mostly and internal class.
* missing required settings now throws a TypeError instead of
a ValueError, to be more in line with std python behavior.
* The norm_xxx functions provided by the GenericHandler mixins
(e.g. norm_salt) have been renamed to _norm_xxx() to reflect their
private nature; and converted from class methods to instance
methods, to simplify their call signature for subclassing.
misc
----
* rewrote GenericHandler unittests to use constructor only,
instead of poking into norm_salt/norm_rounds internals.
* checksum/salt charset checks speed up using set comparison
* some small cleanups to FHSP implementation
Diffstat (limited to 'passlib/handlers/pbkdf2.py')
-rw-r--r-- | passlib/handlers/pbkdf2.py | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/passlib/handlers/pbkdf2.py b/passlib/handlers/pbkdf2.py index 8621f03..96cd47a 100644 --- a/passlib/handlers/pbkdf2.py +++ b/passlib/handlers/pbkdf2.py @@ -77,7 +77,6 @@ class Pbkdf2DigestHandler(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.Gen rounds=int_rounds, salt=raw_salt, checksum=raw_chk, - strict=bool(raw_chk), ) def to_string(self, withchk=True): @@ -217,7 +216,6 @@ class cta_pbkdf2_sha1(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.Generic rounds=rounds, salt=salt, checksum=chk, - strict=bool(chk), ) def to_string(self, withchk=True): @@ -310,7 +308,6 @@ class dlitz_pbkdf2_sha1(uh.HasRounds, uh.HasSalt, uh.GenericHandler): rounds=rounds, salt=salt, checksum=chk, - strict=bool(chk), ) def to_string(self, withchk=True): @@ -373,7 +370,7 @@ class atlassian_pbkdf2_sha1(uh.HasStubChecksum, uh.HasRawSalt, uh.HasRawChecksum raise ValueError("invalid %s hash" % (cls.name,)) data = b64decode(hash[len(ident):].encode("ascii")) salt, chk = data[:16], data[16:] - return cls(salt=salt, checksum=chk, strict=True) + return cls(salt=salt, checksum=chk) def to_string(self): data = self.salt + (self.checksum or self._stub_checksum) @@ -442,7 +439,6 @@ class grub_pbkdf2_sha512(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.Gene rounds=int_rounds, salt=raw_salt, checksum=raw_chk, - strict=bool(raw_chk), ) def to_string(self, withchk=True): |