X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fapp_rand.c;h=a6805d4d75fbb2df100c7258510a3e782bcd54ce;hp=595fc7821c85e6d3d0dcefe85a5d0bd993c38eff;hb=5dc312215fa54b70cc8b4baec933bcc19525bc03;hpb=0f113f3ee4d629ef9a4a30911b22b224772085e5 diff --git a/apps/app_rand.c b/apps/app_rand.c index 595fc7821c..a6805d4d75 100644 --- a/apps/app_rand.c +++ b/apps/app_rand.c @@ -1,4 +1,3 @@ -/* apps/app_rand.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -109,29 +108,25 @@ * */ -#define NON_MAIN #include "apps.h" -#undef NON_MAIN #include #include static int seeded = 0; static int egdsocket = 0; -int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn) +int app_RAND_load_file(const char *file, int dont_warn) { int consider_randfile = (file == NULL); char buffer[200]; #ifdef OPENSSL_SYS_WINDOWS - BIO_printf(bio_e, "Loading 'screen' into random state -"); - BIO_flush(bio_e); RAND_screen(); - BIO_printf(bio_e, " done\n"); #endif if (file == NULL) file = RAND_file_name(buffer, sizeof buffer); +#ifndef OPENSSL_NO_EGD else if (RAND_egd(file) > 0) { /* * we try if the given filename is an EGD socket. if it is, we don't @@ -140,18 +135,19 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn) egdsocket = 1; return 1; } +#endif if (file == NULL || !RAND_load_file(file, -1)) { if (RAND_status() == 0) { if (!dont_warn) { - BIO_printf(bio_e, "unable to load 'random state'\n"); - BIO_printf(bio_e, + BIO_printf(bio_err, "unable to load 'random state'\n"); + BIO_printf(bio_err, "This means that the random number generator has not been seeded\n"); - BIO_printf(bio_e, "with much random data.\n"); + BIO_printf(bio_err, "with much random data.\n"); if (consider_randfile) { /* explanation does not apply when a * file is explicitly named */ - BIO_printf(bio_e, + BIO_printf(bio_err, "Consider setting the RANDFILE environment variable to point at a file that\n"); - BIO_printf(bio_e, + BIO_printf(bio_err, "'random' data can be kept in (the file will be overwritten).\n"); } } @@ -167,7 +163,9 @@ long app_RAND_load_files(char *name) char *p, *n; int last; long tot = 0; +#ifndef OPENSSL_NO_EGD int egd; +#endif for (;;) { last = 0; @@ -180,10 +178,12 @@ long app_RAND_load_files(char *name) if (*n == '\0') break; +#ifndef OPENSSL_NO_EGD egd = RAND_egd(n); if (egd > 0) tot += egd; else +#endif tot += RAND_load_file(n, -1); if (last) break; @@ -193,7 +193,7 @@ long app_RAND_load_files(char *name) return (tot); } -int app_RAND_write_file(const char *file, BIO *bio_e) +int app_RAND_write_file(const char *file) { char buffer[200]; @@ -208,7 +208,7 @@ int app_RAND_write_file(const char *file, BIO *bio_e) if (file == NULL) file = RAND_file_name(buffer, sizeof buffer); if (file == NULL || !RAND_write_file(file)) { - BIO_printf(bio_e, "unable to write 'random state'\n"); + BIO_printf(bio_err, "unable to write 'random state'\n"); return 0; } return 1;