# Copyright (C) 2006 The Trustees of Princeton University
#
# $Id$
+# $URL$
#
import crypt
-import sha
+import hashlib
import hmac
import time
expected = AnonymousAuth()
else:
raise PLCInvalidArgument("must be 'session', 'password', 'gpg', 'hmac', 'hmac_dummybox', or 'anonymous'", "AuthMethod")
+ return expected
class Auth(Parameter):
"""
# We encode in UTF-8 before calculating the HMAC, which is
# an 8-bit algorithm.
- digest = hmac.new(key, msg.encode('utf-8'), sha).hexdigest()
+ # python 2.6 insists on receiving a 'str' as opposed to a 'unicode'
+ digest = hmac.new(str(key), msg.encode('utf-8'), hashlib.sha1).hexdigest()
if digest != auth['value']:
raise PLCAuthenticationFailure, "Call could not be authenticated"