Example #1
0
 def from_string(cls, hash):
     # NOTE: passlib deviation - forbidding zero-padded rounds
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, rounds_base=16, handler=cls)
     salt = b64decode(salt.encode("ascii"), CTA_ALTCHARS)
     if chk:
         chk = b64decode(chk.encode("ascii"), CTA_ALTCHARS)
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #2
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash,
                                      cls.ident,
                                      rounds_base=16,
                                      default_rounds=400,
                                      handler=cls)
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #3
0
 def from_string(cls, hash):
     # NOTE: passlib deviation - forbidding zero-padded rounds
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, rounds_base=16, handler=cls)
     salt = b64decode(salt.encode("ascii"), CTA_ALTCHARS)
     if chk:
         chk = b64decode(chk.encode("ascii"), CTA_ALTCHARS)
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #4
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, sep=u("."),
                                      handler=cls)
     salt = unhexlify(salt.encode("ascii"))
     if chk:
         chk = unhexlify(chk.encode("ascii"))
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #5
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, sep=u("."),
                                      handler=cls)
     salt = unhexlify(salt.encode("ascii"))
     if chk:
         chk = unhexlify(chk.encode("ascii"))
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #6
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     if rounds.startswith("0"):
         raise ValueError("invalid sha1-crypt hash (zero-padded rounds)")
     return cls(
         rounds=int(rounds),
         salt=salt,
         checksum=chk,
         strict=bool(chk),
     )
Example #7
0
 def from_string(cls, hash):
     if not hash:
         raise ValueError("no hash specified")
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     if rounds.startswith("0"): #zero not allowed, nor left-padded with zeroes
         raise ValueError("invalid dlitz_pbkdf2_sha1 hash")
     rounds = int(rounds, 16) if rounds else 400
     return cls(
         rounds=rounds,
         salt=salt,
         checksum=chk,
         strict=bool(chk),
     )
Example #8
0
 def from_string(cls, hash):
     if not hash:
         raise ValueError("no hash specified")
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     if rounds.startswith(
             "0"):  #zero not allowed, nor left-padded with zeroes
         raise ValueError("invalid dlitz_pbkdf2_sha1 hash")
     rounds = int(rounds, 16) if rounds else 400
     return cls(
         rounds=rounds,
         salt=salt,
         checksum=chk,
         strict=bool(chk),
     )
Example #9
0
 def from_string(cls, hash):
     if not hash:
         raise ValueError("no hash specified")
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     int_rounds = int(rounds)
     if rounds != unicode(int_rounds): #forbid zero padding, etc.
         raise ValueError("invalid %s hash" % (cls.name,))
     raw_salt = adapted_b64_decode(salt.encode("ascii"))
     raw_chk = adapted_b64_decode(chk.encode("ascii")) if chk else None
     return cls(
         rounds=int_rounds,
         salt=raw_salt,
         checksum=raw_chk,
         strict=bool(raw_chk),
     )
Example #10
0
 def from_string(cls, hash):
     if not hash:
         raise ValueError("no hash specified")
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     int_rounds = int(rounds)
     if rounds != unicode(int_rounds):  #forbid zero padding, etc.
         raise ValueError("invalid %s hash" % (cls.name, ))
     raw_salt = adapted_b64_decode(salt.encode("ascii"))
     raw_chk = adapted_b64_decode(chk.encode("ascii")) if chk else None
     return cls(
         rounds=int_rounds,
         salt=raw_salt,
         checksum=raw_chk,
         strict=bool(raw_chk),
     )
Example #11
0
 def from_string(cls, hash):
     if not hash:
         raise ValueError("no hash specified")
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     if rounds.startswith("0"):
         #passlib deviation: forbidding
         #left-padded with zeroes
         raise ValueError("invalid cta_pbkdf2_sha1 hash")
     rounds = int(rounds, 16)
     salt = b64decode(salt.encode("ascii"), CTA_ALTCHARS)
     if chk:
         chk = b64decode(chk.encode("ascii"), CTA_ALTCHARS)
     return cls(
         rounds=rounds,
         salt=salt,
         checksum=chk,
         strict=bool(chk),
     )
Example #12
0
 def from_string(cls, hash):
     if not hash:
         raise ValueError("no hash specified")
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name)
     if rounds.startswith("0"):
         #passlib deviation: forbidding
         #left-padded with zeroes
         raise ValueError("invalid cta_pbkdf2_sha1 hash")
     rounds = int(rounds, 16)
     salt = b64decode(salt.encode("ascii"), CTA_ALTCHARS)
     if chk:
         chk = b64decode(chk.encode("ascii"), CTA_ALTCHARS)
     return cls(
         rounds=rounds,
         salt=salt,
         checksum=chk,
         strict=bool(chk),
     )
Example #13
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, handler=cls)
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #14
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, handler=cls)
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #15
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, rounds_base=16,
                                      default_rounds=400, handler=cls)
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #16
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, handler=cls)
     salt = ab64_decode(salt.encode("ascii"))
     if chk:
         chk = ab64_decode(chk.encode("ascii"))
     return cls(rounds=rounds, salt=salt, checksum=chk)
Example #17
0
 def from_string(cls, hash):
     rounds, salt, chk = uh.parse_mc3(hash, cls.ident, handler=cls)
     salt = ab64_decode(salt.encode("ascii"))
     if chk:
         chk = ab64_decode(chk.encode("ascii"))
     return cls(rounds=rounds, salt=salt, checksum=chk)