random.c File Reference

#include "../drivers.h"
#include "../../kernel/const.h"
#include "assert.h"
#include "random.h"
#include "sha2.h"
#include "aes/rijndael.h"

Include dependency graph for random.c:

Go to the source code of this file.

Defines

#define N_DERIV   16
#define NR_POOLS   32
#define MIN_SAMPLES   256

Functions

FORWARD _PROTOTYPE (void add_sample,(int source, unsigned long sample))
FORWARD _PROTOTYPE (void data_block,(rd_keyinstance *keyp, void *data))
FORWARD _PROTOTYPE (void reseed,(void))
PUBLIC void random_init ()
PUBLIC int random_isseeded ()
PUBLIC void random_update (int source, unsigned short *buf, int count)
PUBLIC void random_getbytes (void *buf, size_t size)
PUBLIC void random_putbytes (void *buf, size_t size)
PRIVATE void add_sample (int source, unsigned long sample)
PRIVATE void data_block (rd_keyinstance *keyp, void *data)
PRIVATE void reseed ()

Variables

PRIVATE unsigned long deriv [RANDOM_SOURCES][N_DERIV]
PRIVATE int pool_ind [RANDOM_SOURCES]
PRIVATE SHA256_CTX pool_ctx [NR_POOLS]
PRIVATE unsigned samples = 0
PRIVATE int got_seeded = 0
PRIVATE u8_t random_key [2 *AES_BLOCKSIZE]
PRIVATE u32_t count_lo
PRIVATE u32_t count_hi
PRIVATE u32_t reseed_count


Define Documentation

#define MIN_SAMPLES   256
 

Definition at line 20 of file random.c.

Referenced by reseed().

#define N_DERIV   16
 

Definition at line 18 of file random.c.

Referenced by add_sample(), and random_init().

#define NR_POOLS   32
 

Definition at line 19 of file random.c.


Function Documentation

FORWARD _PROTOTYPE void  reseed,
(void) 
 

FORWARD _PROTOTYPE void  data_block,
(rd_keyinstance *keyp, void *data) 
 

FORWARD _PROTOTYPE void  add_sample,
(int source, unsigned long sample) 
 

PRIVATE void add_sample int  source,
unsigned long  sample
 

Definition at line 131 of file random.c.

References d, deriv, i, long(), min, and N_DERIV.

Referenced by random_update().

PRIVATE void data_block rd_keyinstance keyp,
void *  data
 

Definition at line 182 of file random.c.

References AES_BLOCKSIZE, assert, count_hi, count_lo, input, memcpy(), memset(), NULL, r, and rijndael_ecb_encrypt().

Referenced by random_getbytes().

PUBLIC void random_getbytes void *  buf,
size_t  size
 

Definition at line 82 of file random.c.

References AES_BLOCKSIZE, assert, cp, data_block(), key, memcpy(), n, r, random_key, and rijndael_makekey().

Referenced by r_transfer().

PUBLIC void random_init  ) 
 

Definition at line 38 of file random.c.

References assert, deriv, i, j, N_DERIV, pool_ind, and RANDOM_SOURCES.

Referenced by r_init().

PUBLIC int random_isseeded  ) 
 

Definition at line 58 of file random.c.

References got_seeded.

Referenced by r_transfer().

PUBLIC void random_putbytes void *  buf,
size_t  size
 

Definition at line 116 of file random.c.

References pool_ctx, reseed(), samples, and SHA256_Update().

Referenced by r_transfer().

PUBLIC void random_update int  source,
unsigned short *  buf,
int  count
 

Definition at line 65 of file random.c.

References add_sample(), i, panic, printf, RANDOM_SOURCES, and reseed().

Referenced by r_random().

PRIVATE void reseed  ) 
 

Definition at line 207 of file random.c.

References got_seeded, i, MIN_SAMPLES, pool_ctx, random_key, reseed_count, samples, SHA256_DIGEST_LENGTH, SHA256_Final(), SHA256_Init(), and SHA256_Update().

Referenced by random_putbytes(), and random_update().


Variable Documentation

PRIVATE u32_t count_hi
 

Definition at line 30 of file random.c.

Referenced by data_block().

PRIVATE u32_t count_lo
 

Definition at line 30 of file random.c.

Referenced by data_block().

PRIVATE unsigned long deriv[RANDOM_SOURCES][N_DERIV]
 

Definition at line 24 of file random.c.

Referenced by add_sample(), and random_init().

PRIVATE int got_seeded = 0
 

Definition at line 28 of file random.c.

Referenced by random_isseeded(), and reseed().

PRIVATE SHA256_CTX pool_ctx[NR_POOLS]
 

Definition at line 26 of file random.c.

Referenced by random_putbytes(), and reseed().

PRIVATE int pool_ind[RANDOM_SOURCES]
 

Definition at line 25 of file random.c.

Referenced by random_init().

PRIVATE u8_t random_key[2 *AES_BLOCKSIZE]
 

Definition at line 29 of file random.c.

Referenced by random_getbytes(), and reseed().

PRIVATE u32_t reseed_count
 

Definition at line 31 of file random.c.

Referenced by reseed().

PRIVATE unsigned samples = 0
 

Definition at line 27 of file random.c.

Referenced by random_putbytes(), and reseed().


Generated on Fri Apr 14 23:09:16 2006 for minix by  doxygen 1.4.6