docs: def sign(xml, private, public):
      '''
      Return xmldsig XML string from xml_string of XML.
      @param xml: str of bytestring xml to sign
      @param private: publicKey Private key
      @param public: publicKey Public key
      @return str: signed XML byte string
      '''
      xml = xml.encode('utf-8', 'xmlcharrefreplace')
      signed_info_xml = _generate_signed_info(xml)
  
      signer = PKCS1_v1_5.PKCS115_SigScheme(private)
      signature_value = signer.sign(SHA.new(c14n(signed_info_xml)))
  
      signature_xml = PTN_SIGNATURE_XML % {
          'signed_info_xml': signed_info_xml,
          'signature_value': binascii.b2a_base64(signature_value)[:-1],
          'key_info_xml': _generate_key_info_xml_rsa(public.key.n, public.key.e)
      }
  
      position = xml.rfind('</')
      return xml[0:position] + signature_xml + xml[position:]