From e92d6ed5e7e5b5d4f1a2351eb96a4561bda3c002 Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Fri, 16 Jun 2000 01:38:13 +0000 Subject: [PATCH] snapshot --- lib/isc/include/isc/entropy.h | 29 +++++++++++++++++++++++++++++ lib/isc/unix/entropy.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/lib/isc/include/isc/entropy.h b/lib/isc/include/isc/entropy.h index e59254ca95..447b3b99c0 100644 --- a/lib/isc/include/isc/entropy.h +++ b/lib/isc/include/isc/entropy.h @@ -64,6 +64,19 @@ ISC_LANG_BEGINDECLS +/* + * Entropy callback function. + */ +typedef isc_result_t (*isc_entropystart_t)(isc_entropy_t *ent, + isc_entropysource_t *source, + void *arg); +typedef isc_result_t (*isc_entropyget_t)(isc_entropy_t *ent, + isc_entropysource_t *source, + void *arg, unsigned int entropy); +typedef void (*isc_entropystop_t)(isc_entropy_t *ent, + isc_entropysource_t *source, + void *arg); + /*** *** Flags. ***/ @@ -156,6 +169,22 @@ isc_entropy_createsamplesource(isc_entropy_t *ent, * to the source via isc_entropy_addsamples(), below. */ +isc_result_t +isc_entropy_createcallbacksource(isc_entropy_t *ent, + isc_entropystart_t start, + isc_entropyget_t get, + isc_entropystop_t stop, + void *arg, + isc_entropysource_t **sourcep); +/* + * Create an entropy source that is polled via a callback. This would + * be used when keyboard input is used, or a GUI input method. It can + * also be used to hook in any external entropy source. + */ + +void +isc_entropy_resetcallbacksources(isc_entropy_t *ent); + void isc_entropy_addsample(isc_entropysource_t *source, isc_uint32_t sample, isc_uint32_t extra); diff --git a/lib/isc/unix/entropy.c b/lib/isc/unix/entropy.c index 0ba1be4c7b..7adc3e5f03 100644 --- a/lib/isc/unix/entropy.c +++ b/lib/isc/unix/entropy.c @@ -98,6 +98,10 @@ typedef struct { isc_uint32_t *extra; /* extra samples added in */ } isc_entropysamplesource_t ; +typedef struct { + isc_boolean_t msg_printed; +} isc_entropycallbacksource_t; + typedef struct { int fd; /* fd for the file, or -1 if closed */ } isc_entropyfilesource_t; @@ -118,6 +122,7 @@ struct isc_entropysource { #define ENTROPY_SOURCETYPE_SAMPLE 1 /* Type is a sample source */ #define ENTROPY_SOURCETYPE_FILE 2 /* Type is a file source */ +#define ENTROPY_SOURCETYPE_CALLBACK 3 /* Type is a callback source */ /* * The random pool "taps" @@ -908,6 +913,30 @@ isc_entropy_destroysource(isc_entropysource_t **sourcep) { destroy(&ent); } +isc_result_t +isc_entropy_createcallbacksource(isc_entropy_t *ent, + isc_entropystart_t start, + isc_entropyget_t get, + isc_entropystop_t stop, + void *arg, + isc_entropysource_t **sourcep) +{ + REQUIRE(VALID_ENTROPY(ent)); + REQUIRE(sourcep != NULL && *sourcep == NULL); + + LOCK(&ent->lock); + + ent->nsources++; + + UNLOCK(&ent->lock); + + return (ISC_R_NOTIMPLEMENTED); +} + +void +isc_entropy_resetcallbacksources(isc_entropy_t *ent) { +} + isc_result_t isc_entropy_createsamplesource(isc_entropy_t *ent, isc_entropysource_t **sourcep)