This commit is contained in:
Michael Graff 2000-06-16 01:38:13 +00:00
parent 8bbc3795bf
commit e92d6ed5e7
2 changed files with 58 additions and 0 deletions

View file

@ -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);

View file

@ -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)