summaryrefslogtreecommitdiff
path: root/ssh-rand-helper.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-11-21 23:48:55 +1100
committerDamien Miller <djm@mindrot.org>2003-11-21 23:48:55 +1100
commita8e06cef35c205e1aa562513c6d034a10c8c9a6d (patch)
treecf8bdb4466f553088c020b9179cabd6eaf196075 /ssh-rand-helper.c
parent8c5e91c03fdd2693f0635f8b2a9904bffc94ce16 (diff)
- djm@cvs.openbsd.org 2003/11/21 11:57:03
[everything] unexpand and delete whitespace at EOL; ok markus@ (done locally and RCS IDs synced)
Diffstat (limited to 'ssh-rand-helper.c')
-rw-r--r--ssh-rand-helper.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/ssh-rand-helper.c b/ssh-rand-helper.c
index effc8745e..abdb779f0 100644
--- a/ssh-rand-helper.c
+++ b/ssh-rand-helper.c
@@ -39,7 +39,7 @@
39#include "pathnames.h" 39#include "pathnames.h"
40#include "log.h" 40#include "log.h"
41 41
42RCSID("$Id: ssh-rand-helper.c,v 1.14 2003/09/22 15:36:15 mouring Exp $"); 42RCSID("$Id: ssh-rand-helper.c,v 1.15 2003/11/21 12:48:56 djm Exp $");
43 43
44/* Number of bytes we write out */ 44/* Number of bytes we write out */
45#define OUTPUT_SEED_SIZE 48 45#define OUTPUT_SEED_SIZE 48
@@ -115,19 +115,19 @@ double stir_gettimeofday(double entropy_estimate);
115double stir_clock(double entropy_estimate); 115double stir_clock(double entropy_estimate);
116double stir_rusage(int who, double entropy_estimate); 116double stir_rusage(int who, double entropy_estimate);
117double hash_command_output(entropy_cmd_t *src, unsigned char *hash); 117double hash_command_output(entropy_cmd_t *src, unsigned char *hash);
118int get_random_bytes_prngd(unsigned char *buf, int len, 118int get_random_bytes_prngd(unsigned char *buf, int len,
119 unsigned short tcp_port, char *socket_path); 119 unsigned short tcp_port, char *socket_path);
120 120
121/* 121/*
122 * Collect 'len' bytes of entropy into 'buf' from PRNGD/EGD daemon 122 * Collect 'len' bytes of entropy into 'buf' from PRNGD/EGD daemon
123 * listening either on 'tcp_port', or via Unix domain socket at * 123 * listening either on 'tcp_port', or via Unix domain socket at *
124 * 'socket_path'. 124 * 'socket_path'.
125 * Either a non-zero tcp_port or a non-null socket_path must be 125 * Either a non-zero tcp_port or a non-null socket_path must be
126 * supplied. 126 * supplied.
127 * Returns 0 on success, -1 on error 127 * Returns 0 on success, -1 on error
128 */ 128 */
129int 129int
130get_random_bytes_prngd(unsigned char *buf, int len, 130get_random_bytes_prngd(unsigned char *buf, int len,
131 unsigned short tcp_port, char *socket_path) 131 unsigned short tcp_port, char *socket_path)
132{ 132{
133 int fd, addr_len, rval, errors; 133 int fd, addr_len, rval, errors;
@@ -289,7 +289,7 @@ hash_command_output(entropy_cmd_t *src, unsigned char *hash)
289 if (devnull == -1) { 289 if (devnull == -1) {
290 devnull = open("/dev/null", O_RDWR); 290 devnull = open("/dev/null", O_RDWR);
291 if (devnull == -1) 291 if (devnull == -1)
292 fatal("Couldn't open /dev/null: %s", 292 fatal("Couldn't open /dev/null: %s",
293 strerror(errno)); 293 strerror(errno));
294 } 294 }
295 295
@@ -314,7 +314,7 @@ hash_command_output(entropy_cmd_t *src, unsigned char *hash)
314 314
315 execv(src->path, (char**)(src->args)); 315 execv(src->path, (char**)(src->args));
316 316
317 debug("(child) Couldn't exec '%s': %s", 317 debug("(child) Couldn't exec '%s': %s",
318 src->cmdstring, strerror(errno)); 318 src->cmdstring, strerror(errno));
319 _exit(-1); 319 _exit(-1);
320 default: /* Parent */ 320 default: /* Parent */
@@ -376,7 +376,7 @@ hash_command_output(entropy_cmd_t *src, unsigned char *hash)
376 case -1: 376 case -1:
377 default: 377 default:
378 /* error */ 378 /* error */
379 debug("Command '%s': select() failed: %s", 379 debug("Command '%s': select() failed: %s",
380 src->cmdstring, strerror(errno)); 380 src->cmdstring, strerror(errno));
381 error_abort = 1; 381 error_abort = 1;
382 break; 382 break;
@@ -400,8 +400,8 @@ hash_command_output(entropy_cmd_t *src, unsigned char *hash)
400 if (error_abort) { 400 if (error_abort) {
401 /* 401 /*
402 * Closing p[0] on timeout causes the entropy command to 402 * Closing p[0] on timeout causes the entropy command to
403 * SIGPIPE. Take whatever output we got, and mark this 403 * SIGPIPE. Take whatever output we got, and mark this
404 * command as slow 404 * command as slow
405 */ 405 */
406 debug2("Command '%s' timed out", src->cmdstring); 406 debug2("Command '%s' timed out", src->cmdstring);
407 src->sticky_badness *= 2; 407 src->sticky_badness *= 2;
@@ -479,7 +479,7 @@ stir_from_programs(void)
479 /* Stir it in */ 479 /* Stir it in */
480 RAND_add(hash, sizeof(hash), entropy); 480 RAND_add(hash, sizeof(hash), entropy);
481 481
482 debug3("Got %0.2f bytes of entropy from '%s'", 482 debug3("Got %0.2f bytes of entropy from '%s'",
483 entropy, entropy_cmds[c].cmdstring); 483 entropy, entropy_cmds[c].cmdstring);
484 484
485 total_entropy += entropy; 485 total_entropy += entropy;
@@ -491,7 +491,7 @@ stir_from_programs(void)
491 total_entropy += stir_rusage(RUSAGE_CHILDREN, 0.1); 491 total_entropy += stir_rusage(RUSAGE_CHILDREN, 0.1);
492 } else { 492 } else {
493 debug2("Command '%s' disabled (badness %d)", 493 debug2("Command '%s' disabled (badness %d)",
494 entropy_cmds[c].cmdstring, 494 entropy_cmds[c].cmdstring,
495 entropy_cmds[c].badness); 495 entropy_cmds[c].badness);
496 496
497 if (entropy_cmds[c].badness > 0) 497 if (entropy_cmds[c].badness > 0)
@@ -511,8 +511,8 @@ prng_check_seedfile(char *filename)
511 struct stat st; 511 struct stat st;
512 512
513 /* 513 /*
514 * XXX raceable: eg replace seed between this stat and subsequent 514 * XXX raceable: eg replace seed between this stat and subsequent
515 * open. Not such a problem because we don't really trust the 515 * open. Not such a problem because we don't really trust the
516 * seed file anyway. 516 * seed file anyway.
517 * XXX: use secure path checking as elsewhere in OpenSSH 517 * XXX: use secure path checking as elsewhere in OpenSSH
518 */ 518 */
@@ -651,7 +651,7 @@ prng_read_commands(char *cmdfilename)
651 continue; /* done with this line */ 651 continue; /* done with this line */
652 652
653 /* 653 /*
654 * The first non-whitespace char should be a double quote 654 * The first non-whitespace char should be a double quote
655 * delimiting the commandline 655 * delimiting the commandline
656 */ 656 */
657 if (*cp != '"') { 657 if (*cp != '"') {
@@ -726,7 +726,7 @@ prng_read_commands(char *cmdfilename)
726 726
727 /* 727 /*
728 * If we've filled the array, reallocate it twice the size 728 * If we've filled the array, reallocate it twice the size
729 * Do this now because even if this we're on the last 729 * Do this now because even if this we're on the last
730 * command we need another slot to mark the last entry 730 * command we need another slot to mark the last entry
731 */ 731 */
732 if (cur_cmd == num_cmds) { 732 if (cur_cmd == num_cmds) {
@@ -761,7 +761,7 @@ usage(void)
761 OUTPUT_SEED_SIZE); 761 OUTPUT_SEED_SIZE);
762} 762}
763 763
764int 764int
765main(int argc, char **argv) 765main(int argc, char **argv)
766{ 766{
767 unsigned char *buf; 767 unsigned char *buf;
@@ -816,11 +816,11 @@ main(int argc, char **argv)
816 /* 816 /*
817 * Seed the RNG from wherever we can 817 * Seed the RNG from wherever we can
818 */ 818 */
819 819
820 /* Take whatever is on the stack, but don't credit it */ 820 /* Take whatever is on the stack, but don't credit it */
821 RAND_add(buf, bytes, 0); 821 RAND_add(buf, bytes, 0);
822 822
823 debug("Seeded RNG with %i bytes from system calls", 823 debug("Seeded RNG with %i bytes from system calls",
824 (int)stir_from_system()); 824 (int)stir_from_system());
825 825
826#ifdef PRNGD_PORT 826#ifdef PRNGD_PORT
@@ -835,7 +835,7 @@ main(int argc, char **argv)
835 /* Read in collection commands */ 835 /* Read in collection commands */
836 if (prng_read_commands(SSH_PRNG_COMMAND_FILE) == -1) 836 if (prng_read_commands(SSH_PRNG_COMMAND_FILE) == -1)
837 fatal("PRNG initialisation failed -- exiting."); 837 fatal("PRNG initialisation failed -- exiting.");
838 debug("Seeded RNG with %i bytes from programs", 838 debug("Seeded RNG with %i bytes from programs",
839 (int)stir_from_programs()); 839 (int)stir_from_programs());
840#endif 840#endif
841 841