1.1 --- a/WebStack/Helpers/Auth.py Mon Nov 12 00:51:58 2007 +0000
1.2 +++ b/WebStack/Helpers/Auth.py Tue Nov 13 23:15:50 2007 +0000
1.3 @@ -22,10 +22,15 @@
1.4
1.5 import base64
1.6 import md5
1.7 +import hmac
1.8 try:
1.9 - import hmac
1.10 + from hashlib import sha1, sha256
1.11 except ImportError:
1.12 - hmac = None
1.13 + sha256 = None
1.14 + try:
1.15 + from sha import new as sha1
1.16 + except ImportError:
1.17 + sha1 = None
1.18
1.19 class UserInfo:
1.20
1.21 @@ -193,7 +198,10 @@
1.22
1.23 return plaintext + ":" + md5.md5(plaintext + secret_key).hexdigest()
1.24
1.25 -if hmac is not None:
1.26 +# OpenID token verification.
1.27 +# NOTE: Add SHA256 usage for associations.
1.28 +
1.29 +if sha1 is not None:
1.30
1.31 def get_openid_token(items, secret_key):
1.32
1.33 @@ -203,7 +211,7 @@
1.34 """
1.35
1.36 plaintext = "\n".join([(key + ":" + value) for (key, value) in items]) + "\n"
1.37 - hash = hmac.new(secret_key, plaintext)
1.38 + hash = hmac.new(secret_key, plaintext, sha1)
1.39 return base64.standard_b64encode(hash.digest())
1.40
1.41 def check_openid_signature(fields, secret_key):