def METHOD_NAME(self, data, msg):
    sig_algorithm = msg.get_text()
    if sig_algorithm not in self.HASHES:
        return False
    key = self.key
    if isinstance(key, rsa.RSAPrivateKey):
        key = key.public_key()
    # NOTE: pad received signature with leading zeros, key.verify()
    # expects a signature of key size (e.g. PuTTY doesn't pad)
    sign = msg.get_binary()
    diff = key.key_size - len(sign) * 8
    if diff > 0:
        sign = b"\x00" * ((diff + 7) // 8) + sign
    try:
        key.verify(
            sign, data, padding.PKCS1v15(), self.HASHES[sig_algorithm]()
        )
    except InvalidSignature:
        return False
    else:
        return True