Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>3.2 rand -- An interface to the OpenSSL pseudo random number generator </title> |
| 5 | <META NAME="description" CONTENT="3.2 rand -- An interface to the OpenSSL pseudo random number generator "> |
| 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-ssl.html"> |
| 11 | <LINK REL="previous" href="openssl-crypto.html"> |
| 12 | <LINK REL="up" href="openssl.html"> |
| 13 | <LINK REL="next" href="openssl-ssl.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-netscape-spki.html"><img src="previous.gif" |
| 20 | border="0" height="32" |
| 21 | alt="Previous Page" width="32"></A></td> |
| 22 | <td><A href="openssl.html"><img src="up.gif" |
| 23 | border="0" height="32" |
| 24 | alt="Up One Level" width="32"></A></td> |
| 25 | <td><A href="openssl-ssl.html"><img src="next.gif" |
| 26 | border="0" height="32" |
| 27 | 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" |
| 30 | border="0" height="32" |
| 31 | 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-netscape-spki.html">3.1.9 NetscapeSPKI objects</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-ssl.html">3.3 SSL </A> |
| 42 | <br><hr> |
| 43 | </DIV> |
| 44 | <!--End of Navigation Panel--> |
| 45 | |
| 46 | <H2><A NAME="SECTION000420000000000000000"> </A> |
| 47 | <BR> |
| 48 | 3.2 <tt class="module">rand</tt> -- An interface to the OpenSSL pseudo random number generator |
| 49 | </H2> |
| 50 | <P> |
| 51 | <EM><EM><EM> |
| 52 | </EM></EM></EM> |
| 53 | <P> |
| 54 | <EM><EM><EM>This module handles the OpenSSL pseudo random number generator (PRNG) and |
| 55 | declares the following: |
| 56 | </EM></EM></EM> |
| 57 | <P> |
| 58 | <dl><dt><b><a name='l2h-82'><tt class='function'>add</tt></a></b>(<var>string, entropy</var>) |
| 59 | <dd> |
| 60 | Mix bytes from <var>string</var> into the PRNG state. The <var>entropy</var> argument is |
| 61 | (the lower bound of) an estimate of how much randomness is contained in |
Jean-Paul Calderone | 72b8f0f | 2008-02-21 23:57:40 -0500 | [diff] [blame^] | 62 | <var>string</var>, measured in bytes. For more information, see e.g. <a class="rfc" name="rfcref-1801" |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 63 | href="http://www.ietf.org/rfc/rfc1750.txt">RFC 1750</a>. |
| 64 | </dl> |
| 65 | <P> |
| 66 | <dl><dt><b><a name='l2h-83'><tt class='function'>egd</tt></a></b>(<var>path</var><big>[</big><var>, bytes</var><big>]</big>) |
| 67 | <dd> |
| 68 | Query the Entropy Gathering Daemon<A NAME="tex2html3" |
Jean-Paul Calderone | 72b8f0f | 2008-02-21 23:57:40 -0500 | [diff] [blame^] | 69 | HREF="#foot916"><SUP>3</SUP></A> on socket <var>path</var> for <var>bytes</var> |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 70 | bytes of random data and and uses <tt class="function">add</tt> to seed the PRNG. The default |
| 71 | value of <var>bytes</var> is 255. |
| 72 | </dl> |
| 73 | <P> |
| 74 | <dl><dt><b><a name='l2h-84'><tt class='function'>load_file</tt></a></b>(<var>path</var><big>[</big><var>, bytes</var><big>]</big>) |
| 75 | <dd> |
| 76 | Read <var>bytes</var> bytes (or all of it, if <var>bytes</var> is negative) of data from |
| 77 | the file <var>path</var> to seed the PRNG. The default value of <var>bytes</var> is -1. |
| 78 | </dl> |
| 79 | <P> |
| 80 | <dl><dt><b><a name='l2h-85'><tt class='function'>screen</tt></a></b>() |
| 81 | <dd> |
| 82 | Add the current contents of the screen to the PRNG state. |
| 83 | Availability: Windows. |
| 84 | </dl> |
| 85 | <P> |
| 86 | <dl><dt><b><a name='l2h-86'><tt class='function'>seed</tt></a></b>(<var>string</var>) |
| 87 | <dd> |
| 88 | This is equivalent to calling <tt class="function">add</tt> with <var>entropy</var> as the length |
| 89 | of the string. |
| 90 | </dl> |
| 91 | <P> |
| 92 | <dl><dt><b><a name='l2h-87'><tt class='function'>status</tt></a></b>() |
| 93 | <dd> |
| 94 | Returns true if the PRNG has been seeded with enough data, and false otherwise. |
| 95 | </dl> |
| 96 | <P> |
| 97 | <dl><dt><b><a name='l2h-88'><tt class='function'>write_file</tt></a></b>(<var>path</var>) |
| 98 | <dd> |
| 99 | Write a number of random bytes (currently 1024) to the file <var>path</var>. This |
| 100 | file can then be used with <tt class="function">load_file</tt> to seed the PRNG again. |
| 101 | </dl> |
| 102 | <P> |
| 103 | <BR><HR><H4>Footnotes</H4> |
| 104 | <DL> |
Jean-Paul Calderone | 72b8f0f | 2008-02-21 23:57:40 -0500 | [diff] [blame^] | 105 | <DT><A NAME="foot916">... Daemon</A><A |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 106 | href="openssl-rand.html#tex2html3"><SUP>3</SUP></A></DT> |
| 107 | <DD>See |
| 108 | <a class="url" href="http://www.lothar.com/tech/crypto/">http://www.lothar.com/tech/crypto/</a> |
| 109 | |
| 110 | </DD> |
| 111 | </DL> |
| 112 | <DIV CLASS="navigation"> |
| 113 | <p><hr> |
| 114 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 115 | <tr> |
| 116 | <td><A href="openssl-netscape-spki.html"><img src="previous.gif" |
| 117 | border="0" height="32" |
| 118 | alt="Previous Page" width="32"></A></td> |
| 119 | <td><A href="openssl.html"><img src="up.gif" |
| 120 | border="0" height="32" |
| 121 | alt="Up One Level" width="32"></A></td> |
| 122 | <td><A href="openssl-ssl.html"><img src="next.gif" |
| 123 | border="0" height="32" |
| 124 | alt="Next Page" width="32"></A></td> |
| 125 | <td align="center" width="100%">Python OpenSSL Manual</td> |
| 126 | <td><A href="contents.html"><img src="contents.gif" |
| 127 | border="0" height="32" |
| 128 | alt="Contents" width="32"></A></td> |
| 129 | <td><img src="blank.gif" |
| 130 | border="0" height="32" |
| 131 | alt="" width="32"></td> |
| 132 | <td><img src="blank.gif" |
| 133 | border="0" height="32" |
| 134 | alt="" width="32"></td> |
| 135 | </tr></table> |
| 136 | <b class="navlabel">Previous:</b> <a class="sectref" href="openssl-netscape-spki.html">3.1.9 NetscapeSPKI objects</A> |
| 137 | <b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A> |
| 138 | <b class="navlabel">Next:</b> <a class="sectref" href="openssl-ssl.html">3.3 SSL </A> |
| 139 | <hr> |
| 140 | <span class="release-info">Release 0.6.</span> |
| 141 | </DIV> |
| 142 | <!--End of Navigation Panel--> |
| 143 | |
| 144 | </BODY> |
| 145 | </HTML> |