X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/d42e98caaaf4f07c8d1252236f03eb68b8be4619..211af11eabdfa1226ee2c7aec25002a1d7b25567:/python/disorder.py.in diff --git a/python/disorder.py.in b/python/disorder.py.in index e873e49..f6fe1a4 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())