def verify_signature(key_dict, signature, data):
<EOL>securesystemslib.formats.ANYKEY_SCHEMA.check_match(key_dict)<EOL>securesystemslib.formats.SIGNATURE_SCHEMA.check_match(signature)<EOL>if key_dict['<STR_LIT>'] != signature['<STR_LIT>']:<EOL><INDENT>raise securesystemslib.exceptions.CryptoError('<STR_LIT>'<EOL>'<STR_LIT:U+0020>' + repr(key_dict['<STR_LIT>']) + '<STR_LIT>'<EOL>'<STR_LIT>' + repr(signature['<STR_LIT>']) + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>logger.debug('<STR_LIT>')<EOL><DEDENT>sig = signature['<STR_LIT>']<EOL>sig = binascii.unhexlify(sig.encode('<STR_LIT:utf-8>'))<EOL>public = key_dict['<STR_LIT>']['<STR_LIT>']<EOL>keytype = key_dict['<STR_LIT>']<EOL>scheme = key_dict['<STR_LIT>']<EOL>valid_signature = False<EOL>if keytype == '<STR_LIT>':<EOL><INDENT>if scheme == '<STR_LIT>':<EOL><INDENT>valid_signature = securesystemslib.pyca_crypto_keys.verify_rsa_signature(sig,<EOL>scheme, public, data)<EOL><DEDENT>else:<EOL><INDENT>raise securesystemslib.exceptions.UnsupportedAlgorithmError('<STR_LIT>'<EOL>'<STR_LIT>' + repr(scheme))<EOL><DEDENT><DEDENT>elif keytype == '<STR_LIT>':<EOL><INDENT>if scheme == '<STR_LIT>':<EOL><INDENT>public = binascii.unhexlify(public.encode('<STR_LIT:utf-8>'))<EOL>valid_signature = securesystemslib.ed25519_keys.verify_signature(public,<EOL>scheme, sig, data, use_pynacl=USE_PYNACL)<EOL><DEDENT>else:<EOL><INDENT>raise securesystemslib.exceptions.UnsupportedAlgorithmError('<STR_LIT>'<EOL>'<STR_LIT>' + repr(scheme))<EOL><DEDENT><DEDENT>elif keytype == '<STR_LIT>':<EOL><INDENT>if scheme == '<STR_LIT>':<EOL><INDENT>valid_signature = securesystemslib.ecdsa_keys.verify_signature(public,<EOL>scheme, sig, data)<EOL><DEDENT>else:<EOL><INDENT>raise securesystemslib.exceptions.UnsupportedAlgorithmError('<STR_LIT>'<EOL>'<STR_LIT>' + repr(scheme))<EOL><DEDENT><DEDENT>else: <EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>return valid_signature<EOL>
<Purpose>
  Determine whether the private key belonging to 'key_dict' produced
  'signature'.  verify_signature() will use the public key found in
  'key_dict', the 'sig' objects contained in 'signature', and 'data' to
  complete the verification.

  >>> ed25519_key = generate_ed25519_key()
  >>> data = 'The quick brown fox jumps over the lazy dog'
  >>> signature = create_signature(ed25519_key, data)
  >>> verify_signature(ed25519_key, signature, data)
  True
  >>> verify_signature(ed25519_key, signature, 'bad_data')
  False
  >>> rsa_key = generate_rsa_key()
  >>> signature = create_signature(rsa_key, data)
  >>> verify_signature(rsa_key, signature, data)
  True
  >>> verify_signature(rsa_key, signature, 'bad_data')
  False
  >>> ecdsa_key = generate_ecdsa_key()
  >>> signature = create_signature(ecdsa_key, data)
  >>> verify_signature(ecdsa_key, signature, data)
  True
  >>> verify_signature(ecdsa_key, signature, 'bad_data')
  False

<Arguments>
  key_dict:
    A dictionary containing the keys and other identifying information.
    If 'key_dict' is an RSA key, it has the form:

    {'keytype': 'rsa',
     'scheme': 'rsassa-pss-sha256',
     'keyid': 'f30a0870d026980100c0573bd557394f8c1bbd6...',
     'keyval': {'public': '-----BEGIN RSA PUBLIC KEY----- ...',
                'private': '-----BEGIN RSA PRIVATE KEY----- ...'}}

    The public and private keys are strings in PEM format.

  signature:
    The signature dictionary produced by one of the key generation functions.
    'signature' has the form:

    {'keyid': 'f30a0870d026980100c0573bd557394f8c1bbd6...',
     'sig': sig}.

    Conformant to 'securesystemslib.formats.SIGNATURE_SCHEMA'.

  data:
    Data that the signature is expected to be over.  This should be a bytes
    object; data should be encoded/serialized before it is passed here.)
    This is the same value that can be passed into
    securesystemslib.create_signature() in order to create the signature.

<Exceptions>
  securesystemslib.exceptions.FormatError, raised if either 'key_dict' or
  'signature' are improperly formatted.

  securesystemslib.exceptions.UnsupportedAlgorithmError, if 'key_dict' or
  'signature' specifies an unsupported algorithm.

  securesystemslib.exceptions.CryptoError, if the KEYID in the given
  'key_dict' does not match the KEYID in 'signature'.

<Side Effects>
  The cryptography library specified in 'settings' called to do the actual
  verification.

<Returns>
  Boolean.  True if the signature is valid, False otherwise.