def verify_mid_signature(certificate_data, sp_challenge, response_challenge, signature):
if not response_challenge.startswith(sp_challenge):<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>key = RSA.importKey(certificate_data)<EOL>verifier = PKCS1_v1_5.new(key)<EOL><DEDENT>except ValueError:<EOL><INDENT>key = ECC.import_key(certificate_data)<EOL>verifier = DSS.new(key, '<STR_LIT>')<EOL><DEDENT>digest = PrehashedMessageData(response_challenge)<EOL>try:<EOL><INDENT>verifier.verify(digest, signature)<EOL>return True<EOL><DEDENT>except ValueError:<EOL><INDENT>return False<EOL><DEDENT>
Verify mobile id Authentication signature is valid

    :param certificate_data: binary certificate data, from 'CertificateData' field
    :param sp_challenge: binary challenge sent via 'SPChallenge' field
    :param response_challenge: response challenge, from 'Challenge' field
    :param signature: response signature
    :return: