Skip to content

Commit f316fd2

Browse files
Shigeki OhtsuMyles Borins
Shigeki Ohtsu
authored and
Myles Borins
committed
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 c1ddefd commit f316fd2

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

deps/openssl/openssl/apps/app_rand.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +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-
RAND_screen();
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+
}
128137
#endif
129138

130139
if (file == NULL)

deps/openssl/openssl/apps/s_client.c

Lines changed: 10 additions & 1 deletion
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 */
@@ -454,6 +455,10 @@ static void sc_usage(void)
454455
" -keymatexport label - Export keying material using label\n");
455456
BIO_printf(bio_err,
456457
" -keymatexportlen len - Export len bytes of keying material (default 20)\n");
458+
#ifdef OPENSSL_SYS_WINDOWS
459+
BIO_printf(bio_err,
460+
" -no_rand_screen - Do not use RAND_screen() to initialize random state\n");
461+
#endif
457462
}
458463

459464
#ifndef OPENSSL_NO_TLSEXT
@@ -1133,6 +1138,10 @@ int MAIN(int argc, char **argv)
11331138
keymatexportlen = atoi(*(++argv));
11341139
if (keymatexportlen == 0)
11351140
goto bad;
1141+
#ifdef OPENSSL_SYS_WINDOWS
1142+
} else if (strcmp(*argv, "-no_rand_screen") == 0) {
1143+
c_no_rand_screen = 1;
1144+
#endif
11361145
} else {
11371146
BIO_printf(bio_err, "unknown option %s\n", *argv);
11381147
badop = 1;
@@ -1238,7 +1247,7 @@ int MAIN(int argc, char **argv)
12381247
if (!load_excert(&exc, bio_err))
12391248
goto end;
12401249

1241-
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
1250+
if (!app_RAND_load_file(NULL, bio_err, ++c_no_rand_screen) && inrand == NULL
12421251
&& !RAND_status()) {
12431252
BIO_printf(bio_err,
12441253
"warning, not much extra random data, consider using the -rand option\n");

0 commit comments

Comments
 (0)