3 * $Id: rand.h,v 1.1 1997/08/07 09:46:05 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.1 1997/08/07 09:46:05 mdw
33 * New source file added to maintain a randomness pool.
44 /*----- Required headers --------------------------------------------------*/
52 /*----- Functions provided ------------------------------------------------*/
54 /* --- @rand_read@ --- *
56 * Arguments: @FILE *fp@ = pointer to file to read from
60 * Use: Reads a random number seed from the stream.
63 extern void rand_read(FILE */
*fp*/
);
65 /* --- @rand_write@ --- *
67 * Arguments: @FILE *fp@ = pointer to file to write on
71 * Use: Writes a random number seed back to the stream.
74 extern void rand_write(FILE */
*fp*/
);
76 /* --- @rand_clear@ --- *
82 * Use: Clears the random number pool.
85 extern void rand_clear(void);
87 /* --- @rand_encrypt@ --- *
89 * Arguments: @icrypt_job *j@ = pointer to an encryption job to apply
93 * Use: Encrypts the randomness pool with a given key. This should
94 * be done before use, in case the pool gets compromised.
97 extern void rand_encrypt(icrypt_job */
*j*/
);
99 /* --- @rand_add@ --- *
101 * Arguments: @const void *p@ = pointer to some data
102 * @size_t sz@ = size of the data in bytes
106 * Use: Adds entropy to the pool.
109 extern void rand_add(const void */
*p*/
, size_t /*sz*/);
111 /* --- @rand_extract@ --- *
113 * Arguments: @unsigned char *b@ = pointer to output buffer
114 * @size_t sz@ = number of bytes wanted
118 * Use: Produces a number of random bytes.
121 extern void rand_extract(unsigned char */
*b*/
, size_t /*sz*/);
123 /* --- @rand_churn@ --- *
129 * Use: Churns the randomness pool completely. The pool is replaced
130 * by repeated MD5-ings of itself.
133 extern void rand_churn(void);
135 /*----- That's all, folks -------------------------------------------------*/