/* Copyright 1999 Enhanced Software Technologies Inc.
 * Released for public use under a BSD-style Open Source license. 
 * See file LICENSE.ocotillo for more information. 
 *   
 * ocrandom.h -- Ocotillo pseudo-random number generator, by Eric Green
 *
 * Feeds two entropy pools into a TwoFish block cipher, which then stirs an
 * output pool. See README.ocotillo for more info.
 *
 * RCS CHANGE LOG
 * Revision 1.1  2001/01/06 10:46:00  eric
 * Initial checkin of ocotillo.
 *
 * Revision 1.3  1999/09/17 21:19:04  eric
 * Initial checkin?
 *
 * Revision 1.2  1999/09/13 16:02:10  eric
 * Added licensing information to source.
 *
 * Revision 1.1  1999/09/10 00:06:05  eric
 * Initial checkin, Ocotillo pseudo-random number generator.
 *
 *
 *
 */

#ifndef OCRANDOM_H
#define OCRANDOM_H 1

#include "md5.h"


/***************************** Entropy pools: ***************************/
typedef struct ent_pool_struct {
  MD5_CTX pool;                
  MD5_CTX output_buffer;         /* a temp used for output.     */
} ent_pool;

/* Initialize a new entropy pool */
int init_ent_pool(ent_pool *pool); 
/* Stir some new entropy into the pool: */
int stir_ent_pool(ent_pool *pool, unsigned char *entropy, unsigned int numbytes);

/* Get values out of the pool, without disturbing it */
unsigned char *get_pool_value(ent_pool *pool);

/* Add a file to the pool: */
int add_file_to_pool(ent_pool *pool, char *filename);

/*********************** Random Numbers: *****************************/
/* There is only one PRNG for the program, for reasons of entropy... */
/*********************************************************************/
int oc_start(void);                       /* initialize the entropy pools */
int oc_stir(char *entropy, int numbytes); /* stir the input pool, possibly
					     stirring the key pool.   */
unsigned char *oc_random(int numbytes);  /* get a random number, or best
					    we can do anyhow. */



#endif
