blob: 38775242c8710ea111dbd0dd2856e8973c1a5125 [file] [log] [blame]
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<title>3.1 crypto -- Generic cryptographic module </title>
5<META NAME="description" CONTENT="3.1 crypto -- Generic cryptographic module ">
6<META NAME="keywords" CONTENT="pyOpenSSL">
7<META NAME="resource-type" CONTENT="document">
8<META NAME="distribution" CONTENT="global">
9<link rel="STYLESHEET" href="pyOpenSSL.css">
10<LINK REL="next" href="openssl-rand.html">
11<LINK REL="previous" href="openssl.html">
12<LINK REL="up" href="openssl.html">
13<LINK REL="next" href="openssl-x509.html">
14</head>
15<body>
16<DIV CLASS="navigation">
17<table align="center" width="100%" cellpadding="0" cellspacing="2">
18<tr>
19<td><A href="openssl.html"><img src="previous.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050020 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050021 alt="Previous Page" width="32"></A></td>
22<td><A href="openssl.html"><img src="up.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050023 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050024 alt="Up One Level" width="32"></A></td>
25<td><A href="openssl-x509.html"><img src="next.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050026 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050027 alt="Next Page" width="32"></A></td>
28<td align="center" width="100%">Python OpenSSL Manual</td>
29<td><A href="contents.html"><img src="contents.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050030 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050031 alt="Contents" width="32"></A></td>
32<td><img src="blank.gif"
33 border="0" height="32"
34 alt="" width="32"></td>
35<td><img src="blank.gif"
36 border="0" height="32"
37 alt="" width="32"></td>
38</tr></table>
39<b class="navlabel">Previous:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A>
40<b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A>
41<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509.html">3.1.1 X509 objects</A>
42<br><hr>
43</DIV>
44<!--End of Navigation Panel-->
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050045
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050046<H2><A NAME="SECTION000410000000000000000">&nbsp;</A>
47<BR>
483.1 <tt class="module">crypto</tt> -- Generic cryptographic module
49</H2>
50
51<P>
52
53
54<P>
55<dl><dt><b><a name='l2h-6'><tt>X509Type</tt></a></b>
56<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050057See <tt class="class">X509</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050058</dl>
59
60<P>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050061<dl><dt><b>class <a name='l2h-7'><tt class='class'>X509</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050062<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050063A class representing X.509 certificates.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050064</dl>
65
66<P>
67<dl><dt><b><a name='l2h-8'><tt>X509NameType</tt></a></b>
68<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050069See <tt class="class">X509Name</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050070</dl>
71
72<P>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050073<dl><dt><b>class <a name='l2h-9'><tt class='class'>X509Name</tt></a></b>(<var>x509name</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050074<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050075A class representing X.509 Distinguished Names.
76
77<P>
78This constructor creates a copy of <var>x509name</var> which should be an
79instance of <tt class="class">X509Name</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050080</dl>
81
82<P>
83<dl><dt><b><a name='l2h-10'><tt>X509ReqType</tt></a></b>
84<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050085See <tt class="class">X509Req</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050086</dl>
87
88<P>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050089<dl><dt><b>class <a name='l2h-11'><tt class='class'>X509Req</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050090<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -050091A class representing X.509 certificate requests.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050092</dl>
93
94<P>
95<dl><dt><b><a name='l2h-12'><tt>X509StoreType</tt></a></b>
96<dd>
97A Python type object representing the X509Store object type.
98</dl>
99
100<P>
101<dl><dt><b><a name='l2h-13'><tt>PKeyType</tt></a></b>
102<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500103See <tt class="class">PKey</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500104</dl>
105
106<P>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500107<dl><dt><b>class <a name='l2h-14'><tt class='class'>PKey</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500108<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500109A class representing DSA or RSA keys.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500110</dl>
111
112<P>
113<dl><dt><b><a name='l2h-15'><tt>PKCS7Type</tt></a></b>
114<dd>
115A Python type object representing the PKCS7 object type.
116</dl>
117
118<P>
119<dl><dt><b><a name='l2h-16'><tt>PKCS12Type</tt></a></b>
120<dd>
121A Python type object representing the PKCS12 object type.
122</dl>
123
124<P>
125<dl><dt><b><a name='l2h-17'><tt>X509ExtensionType</tt></a></b>
126<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500127See <tt class="class">X509Extension</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500128</dl>
129
130<P>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500131<dl><dt><b>class <a name='l2h-18'><tt class='class'>X509Extension</tt></a></b>(<var>typename, critical, value</var><big>[</big><var>, subject</var><big>]</big><big>[</big><var>, issuer</var><big>]</big>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500132<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500133A class representing an X.509 v3 certificate extensions.
134See <a class="url" href="http://openssl.org/docs/apps/x509v3_config.html#STANDARD_EXTENSIONS">http://openssl.org/docs/apps/x509v3_config.html#STANDARD_EXTENSIONS</a>for <var>typename</var> strings and their options.
135Optional parameters <var>subject</var> and <var>issuer</var> must be X509 objects.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500136</dl>
137
138<P>
139<dl><dt><b><a name='l2h-19'><tt>NetscapeSPKIType</tt></a></b>
140<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500141See <tt class="class">NetscapeSPKI</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500142</dl>
143
144<P>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500145<dl><dt><b>class <a name='l2h-20'><tt class='class'>NetscapeSPKI</tt></a></b>(<big>[</big><var>enc</var><big>]</big>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500146<dd>
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500147A class representing Netscape SPKI objects.
148
149<P>
150If the <var>enc</var> argument is present, it should be a base64-encoded string
151representing a NetscapeSPKI object, as returned by the <tt class="method">b64_encode</tt>
152method.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500153</dl>
154
155<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400156<dl><dt><b>class <a name='l2h-21'><tt class='class'>CRL</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500157<dd>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400158A class representing Certifcate Revocation List objects.
159</dl>
160
161<P>
162<dl><dt><b>class <a name='l2h-22'><tt class='class'>Revoked</tt></a></b>()
163<dd>
164A class representing Revocation objects of CRL.
165</dl>
166
167<P>
168<dl><dt><b><a name='l2h-23'><tt>FILETYPE_PEM</tt></a></b>
169<dd>
170<dt><b><a name='l2h-37'><tt>FILETYPE_ASN1</tt></a></b><dd>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500171File type constants.
172</dl>
173
174<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400175<dl><dt><b><a name='l2h-24'><tt>TYPE_RSA</tt></a></b>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500176<dd>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400177<dt><b><a name='l2h-38'><tt>TYPE_DSA</tt></a></b><dd>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500178Key type constants.
179</dl>
180
181<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400182<dl><dt><b>exception <a name='l2h-25'><tt class='exception'>Error</tt></a></b>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500183<dd>
184Generic exception used in the <tt class="module">crypto</tt> module.
185</dl>
186
187<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400188<dl><dt><b><a name='l2h-26'><tt class='function'>dump_certificate</tt></a></b>(<var>type, cert</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500189<dd>
190Dump the certificate <var>cert</var> into a buffer string encoded with the type
191<var>type</var>.
192</dl>
193
194<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400195<dl><dt><b><a name='l2h-27'><tt class='function'>dump_certificate_request</tt></a></b>(<var>type, req</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500196<dd>
197Dump the certificate request <var>req</var> into a buffer string encoded with the
198type <var>type</var>.
199</dl>
200
201<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400202<dl><dt><b><a name='l2h-28'><tt class='function'>dump_privatekey</tt></a></b>(<var>type, pkey</var><big>[</big><var>, cipher, passphrase</var><big>]</big>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500203<dd>
204Dump the private key <var>pkey</var> into a buffer string encoded with the type
205<var>type</var>, optionally (if <var>type</var> is <tt class="constant">FILETYPE_PEM</tt>) encrypting it
206using <var>cipher</var> and <var>passphrase</var>.
207
208<P>
209<var>passphrase</var> must be either a string or a callback for providing the
210pass phrase.
211</dl>
212
213<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400214<dl><dt><b><a name='l2h-29'><tt class='function'>load_certificate</tt></a></b>(<var>type, buffer</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500215<dd>
216Load a certificate (X509) from the string <var>buffer</var> encoded with the
217type <var>type</var>.
218</dl>
219
220<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400221<dl><dt><b><a name='l2h-30'><tt class='function'>load_certificate_request</tt></a></b>(<var>type, buffer</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500222<dd>
223Load a certificate request (X509Req) from the string <var>buffer</var> encoded with
224the type <var>type</var>.
225</dl>
226
227<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400228<dl><dt><b><a name='l2h-31'><tt class='function'>load_privatekey</tt></a></b>(<var>type, buffer</var><big>[</big><var>, passphrase</var><big>]</big>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500229<dd>
230Load a private key (PKey) from the string <var>buffer</var> encoded with
231the type <var>type</var> (must be one of <tt class="constant">FILETYPE_PEM</tt> and
232<tt class="constant">FILETYPE_ASN1</tt>).
233
234<P>
235<var>passphrase</var> must be either a string or a callback for providing the
236pass phrase.
237</dl>
238
239<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400240<dl><dt><b><a name='l2h-32'><tt class='function'>load_crl</tt></a></b>(<var>type, buffer</var>)
241<dd>
242Load Certificate Revocation List (CRL) data from a string <var>buffer</var>.
243<var>buffer</var> encoded with the type <var>type</var>. The type <var>type</var>
244must either <tt class="constant">FILETYPE_PEM</tt> or <tt class="constant">FILETYPE_ASN1</tt>).
245</dl>
246
247<P>
248<dl><dt><b><a name='l2h-33'><tt class='function'>load_pkcs7_data</tt></a></b>(<var>type, buffer</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500249<dd>
250Load pkcs7 data from the string <var>buffer</var> encoded with the type <var>type</var>.
251</dl>
252
253<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400254<dl><dt><b><a name='l2h-34'><tt class='function'>load_pkcs12</tt></a></b>(<var>buffer</var><big>[</big><var>, passphrase</var><big>]</big>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500255<dd>
256Load pkcs12 data from the string <var>buffer</var>. If the pkcs12 structure is
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500257encrypted, a <var>passphrase</var> must be included. The MAC is always
258checked and thus required.
259
260<P>
261See also the man page for the C function <tt class="function">PKCS12_parse</tt>.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500262</dl>
263
264<P>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400265<dl><dt><b><a name='l2h-35'><tt class='function'>sign</tt></a></b>(<var>key, data, digest</var>)
266<dd>
267Sign a data string using the given key and message digest.
268
269<P>
270<var>key</var> is a <code>PKey</code> instance. <var>data</var> is a <code>str</code> instance.
271<var>digest</var> is a <code>str</code> naming a supported message digest type, for example
272<code>``sha1''</code>.
273
274<span class='versionnote'>New in version 0.11.</span>
275
276</dl>
277
278<P>
279<dl><dt><b><a name='l2h-36'><tt class='function'>verify</tt></a></b>(<var>certificate, signature, data, digest</var>)
280<dd>
281Verify the signature for a data string.
282
283<P>
284<var>certificate</var> is a <code>X509</code> instance corresponding to the private key
285which generated the signature. <var>signature</var> is a <var>str</var> instance giving
286the signature itself. <var>data</var> is a <var>str</var> instance giving the data to
287which the signature applies. <var>digest</var> is a <var>str</var> instance naming the
288message digest type of the signature, for example <code>``sha1''</code>.
289
290<span class='versionnote'>New in version 0.11.</span>
291
292</dl>
293
294<P>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500295
296<p><hr>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500297<!--Table of Child-Links-->
298<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
299
300<UL CLASS="ChildLinks">
Jean-Paul Calderone657d3ec2008-09-21 18:59:46 -0400301<LI><A NAME="tex2html139"
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400302 href="openssl-x509.html">3.1.1 X509 objects </A>
Jean-Paul Calderone657d3ec2008-09-21 18:59:46 -0400303<LI><A NAME="tex2html140"
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400304 href="openssl-x509name.html">3.1.2 X509Name objects </A>
Jean-Paul Calderone657d3ec2008-09-21 18:59:46 -0400305<LI><A NAME="tex2html141"
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400306 href="openssl-x509req.html">3.1.3 X509Req objects </A>
Jean-Paul Calderone657d3ec2008-09-21 18:59:46 -0400307<LI><A NAME="tex2html142"
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400308 href="openssl-x509store.html">3.1.4 X509Store objects </A>
Jean-Paul Calderone657d3ec2008-09-21 18:59:46 -0400309<LI><A NAME="tex2html143"
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400310 href="openssl-pkey.html">3.1.5 PKey objects </A>
311<LI><A NAME="tex2html144"
312 href="openssl-pkcs7.html">3.1.6 PKCS7 objects </A>
313<LI><A NAME="tex2html145"
314 href="openssl-pkcs12.html">3.1.7 PKCS12 objects </A>
315<LI><A NAME="tex2html146"
316 href="openssl-509ext.html">3.1.8 X509Extension objects </A>
317<LI><A NAME="tex2html147"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500318 href="openssl-netscape-spki.html">3.1.9 NetscapeSPKI objects </A>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400319<LI><A NAME="tex2html148"
320 href="crl.html">3.1.10 CRL objects </A>
321<LI><A NAME="tex2html149"
322 href="revoked.html">3.1.11 Revoked objects </A>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500323</UL>
324<!--End of Table of Child-Links-->
325
326<DIV CLASS="navigation">
327<p><hr>
328<table align="center" width="100%" cellpadding="0" cellspacing="2">
329<tr>
330<td><A href="openssl.html"><img src="previous.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500331 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500332 alt="Previous Page" width="32"></A></td>
333<td><A href="openssl.html"><img src="up.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500334 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500335 alt="Up One Level" width="32"></A></td>
336<td><A href="openssl-x509.html"><img src="next.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500337 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500338 alt="Next Page" width="32"></A></td>
339<td align="center" width="100%">Python OpenSSL Manual</td>
340<td><A href="contents.html"><img src="contents.gif"
Jean-Paul Calderone215d51b2009-11-13 09:19:21 -0500341 border="0" height="32"
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500342 alt="Contents" width="32"></A></td>
343<td><img src="blank.gif"
344 border="0" height="32"
345 alt="" width="32"></td>
346<td><img src="blank.gif"
347 border="0" height="32"
348 alt="" width="32"></td>
349</tr></table>
350<b class="navlabel">Previous:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A>
351<b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A>
352<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509.html">3.1.1 X509 objects</A>
353<hr>
Jean-Paul Calderoneec155e52010-10-07 22:34:15 -0400354<span class="release-info">Release 0.11a1.</span>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500355</DIV>
356<!--End of Navigation Panel-->
357
358</BODY>
359</HTML>