3 * $Id: rand.h,v 1.2 1998/01/12 16:46:24 mdw Exp $
5 * Random number generation
10 /*----- Licencing notice --------------------------------------------------*
12 * This file is part of Become.
14 * Become is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * Become is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Become; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.2 1998/01/12 16:46:24 mdw
35 * Revision 1.1 1997/08/07 09:46:05 mdw
36 * New source file added to maintain a randomness pool.
47 /*----- Required headers --------------------------------------------------*/
55 /*----- Functions provided ------------------------------------------------*/
57 /* --- @rand_read@ --- *
59 * Arguments: @FILE *fp@ = pointer to file to read from
63 * Use: Reads a random number seed from the stream.
66 extern void rand_read(FILE */*fp*/);
68 /* --- @rand_write@ --- *
70 * Arguments: @FILE *fp@ = pointer to file to write on
74 * Use: Writes a random number seed back to the stream.
77 extern void rand_write(FILE */*fp*/);
79 /* --- @rand_clear@ --- *
85 * Use: Clears the random number pool.
88 extern void rand_clear(void);
90 /* --- @rand_encrypt@ --- *
92 * Arguments: @icrypt_job *j@ = pointer to an encryption job to apply
96 * Use: Encrypts the randomness pool with a given key. This should
97 * be done before use, in case the pool gets compromised.
100 extern void rand_encrypt(icrypt_job */*j*/);
102 /* --- @rand_add@ --- *
104 * Arguments: @const void *p@ = pointer to some data
105 * @size_t sz@ = size of the data in bytes
109 * Use: Adds entropy to the pool.
112 extern void rand_add(const void */*p*/, size_t /*sz*/);
114 /* --- @rand_extract@ --- *
116 * Arguments: @unsigned char *b@ = pointer to output buffer
117 * @size_t sz@ = number of bytes wanted
121 * Use: Produces a number of random bytes.
124 extern void rand_extract(unsigned char */*b*/, size_t /*sz*/);
126 /* --- @rand_churn@ --- *
132 * Use: Churns the randomness pool completely. The pool is replaced
133 * by repeated MD5-ings of itself.
136 extern void rand_churn(void);
138 /*----- That's all, folks -------------------------------------------------*/