X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/chopwood/blobdiff_plain/c958c9a5b4de96fe309fce0e598215b0d411e33a..44e941123a4c6ef44ad4e6856c09a0762b8bce86:/httpauth.py diff --git a/httpauth.py b/httpauth.py index 13ba0d1..ea978eb 100644 --- a/httpauth.py +++ b/httpauth.py @@ -100,7 +100,10 @@ CONF.DEFAULTS.update( SECRETLIFE = 30*60, ## Maximum age of an authentication key, in seconds. - SECRETFRESH = 5*60) + SECRETFRESH = 5*60, + + ## Hash function to use for crypto. + AUTHHASH = H.sha256) def cleansecrets(): """Remove dead secrets from the database.""" @@ -152,7 +155,7 @@ def hack_octets(s): def auth_tag(sec, stamp, nonce, user): """Compute a tag using secret SEC on `STAMP.NONCE.USER'.""" - hmac = HM.HMAC(sec, digestmod = H.sha256) + hmac = HM.HMAC(sec, digestmod = CFG.AUTHHASH) hmac.update('%d.%s.%s' % (stamp, nonce, user)) return hack_octets(hmac.digest())