The "rp" Package

These routines are meant to provide management of cryptographically strong random pools of bytes. Partially random data (entropy) may be added and extracted from a pool. As data is added, the pool is stirred to randomly distribute the bits. Data extracted from a random pool may be used in the generation of unpredictable (secure) session keys for cryptographic algorithms.

Library: karma
Link With: -lkarma

Functions

rp_createCreate a pool of random bytes.
rp_add_bytesAdd bytes (entropy) to a random pool.
rp_get_bytesGet bytes of data from a random pool.
rp_destroyDestroy a random pool of bytes, erasing all information.
rp_destroy_allDestroy all randpools.
rp_add_time_noiseAdd time-based entropy to a randpool.
rp_register_destroy_funcRegister randpool destroy callback.

Prototype Functions

rp_PROTO_hash_funcHash callback.
rp_PROTO_destroy_funcDestroy callback.


Functions


RandPool rp_create ( unsigned int size, unsigned int hash_digest_size, unsigned int hash_block_size, void (*hash_func) () )

This routine will create a random pool of bytes to which random data may be subsequently added or extracted. The pool is initialised with pseudo-random data (which is *not* cryptographically secure). When data is added to the pool, the pool is stirred using a supplied hash function. Bytes extracted from the pool should be cryptographically secure.

Parameters:

Returns: A RandPool object on success, else NULL.
Multithreading Level: Unsafe


void rp_add_bytes (RandPool rp, CONST unsigned char *buf, unsigned int length)

This routine will add bytes of data (entropy) into a pool. The pool is then stirred using its registered hash function in order to distribute the bits.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void rp_get_bytes (RandPool rp, unsigned char *buf, unsigned int length)

Get bytes of data from a random pool.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void rp_destroy (RandPool rp)

Destroy a random pool of bytes, erasing all information.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void rp_destroy_all ()

This routine will destroy all randpools. The routine is meant to be called from the exit(3) function. It should also be called by the application prior to execve(2).

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void rp_add_time_noise (RandPool rp)

This routine will add bytes of data (entropy) into a pool, derived from the system time. It is suggested that this routine be called by various callback routines to assist in the addition of entropy.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void rp_register_destroy_func (RandPool rp, void (*destroy_func) (),void *info)

This routine will register a routine which should be called when a random pool is destroyed.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Prototype Functions


void rp_PROTO_hash_func (unsigned char buffer[hash_digest_size], CONST unsigned char block[hash_block_size];)

This routine is called when a hash buffer must be scrambled with a block of data.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void rp_PROTO_destroy_func (RandPool rp, void *info)

This routine is called when a random pool is destroyed.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services