summaryrefslogtreecommitdiff
path: root/passlib/handlers/des_crypt.py
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-04-10 14:26:52 -0400
committerEli Collins <elic@assurancetechnologies.com>2012-04-10 14:26:52 -0400
commit75758ab6138a01ef58d75a0b4cb4c172248d9d8e (patch)
tree0b3b1db5cb2a2553dca6397231d71493665a3ce5 /passlib/handlers/des_crypt.py
parentd1cd32ca8209513eb7f00201c3555363b3675dd6 (diff)
downloadpasslib-75758ab6138a01ef58d75a0b4cb4c172248d9d8e.tar.gz
tightened OS crypt backend tests
* split os_crypt tests into separate mixin * tests now require os_crypt backends to detect some simple incorrect returns from crypt() - e.g. returning wrong ident prefix, wrong size, etc - added relevant asserts to all os_crypt backends * tests now check if platform crypt detection is functioning correctly via platform_crypt_support dict in tests.
Diffstat (limited to 'passlib/handlers/des_crypt.py')
-rw-r--r--passlib/handlers/des_crypt.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/passlib/handlers/des_crypt.py b/passlib/handlers/des_crypt.py
index 41e132a..df7683a 100644
--- a/passlib/handlers/des_crypt.py
+++ b/passlib/handlers/des_crypt.py
@@ -219,7 +219,8 @@ class des_crypt(uh.HasManyBackends, uh.HasSalt, uh.GenericHandler):
# no official policy since des-crypt predates unicode
hash = safe_crypt(secret, self.salt)
if hash:
- return hash[2:]
+ assert hash.startswith(self.salt) and len(hash) == 4
+ return hash[-2:]
else:
return self._calc_checksum_builtin(secret)
@@ -331,9 +332,11 @@ class bsdi_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
return raw_ext_crypt(secret, self.rounds, self.salt.encode("ascii")).decode("ascii")
def _calc_checksum_os_crypt(self, secret):
- hash = safe_crypt(secret, self.to_string())
+ config = self.to_string()
+ hash = safe_crypt(secret, config)
if hash:
- return hash[9:]
+ assert hash.startswith(config[:9]) and len(hash) == 20
+ return hash[-11:]
else:
return self._calc_checksum_builtin(secret)