'Verifies the HMAC.
This method raises a DecryptionError if the received HMAC does not
verify. If the HMAC verifies correctly, True is returned.
Args:
comms: The comms RdfValue to verify.
Raises:
DecryptionError: The HMAC did not verify.
Returns:
True'

def _VerifyHMAC(self, comms=None):

    if (self.hmac_type == 'SIMPLE_HMAC'):
        digest = self.HMAC(comms.encrypted)
        if (not hmac.compare_digest(comms.hmac, digest)):
            raise DecryptionError('HMAC    verification    failed.')
    elif (self.hmac_type == 'FULL_HMAC'):
        digest = self.HMAC(comms.encrypted, comms.encrypted_cipher, comms.encrypted_cipher_metadata, comms.packet_iv.SerializeToString(), struct.pack('<I', comms.api_version))
        if (not hmac.compare_digest(comms.full_hmac, digest)):
            raise DecryptionError('HMAC    verification    failed.')
    else:
        raise DecryptionError('HMAC    type    no    supported.')
    return True
