entropy.c File Reference

#include <config.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <isc/platform.h>
#include <isc/strerror.h>
#include "errno2result.h"
#include "../entropy.c"

Go to the source code of this file.

Data Structures

struct  isc_entropyusocketsource_t

Defines

#define FILESOURCE_HANDLE_TYPE   int
 There is only one variable in the entropy data structures that is not system independent, but pulling the structure that uses it into this file ultimately means pulling several other independent structures here also to resolve their interdependencies. Thus only the problem variable's type is defined here.

Functions

static unsigned int get_from_filesource (isc_entropysource_t *source, isc_uint32_t desired)
static unsigned int get_from_usocketsource (isc_entropysource_t *source, isc_uint32_t desired)
static void fillpool (isc_entropy_t *ent, unsigned int desired, isc_boolean_t blocking)
static int wait_for_sources (isc_entropy_t *ent)
static void destroyfilesource (isc_entropyfilesource_t *source)
static void destroyusocketsource (isc_entropyusocketsource_t *source)
static isc_result_t make_nonblock (int fd)
isc_result_t isc_entropy_createfilesource (isc_entropy_t *ent, const char *fname)
 Create a new entropy source from a file.


Define Documentation

#define FILESOURCE_HANDLE_TYPE   int

There is only one variable in the entropy data structures that is not system independent, but pulling the structure that uses it into this file ultimately means pulling several other independent structures here also to resolve their interdependencies. Thus only the problem variable's type is defined here.

Definition at line 55 of file entropy.c.


Function Documentation

static unsigned int get_from_filesource ( isc_entropysource_t source,
isc_uint32_t  desired 
) [static]

Definition at line 73 of file entropy.c.

References isc_entropysource::ent, entropypool_adddata(), ISC_MIN, ISC_TRUE, and isc_entropysource::sources.

Referenced by fillpool().

static unsigned int get_from_usocketsource ( isc_entropysource_t source,
isc_uint32_t  desired 
) [static]

Definition at line 113 of file entropy.c.

References isc_entropysource::ent, entropypool_adddata(), INSIST, ISC_MIN, ISC_TRUE, and isc_entropysource::sources.

Referenced by fillpool().

static void fillpool ( isc_entropy_t ent,
unsigned int  desired,
isc_boolean_t  blocking 
) [static]

Definition at line 250 of file entropy.c.

References isc_entropypool_t::entropy, ENTROPY_SOURCETYPE_CALLBACK, ENTROPY_SOURCETYPE_FILE, ENTROPY_SOURCETYPE_USOCKET, get_from_callback(), get_from_filesource(), get_from_usocketsource(), isc_entropy::initialized, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_MAX, ISC_MIN, isc_entropy::nextsource, isc_entropy::nsources, isc_entropy::pool, isc_entropypool_t::pseudo, REQUIRE, RND_POOLBITS, THRESHOLD_BITS, isc_entropysource::type, VALID_ENTROPY, and wait_for_sources().

static int wait_for_sources ( isc_entropy_t ent  )  [static]

Definition at line 390 of file entropy.c.

References ENTROPY_SOURCETYPE_FILE, ENTROPY_SOURCETYPE_USOCKET, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_MAX, isc_entropysource::sources, and isc_entropysource::type.

static void destroyfilesource ( isc_entropyfilesource_t source  )  [static]

Definition at line 444 of file entropy.c.

References isc_entropyfilesource_t::handle.

static void destroyusocketsource ( isc_entropyusocketsource_t source  )  [static]

Definition at line 449 of file entropy.c.

References isc_entropyusocketsource_t::handle.

static isc_result_t make_nonblock ( int  fd  )  [static]

Definition at line 457 of file entropy.c.

References isc__strerror(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, and UNEXPECTED_ERROR.

Referenced by internal_accept(), and isc_entropy_createfilesource().

isc_result_t isc_entropy_createfilesource ( isc_entropy_t ent,
const char *  fname 
)

Create a new entropy source from a file.

The file is assumed to contain good randomness, and will be mixed directly into the pool with every byte adding 8 bits of entropy.

The file will be put into non-blocking mode, so it may be a device file, such as /dev/random. /dev/urandom should not be used here if it can be avoided, since it will always provide data even if it isn't good. We will make as much pseudorandom data as we need internally if our caller asks for it.

If we hit end-of-file, we will stop reading from this source. Callers who require strong random data will get failure when our pool drains. The file will never be opened/read again once EOF is reached.

Definition at line 488 of file entropy.c.

References isc_entropysource::ent, ENTROPY_SOURCETYPE_FILE, ENTROPY_SOURCETYPE_USOCKET, isc__errno2result, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_APPEND, isc_mem_get, ISC_R_NOMEMORY, ISC_R_SUCCESS, ISC_TRUE, isc_entropy::lock, LOCK, isc_entropysource::magic, make_nonblock(), isc_entropy::mctx, isc_entropy::nsources, REQUIRE, SOURCE_MAGIC, isc_entropysource::sources, isc_entropysource::total, isc_entropysource::type, UNLOCK, and VALID_ENTROPY.

Referenced by isc_entropy_usebestsource(), load_configuration(), and setup().


Generated on Tue Apr 28 17:41:14 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha