code: def verify_mid_signature(certificate_data, sp_challenge, response_challenge, signature):
      
  
      if not response_challenge.startswith(sp_challenge):
          return False
  
      try:
          key = RSA.importKey(certificate_data)
          verifier = PKCS1_v1_5.new(key)
  
      except ValueError:
          key = ECC.import_key(certificate_data)
          verifier = DSS.new(key, 'deterministic-rfc6979')
  
      digest = PrehashedMessageData(response_challenge)
  
      try:
          verifier.verify(digest, signature)
  
          return True
  
      except ValueError:
          return False
docs: 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: