X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/f0bd437a6f04dc8681c6d705dba04c84d297b97f..c9467b7a34160c4e25580a2dc82087c5ae0bb2d0:/python/disorder.py.in diff --git a/python/disorder.py.in b/python/disorder.py.in index 3e1541e..d06c7ee 100644 --- a/python/disorder.py.in +++ b/python/disorder.py.in @@ -50,7 +50,7 @@ import os import pwd import socket import binascii -import sha +import hashlib import sys import locale @@ -66,6 +66,18 @@ _unquoted = re.compile("[^\"' \\t\\n\\r][^ \t\n\r]*") _response = re.compile("([0-9]{3}) ?(.*)") +# hashes +_hashes = { + "sha1": hashlib.sha1, + "SHA1": hashlib.sha1, + "sha256": hashlib.sha256, + "SHA256": hashlib.sha256, + "sha384": hashlib.sha384, + "SHA384": hashlib.sha384, + "sha512": hashlib.sha512, + "SHA512": hashlib.sha512, +}; + version = "_version_" ######################################################################## @@ -387,8 +399,7 @@ class client: password = self.config['password'] else: password = self.password - # TODO support algorithms other than SHA-1 - h = sha.sha() + h = _hashes[algo]() h.update(password) h.update(binascii.unhexlify(challenge)) self._simple("user", user, h.hexdigest())