X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FAuth.py;fp=PLC%2FAuth.py;h=927850ee20a780bb7b160418aa5bda3745e65a47;hb=aed64f31afdf04bdd6e22f3b1efdd61a2d63174a;hp=c1684b598e02bae91853b99e23aaf4c48503253f;hpb=b92fd6505ef9a6e2e3532add89f0eb368bd4e2e2;p=plcapi.git diff --git a/PLC/Auth.py b/PLC/Auth.py index c1684b5..927850e 100644 --- a/PLC/Auth.py +++ b/PLC/Auth.py @@ -6,10 +6,7 @@ # import crypt -try: - from hashlib import sha1 as sha -except ImportError: - import sha +from hashlib import sha1 as sha import hmac import time import os @@ -184,12 +181,6 @@ class BootAuth(Auth): PlanetLab version 3.x node authentication structure. Used by the Boot Manager to make authenticated calls to the API based on a unique node key or boot nonce value. - - The original parameter serialization code did not define the byte - encoding of strings, or the string encoding of all other types. We - define the byte encoding to be UTF-8, and the string encoding of - all other types to be however Python version 2.3 unicode() encodes - them. """ def __init__(self): @@ -245,10 +236,7 @@ class BootAuth(Auth): args.sort() msg = "[" + "".join(args) + "]" - # We encode in UTF-8 before calculating the HMAC, which is - # an 8-bit algorithm. - # python 2.6 insists on receiving a 'str' as opposed to a 'unicode' - digest = hmac.new(str(key), msg.encode('utf-8'), sha).hexdigest() + digest = hmac.new(key.encode('utf-8'), msg.encode('utf-8'), sha).hexdigest() if digest != auth['value']: raise PLCAuthenticationFailure(