From c0f420bf7d7659ee110432f7cbb0233554dfd32a Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 12 Apr 2012 21:52:26 -0400 Subject: assorted bugfixes, tweaks, and tests added; based on coverage examination * test os_crypt backend has functional fallback * test handler methods accept all unicode/bytes combinations for secret & hash * fixed some incorrect error messages & types being caught & raised * other minor cleanups --- passlib/handlers/fshp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'passlib/handlers/fshp.py') diff --git a/passlib/handlers/fshp.py b/passlib/handlers/fshp.py index 3404bd8..2e536ce 100644 --- a/passlib/handlers/fshp.py +++ b/passlib/handlers/fshp.py @@ -116,7 +116,7 @@ class fshp(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler): if not isinstance(variant, int): raise TypeError("fshp variant must be int or known alias") if variant not in self._variant_info: - raise TypeError("unknown fshp variant") + raise ValueError("invalid fshp variant") return variant @property @@ -152,7 +152,7 @@ class fshp(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler): rounds = int(rounds) try: data = b64decode(data.encode("ascii")) - except ValueError: + except TypeError: raise uh.exc.MalformedHashError(cls) salt = data[:salt_size] chk = data[salt_size:] -- cgit v1.2.1 From 8583409d34d9491553f6c8e545653842518f311c Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Tue, 17 Apr 2012 19:37:20 -0400 Subject: retuned default_rounds for a few hashes based on benchmarks --- passlib/handlers/fshp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'passlib/handlers/fshp.py') diff --git a/passlib/handlers/fshp.py b/passlib/handlers/fshp.py index 2e536ce..28be83c 100644 --- a/passlib/handlers/fshp.py +++ b/passlib/handlers/fshp.py @@ -68,7 +68,9 @@ class fshp(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler): max_salt_size = None #--HasRounds-- - default_rounds = 16384 #current passlib default, FSHP uses 4096 + # FIXME: should probably use different default rounds + # based on the variant. setting for default variant (sha256) for now. + default_rounds = 50000 #current passlib default, FSHP uses 4096 min_rounds = 1 #set by FSHP max_rounds = 4294967295 # 32-bit integer limit - not set by FSHP rounds_cost = "linear" -- cgit v1.2.1