X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d03ab969116fe715d569304c1c474749b2f64529..4ab1268f3ec850a115a68966325aced4f08ec603:/rand.h diff --git a/rand.h b/rand.h index 8ccd38c..543af41 100644 --- a/rand.h +++ b/rand.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rand.h,v 1.1 1999/09/03 08:41:12 mdw Exp $ + * $Id: rand.h,v 1.4 1999/12/10 23:29:48 mdw Exp $ * * Secure random number generator * @@ -30,6 +30,15 @@ /*----- Revision history --------------------------------------------------* * * $Log: rand.h,v $ + * Revision 1.4 1999/12/10 23:29:48 mdw + * Change header file guard names. + * + * Revision 1.3 1999/10/15 21:04:30 mdw + * Increase output buffer a bit for performance. + * + * Revision 1.2 1999/10/12 21:00:15 mdw + * Make pool and buffer sizes more sensible. + * * Revision 1.1 1999/09/03 08:41:12 mdw * Initial import. * @@ -47,7 +56,7 @@ * concerns I expressed about the Linux generator in a Usenet article to * sci.crypt. * - * The generator is divided into two parts: an input pool and an outpu + * The generator is divided into two parts: an input pool and an output * buffer. New random data is placed into the pool in the way described * below, which is shamelessly stolen from the Linux /dev/random generator. * The only interaction that the pool has on the output buffer is through the @@ -74,8 +83,8 @@ * an adversary has to guess before predicting generator output. */ -#ifndef RAND_H -#define RAND_H +#ifndef CATACOMB_RAND_H +#define CATACOMB_RAND_H #ifdef __cplusplus extern "C" { @@ -85,12 +94,18 @@ #include -#include "rmd160-hmac.h" +#ifndef CATACOMB_GRAND_H +# include "grand.h" +#endif + +#ifndef CATACOMB_RMD160_HMAC_H +# include "rmd160-hmac.h" +#endif /*----- Magic numbers -----------------------------------------------------*/ -#define RAND_POOLSZ 1279 /* Input pool size in bytes */ -#define RAND_BUFSZ 1024 /* Output buffer size in bytes */ +#define RAND_POOLSZ 128 /* Input pool size in bytes */ +#define RAND_BUFSZ 512 /* Output buffer size in bytes */ #define RAND_SECSZ 20 /* Secret octets in output buffer */ #define RAND_IBITS (RAND_POOLSZ * 8) @@ -261,6 +276,33 @@ extern void rand_get(rand_pool */*r*/, void */*p*/, size_t /*sz*/); extern void rand_getgood(rand_pool */*r*/, void */*p*/, size_t /*sz*/); +/*----- Generic random number generator interface -------------------------*/ + +/* --- Miscellaneous operations --- */ + +enum { + RAND_GATE = GRAND_SPECIFIC, /* No args */ + RAND_STRETCH, /* No args */ + RAND_KEY, /* @const void *k, size_t sz@ */ + RAND_NOISESRC /* @const rand_source *s@ */ +}; + +/* --- Default random number generator --- */ + +extern grand rand_global; + +/* --- @rand_create@ --- * + * + * Arguments: --- + * + * Returns: Pointer to a generic generator. + * + * Use: Constructs a generic generator interface over a Catacomb + * entropy pool generator. + */ + +extern grand *rand_create(void); + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus