@@ -180,6 +180,13 @@ typedef unsigned int u_int;
180180# include <fcntl.h>
181181#endif
182182
183+ /* Use Windows API with STD_INPUT_HANDLE when checking for input?
184+ Don't look at OPENSSL_SYS_MSDOS for this, since it is always defined if
185+ OPENSSL_SYS_WINDOWS is defined */
186+ #if defined(OPENSSL_SYS_WINDOWS ) && !defined(OPENSSL_SYS_WINCE ) && defined(STD_INPUT_HANDLE )
187+ #define OPENSSL_USE_STD_INPUT_HANDLE
188+ #endif
189+
183190#undef PROG
184191#define PROG s_client_main
185192
@@ -226,6 +233,7 @@ static int ocsp_resp_cb(SSL *s, void *arg);
226233static BIO * bio_c_out = NULL ;
227234static int c_quiet = 0 ;
228235static int c_ign_eof = 0 ;
236+ static int c_no_rand_screen = 0 ;
229237
230238#ifndef OPENSSL_NO_PSK
231239/* Default PSK identity and key */
@@ -428,6 +436,10 @@ static void sc_usage(void)
428436 " -keymatexport label - Export keying material using label\n" );
429437 BIO_printf (bio_err ,
430438 " -keymatexportlen len - Export len bytes of keying material (default 20)\n" );
439+ #ifdef OPENSSL_SYS_WINDOWS
440+ BIO_printf (bio_err ,
441+ " -no_rand_screen - Do not use RAND_screen() to initialize random state\n" );
442+ #endif
431443}
432444
433445#ifndef OPENSSL_NO_TLSEXT
@@ -1004,6 +1016,10 @@ int MAIN(int argc, char **argv)
10041016 keymatexportlen = atoi (* (++ argv ));
10051017 if (keymatexportlen == 0 )
10061018 goto bad ;
1019+ #ifdef OPENSSL_SYS_WINDOWS
1020+ } else if (strcmp (* argv , "-no_rand_screen" ) == 0 ) {
1021+ c_no_rand_screen = 1 ;
1022+ #endif
10071023 } else {
10081024 BIO_printf (bio_err , "unknown option %s\n" , * argv );
10091025 badop = 1 ;
@@ -1087,7 +1103,7 @@ int MAIN(int argc, char **argv)
10871103 }
10881104 }
10891105
1090- if (!app_RAND_load_file (NULL, bio_err , 1 ) && inrand == NULL
1106+ if (!app_RAND_load_file (NULL , bio_err , ++ c_no_rand_screen ) && inrand == NULL
10911107 && !RAND_status ()) {
10921108 BIO_printf (bio_err ,
10931109 "warning, not much extra random data, consider using the -rand option\n" );
@@ -1584,18 +1600,11 @@ int MAIN(int argc, char **argv)
15841600 tv .tv_usec = 0 ;
15851601 i = select (width , (void * )& readfds , (void * )& writefds ,
15861602 NULL , & tv );
1587- # if defined(OPENSSL_SYS_WINCE ) || defined(OPENSSL_SYS_MSDOS )
1588- if (!i && (!_kbhit () || !read_tty ))
1589- continue ;
1590- # else
1591- if (!i && (!((_kbhit ())
1592- || (WAIT_OBJECT_0 ==
1593- WaitForSingleObject (GetStdHandle
1594- (STD_INPUT_HANDLE ),
1595- 0 )))
1596- || !read_tty ))
1597- continue ;
1598- # endif
1603+ #if defined(OPENSSL_USE_STD_INPUT_HANDLE )
1604+ if (!i && (!((_kbhit ()) || (WAIT_OBJECT_0 == WaitForSingleObject (GetStdHandle (STD_INPUT_HANDLE ), 0 ))) || !read_tty ) ) continue ;
1605+ #else
1606+ if (!i && (!_kbhit () || !read_tty ) ) continue ;
1607+ #endif
15991608 } else
16001609 i = select (width , (void * )& readfds , (void * )& writefds ,
16011610 NULL , timeoutp );
@@ -1793,13 +1802,11 @@ int MAIN(int argc, char **argv)
17931802 }
17941803 }
17951804#if defined(OPENSSL_SYS_WINDOWS ) || defined(OPENSSL_SYS_MSDOS )
1796- # if defined(OPENSSL_SYS_WINCE ) || defined(OPENSSL_SYS_MSDOS )
1805+ #if defined(OPENSSL_USE_STD_INPUT_HANDLE )
1806+ else if ((_kbhit ()) || (WAIT_OBJECT_0 == WaitForSingleObject (GetStdHandle (STD_INPUT_HANDLE ), 0 )))
1807+ #else
17971808 else if (_kbhit ())
1798- # else
1799- else if ((_kbhit ())
1800- || (WAIT_OBJECT_0 ==
1801- WaitForSingleObject (GetStdHandle (STD_INPUT_HANDLE ), 0 )))
1802- # endif
1809+ #endif
18031810#elif defined (OPENSSL_SYS_NETWARE )
18041811 else if (_kbhit ())
18051812#elif defined(OPENSSL_SYS_BEOS_R5 )
0 commit comments