Cleanup certutil's keybaord entropy collector. Bug 387621, r=julien.pierre
If this patch is found to be unsatisfactory, we can revert to the other patch attached to bug 387621. git-svn-id: svn://10.0.0.236/trunk@230733 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
69ad969c1d
commit
7b65ce0781
@ -82,7 +82,7 @@ const SEC_ASN1Template SECKEY_PQGParamsTemplate[] = {
|
||||
static int
|
||||
UpdateRNG(void)
|
||||
{
|
||||
char * randbuf;
|
||||
char randbuf[RAND_BUF_SIZE];
|
||||
int fd, i, count;
|
||||
int c;
|
||||
int rv = 0;
|
||||
@ -92,6 +92,8 @@ UpdateRNG(void)
|
||||
tcflag_t orig_lflag;
|
||||
struct termios tio;
|
||||
#endif
|
||||
char meter[] = {
|
||||
"\r| |" };
|
||||
|
||||
#define FPS fprintf(stderr,
|
||||
FPS "\n");
|
||||
@ -104,7 +106,8 @@ UpdateRNG(void)
|
||||
FPS "\n");
|
||||
FPS "\n");
|
||||
FPS "Continue typing until the progress meter is full:\n\n");
|
||||
FPS "| |\r");
|
||||
FPS meter);
|
||||
FPS "\r|");
|
||||
|
||||
/* turn off echo on stdin & return on 1 char instead of NL */
|
||||
fd = fileno(stdin);
|
||||
@ -122,9 +125,8 @@ UpdateRNG(void)
|
||||
#endif
|
||||
|
||||
/* Get random noise from keyboard strokes */
|
||||
randbuf = (char *) PORT_Alloc(RAND_BUF_SIZE);
|
||||
count = 0;
|
||||
while (count < NUM_KEYSTROKES+1) {
|
||||
while (count < sizeof randbuf) {
|
||||
#ifdef VMS
|
||||
c = GENERIC_GETCHAR_NOECHO();
|
||||
#elif XP_UNIX
|
||||
@ -136,19 +138,14 @@ UpdateRNG(void)
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
PK11_RandomUpdate(randbuf, sizeof(randbuf));
|
||||
if (c != randbuf[0]) {
|
||||
randbuf[0] = c;
|
||||
FPS "\r|");
|
||||
for (i=0; i<count/(NUM_KEYSTROKES/RAND_BUF_SIZE); i++) {
|
||||
FPS "*");
|
||||
}
|
||||
if (count%(NUM_KEYSTROKES/RAND_BUF_SIZE) == 1)
|
||||
FPS "/");
|
||||
randbuf[count] = c;
|
||||
if (count == 0 || c != randbuf[count-1]) {
|
||||
count++;
|
||||
FPS "*");
|
||||
}
|
||||
}
|
||||
free(randbuf);
|
||||
PK11_RandomUpdate(randbuf, sizeof randbuf);
|
||||
memset(randbuf, 0, sizeof randbuf);
|
||||
|
||||
FPS "\n\n");
|
||||
FPS "Finished. Press enter to continue: ");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user