parse hex string for hmac

This commit is contained in:
Jakob Ketterl 2020-06-11 20:55:05 +02:00
parent 5a88856825
commit 9a61f90fec

View File

@ -75,6 +75,7 @@ class ReceiverId(object):
@staticmethod
def signChallenge(challenge, key):
now = datetime.utcnow().isoformat()
signString = "{challenge}:{time}".format(challenge=challenge.challenge, time=now)
m = hmac.new(bytes.fromhex(key.secret), msg=signString.encode('utf8'), digestmod=hashlib.sha256)
m = hmac.new(bytes.fromhex(key.secret), digestmod=hashlib.sha256)
m.update(bytes.fromhex(challenge.challenge))
m.update(now.encode('utf8'))
return now, m.hexdigest()