projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix for non-monolithic build.
[openssl.git]
/
apps
/
app_rand.c
diff --git
a/apps/app_rand.c
b/apps/app_rand.c
index 2543a6405721ef5f2fd74864e5c4342f228c0e00..9835c84ed00d4fccb4b90953c271def2f9d9a582 100644
(file)
--- a/
apps/app_rand.c
+++ b/
apps/app_rand.c
@@
-109,12
+109,15
@@
*
*/
*
*/
+#define NON_MAIN
+#include "apps.h"
+#undef NON_MAIN
#include <openssl/bio.h>
#include <openssl/rand.h>
#include <openssl/bio.h>
#include <openssl/rand.h>
-#include "apps.h"
static int seeded = 0;
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, 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);
if (file == NULL)
file = RAND_file_name(buffer, sizeof buffer);
- if (file == NULL || !RAND_load_file(file, 1024L*1024L))
+ 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,"unable to load 'random state'\n");
- BIO_printf(bio_e,"
What this means i
s that the random number generator has not been seeded\n");
+ BIO_printf(bio_e,"
This mean
s 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 */
{
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;
char *p,*n;
int last;
long tot=0;
-
+ int egd;
+
for (;;)
{
last=0;
for (;;)
{
last=0;
@@
-165,6
+176,8
@@
long app_RAND_load_files(char *name)
name=p+1;
if (*n == '\0') break;
name=p+1;
if (*n == '\0') break;
+ egd=RAND_egd(n);
+ if (egd > 0) tot+=egd;
tot+=RAND_load_file(n,1024L*1024L);
if (last) break;
}
tot+=RAND_load_file(n,1024L*1024L);
if (last) break;
}
@@
-177,10
+190,10
@@
int app_RAND_write_file(const char *file, BIO *bio_e)
{
char buffer[200];
{
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 --
/* 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 sup
p
ress a crucial warning the next time
* we want to use it. */
return 0;
* we want to use it. */
return 0;