X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/16efb197c59c4b4cfaef7b2f23bd39f70176dd9e..a90d420cbe87490c844ae422c966e746d3134b07:/rand/rand.h diff --git a/rand/rand.h b/rand/rand.h index 3c2fa738..5584c54d 100644 --- a/rand/rand.h +++ b/rand/rand.h @@ -99,8 +99,9 @@ typedef struct rand_pool { octet pool[RAND_POOLSZ]; /* Actual contents of the pool */ - unsigned i; /* Current index into pool */ - unsigned irot; /* Current rotation applied */ + unsigned gen; /* Generation number */ + unsigned short i; /* Current index into pool */ + unsigned short irot; /* Current rotation applied */ unsigned ibits; /* Number of good bits in pool */ octet buf[RAND_BUFSZ]; /* Random octet output buffer */ unsigned o; /* Current index into buffer */ @@ -132,6 +133,20 @@ typedef struct rand_source { extern void rand_init(rand_pool */*r*/); +/* --- @rand_generation@ --- * + * + * Arguments: --- + * + * Returns: A nonzero generation number. + * + * Use: Returns a generation number for the current process. Each + * pool has its own number. If this matches the process number + * then all is well. If it doesn't match, then the pool needs + * to be cleaned before its next use. + */ + +extern unsigned rand_generation(void); + /* --- @rand_noisesrc@ --- * * * Arguments: @rand_pool *r@ = pointer to a randomness pool @@ -180,6 +195,19 @@ extern void rand_seed(rand_pool */*r*/, unsigned /*bits*/); extern void rand_key(rand_pool */*r*/, const void */*k*/, size_t /*sz*/); +/* --- @rand_quick@ --- * + * + * Arguments: @rand_pool *r@ = pointer to a randomness pool + * + * Returns: Zero on success; @-1@ on failure. + * + * Use Attempts to use some machine-specific `quick' source of + * entropy to top up @r@. This may not do anything at all on + * many systems. + */ + +extern int rand_quick(rand_pool */*r*/); + /* --- @rand_add@ --- * * * Arguments: @rand_pool *r@ = pointer to a randomness pool