2727
2828int err = 0 ;
2929
30+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
3031typedef enum {
3132 INIT_LIB_CTX ,
3233 INIT_LIB_AND_SSL_CTX ,
@@ -38,11 +39,13 @@ struct ctxs {
3839 SSL_CTX * cctx ;
3940};
4041
42+ static struct ctxs * * ctx_pool = NULL ;
43+ #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
44+
4145static SSL_CTX * sctx = NULL , * cctx = NULL ;
4246static int share_ctx = 1 ;
4347static char * cert = NULL ;
4448static char * privkey = NULL ;
45- static struct ctxs * * ctx_pool = NULL ;
4649
4750size_t * counts ;
4851
@@ -52,9 +55,11 @@ static long pool_size = 16;
5255
5356typedef enum {
5457 TC_SSL_CTX ,
58+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
5559 TC_OSSL_LIB_CTX_PER_THREAD ,
5660 TC_OSSL_LIB_CTX_POOL ,
5761 TC_SSL_CTX_POOL ,
62+ #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
5863} test_case_t ;
5964OSSL_TIME max_time ;
6065static test_case_t test_case = TC_SSL_CTX ;
@@ -105,6 +110,8 @@ static void do_handshake(size_t num)
105110 err = 1 ;
106111}
107112
113+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
114+
108115static void do_handshake_ossl_lib_ctx_per_thread (size_t num )
109116{
110117 SSL * clientssl = NULL , * serverssl = NULL ;
@@ -315,17 +322,21 @@ static int test_ossl_lib_ctx_pool(size_t threadcount, OSSL_TIME *duration)
315322 free_ctx_pool ();
316323
317324 return ret ;
318- }
325+ }
326+
327+ #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
319328
320329void usage (const char * progname )
321330{
322331 printf ("Usage: %s [options] certsdir threadcount\n" , progname );
323332 printf ("-t - terse output\n" );
324333 printf ("-s - disable context sharing\n" );
334+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
325335 printf ("-p - use ossl_lib_ctx per thread\n" );
326336 printf ("-P - use ossl_lib_ctx pool\n" );
327337 printf ("-l - use ssl ctx pool\n" );
328338 printf ("-o - set ossl_lib_ctx pool size\n" );
339+ #endif
329340 printf ("-S [n] - use secure memory\n" );
330341}
331342
@@ -342,14 +353,21 @@ int main(int argc, char * const argv[])
342353 int p_flag = 0 , P_flag = 0 , l_flag = 0 ;
343354 char * endptr = NULL ;
344355
345- while ((opt = getopt (argc , argv , "tspPo:lS:" )) != -1 ) {
356+ while ((opt = getopt (argc , argv ,
357+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
358+ "tspPo:lS:"
359+ #else
360+ "tsS:"
361+ #endif
362+ )) != -1 ) {
346363 switch (opt ) {
347364 case 't' :
348365 terse = 1 ;
349366 break ;
350367 case 's' :
351368 share_ctx = 0 ;
352369 break ;
370+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
353371 case 'p' :
354372 p_flag = 1 ;
355373 test_case = TC_OSSL_LIB_CTX_PER_THREAD ;
@@ -381,6 +399,7 @@ int main(int argc, char * const argv[])
381399 l_flag = 1 ;
382400 test_case = TC_SSL_CTX_POOL ;
383401 break ;
402+ #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
384403 case 'S' : {
385404 char * end = NULL ;
386405 int sec_mem_size ;
@@ -408,12 +427,14 @@ int main(int argc, char * const argv[])
408427 }
409428 }
410429
430+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
411431 if ((p_flag + P_flag + l_flag ) > 1 ) {
412432 fprintf (stderr , "Error: -p, -P, and -l are mutually exclusive."
413433 " Choose only one.\n\n" );
414434 usage (basename (argv [0 ]));
415435 return EXIT_FAILURE ;
416436 }
437+ #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
417438
418439 if (argv [optind ] == NULL ) {
419440 printf ("certsdir is missing\n" );
@@ -461,6 +482,7 @@ int main(int argc, char * const argv[])
461482 }
462483 break ;
463484 }
485+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
464486 case TC_OSSL_LIB_CTX_PER_THREAD : {
465487 if (!perflib_run_multi_thread_test (do_handshake_ossl_lib_ctx_per_thread ,
466488 threadcount , & duration )) {
@@ -477,6 +499,7 @@ int main(int argc, char * const argv[])
477499 }
478500 break ;
479501 }
502+ #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
480503 default :
481504 fprintf (stderr , "Invalid test case\n" );
482505 goto err ;
0 commit comments