Entropy Sources


Random Generators

The following structure is used to hold information describing a specific random generator implementation:


typedef struct
{
  const char*                  name;
  const unsigned int           paramsize;
  const randomGeneratorSetup   setup;
  const randomGeneratorSeed    seed;
  const randomGeneratorNext    next;
  const randomGeneratorCleanup cleanup;
} randomGenerator;

The following structure is used to work with a specific random generator implementation:


typedef struct
{
  const randomGenerator* rng;
  randomGeneratorparam*  param;
} randomGeneratorContext;

The following functions will operate on this structure:

void randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng);
This function initializes ctxt by allocating and initializing parameters appropriate for rng.
void randomGeneratorContextFree(randomGeneratorContext* ctxt);
This function cleans up ctxt and frees its allocated parameters.


Hash Functions


Keyed Hash Functions


Block Ciphers


Multi-Precision Integer routines

The following structure is used to hold a multi-precision integer:


typedef struct
{
  uint32  size;
  uint32* data;
} mp32number;

The following structure is used for barrett modular reduction operations on multi-precision integers:


typedef struct
{
  uint32  size;
  uint32* modl;
  uint32* mu;
} mp32barrett;


Discrete Logarithm Public Key Primitives

Discrete logarithm operations can be performed in a variety of fields. This API implements discrete logarithms over a prime field, conform with IEEE P1363.

You can find the exact mathematics in:

"Handbook of Applied Cryptography"
Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone
CRC Press

The domain parameters are defined by a prime P, a prime factor Q of (P-1), and a group generator G.

The following struct is used to hold the discrete logarithm domain parameters:


typedef struct
{
  mp32barrett p;
  mp32barrett q;
  mp32number  r;
  mp32number  g;
  mp32barrett n;
} dldp_p;

The struct holds more than the three domain parameters required by IEEE P1363. Some discrete logarithm operations call for a reduction modulo (P-1). Hence we've defined N as (P-1). R is the cofactor of (P-1), so that P-1=N=Q*R, where P and Q are (probable) primes.

If you save the domain parameters, you don't need to save N, and R, since they can be trivially recomputed.

The following functions will operate on this structure:

void dldp_pInit(dldp_p* domain);
void dldp_pFree(dldp_p* domain);
void dldp_pCopy(dldp_p* dest, const dldp_p* source);