import hmac
import hashlib


def validate_signature(key, body, signature):
    """ Validate the received signature against the secret key

    :param str key: secret key
    :param str body: message body
    :param str signature: received signature
    :return:
    :rtype: bool
    """
    signature_parts = signature.split('=')
    if signature_parts[0] != "sha1":
        return False
    generated_sig = hmac.new(str.encode(key), msg=body, digestmod=hashlib.sha1)
    return hmac.compare_digest(generated_sig.hexdigest(), signature_parts[1])