1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gdata.tlslite.utils.keyfactory</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="gdata.html"><font color="#ffffff">gdata</font></a>.<a href="gdata.tlslite.html"><font color="#ffffff">tlslite</font></a>.<a href="gdata.tlslite.utils.html"><font color="#ffffff">utils</font></a>.keyfactory</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/afshar/wrk/gdata-python-client/src/gdata/tlslite/utils/keyfactory.py">/home/afshar/wrk/gdata-python-client/src/gdata/tlslite/utils/keyfactory.py</a></font></td></tr></table>
<p><tt>Factory functions for asymmetric cryptography.<br>
@sort: generateRSAKey, parseXMLKey, parsePEMKey, parseAsPublicKey,<br>
parseAsPrivateKey</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="array.html">array</a><br>
<a href="gdata.tlslite.utils.cryptomath.html">gdata.tlslite.utils.cryptomath</a><br>
</td><td width="25%" valign=top><a href="math.html">math</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
<a href="traceback.html">traceback</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-generateRSAKey"><strong>generateRSAKey</strong></a>(bits, implementations<font color="#909090">=['openssl', 'python']</font>)</dt><dd><tt>Generate an RSA key with the specified bit length.<br>
<br>
@type bits: int<br>
@param bits: Desired bit length of the new key's modulus.<br>
<br>
@rtype: L{tlslite.utils.RSAKey.RSAKey}<br>
@return: A new RSA private key.</tt></dd></dl>
<dl><dt><a name="-parseAsPublicKey"><strong>parseAsPublicKey</strong></a>(s)</dt><dd><tt>Parse an XML or PEM-formatted public key.<br>
<br>
@type s: str<br>
@param s: A string containing an XML or PEM-encoded public or private key.<br>
<br>
@rtype: L{tlslite.utils.RSAKey.RSAKey}<br>
@return: An RSA public key.<br>
<br>
@raise SyntaxError: If the key is not properly formatted.</tt></dd></dl>
<dl><dt><a name="-parsePEMKey"><strong>parsePEMKey</strong></a>(s, private<font color="#909090">=False</font>, public<font color="#909090">=False</font>, passwordCallback<font color="#909090">=None</font>, implementations<font color="#909090">=['openssl', 'python']</font>)</dt><dd><tt>Parse a PEM-format key.<br>
<br>
The PEM format is used by OpenSSL and other tools. The<br>
format is typically used to store both the public and private<br>
components of a key. For example::<br>
<br>
-----BEGIN RSA PRIVATE KEY-----<br>
MIICXQIBAAKBgQDYscuoMzsGmW0pAYsmyHltxB2TdwHS0dImfjCMfaSDkfLdZY5+<br>
dOWORVns9etWnr194mSGA1F0Pls/VJW8+cX9+3vtJV8zSdANPYUoQf0TP7VlJxkH<br>
dSRkUbEoz5bAAs/+970uos7n7iXQIni+3erUTdYEk2iWnMBjTljfgbK/dQIDAQAB<br>
AoGAJHoJZk75aKr7DSQNYIHuruOMdv5ZeDuJvKERWxTrVJqE32/xBKh42/IgqRrc<br>
esBN9ZregRCd7YtxoL+EVUNWaJNVx2mNmezEznrc9zhcYUrgeaVdFO2yBF1889zO<br>
gCOVwrO8uDgeyj6IKa25H6c1N13ih/o7ZzEgWbGG+ylU1yECQQDv4ZSJ4EjSh/Fl<br>
aHdz3wbBa/HKGTjC8iRy476Cyg2Fm8MZUe9Yy3udOrb5ZnS2MTpIXt5AF3h2TfYV<br>
VoFXIorjAkEA50FcJmzT8sNMrPaV8vn+9W2Lu4U7C+K/O2g1iXMaZms5PC5zV5aV<br>
CKXZWUX1fq2RaOzlbQrpgiolhXpeh8FjxwJBAOFHzSQfSsTNfttp3KUpU0LbiVvv<br>
i+spVSnA0O4rq79KpVNmK44Mq67hsW1P11QzrzTAQ6GVaUBRv0YS061td1kCQHnP<br>
wtN2tboFR6lABkJDjxoGRvlSt4SOPr7zKGgrWjeiuTZLHXSAnCY+/hr5L9Q3ZwXG<br>
6x6iBdgLjVIe4BZQNtcCQQDXGv/gWinCNTN3MPWfTW/RGzuMYVmyBFais0/VrgdH<br>
h1dLpztmpQqfyH/zrBXQ9qL/zR4ojS6XYneO/U18WpEe<br>
-----END RSA PRIVATE KEY-----<br>
<br>
To generate a key like this with OpenSSL, run::<br>
<br>
openssl genrsa 2048 > key.pem<br>
<br>
This format also supports password-encrypted private keys. TLS<br>
Lite can only handle password-encrypted private keys when OpenSSL<br>
and M2Crypto are installed. In this case, passwordCallback will be<br>
invoked to query the user for the password.<br>
<br>
@type s: str<br>
@param s: A string containing a PEM-encoded public or private key.<br>
<br>
@type private: bool<br>
@param private: If True, a L{SyntaxError} will be raised if the<br>
private key component is not present.<br>
<br>
@type public: bool<br>
@param public: If True, the private key component (if present) will<br>
be discarded, so this function will always return a public key.<br>
<br>
@type passwordCallback: callable<br>
@param passwordCallback: This function will be called, with no<br>
arguments, if the PEM-encoded private key is password-encrypted.<br>
The callback should return the password string. If the password is<br>
incorrect, SyntaxError will be raised. If no callback is passed<br>
and the key is password-encrypted, a prompt will be displayed at<br>
the console.<br>
<br>
@rtype: L{tlslite.utils.RSAKey.RSAKey}<br>
@return: An RSA key.<br>
<br>
@raise SyntaxError: If the key is not properly formatted.</tt></dd></dl>
<dl><dt><a name="-parsePrivateKey"><strong>parsePrivateKey</strong></a>(s)</dt><dd><tt>Parse an XML or PEM-formatted private key.<br>
<br>
@type s: str<br>
@param s: A string containing an XML or PEM-encoded private key.<br>
<br>
@rtype: L{tlslite.utils.RSAKey.RSAKey}<br>
@return: An RSA private key.<br>
<br>
@raise SyntaxError: If the key is not properly formatted.</tt></dd></dl>
<dl><dt><a name="-parseXMLKey"><strong>parseXMLKey</strong></a>(s, private<font color="#909090">=False</font>, public<font color="#909090">=False</font>, implementations<font color="#909090">=['python']</font>)</dt><dd><tt>Parse an XML-format key.<br>
<br>
The XML format used here is specific to tlslite and cryptoIDlib. The<br>
format can store the public component of a key, or the public and<br>
private components. For example::<br>
<br>
<publicKey xmlns="<a href="http://trevp.net/rsa">http://trevp.net/rsa</a>"><br>
<n>4a5yzB8oGNlHo866CAspAC47M4Fvx58zwK8pou...<br>
<e>Aw==</e><br>
</publicKey><br>
<br>
<privateKey xmlns="<a href="http://trevp.net/rsa">http://trevp.net/rsa</a>"><br>
<n>4a5yzB8oGNlHo866CAspAC47M4Fvx58zwK8pou...<br>
<e>Aw==</e><br>
<d>JZ0TIgUxWXmL8KJ0VqyG1V0J3ern9pqIoB0xmy...<br>
<p>5PreIj6z6ldIGL1V4+1C36dQFHNCQHJvW52GXc...<br>
<q>/E/wDit8YXPCxx126zTq2ilQ3IcW54NJYyNjiZ...<br>
<dP>mKc+wX8inDowEH45Qp4slRo1YveBgExKPROu6...<br>
<dQ>qDVKtBz9lk0shL5PR3ickXDgkwS576zbl2ztB...<br>
<qInv>j6E8EA7dNsTImaXexAmLA1DoeArsYeFAInr...<br>
</privateKey><br>
<br>
@type s: str<br>
@param s: A string containing an XML public or private key.<br>
<br>
@type private: bool<br>
@param private: If True, a L{SyntaxError} will be raised if the private<br>
key component is not present.<br>
<br>
@type public: bool<br>
@param public: If True, the private key component (if present) will be<br>
discarded, so this function will always return a public key.<br>
<br>
@rtype: L{tlslite.utils.RSAKey.RSAKey}<br>
@return: An RSA key.<br>
<br>
@raise SyntaxError: If the key is not properly formatted.</tt></dd></dl>
</td></tr></table>
</body></html>
|