def symmetric_decrypt_HMAC(cyphertext, key, hmac_secret):
    """:raises: :class:`RuntimeError` when HMAC verification fails"""
    iv = symmetric_decrypt_iv(cyphertext, key)
    message = symmetric_decrypt_with_iv(cyphertext, key, iv)

    hmac = hmac_sha1(hmac_secret, iv[-3:] + message)

    if iv[:13] != hmac[:13]:
        raise RuntimeError("Unable to decrypt message. HMAC does not match.")

    return message
def symmetric_decrypt_HMAC ( cyphertext , key , hmac_secret ) : iv = symmetric_decrypt_iv ( cyphertext , key ) message = symmetric_decrypt_with_iv ( cyphertext , key , iv ) hmac = hmac_sha1 ( hmac_secret , iv [ - 3 : ] + message ) if iv [ : 13 ] != hmac [ : 13 ] : raise RuntimeError ( "Unable to decrypt message. HMAC does not match." ) return message
:raises: :class:`RuntimeError` when HMAC verification fails