RSA BSAFE Cert-C Micro Edition

The power of PKI for the smallest of devices

Management Functions

This section lists the functions used for generating pseudo random numbers.

Typedefs

typedef int R_RAND_ENT_FUNC_T (unsigned char *data, unsigned int len)
 Creates user-defined random entropy collection routines for seeding a random object. More...


Functions

R_RANDOMR_rand_new (R_RANDOM *rnd)
 Allocates a new random object. More...

void R_rand_free (R_RANDOM *rnd)
 Deallocates a random object. More...

int R_rand_add_entropy (R_RANDOM *rnd, int num)
 Adds entropy to the Random Number Generator (RNG) specified by rnd. More...

R_RANDOMR_rand_get_default (void)
 Returns a pointer to a static copy of the default random method. More...

int R_rand_set_default (R_RANDOM *rnd)
 Sets the default callbacks for the Random Number Generator (RNG). More...

int R_rand_seed (R_RANDOM *rnd, unsigned char *buffer, int num)
 Adds additional seed to the R_RANDOM rnd by adding num Bytes from buffer. More...

int R_rand_bytes (R_RANDOM *rnd, unsigned char *buffer, int num)
 Places num random Bytes into a buffer buffer. More...

int R_rand_entropy_count (R_RANDOM *rnd, unsigned long *num)
 Returns the approximate number of random bits added to the system. More...

int R_rand_set_entropy_func (R_RANDOM *rnd, R_RAND_ENT_FUNC_T *entropy_func)
 Sets a random entropy collection function to be used in a random object. More...

R_RAND_ENT_FUNC_TR_rand_get_entropy_func (R_RANDOM *rnd)
 Retrieves a random entropy collection function used by a random object. More...

int R_rand_load_file (R_RANDOM *rnd, char *filename, long size)
 Reads data from the named file in sections of size until the end of the file is reached. More...

int R_rand_write_file (R_RANDOM *rnd, char *filename)
 Writes data in sections of size BUFSIZE to the file filename. More...

char* R_rand_file_name (char *buffer, int size)
 Returns a default name for the location of a rand file. More...


Typedef Documentation

typedef int R_RAND_ENT_FUNC_T(unsigned char *data, unsigned int len)
 

Creates user-defined random entropy collection routines for seeding a random object. The buffer allocated for collection should be at least as long as the value specified in len.

Parameters:
data [Out] The random entropy buffer.
len [In] The length of random entropy to write to data.
Returns:
R_ERROR_NONE indicates success.
See Error Identifiers for valid values.


Function Documentation

int R_rand_add_entropy R_RANDOM   rnd,
int    num
;
 

Adds entropy to the Random Number Generator (RNG) specified by rnd.

Parameters:
rnd [In, Out] The R_RANDOM reference.
num [In] The number of Bytes to set.
Returns:
0 indicates success.
!=0 indicates error.
See also:
R_rand_entropy_count().

int R_rand_bytes R_RANDOM   rnd,
unsigned char *    buffer,
int    num
;
 

Places num random Bytes into a buffer buffer.

Parameters:
rnd [In, Out] The R_RANDOM reference.
buffer [Out] The buffer.
num [In] The buffer length.
Returns:
0 indicates success.
!=0 indicates error.
Note:
R_rand_seed() must be called before using R_rand_bytes().
See also:
R_rand_seed().

int R_rand_entropy_count R_RANDOM   rnd,
unsigned long *    num
;
 

Returns the approximate number of random bits added to the system. The higher the number of random bits added, the less predictable the Random Number Generator (RNG).

Parameters:
rnd [In] The R_RANDOM reference.
num [Out] The amount of entropy.
Returns:
0 indicates success.
!=0 indicates error.
Note:
Adding additional entropy is recommended if num is less than 100.
See also:
R_rand_add_entropy().

char* R_rand_file_name char *    buffer,
int    size
;
 

Returns a default name for the location of a rand file. The file name is stored in the buffer buffer of size Bytes in length.

Parameters:
buffer [In, Out] The buffer.
size [In] The buffer length in Bytes.
Returns:
0 indicates success.
!=0 indicates error.

void R_rand_free R_RANDOM   rnd ;
 

Deallocates a random object.

Parameters:
rnd [In] The R_RANDOM reference.
Note:
It is the calling function's responsibility to set the reference pointer rnd to NULL.
See also:
R_rand_new().

R_RANDOM* R_rand_get_default void    ;
 

Returns a pointer to a static copy of the default random method. The R_RANDOM returned will be uninitialized.

Returns:
A pointer to a static R_RANDOM.

R_RAND_ENT_FUNC_T* R_rand_get_entropy_func R_RANDOM   rnd ;
 

Retrieves a random entropy collection function used by a random object. rnd is a valid random object.

Parameters:
rnd [In] The R_RANDOM reference.
Returns:
A pointer to the random entropy collection function.

int R_rand_load_file R_RANDOM   rnd,
char *    filename,
long    size
;
 

Reads data from the named file in sections of size until the end of the file is reached.

Parameters:
rnd [In] The random object.
filename [In] The file to load.
size [In] The size of data buffer to read.
Returns:
0 indicates success.
!=0 indicates error.

R_RANDOM* R_rand_new R_RANDOM   rnd ;
 

Allocates a new random object.

Parameters:
rnd [In] The random object reference.
Returns:
The pointer to a random object indicates success.
NULL indicates error.
Note:
If rnd is NULL, a default random is allocated via a call to R_rand_get_default().
If rnd is supplied and valid it is copied to the newly allocated random object.
See also:
R_rand_free() and R_rand_get_default().

int R_rand_seed R_RANDOM   rnd,
unsigned char *    buffer,
int    num
;
 

Adds additional seed to the R_RANDOM rnd by adding num Bytes from buffer. This function can be called with sensitive data such as user-entered passwords.

Parameters:
rnd [In, Out] The R_RANDOM reference.
buffer [In] The buffer.
num [In] The number of Bytes to add.
Returns:
0 indicates success.
!=0 indicates error.

int R_rand_set_default R_RANDOM   rnd ;
 

Sets the default callbacks for the Random Number Generator (RNG). The random callbacks are held in rnd.

Parameters:
rnd [Out] The R_RANDOM reference.
Returns:
0 indicates success.
!=0 indicates error.

int R_rand_set_entropy_func R_RANDOM   rnd,
R_RAND_ENT_FUNC_T   entropy_func
;
 

Sets a random entropy collection function to be used in a random object. rnd is a valid random object.

Parameters:
rnd [In] The R_RANDOM reference.
entropy_func [In] The random entropy function pointer.
Returns:
0 indicates success.
!=0 indicates error.

int R_rand_write_file R_RANDOM   rnd,
char *    filename
;
 

Writes data in sections of size BUFSIZE to the file filename.

Parameters:
rnd [In, Out] The data.
filename [In] The file to write.
Returns:
0 indicates success.
!=0 indicates error.


Copyright (c) 1999-2002 RSA Security Inc. All rights reserved. 061-001005-150-001-000-3768 - 1.5