updates.
[website.git] / docs / toolkit / manual / silcrng_intro.html
1
2 <html>
3 <head>
4  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-a" />
5  <meta http-equiv="Content-Language" content="en" />
6  <meta name="description" content="SILC Secure Internet Live Conferencing" />
7  <meta name="keywords" content="SILC, secure, chat, protocol, cipher, encrypt, SKE" />
8  <meta content="INDEX, FOLLOW" name="ROBOTS" />
9  <style type="text/css">
10   <!--
11   body { color: #000000; background: #f0f0f0; font-family: Helvetica, Arial, Sans-serif; }
12   a:link { text-decoration: none; color: #2f488f; }
13   a:visited { text-decoration: none;color: #2f488f; }
14   a:active { text-decoration: none; color: #2f488f; }
15   -->
16  </style>
17 </head>
18
19 <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
20
21 <table border="0" cellspacing="0" cellpadding="6" width="100%">
22  <tr valign="top" bgcolor="#dddddd">
23   <td><small>Copyright &copy; 2001 - 2007 SILC Project<br />
24     <a href="http://silcnet.org">SILC Project Website</a></small></td>
25   <td align="right"><small>
26    <a href="index.html">SILC Toolkit Reference Manual</a><br />
27    <a href="toolkit_index.html">Index</a></small></td>
28    </small></td>
29  </tr>
30 </table>
31 <table border="0" cellspacing="0" cellpadding="0" width="100%">
32 <tr bgcolor="#444444"><td><img src="space.gif" width="1" height="1"border="0" alt="" ></td></tr>
33 </table>
34
35 <table cellpadding="0" cellspacing="0" border="0">
36  <tr valign="top">
37
38   <td width="200" bgcolor="#f0f0f0">
39    <img src="space.gif" width="1" height="1" border="0" alt="">
40    <table width="100%" cellpadding="2" cellspacing="2" border="0">
41     <tr valign="top"><td>
42 <br />
43 <small>
44 <!-- Template file for the big index that appears in the Toolkit reference
45 manual on the left side.  With this file it is possible to add other than
46 automatically generated links to that list. -->
47
48 <a href="index.html"><img src="box.gif" border="0" alt="">SILC Toolkit Reference Manual</a><br />
49
50
51 <a href=silccryptlib.html><img src=box.gif border=0 alt=>SILC Crypto Library</a><br />
52 &nbsp;&nbsp;&nbsp; <a href=silcrng_intro.html><img src=box2.gif border=0 alt=>Introduction to SILC RNG</a><br />
53 &nbsp;&nbsp;&nbsp; <a href=silcrng.html><img src=box2.gif border=0 alt=>SILC RNG Interface</a><br />
54 &nbsp;&nbsp;&nbsp; <a href=silccipher.html><img src=box2.gif border=0 alt=>SILC Cipher API</a><br />
55 &nbsp;&nbsp;&nbsp; <a href=silcpkcs.html><img src=box2.gif border=0 alt=>SILC PKCS API</a><br />
56 &nbsp;&nbsp;&nbsp; <a href=silcpk.html><img src=box2.gif border=0 alt=>SILC Public Key API</a><br />
57 &nbsp;&nbsp;&nbsp; <a href=silcpkcs1.html><img src=box2.gif border=0 alt=>SILC PKCS #1 API</a><br />
58 &nbsp;&nbsp;&nbsp; <a href=silchash.html><img src=box2.gif border=0 alt=>SILC Hash Interface</a><br />
59 &nbsp;&nbsp;&nbsp; <a href=silchmac.html><img src=box2.gif border=0 alt=>SILC HMAC Interface</a><br />
60 <a href=silccorelib.html><img src=box.gif border=0 alt=>SILC Core Library</a><br />
61 &nbsp;&nbsp;&nbsp; <a href=silcauth.html><img src=box2.gif border=0 alt=>SILC Authentication Interface</a><br />
62 &nbsp;&nbsp;&nbsp; <a href=silcmessage.html><img src=box2.gif border=0 alt=>SILC Message Interface</a><br />
63 &nbsp;&nbsp;&nbsp; <a href=silcchannel.html><img src=box2.gif border=0 alt=>SILC Channel Interface</a><br />
64 &nbsp;&nbsp;&nbsp; <a href=silccommand.html><img src=box2.gif border=0 alt=>SILC Command Interface</a><br />
65 &nbsp;&nbsp;&nbsp; <a href=silcnotify.html><img src=box2.gif border=0 alt=>SILC Notify Interface</a><br />
66 &nbsp;&nbsp;&nbsp; <a href=silcstatus.html><img src=box2.gif border=0 alt=>SILC Status Types</a><br />
67 &nbsp;&nbsp;&nbsp; <a href=silcmode.html><img src=box2.gif border=0 alt=>SILC Modes</a><br />
68 &nbsp;&nbsp;&nbsp; <a href=silcid.html><img src=box2.gif border=0 alt=>SILC ID Interface</a><br />
69 &nbsp;&nbsp;&nbsp; <a href=silcargument.html><img src=box2.gif border=0 alt=>SILC Argument Interface</a><br />
70 &nbsp;&nbsp;&nbsp; <a href=silcattrs.html><img src=box2.gif border=0 alt=>SILC Attributes Interface</a><br />
71 &nbsp;&nbsp;&nbsp; <a href=silcpacket.html><img src=box2.gif border=0 alt=>Packet Engine Interface</a><br />
72 &nbsp;&nbsp;&nbsp; <a href=silcpubkey.html><img src=box2.gif border=0 alt=>SILC Public Key Payload Interface</a><br />
73 <a href=silcskelib.html><img src=box.gif border=0 alt=>SILC Key Exchange Library</a><br />
74 &nbsp;&nbsp;&nbsp; <a href=silcske.html><img src=box2.gif border=0 alt=>SILC SKE Interface</a><br />
75 &nbsp;&nbsp;&nbsp; <a href=silcconnauth.html><img src=box2.gif border=0 alt=>SILC Connection Authentication Interface</a><br />
76 <a href=silcvcardlib.html><img src=box.gif border=0 alt=>SILC VCard Library</a><br />
77 &nbsp;&nbsp;&nbsp; <a href=silcvcard.html><img src=box2.gif border=0 alt=>SILC VCard Interface</a><br />
78 <a href=silcmathlib.html><img src=box.gif border=0 alt=>SILC Math Library</a><br />
79 &nbsp;&nbsp;&nbsp; <a href=silcmp.html><img src=box2.gif border=0 alt=>SILC MP Interface</a><br />
80 &nbsp;&nbsp;&nbsp; <a href=silcmath.html><img src=box2.gif border=0 alt=>SILC Math Interface</a><br />
81 <a href=silcclientlib.html><img src=box.gif border=0 alt=>SILC Client Library</a><br />
82 &nbsp;&nbsp;&nbsp; <a href=silcclient_using.html><img src=box2.gif border=0 alt=>Using SILC Client Library Tutorial</a><br />
83 &nbsp;&nbsp;&nbsp; <a href=command_reply_args.html><img src=box2.gif border=0 alt=>Arguments for <b>command_reply</b> Client Operation</a><br />
84 &nbsp;&nbsp;&nbsp; <a href=silcstatus_args.html><img src=box2.gif border=0 alt=>SilcStatus Error Arguments in <b>command_reply</b> Client Operation</a><br />
85 &nbsp;&nbsp;&nbsp; <a href=notifyargs.html><img src=box2.gif border=0 alt=>Arguments for <b>notify</b> Client Operation</a><br />
86 &nbsp;&nbsp;&nbsp; <a href=silcclient_unicode.html><img src=box2.gif border=0 alt=>Unicode and UTF-8 Strings in Client Library</a><br />
87 &nbsp;&nbsp;&nbsp; <a href=silcclient.html><img src=box2.gif border=0 alt=>Client Library Interface Reference</a><br />
88 &nbsp;&nbsp;&nbsp; <a href=silcclient_entry.html><img src=box2.gif border=0 alt=>Client Entry Interface Reference</a><br />
89 <a href=silcasn1lib.html><img src=box.gif border=0 alt=>SILC ASN.1 Library</a><br />
90 &nbsp;&nbsp;&nbsp; <a href=silcasn1.html><img src=box2.gif border=0 alt=>SILC ASN.1 Interface</a><br />
91 &nbsp;&nbsp;&nbsp; <a href=silcber.html><img src=box2.gif border=0 alt=>SILC BER interface</a><br />
92 <a href=silchttplib.html><img src=box.gif border=0 alt=>SILC HTTP Library</a><br />
93 &nbsp;&nbsp;&nbsp; <a href=silchttpserver.html><img src=box2.gif border=0 alt=>SILC HTTP Server Interface</a><br />
94 &nbsp;&nbsp;&nbsp; <a href=silchttpphp.html><img src=box2.gif border=0 alt=>SILC HTTP PHP Translator</a><br />
95 <a href=silcutillib.html><img src=box.gif border=0 alt=>SILC Utility Library</a><br />
96 &nbsp;&nbsp;&nbsp; <a href=silctypes.html><img src=box2.gif border=0 alt=>Basic Types and Definitions</a><br />
97 &nbsp;&nbsp;&nbsp; <a href=silcbuffer.html><img src=box2.gif border=0 alt=>Data Buffer Interface</a><br />
98 &nbsp;&nbsp;&nbsp; <a href=silcbuffmt.html><img src=box2.gif border=0 alt=>Data Buffer Format Interface</a><br />
99 &nbsp;&nbsp;&nbsp; <a href=silchashtable.html><img src=box2.gif border=0 alt=>Hash Table Interface</a><br />
100 &nbsp;&nbsp;&nbsp; <a href=silcmemory.html><img src=box2.gif border=0 alt=>Memory Allocation Interface</a><br />
101 &nbsp;&nbsp;&nbsp; <a href=silcstack.html><img src=box2.gif border=0 alt=>Data Stack (memory pool) Interface</a><br />
102 &nbsp;&nbsp;&nbsp; <a href=silcfsm.html><img src=box2.gif border=0 alt=>Finite State Machine Interface</a><br />
103 &nbsp;&nbsp;&nbsp; <a href=silcthread.html><img src=box2.gif border=0 alt=>Thread Interface</a><br />
104 &nbsp;&nbsp;&nbsp; <a href=silcmutex.html><img src=box2.gif border=0 alt=>Mutual Exclusion Lock Interface</a><br />
105 &nbsp;&nbsp;&nbsp; <a href=silccond.html><img src=box2.gif border=0 alt=>Condition Variable Interface</a><br />
106 &nbsp;&nbsp;&nbsp; <a href=silcatomic.html><img src=box2.gif border=0 alt=>Atomic Operations Interface</a><br />
107 &nbsp;&nbsp;&nbsp; <a href=silcnet.html><img src=box2.gif border=0 alt=>Network (TCP and UDP) Interface</a><br />
108 &nbsp;&nbsp;&nbsp; <a href=silcschedule.html><img src=box2.gif border=0 alt=>Scheduler Interface</a><br />
109 &nbsp;&nbsp;&nbsp; <a href=silcasync.html><img src=box2.gif border=0 alt=>Asynchronous Operation Interface</a><br />
110 &nbsp;&nbsp;&nbsp; <a href=silcstream.html><img src=box2.gif border=0 alt=>Abstract Stream Interface</a><br />
111 &nbsp;&nbsp;&nbsp; <a href=silcsocketstream.html><img src=box2.gif border=0 alt=>Socket Stream Interface</a><br />
112 &nbsp;&nbsp;&nbsp; <a href=silcfdstream.html><img src=box2.gif border=0 alt=>File Descriptor Stream Interface</a><br />
113 &nbsp;&nbsp;&nbsp; <a href=silcfileutil.html><img src=box2.gif border=0 alt=>File Utility Functions</a><br />
114 &nbsp;&nbsp;&nbsp; <a href=silcstrutil.html><img src=box2.gif border=0 alt=>String Utility Interface</a><br />
115 &nbsp;&nbsp;&nbsp; <a href=silcsnprintf.html><img src=box2.gif border=0 alt=>Snprintf Interface</a><br />
116 &nbsp;&nbsp;&nbsp; <a href=silcutf8.html><img src=box2.gif border=0 alt=>UTF-8 String Interface</a><br />
117 &nbsp;&nbsp;&nbsp; <a href=silcstringprep.html><img src=box2.gif border=0 alt=>Stringprep Interface</a><br />
118 &nbsp;&nbsp;&nbsp; <a href=silcutil.html><img src=box2.gif border=0 alt=>Utility Functions</a><br />
119 &nbsp;&nbsp;&nbsp; <a href=silclist.html><img src=box2.gif border=0 alt=>List Interface</a><br />
120 &nbsp;&nbsp;&nbsp; <a href=silcdlist.html><img src=box2.gif border=0 alt=>Dynamic List Interface</a><br />
121 &nbsp;&nbsp;&nbsp; <a href=silcmime.html><img src=box2.gif border=0 alt=>MIME Interface</a><br />
122 &nbsp;&nbsp;&nbsp; <a href=silctime.html><img src=box2.gif border=0 alt=>Time Utility Functions</a><br />
123 &nbsp;&nbsp;&nbsp; <a href=silclog.html><img src=box2.gif border=0 alt=>Logging Interface</a><br />
124 &nbsp;&nbsp;&nbsp; <a href=silcconfig.html><img src=box2.gif border=0 alt=>Config File Interface</a><br />
125 <a href=silcskrlib.html><img src=box.gif border=0 alt=>SILC Key Repository Library</a><br />
126 &nbsp;&nbsp;&nbsp; <a href=silcskr.html><img src=box2.gif border=0 alt=>SILC SKR Interface</a><br />
127 <a href=silcaputillib.html><img src=box.gif border=0 alt=>SILC Application Utility Library</a><br />
128 &nbsp;&nbsp;&nbsp; <a href=silcapputil.html><img src=box2.gif border=0 alt=>SILC Application Utilities</a><br />
129 &nbsp;&nbsp;&nbsp; <a href=silcidcache.html><img src=box2.gif border=0 alt=>SILC ID Cache Interface</a><br />
130 <a href=silcsftplib.html><img src=box.gif border=0 alt=>SILC SFTP Library</a><br />
131 &nbsp;&nbsp;&nbsp; <a href=silcsftp.html><img src=box2.gif border=0 alt=>SILC SFTP Interface</a><br />
132 &nbsp;&nbsp;&nbsp; <a href=silcsftp_fs.html><img src=box2.gif border=0 alt=>SFTP Filesystems Interface</a><br />
133
134 <br />
135 <b>Resource Links</b>
136 <br />
137 <a href="http://silcnet.org"><img src="box.gif" border="0" alt="">SILC Project Website</a><br />
138 <a href="http://silcnet.org/support/documentation/"><img src="box.gif" border="0" alt="">SILC Protocol Documentation</a><br />
139 <a href="http://silcnet.org/support/documentation/wp/"><img src="box.gif" border="0" alt="">SILC White Paper</a><br />
140 <a href="http://silcnet.org/support/faq/"><img src="box.gif" border="0" alt="">SILC FAQs</a><br />
141
142 </small>
143 <br /><br /><br /><br />
144     </td></tr>
145    </table>
146   </td>
147
148   <td bgcolor="#cccccc" background="dot.gif">
149    <img src="space.gif" width="1" height="1" border="0" alt=""></td>
150
151   <td width="720" bgcolor="#ffffff">
152    <img src="space.gif" width="1" height="1" border="0" alt="">
153    <table cellpadding="2" cellspacing="6" width="100%">
154     <tr><td valign="top">
155 <br />
156 <big><b>Introduction to Random Number Generator</b></big>
157
158 <br />&nbsp;<br />&nbsp;<br />
159 <b>Overview</b>
160
161 <br />&nbsp;<br />
162 SILC Random Number Generator is cryptographically strong pseudo random
163 number generator. It is used to generate all the random numbers needed
164 in the SILC sessions. All key material and other sources needing random
165 numbers use this generator.
166
167 <br />&nbsp;<br />
168 The RNG has a random pool of 1024 bytes of size that provides the actual
169 random numbers for the application. The pool is initialized when the
170 RNG is allocated and initialized with silc_rng_alloc and silc_rng_init
171 functions, respectively. 
172
173
174 <br />&nbsp;<br />&nbsp;<br />
175 <b>Random Pool Initialization</b>
176
177 <br />&nbsp;<br />
178 The RNG's random pool is the source of all random output data. The pool is
179 initialized with silc_rng_init and application can reseed it at any time
180 by calling the silc_rng_add_noise function.
181
182 <br />&nbsp;<br />
183 The initializing phase attempts to set the random pool in a state that it
184 is impossible to learn the input data to the RNG or any random output
185 data. This is achieved by acquiring noise from various system sources. The
186 first source is called to provide "soft noise". This noise is various
187 data from system's processes. The second source is called to provide
188 "medium noise". This noise is various output data from executed commands.
189 Usually the commands are Unix `ps' and `ls' commands with various options.
190 The last source is called to provide "hard noise" and is noise from
191 system's /dev/random, if it exists.
192
193
194 <br />&nbsp;<br />&nbsp;<br />
195 <b>Stirring the Random Pool</b>
196
197 <br />&nbsp;<br />
198 Every time data is acquired from any source, the pool is stirred. The
199 stirring process performs an CFB (cipher feedback) encryption with SHA1
200 algorithm to the entire random pool. First it acquires an IV (Initial
201 Vector) from the constant (random) location of the pool and performs
202 the first CFB pass. Then it acquires a new encryption key from variable
203 location of the pool and performs the second CFB pass. The encryption
204 key thus is always acquired from unguessable data.
205
206 <br />&nbsp;<br />
207 The encryption process to the entire random pool assures that it is
208 impossible to learn the input data to the random pool without breaking the
209 encryption process. This would effectively mean breaking the SHA1 hash
210 function. The encryption process also assures that each random output from
211 the random pool is secured with cryptographically strong function, the
212 SHA1 in this case.
213
214 <br />&nbsp;<br />
215 The random pool can be restirred by the application at any point by
216 calling the silc_rng_add_noise function. This function adds new noise to
217 the pool and then stirs the entire pool.
218
219
220 <br />&nbsp;<br />&nbsp;<br />
221 <b>Stirring Thresholds</b>
222
223 <br />&nbsp;<br />
224 The random pool has two thresholds that controls when the random pool
225 needs more new noise and requires restirring. As previously mentioned, the
226 application may do this by calling the silc_rng_add_noise. However, the
227 RNG performs this also automatically.
228
229 <br />&nbsp;<br />
230 The first threshold gets soft noise from system and stirs the random pool.
231 The threshold is reached after 64 bits of random data has been fetched
232 from the RNG. After the 64 bits, the soft noise acquiring and restirring
233 process is performed every 8 bits of random output data until the second
234 threshold is reached.
235
236 <br />&nbsp;<br />
237 The second threshold gets hard noise from system and stirs the random
238 pool. The threshold is reached after 160 bits of random output. After the
239 noise is acquired (from /dev/urandom) the random pool is stirred and the
240 thresholds are set to zero. The process is repeated again after 64 bits of
241 output for first threshold and after 160 bits of output for the second
242 threshold.
243
244
245 <br />&nbsp;<br />&nbsp;<br />
246 <b>Internal State of the Random Pool</b>
247
248 <br />&nbsp;<br />
249 The random pool has also internal state that provides several variable
250 distinct points to the random pool where the data is fetched. The state
251 changes every 8 bits of output data and it is guaranteed that the fetched
252 8 bits of data is from distinct location compared to the previous 8 bits.
253 It is also guaranteed that the internal state never wraps before
254 restirring the entire random pool. The internal state means that the data
255 is not fetched linearly from the pool, eg. starting from zero and wrapping
256 at the end of the pool. The internal state is not dependent of any random
257 data in the pool. The internal states are initialized (by default the pool
258 is splitted to four different sections (states)) at the RNG
259 initialization phase. The state's current position is added linearly and
260 wraps at the the start of the next state. The states provides the distinct
261 locations.
262
263
264 <br />&nbsp;<br />&nbsp;<br />
265 <b>Security Considerations</b>
266
267 <br />&nbsp;<br />
268 The security of this random number generator, like of any other RNG's,
269 depends of the initial state of the RNG. The initial state of the random
270 number generators must be unknown to an adversary. This means that after
271 the RNG is initialized it is required that the input data to the RNG and
272 the output data to the application has no correlation of any kind that
273 could be used to compromise the acquired random numbers or any future
274 random numbers. 
275
276 <br />&nbsp;<br />
277 It is, however, clear that the correlation exists but it needs to be
278 hard to solve for an adversary. To accomplish this the input data to the
279 random number generator needs to be secret. Usually this is impossible to
280 achieve. That is why SILC's RNG acquires the noise from three different
281 sources and provides for the application an interface to add more noise at
282 any time. The first source ("soft noise") is known to the adversary but
283 requires exact timing to get all of the input data. However, getting only
284 partial data is easy. The second source ("medium noise") depends on the
285 place of execution of the application. Getting at least partial data is
286 easy but securing for example the user's home directory from outside access
287 makes it harder. The last source ("hard noise") is considered to be the
288 most secure source of data. An adversary is not considered to have any
289 access on this data. This of course greatly depends on the operating system.
290
291 <br />&nbsp;<br />
292 These three sources are considered to be adequate since the random pool is
293 relatively large and the output of each bit of the random pool is secured
294 by cryptographically secure function, the SHA1 in CFB mode encryption.
295 Furthermore the application may provide other random data, such as random
296 key strokes or mouse movement to the RNG. However, it is recommended that
297 the application would not be the single point of source for the RNG, in
298 either intializing or reseeding phases later in the session. Good solution
299 is probably to use both, the application's seeds and the RNG's own
300 sources, equally.
301
302 <br />&nbsp;<br />
303 The RNG must also assure that any old or future random numbers are not
304 compromised if an adversary would learn the initial input data (or any
305 input data for that matter). The SILC's RNG provides good protection for
306 this even if the some of the input bits would be compromised for old or
307 future random numbers. The RNG reinitalizes (reseeds) itself using the
308 thresholds after every 64 and 160 bits of output. This is considered to be
309 adequate even if some of the bits would get compromised. Also, the
310 applications that use the RNG usually fetches at least 256 bits from the
311 RNG. This means that everytime RNG is accessed both of the thresholds are
312 reached. This should mean that the RNG is never too long in an compromised
313 state and recovers as fast as possible.
314
315
316 <br />&nbsp;<br />&nbsp;<br />
317 <b>Caveat Windows Programmer</b>
318
319 <br />&nbsp;<br />
320 The caller must be cautios when using this RNG with native WIN32 system.
321 The RNG most likely is impossible to set in unguessable state just by
322 using the RNG's input data sources.  On WIN32 it is stronly suggested
323 that caller would add more random noise after the initialization of the
324 RNG using the silc_rng_add_noise function.  For example, random mouse
325 movements may be used.
326
327 <br /><br /><br /><br />
328     </td></tr>
329    </table>
330   </td>
331
332   <td bgcolor="#cccccc" background="dot.gif">
333    <img src="space.gif" width="1" height="1" border="0" alt=""></td>
334
335   <td width="180" bgcolor="#f0f0f0">
336     <img src="space.gif" width="1" height="1" border="0" alt="">
337     <table width="100%" cellpadding="4" cellspacing="0">
338     <tr valign="top"><td>
339 <br />
340 <font face="Helvetica,Arial,Sans-serif" size="1">
341 </font>
342
343 <br /><br /><br /><br />
344     </td></tr>
345     </table>
346   </td>
347 </tr>
348 </table>
349
350 <table border="0" cellspacing="0" cellpadding="0" width="100%">
351 <tr bgcolor="#444444"><td><img src="space.gif" width="1" height="1"border="0" alt="" ></td></tr>
352 </table>
353 <table border="0" cellspacing="0" cellpadding="6" width="100%">
354  <tr valign="top" bgcolor="#dddddd">
355   <td><small>Copyright &copy; 2001 - 2007 SILC Project<br />
356     <a href="http://silcnet.org">SILC Project Website</a></small></td>
357   <td align="right"><small>
358    <a href="index.html">SILC Toolkit Reference Manual</a><br />
359    <a href="toolkit_index.html">Index</a></small></td>
360    </small></td>
361  </tr>
362 </table>
363
364 </body>
365 </html>