code: def make_signature(signer_func, data_to_sign, public_algo,
                     hashed_subpackets, unhashed_subpackets, sig_type=0):
      
      # pylint: disable=too-many-arguments
      header = struct.pack('>BBBB',
                           4,         # version
                           sig_type,  # rfc4880 (section-5.2.1)
                           public_algo,
                           8)         # hash_alg (SHA256)
      hashed = subpackets(*hashed_subpackets)
      unhashed = subpackets(*unhashed_subpackets)
      tail = b'\x04\xff' + struct.pack('>L', len(header) + len(hashed))
      data_to_hash = data_to_sign + header + hashed + tail
  
      log.debug('hashing %d bytes', len(data_to_hash))
      digest = hashlib.sha256(data_to_hash).digest()
      log.debug('signing digest: %s', util.hexlify(digest))
      params = signer_func(digest=digest)
      sig = b''.join(mpi(p) for p in params)
  
      return bytes(header + hashed + unhashed +
                   digest[:2] +  # used for decoder's sanity check
                   sig)
docs: Create new GPG signature.