mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Add some conditionally-compilable diagnostics to the RNG. I got
briefly worried that it might not be doing what I thought it was doing, but examining these diagnostics shows that it is after all, and now I've written them it would be a shame not to keep them for future use. [originally from svn r9938]
This commit is contained in:
parent
407fd7b9ab
commit
8966f7c1ea
75
sshrand.c
75
sshrand.c
@ -49,6 +49,10 @@ static struct RandPool pool;
|
||||
int random_active = 0;
|
||||
long next_noise_collection;
|
||||
|
||||
#ifdef RANDOM_DIAGNOSTICS
|
||||
int random_diagnostics = 0;
|
||||
#endif
|
||||
|
||||
static void random_stir(void)
|
||||
{
|
||||
word32 block[HASHINPUT / sizeof(word32)];
|
||||
@ -65,6 +69,30 @@ static void random_stir(void)
|
||||
|
||||
noise_get_light(random_add_noise);
|
||||
|
||||
#ifdef RANDOM_DIAGNOSTICS
|
||||
{
|
||||
int p, q;
|
||||
printf("random stir starting\npool:\n");
|
||||
for (p = 0; p < POOLSIZE; p += HASHSIZE) {
|
||||
printf(" ");
|
||||
for (q = 0; q < HASHSIZE; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.pool + p + q));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("incoming:\n ");
|
||||
for (q = 0; q < HASHSIZE; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.incoming + q));
|
||||
}
|
||||
printf("\nincomingb:\n ");
|
||||
for (q = 0; q < HASHINPUT; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.incomingb + q));
|
||||
}
|
||||
printf("\n");
|
||||
random_diagnostics++;
|
||||
}
|
||||
#endif
|
||||
|
||||
SHATransform((word32 *) pool.incoming, (word32 *) pool.incomingb);
|
||||
pool.incomingpos = 0;
|
||||
|
||||
@ -116,6 +144,29 @@ static void random_stir(void)
|
||||
for (k = 0; k < sizeof(digest) / sizeof(*digest); k++)
|
||||
((word32 *) (pool.pool + j))[k] = digest[k];
|
||||
}
|
||||
|
||||
#ifdef RANDOM_DIAGNOSTICS
|
||||
if (i == 0) {
|
||||
int p, q;
|
||||
printf("random stir midpoint\npool:\n");
|
||||
for (p = 0; p < POOLSIZE; p += HASHSIZE) {
|
||||
printf(" ");
|
||||
for (q = 0; q < HASHSIZE; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.pool + p + q));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("incoming:\n ");
|
||||
for (q = 0; q < HASHSIZE; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.incoming + q));
|
||||
}
|
||||
printf("\nincomingb:\n ");
|
||||
for (q = 0; q < HASHINPUT; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.incomingb + q));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -128,6 +179,30 @@ static void random_stir(void)
|
||||
pool.poolpos = sizeof(pool.incoming);
|
||||
|
||||
pool.stir_pending = FALSE;
|
||||
|
||||
#ifdef RANDOM_DIAGNOSTICS
|
||||
{
|
||||
int p, q;
|
||||
printf("random stir done\npool:\n");
|
||||
for (p = 0; p < POOLSIZE; p += HASHSIZE) {
|
||||
printf(" ");
|
||||
for (q = 0; q < HASHSIZE; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.pool + p + q));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("incoming:\n ");
|
||||
for (q = 0; q < HASHSIZE; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.incoming + q));
|
||||
}
|
||||
printf("\nincomingb:\n ");
|
||||
for (q = 0; q < HASHINPUT; q += 4) {
|
||||
printf(" %08x", *(word32 *)(pool.incomingb + q));
|
||||
}
|
||||
printf("\n");
|
||||
random_diagnostics--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void random_add_noise(void *noise, int length)
|
||||
|
28
sshsha.c
28
sshsha.c
@ -28,6 +28,21 @@ void SHATransform(word32 * digest, word32 * block)
|
||||
word32 a, b, c, d, e;
|
||||
int t;
|
||||
|
||||
#ifdef RANDOM_DIAGNOSTICS
|
||||
{
|
||||
extern int random_diagnostics;
|
||||
if (random_diagnostics) {
|
||||
int i;
|
||||
printf("SHATransform:");
|
||||
for (i = 0; i < 5; i++)
|
||||
printf(" %08x", digest[i]);
|
||||
printf(" +");
|
||||
for (i = 0; i < 16; i++)
|
||||
printf(" %08x", block[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (t = 0; t < 16; t++)
|
||||
w[t] = block[t];
|
||||
|
||||
@ -83,6 +98,19 @@ void SHATransform(word32 * digest, word32 * block)
|
||||
digest[2] += c;
|
||||
digest[3] += d;
|
||||
digest[4] += e;
|
||||
|
||||
#ifdef RANDOM_DIAGNOSTICS
|
||||
{
|
||||
extern int random_diagnostics;
|
||||
if (random_diagnostics) {
|
||||
int i;
|
||||
printf(" =");
|
||||
for (i = 0; i < 5; i++)
|
||||
printf(" %08x", digest[i]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user