X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fapp_rand.c;h=8a78e12eb732855b445c3e56f9f92c25bda2e8c3;hb=75c3c831db58232769f727d76e0504ce138f2dfc;hp=6384dd0be5c7267a84a57064abddc200f8c51ca9;hpb=05ccd698b986131a217f85281977e767673b27d1;p=oweals%2Fopenssl.git diff --git a/apps/app_rand.c b/apps/app_rand.c index 6384dd0be5..8a78e12eb7 100644 --- a/apps/app_rand.c +++ b/apps/app_rand.c @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ /* ==================================================================== - * Copyright (c) 1998-1999 The OpenSSL Project. All rights reserved. + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -109,12 +109,15 @@ * */ +#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) { @@ -130,12 +133,19 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn) if (file == NULL) file = RAND_file_name(buffer, sizeof buffer); + else if (RAND_egd(file) > 0) + { + /* we try if the given filename is an EGD socket. + if it is, we don't write anything back to the file. */ + egdsocket = 1; + return 1; + } if (file == NULL || !RAND_load_file(file, -1)) { - if (!dont_warn) + if (RAND_status() == 0 && !dont_warn) { BIO_printf(bio_e,"unable to load 'random state'\n"); - BIO_printf(bio_e,"What this means is that the random number generator has not been seeded\n"); + BIO_printf(bio_e,"This means that the random number generator has not been seeded\n"); BIO_printf(bio_e,"with much random data.\n"); if (consider_randfile) /* explanation does not apply when a file is explicitly named */ { @@ -154,7 +164,8 @@ long app_RAND_load_files(char *name) char *p,*n; int last; long tot=0; - + int egd; + for (;;) { last=0; @@ -165,7 +176,11 @@ long app_RAND_load_files(char *name) name=p+1; if (*n == '\0') break; - tot+=RAND_load_file(n,1024L*1024L); + egd=RAND_egd(n); + if (egd > 0) + tot+=egd; + else + tot+=RAND_load_file(n,-1); if (last) break; } if (tot > 512) @@ -177,10 +192,10 @@ int app_RAND_write_file(const char *file, BIO *bio_e) { char buffer[200]; - if (!seeded) + if (egdsocket || !seeded) /* If we did not manage to read the seed file, * we should not write a low-entropy seed file back -- - * it would supress a crucial warning the next time + * it would suppress a crucial warning the next time * we want to use it. */ return 0;