random.c File Reference

#include "wizard/studio.h"
#include "wizard/entropy.h"
#include "wizard/exception.h"
#include "wizard/exception-private.h"
#include "wizard/file.h"
#include "wizard/hash.h"
#include "wizard/magick.h"
#include "wizard/memory_.h"
#include "wizard/random_.h"
#include "wizard/thread_.h"
#include "wizard/thread-private.h"
#include "wizard/semaphore.h"
Include dependency graph for random.c:

Go to the source code of this file.

Data Structures

struct  _RandomInfo

Defines

#define PseudoRandomHash   SHA256Hash
#define RandomEntropyLevel   9
#define RandomFilename   "reservoir.xdm"
#define RandomFiletype   "random"
#define RandomProtocolMajorVersion   1
#define RandomProtocolMinorVersion   1
#define MaxEntropyExtent   64

Functions

static WizardBooleanType SaveEntropyToReservoir (RandomInfo *, ExceptionInfo *)
static StringInfoGenerateEntropicChaos (RandomInfo *, ExceptionInfo *)
static StringInfo ** GetEntropyFromReservoir (RandomInfo *, ExceptionInfo *)
static size_t WizardMin (const size_t x, const size_t y)
WizardExport RandomInfoAcquireRandomInfo (const HashType hash)
WizardExport RandomInfoDestroyRandomInfo (RandomInfo *random_info)
static ssize_t ReadRandom (int file, unsigned char *source, size_t length)
WizardExport double GetPseudoRandomValue (RandomInfo *random_info)
WizardExport StringInfoGetRandomKey (RandomInfo *random_info, const size_t length)
WizardExport double GetRandomValue (RandomInfo *random_info)
WizardExport WizardBooleanType RandomComponentGenesis (void)
WizardExport void RandomComponentTerminus (void)
WizardExport void SeedPseudoRandomGenerator (const size_t seed)
static void IncrementRandomNonce (StringInfo *nonce)
WizardExport void SetRandomKey (RandomInfo *random_info, const size_t length, unsigned char *key)
WizardExport void SetRandomTrueRandom (const WizardBooleanType true_random)

Variables

char ** environ
static SemaphoreInforandom_semaphore = (SemaphoreInfo *) NULL
static size_t random_seed = ~0UL
static WizardBooleanType gather_true_random = WizardFalse

Define Documentation

#define MaxEntropyExtent   64

Referenced by GenerateEntropicChaos().

#define PseudoRandomHash   SHA256Hash

Definition at line 61 of file random.c.

Referenced by AcquireRandomInfo().

#define RandomEntropyLevel   9

Definition at line 62 of file random.c.

Referenced by GenerateEntropicChaos().

#define RandomFilename   "reservoir.xdm"

Definition at line 63 of file random.c.

Referenced by GetEntropyFromReservoir(), and SaveEntropyToReservoir().

#define RandomFiletype   "random"

Definition at line 64 of file random.c.

Referenced by GetEntropyFromReservoir(), and SaveEntropyToReservoir().

#define RandomProtocolMajorVersion   1

Definition at line 65 of file random.c.

Referenced by AcquireRandomInfo().

#define RandomProtocolMinorVersion   1

Definition at line 66 of file random.c.

Referenced by AcquireRandomInfo().


Function Documentation

WizardExport RandomInfo* AcquireRandomInfo ( const HashType  hash  ) 
WizardExport RandomInfo* DestroyRandomInfo ( RandomInfo random_info  ) 
static StringInfo * GenerateEntropicChaos ( RandomInfo random_info,
ExceptionInfo exception 
) [static]
static StringInfo * GetEntropyFromReservoir ( RandomInfo random_info,
ExceptionInfo exception 
)
WizardExport double GetPseudoRandomValue ( RandomInfo random_info  ) 

Definition at line 770 of file random.c.

References _RandomInfo::normalize, and _RandomInfo::seed.

WizardExport StringInfo* GetRandomKey ( RandomInfo random_info,
const size_t  length 
)
WizardExport double GetRandomValue ( RandomInfo random_info  ) 

Definition at line 846 of file random.c.

References SetRandomKey().

static void IncrementRandomNonce ( StringInfo nonce  )  [inline, static]

Definition at line 1045 of file random.c.

References GetStringInfoDatum(), GetStringInfoLength(), RandomFatalError, and ThrowFatalException.

Referenced by SetRandomKey().

WizardExport WizardBooleanType RandomComponentGenesis ( void   ) 

Definition at line 878 of file random.c.

References AcquireSemaphoreInfo(), random_semaphore, and WizardTrue.

Referenced by WizardsToolkitGenesis().

WizardExport void RandomComponentTerminus ( void   ) 

Definition at line 902 of file random.c.

References AcquireSemaphoreInfo(), DestroySemaphoreInfo(), and random_semaphore.

Referenced by WizardsToolkitTerminus().

static ssize_t ReadRandom ( int  file,
unsigned char *  source,
size_t  length 
) [static]

Definition at line 330 of file random.c.

References read.

Referenced by GenerateEntropicChaos().

static WizardBooleanType SaveEntropyToReservoir ( RandomInfo random_info,
ExceptionInfo exception 
) [static]
WizardExport void SeedPseudoRandomGenerator ( const size_t  seed  ) 

Definition at line 1012 of file random.c.

References random_seed.

WizardExport void SetRandomKey ( RandomInfo random_info,
const size_t  length,
unsigned char *  key 
)
WizardExport void SetRandomTrueRandom ( const WizardBooleanType  true_random  ) 

Definition at line 1142 of file random.c.

References gather_true_random.

static size_t WizardMin ( const size_t  x,
const size_t  y 
) [inline, static]

Definition at line 159 of file random.c.

Referenced by AcquireRandomInfo().


Variable Documentation

char** environ

Referenced by GenerateEntropicChaos().

WizardBooleanType gather_true_random = WizardFalse [static]

Definition at line 124 of file random.c.

Referenced by GenerateEntropicChaos(), and SetRandomTrueRandom().

size_t random_seed = ~0UL [static]

Definition at line 121 of file random.c.

Referenced by AcquireRandomInfo(), and SeedPseudoRandomGenerator().

Definition at line 118 of file random.c.

Referenced by RandomComponentGenesis(), and RandomComponentTerminus().

Generated by  doxygen 1.6.2-20100208