diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2011-04-08 13:09:24 -0400 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2011-04-08 13:09:24 -0400 |
commit | a50330acfb270a896630a73111a9ca19483a3fff (patch) | |
tree | 71fcae844874019484a53ef9f2c302c3d4e199f2 /passlib/handlers/des_crypt.py | |
parent | 3da23d45e03f7cb26374a3546106387b8a293ad3 (diff) | |
download | passlib-a50330acfb270a896630a73111a9ca19483a3fff.tar.gz |
added os_crypt backend for bsdi_crypt, sha1_crypt
Diffstat (limited to 'passlib/handlers/des_crypt.py')
-rw-r--r-- | passlib/handlers/des_crypt.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/passlib/handlers/des_crypt.py b/passlib/handlers/des_crypt.py index 2be69ff..528775c 100644 --- a/passlib/handlers/des_crypt.py +++ b/passlib/handlers/des_crypt.py @@ -233,7 +233,7 @@ class des_crypt(uh.HasManyBackends, uh.HasSalt, uh.GenericHandler): # so as not to reveal weak des keys. given the random salt, this shouldn't be # a very likely issue anyways, but should do something about default rounds generation anyways. -class bsdi_crypt(uh.HasRounds, uh.HasSalt, uh.GenericHandler): +class bsdi_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler): """This class implements the BSDi-Crypt password hash, and follows the :ref:`password-hash-api`. It supports a fixed-length salt, and a variable number of rounds. @@ -307,13 +307,25 @@ class bsdi_crypt(uh.HasRounds, uh.HasSalt, uh.GenericHandler): #========================================================= #backend #========================================================= - #TODO: check if os_crypt supports bsdi-crypt. + backends = ("os_crypt", "builtin") - def calc_checksum(self, secret): + _has_backend_builtin = True + + @classproperty + def _has_backend_os_crypt(cls): + h = '_/...lLDAxARksGCHin.' + return os_crypt is not None and os_crypt("test", h) == h + + def _calc_checksum_builtin(self, secret): if isinstance(secret, unicode): secret = secret.encode("utf-8") return raw_ext_crypt(secret, self.rounds, self.salt) + def _calc_checksum_os_crypt(self, secret): + if isinstance(secret, unicode): + secret = secret.encode("utf-8") + return os_crypt(secret, self.to_string())[9:] + #========================================================= #eoc #========================================================= |