Beispiel #1
0
 def _ContentHmacValid(self, response):
     our_hmac = CreateHmac(response.content, self._hmac_secret)
     their_hmac = ToBytes(b64decode(response.headers[HMAC_HEADER]))
     return SecureBytesEqual(our_hmac, their_hmac)
Beispiel #2
0
def _ValidateResponseObject(response):
    our_hmac = CreateHmac(response.content, BaseRequest.hmac_secret)
    their_hmac = ToBytes(b64decode(response.headers[_HMAC_HEADER]))
    if not SecureBytesEqual(our_hmac, their_hmac):
        raise RuntimeError('Received invalid HMAC for response!')
    return True