def create_signature(key_dict, data):
<EOL>securesystemslib.formats.ANYKEY_SCHEMA.check_match(key_dict)<EOL>signature = {}<EOL>keytype = key_dict['<STR_LIT>']<EOL>scheme = key_dict['<STR_LIT>']<EOL>public = key_dict['<STR_LIT>']['<STR_LIT>']<EOL>private = key_dict['<STR_LIT>']['<STR_LIT>']<EOL>keyid = key_dict['<STR_LIT>']<EOL>sig = None<EOL>if keytype == '<STR_LIT>':<EOL><INDENT>if scheme == '<STR_LIT>':<EOL><INDENT>private = private.replace('<STR_LIT:\r\n>', '<STR_LIT:\n>')<EOL>sig, scheme = securesystemslib.pyca_crypto_keys.create_rsa_signature(<EOL>private, data, scheme)<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>public = binascii.unhexlify(public.encode('<STR_LIT:utf-8>'))<EOL>private = binascii.unhexlify(private.encode('<STR_LIT:utf-8>'))<EOL>sig, scheme = securesystemslib.ed25519_keys.create_signature(<EOL>public, private, data, scheme)<EOL><DEDENT>elif keytype == '<STR_LIT>':<EOL><INDENT>sig, scheme = securesystemslib.ecdsa_keys.create_signature(<EOL>public, private, data, scheme)<EOL><DEDENT>else: <EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>signature['<STR_LIT>'] = keyid<EOL>signature['<STR_LIT>'] = binascii.hexlify(sig).decode()<EOL>return signature<EOL>
<Purpose>
  Return a signature dictionary of the form:
  {'keyid': 'f30a0870d026980100c0573bd557394f8c1bbd6...',
   'sig': '...'}.

  The signing process will use the private key in
  key_dict['keyval']['private'] and 'data' to generate the signature.

  The following signature schemes are supported:

  'RSASSA-PSS'
  RFC3447 - RSASSA-PSS
  http://www.ietf.org/rfc/rfc3447.

  'ed25519'
  ed25519 - high-speed high security signatures
  http://ed25519.cr.yp.to/

  Which signature to generate is determined by the key type of 'key_dict'
  and the available cryptography library specified in 'settings'.

  >>> ed25519_key = generate_ed25519_key()
  >>> data = 'The quick brown fox jumps over the lazy dog'
  >>> signature = create_signature(ed25519_key, data)
  >>> securesystemslib.formats.SIGNATURE_SCHEMA.matches(signature)
  True
  >>> len(signature['sig'])
  128
  >>> rsa_key = generate_rsa_key(2048)
  >>> signature = create_signature(rsa_key, data)
  >>> securesystemslib.formats.SIGNATURE_SCHEMA.matches(signature)
  True
  >>> ecdsa_key = generate_ecdsa_key()
  >>> signature = create_signature(ecdsa_key, data)
  >>> securesystemslib.formats.SIGNATURE_SCHEMA.matches(signature)
  True

<Arguments>
  key_dict:
    A dictionary containing the keys.  An example RSA key dict 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.

  data:
    Data to be signed. This should be a bytes object; data should be
    encoded/serialized before it is passed here.  The same value can be be
    passed into securesystemslib.verify_signature() (along with the public
    key) to later verify the signature.

<Exceptions>
  securesystemslib.exceptions.FormatError, if 'key_dict' is improperly
  formatted.

  securesystemslib.exceptions.UnsupportedAlgorithmError, if 'key_dict'
  specifies an unsupported key type or signing scheme.

  TypeError, if 'key_dict' contains an invalid keytype.

<Side Effects>
  The cryptography library specified in 'settings' is called to perform the
  actual signing routine.

<Returns>
  A signature dictionary conformant to
  'securesystemslib_format.SIGNATURE_SCHEMA'.