mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Use the entropy api
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/entropy.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -34,6 +35,8 @@
|
||||
extern int verbose;
|
||||
extern const char *program;
|
||||
|
||||
static isc_entropysource_t *devrandom = NULL;
|
||||
|
||||
void
|
||||
fatal(const char *format, ...) {
|
||||
va_list args;
|
||||
@@ -165,3 +168,19 @@ setup_logging(int verbose, isc_mem_t *mctx, isc_log_t **logp) {
|
||||
*logp = log;
|
||||
}
|
||||
|
||||
void
|
||||
setup_entropy(isc_mem_t *mctx, isc_entropy_t **ectx) {
|
||||
isc_result_t result;
|
||||
result = isc_entropy_create(mctx, ectx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("could not create entropy object");
|
||||
(void) isc_entropy_createfilesource(*ectx, "/dev/random", 0,
|
||||
&devrandom);
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_entropy(isc_entropy_t **ectx) {
|
||||
if (devrandom != NULL)
|
||||
isc_entropy_destroysource(&devrandom);
|
||||
isc_entropy_detach(ectx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user