Skip to content

Commit 0ee497f

Browse files
Shigeki Ohtsuorangemocha
Shigeki Ohtsu
authored andcommitted
deps: add -no_rand_screen to openssl s_client
In openssl s_client on Windows, RAND_screen() is invoked to initialize random state but it takes several seconds in each connection. This added -no_rand_screen to openssl s_client on Windows to skip RAND_screen() and gets a better performance in the unit test of test-tls-server-verify. Do not enable this except to use in the unit test. Fixes: #1461 PR-URL: #1836 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 4cf323d commit 0ee497f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

deps/openssl/openssl/apps/app_rand.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
124124
char buffer[200];
125125

126126
#ifdef OPENSSL_SYS_WINDOWS
127-
BIO_printf(bio_e, "Loading 'screen' into random state -");
128-
BIO_flush(bio_e);
129-
RAND_screen();
130-
BIO_printf(bio_e, " done\n");
127+
/*
128+
* allocate 2 to dont_warn not to use RAND_screen() via
129+
* -no_rand_screen option in s_client
130+
*/
131+
if (dont_warn != 2) {
132+
BIO_printf(bio_e, "Loading 'screen' into random state -");
133+
BIO_flush(bio_e);
134+
RAND_screen();
135+
BIO_printf(bio_e, " done\n");
136+
}
131137
#endif
132138

133139
if (file == NULL)

deps/openssl/openssl/apps/s_client.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ static BIO *bio_c_msg = NULL;
236236
static int c_quiet = 0;
237237
static int c_ign_eof = 0;
238238
static int c_brief = 0;
239+
static int c_no_rand_screen = 0;
239240

240241
#ifndef OPENSSL_NO_PSK
241242
/* Default PSK identity and key */
@@ -446,6 +447,10 @@ static void sc_usage(void)
446447
" -keymatexport label - Export keying material using label\n");
447448
BIO_printf(bio_err,
448449
" -keymatexportlen len - Export len bytes of keying material (default 20)\n");
450+
#ifdef OPENSSL_SYS_WINDOWS
451+
BIO_printf(bio_err,
452+
" -no_rand_screen - Do not use RAND_screen() to initialize random state\n");
453+
#endif
449454
}
450455

451456
#ifndef OPENSSL_NO_TLSEXT
@@ -1125,6 +1130,10 @@ int MAIN(int argc, char **argv)
11251130
keymatexportlen = atoi(*(++argv));
11261131
if (keymatexportlen == 0)
11271132
goto bad;
1133+
#ifdef OPENSSL_SYS_WINDOWS
1134+
} else if (strcmp(*argv, "-no_rand_screen") == 0) {
1135+
c_no_rand_screen = 1;
1136+
#endif
11281137
} else {
11291138
BIO_printf(bio_err, "unknown option %s\n", *argv);
11301139
badop = 1;
@@ -1230,7 +1239,7 @@ int MAIN(int argc, char **argv)
12301239
if (!load_excert(&exc, bio_err))
12311240
goto end;
12321241

1233-
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
1242+
if (!app_RAND_load_file(NULL, bio_err, ++c_no_rand_screen) && inrand == NULL
12341243
&& !RAND_status()) {
12351244
BIO_printf(bio_err,
12361245
"warning, not much extra random data, consider using the -rand option\n");

0 commit comments

Comments
 (0)