Minor fixes.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@282 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Unknown User d91-jda
1996-03-05 16:19:53 +00:00
parent abff312321
commit c1088e5313

View File

@@ -13,21 +13,22 @@ RCSID("$Id$");
static des_key_schedule sequence_seed; static des_key_schedule sequence_seed;
static u_int32_t sequence_index[2]; static u_int32_t sequence_index[2];
/* /*
* These guys are used for the clocked "non crypto" randomness. * Random number generator based on ideas from truerand in cryptolib
* * as described on page 424 in Applied Cryptography 2 ed. by Bruce
* The method used is described on page 424 in * Schneier.
* Applied Cryptography 2 ed. by Bruce Schneier.
*/ */
static volatile int counter; static volatile int counter;
static volatile unsigned char *gdata; /* Global data */ static volatile unsigned char *gdata; /* Global data */
static volatile int igdata; /* Index into global data */ static volatile int igdata; /* Index into global data */
static int gsize;
static static
RETSIGTYPE RETSIGTYPE
sigALRM(int sig) sigALRM(int sig)
{ {
if (igdata < sizeof(des_cblock)) if (igdata < gsize)
gdata[igdata++] ^= counter & 0xff; gdata[igdata++] ^= counter & 0xff;
#ifdef VOID_RETSIGTYPE #ifdef VOID_RETSIGTYPE
@@ -51,12 +52,13 @@ des_clock_rand(unsigned char *data, int size)
int i; int i;
gdata = data; gdata = data;
gsize = size;
igdata = 0; igdata = 0;
counter = 0;
/* Setup signal handler */ /* Setup signal handler */
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sigALRM; sa.sa_handler = sigALRM;
sa.sa_flags = 0;
sa.sa_mask = 0;
sigaction(SIGALRM, &sa, &osa); sigaction(SIGALRM, &sa, &osa);
/* Start timer */ /* Start timer */
@@ -67,9 +69,9 @@ des_clock_rand(unsigned char *data, int size)
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
{ {
for (igdata = 0; igdata < size;) for (igdata = 0; igdata < gsize;)
counter++; counter++;
for (igdata = 0; igdata < size; igdata++) for (igdata = 0; igdata < gsize; igdata++)
gdata[igdata] = (gdata[igdata]>>2) | (gdata[igdata]<<6); gdata[igdata] = (gdata[igdata]>>2) | (gdata[igdata]<<6);
} }
setitimer(ITIMER_REAL, &otv, 0); setitimer(ITIMER_REAL, &otv, 0);
@@ -98,18 +100,20 @@ des_clock_rand_key(des_cblock *key)
} }
/* /*
* Generate 8 bytes of "random" data by checksumming the first 2 * Generate "random" data by checksumming /dev/mem
* megabytes of /dev/mem. *
* It's neccessary to be root to run it. * It's neccessary to be root to run it. Returns -1 if there were any
* problems with permissions.
*/ */
void int
des_mem_rand8(unsigned char *data) des_mem_rand8(unsigned char *data)
{ {
return 1;
} }
#endif #endif
/* /*
* In case the generator does not get initialized use this for backup. * In case the generator does not get initialized use this as fallback.
*/ */
static int initialized; static int initialized;
@@ -179,7 +183,7 @@ des_new_random_key(des_cblock *key)
* *
* Initialize the sequence of random 64 bit blocks. The input seed * Initialize the sequence of random 64 bit blocks. The input seed
* can be a secret key since it should be well hidden and is also not * can be a secret key since it should be well hidden and is also not
* keept. * kept.
* *
*/ */
void void