moved type and constants for random data to include file;

added consistency check in random; added source of randomness
internal to random using timing; only retrieve random bins that are full.
This commit is contained in:
Ben Gras
2009-04-02 15:24:44 +00:00
parent 51596bc608
commit 9647fbc94e
19 changed files with 177 additions and 80 deletions

View File

@@ -290,28 +290,6 @@ int proc_type; /* system or user process flag */
return(OK);
}
/*===========================================================================*
* get_randomness *
*===========================================================================*/
PUBLIC void get_randomness(source)
int source;
{
/* Use architecture-dependent high-resolution clock for
* raw entropy gathering.
*/
int r_next;
unsigned long tsc_high, tsc_low;
source %= RANDOM_SOURCES;
r_next= krandom.bin[source].r_next;
read_tsc(&tsc_high, &tsc_low);
krandom.bin[source].r_buf[r_next] = tsc_low;
if (krandom.bin[source].r_size < RANDOM_ELEMENTS) {
krandom.bin[source].r_size ++;
}
krandom.bin[source].r_next = (r_next + 1 ) % RANDOM_ELEMENTS;
}
/*===========================================================================*
* send_sig *
*===========================================================================*/