MagickCore 7.0.10
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 "wizard/utility-private.h"
Include dependency graph for random.c:

Go to the source code of this file.

Data Structures

struct  _RandomInfo
 

Macros

#define PseudoRandomHash   SHA2256Hash
 
#define RandomEntropyLevel   9
 
#define RandomFilename   "reservoir.xdm"
 
#define RandomFiletype   "random"
 
#define RandomProtocolMajorVersion   1
 
#define RandomProtocolMinorVersion   1
 
#define MaxEntropyExtent   64 /* max permitted: 256 */
 
#define RandomROTL(x, k)   (((x) << (k)) | ((x) >> (64-(k))))
 

Functions

static WizardBooleanType SaveEntropyToReservoir (RandomInfo *, ExceptionInfo *)
 
static StringInfoGenerateEntropicChaos (RandomInfo *, ExceptionInfo *)
 
static StringInfoGetEntropyFromReservoir (RandomInfo *, ExceptionInfo *)
 
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 unsigned long GetRandomSecretKey (const RandomInfo *random_info)
 
WizardExport double GetRandomValue (RandomInfo *random_info)
 
WizardExport WizardBooleanType RandomComponentGenesis (void)
 
WizardExport void RandomComponentTerminus (void)
 
static void IncrementRandomNonce (StringInfo *nonce)
 
WizardExport void SetRandomKey (RandomInfo *random_info, const size_t length, unsigned char *key)
 
WizardExport void SetRandomSecretKey (const unsigned long key)
 
WizardExport void SetRandomTrueRandom (const WizardBooleanType true_random)
 

Variables

char ** environ
 
static SemaphoreInforandom_semaphore = (SemaphoreInfo *) NULL
 
static unsigned long secret_key = ~0UL
 
static WizardBooleanType gather_true_random = WizardFalse
 

Macro Definition Documentation

◆ MaxEntropyExtent

#define MaxEntropyExtent   64 /* max permitted: 256 */

◆ PseudoRandomHash

#define PseudoRandomHash   SHA2256Hash

Definition at line 65 of file random.c.

◆ RandomEntropyLevel

#define RandomEntropyLevel   9

Definition at line 66 of file random.c.

◆ RandomFilename

#define RandomFilename   "reservoir.xdm"

Definition at line 67 of file random.c.

◆ RandomFiletype

#define RandomFiletype   "random"

Definition at line 68 of file random.c.

◆ RandomProtocolMajorVersion

#define RandomProtocolMajorVersion   1

Definition at line 69 of file random.c.

◆ RandomProtocolMinorVersion

#define RandomProtocolMinorVersion   1

Definition at line 70 of file random.c.

◆ RandomROTL

#define RandomROTL (   x,
 
)    (((x) << (k)) | ((x) >> (64-(k))))

Function Documentation

◆ AcquireRandomInfo()

◆ DestroyRandomInfo()

◆ GenerateEntropicChaos()

◆ GetEntropyFromReservoir()

◆ GetPseudoRandomValue()

WizardExport double GetPseudoRandomValue ( RandomInfo random_info)

Definition at line 779 of file random.c.

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

◆ GetRandomKey()

◆ GetRandomSecretKey()

WizardExport unsigned long GetRandomSecretKey ( const RandomInfo random_info)

Definition at line 853 of file random.c.

References random_info, and _RandomInfo::secret_key.

◆ GetRandomValue()

WizardExport double GetRandomValue ( RandomInfo random_info)

Definition at line 878 of file random.c.

References random_info, and SetRandomKey().

◆ IncrementRandomNonce()

static void IncrementRandomNonce ( StringInfo nonce)
inlinestatic

Definition at line 1050 of file random.c.

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

Referenced by SetRandomKey().

◆ RandomComponentGenesis()

WizardExport WizardBooleanType RandomComponentGenesis ( void  )

Definition at line 910 of file random.c.

References AcquireSemaphoreInfo(), random_semaphore, and WizardTrue.

Referenced by WizardsToolkitGenesis().

◆ RandomComponentTerminus()

WizardExport void RandomComponentTerminus ( void  )

Definition at line 935 of file random.c.

References ActivateSemaphoreInfo(), random_semaphore, and RelinquishSemaphoreInfo().

Referenced by WizardsToolkitTerminus().

◆ ReadRandom()

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

Definition at line 336 of file random.c.

Referenced by GenerateEntropicChaos().

◆ SaveEntropyToReservoir()

◆ SetRandomKey()

◆ SetRandomSecretKey()

WizardExport void SetRandomSecretKey ( const unsigned long  key)

Definition at line 1145 of file random.c.

References secret_key.

◆ SetRandomTrueRandom()

WizardExport void SetRandomTrueRandom ( const WizardBooleanType  true_random)

Definition at line 1174 of file random.c.

References gather_true_random.

Variable Documentation

◆ environ

char** environ
extern

Referenced by GenerateEntropicChaos().

◆ gather_true_random

WizardBooleanType gather_true_random = WizardFalse
static

Definition at line 131 of file random.c.

Referenced by GenerateEntropicChaos(), and SetRandomTrueRandom().

◆ random_semaphore

SemaphoreInfo* random_semaphore = (SemaphoreInfo *) NULL
static

Definition at line 125 of file random.c.

Referenced by RandomComponentGenesis(), and RandomComponentTerminus().

◆ secret_key

unsigned long secret_key = ~0UL
static

Definition at line 128 of file random.c.

Referenced by AcquireRandomInfo(), and SetRandomSecretKey().