Add "-rand" option to s_client and s_server.
[openssl.git] / apps / s_client.c
index 2e71b428906e22e8c5006fd740a086445b072f8b..a129a494167a369e9b76ff0635169c17af85219e 100644 (file)
@@ -155,6 +155,7 @@ static void sc_usage(void)
        BIO_printf(bio_err," -cipher       - preferred cipher to use, use the 'openssl ciphers'\n");
        BIO_printf(bio_err,"                 command to see what is available\n");
        BIO_printf(bio_err," -engine id    - Initialise and use the specified engine\n");
+       BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 
        }
 
@@ -182,6 +183,7 @@ int MAIN(int argc, char **argv)
        int prexit = 0;
        SSL_METHOD *meth=NULL;
        BIO *sbio;
+       char *inrand=NULL;
        char *engine_id=NULL;
        ENGINE *e=NULL;
 #ifdef WINDOWS
@@ -328,6 +330,11 @@ int MAIN(int argc, char **argv)
                        if (--argc < 1) goto bad;
                        engine_id = *(++argv);
                        }
+               else if (strcmp(*argv,"-rand") == 0)
+                       {
+                       if (--argc < 1) goto bad;
+                       inrand= *(++argv);
+                       }
                else
                        {
                        BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -344,7 +351,14 @@ bad:
                goto end;
                }
 
-       app_RAND_load_file(NULL, bio_err, 0);
+       if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
+               && !RAND_status())
+               {
+               BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
+               }
+       if (inrand != NULL)
+               BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
+                       app_RAND_load_files(inrand));
 
        if (bio_c_out == NULL)
                {