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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.2 rand -- An interface to the OpenSSL pseudo random number generator </title>
<META NAME="description" CONTENT="3.2 rand -- An interface to the OpenSSL pseudo random number generator ">
<META NAME="keywords" CONTENT="pyOpenSSL">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<link rel="STYLESHEET" href="pyOpenSSL.css">
<LINK REL="next" href="openssl-ssl.html">
<LINK REL="previous" href="openssl-crypto.html">
<LINK REL="up" href="openssl.html">
<LINK REL="next" href="openssl-ssl.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="revoked.html"><img src="previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="openssl.html"><img src="up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="openssl-ssl.html"><img src="next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python OpenSSL Manual</td>
<td><A href="contents.html"><img src="contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="revoked.html">3.1.11 Revoked objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A>
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-ssl.html">3.3 SSL </A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000420000000000000000"> </A>
<BR>
3.2 <tt class="module">rand</tt> -- An interface to the OpenSSL pseudo random number generator
</H2>
<P>
<P>
This module handles the OpenSSL pseudo random number generator (PRNG) and
declares the following:
<P>
<dl><dt><b><a name='l2h-118'><tt class='function'>add</tt></a></b>(<var>string, entropy</var>)
<dd>
Mix bytes from <var>string</var> into the PRNG state. The <var>entropy</var> argument is
(the lower bound of) an estimate of how much randomness is contained in
<var>string</var>, measured in bytes. For more information, see e.g. <a class="rfc" name="rfcref-2374"
href="http://www.ietf.org/rfc/rfc1750.txt">RFC 1750</a>.
</dl>
<P>
<dl><dt><b><a name='l2h-119'><tt class='function'>bytes</tt></a></b>(<var>num_bytes</var>)
<dd>
Get some random bytes from the PRNG as a string.
<P>
This is a wrapper for the C function <tt class="function">RAND_bytes</tt>.
</dl>
<P>
<dl><dt><b><a name='l2h-120'><tt class='function'>cleanup</tt></a></b>()
<dd>
Erase the memory used by the PRNG.
<P>
This is a wrapper for the C function <tt class="function">RAND_cleanup</tt>.
</dl>
<P>
<dl><dt><b><a name='l2h-121'><tt class='function'>egd</tt></a></b>(<var>path</var><big>[</big><var>, bytes</var><big>]</big>)
<dd>
Query the Entropy Gathering Daemon<A NAME="tex2html2"
HREF="#foot1272"><SUP>2</SUP></A> on socket <var>path</var> for <var>bytes</var>
bytes of random data and and uses <tt class="function">add</tt> to seed the PRNG. The default
value of <var>bytes</var> is 255.
</dl>
<P>
<dl><dt><b><a name='l2h-122'><tt class='function'>load_file</tt></a></b>(<var>path</var><big>[</big><var>, bytes</var><big>]</big>)
<dd>
Read <var>bytes</var> bytes (or all of it, if <var>bytes</var> is negative) of data from
the file <var>path</var> to seed the PRNG. The default value of <var>bytes</var> is -1.
</dl>
<P>
<dl><dt><b><a name='l2h-123'><tt class='function'>screen</tt></a></b>()
<dd>
Add the current contents of the screen to the PRNG state.
Availability: Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-124'><tt class='function'>seed</tt></a></b>(<var>string</var>)
<dd>
This is equivalent to calling <tt class="function">add</tt> with <var>entropy</var> as the length
of the string.
</dl>
<P>
<dl><dt><b><a name='l2h-125'><tt class='function'>status</tt></a></b>()
<dd>
Returns true if the PRNG has been seeded with enough data, and false otherwise.
</dl>
<P>
<dl><dt><b><a name='l2h-126'><tt class='function'>write_file</tt></a></b>(<var>path</var>)
<dd>
Write a number of random bytes (currently 1024) to the file <var>path</var>. This
file can then be used with <tt class="function">load_file</tt> to seed the PRNG again.
</dl>
<P>
<dl><dt><b>exception <a name='l2h-127'><tt class='exception'>Error</tt></a></b>
<dd>
If the current RAND method supports any errors, this is raised when needed.
The default method does not raise this when the entropy pool is depleted.
<P>
Whenever this exception is raised directly, it has a list of error messages
from the OpenSSL error queue, where each item is a tuple <code>(<var>lib</var>,
<var>function</var>, <var>reason</var>)</code>. Here <var>lib</var>, <var>function</var> and <var>reason</var>
are all strings, describing where and what the problem is. See <span class='manpage'><i>err</i>(3)</span>
for more information.
</dl>
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
<DT><A NAME="foot1272">... Daemon</A><A
href="openssl-rand.html#tex2html2"><SUP>2</SUP></A></DT>
<DD>See
<a class="url" href="http://www.lothar.com/tech/crypto/">http://www.lothar.com/tech/crypto/</a>
</DD>
</DL>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="revoked.html"><img src="previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="openssl.html"><img src="up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="openssl-ssl.html"><img src="next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python OpenSSL Manual</td>
<td><A href="contents.html"><img src="contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="revoked.html">3.1.11 Revoked objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL </A>
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-ssl.html">3.3 SSL </A>
<hr>
<span class="release-info">Release 0.13.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
|