@@ -1206,7 +1206,7 @@ static int ClientWriteRead(WOLFSSL* ssl, const char* msg, int msgSz,
12061206/* 4. add the same message into Japanese section */
12071207/* (will be translated later) */
12081208/* 5. add printf() into suitable position of Usage() */
1209- static const char * client_usage_msg [][80 ] = {
1209+ static const char * client_usage_msg [][81 ] = {
12101210 /* English */
12111211 {
12121212 " NOTE: All files relative to wolfSSL home dir\n" , /* 0 */
@@ -1451,24 +1451,28 @@ static const char* client_usage_msg[][80] = {
14511451#ifndef NO_PSK
14521452 "--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n" , /* 73 */
14531453#endif
1454+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
1455+ !defined (NO_PSK )
1456+ "--psk-with-certs Use TLS 1.3 PSK with certificates\n" , /* 74 */
1457+ #endif
14541458#ifdef HAVE_RPK
1455- "--rpk Use RPK for the defined certificates\n" , /* 74 */
1459+ "--rpk Use RPK for the defined certificates\n" , /* 75 */
14561460#endif
1457- "--files-are-der Specified files are in DER, not PEM format\n" , /* 75 */
1461+ "--files-are-der Specified files are in DER, not PEM format\n" , /* 76 */
14581462#ifdef WOLFSSL_SYS_CRYPTO_POLICY
1459- "--crypto-policy <path to crypto policy file>\n" , /* 76 */
1463+ "--crypto-policy <path to crypto policy file>\n" , /* 77 */
14601464#endif
14611465#ifdef HAVE_ECC_BRAINPOOL
1462- "--bpKs Use Brainpool ECC group for key share\n" , /* 77 */
1466+ "--bpKs Use Brainpool ECC group for key share\n" , /* 78 */
14631467#endif
14641468#if defined(WOLFSSL_TLS13 ) && defined (HAVE_ECH )
14651469 "--ech <base64> Use Encrypted Client Hello with base64 encoded "
14661470 "ECH configs\n" ,
1467- /* 78 */
1471+ /* 79 */
14681472#endif
14691473 "\n"
14701474 "For simpler wolfSSL TLS client examples, visit\n"
1471- "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 79 */
1475+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 80 */
14721476 NULL ,
14731477 },
14741478#ifndef NO_MULTIBYTE_PRINT
@@ -1717,20 +1721,24 @@ static const char* client_usage_msg[][80] = {
17171721#ifndef NO_PSK
17181722 "--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n" , /* 73 */
17191723#endif
1724+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
1725+ !defined (NO_PSK )
1726+ "--psk-with-certs Use TLS 1.3 PSK with certificates\n" , /* 74 */
1727+ #endif
17201728#ifdef HAVE_RPK
1721- "--rpk Use RPK for the defined certificates\n" , /* 74 */
1729+ "--rpk Use RPK for the defined certificates\n" , /* 75 */
17221730#endif
1723- "--files-are-der Specified files are in DER, not PEM format\n" , /* 75 */
1731+ "--files-are-der Specified files are in DER, not PEM format\n" , /* 76 */
17241732#ifdef WOLFSSL_SYS_CRYPTO_POLICY
1725- "--crypto-policy <path to crypto policy file>\n" , /* 76 */
1733+ "--crypto-policy <path to crypto policy file>\n" , /* 77 */
17261734#endif
17271735#ifdef HAVE_ECC_BRAINPOOL
1728- "--bpKs Use Brainpool ECC group for key share\n" , /* 77 */
1736+ "--bpKs Use Brainpool ECC group for key share\n" , /* 78 */
17291737#endif
17301738 "\n"
17311739 "より簡単なwolfSSL TLS クライアントの例については"
17321740 "下記にアクセスしてください\n"
1733- "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 78 */
1741+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 79 */
17341742 NULL ,
17351743 },
17361744#endif
@@ -1966,6 +1974,10 @@ static void Usage(void)
19661974#ifndef NO_PSK
19671975 printf ("%s" , msg [++ msgid ]); /* --openssl-psk */
19681976#endif
1977+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
1978+ !defined(NO_PSK )
1979+ printf ("%s" , msg [++ msgid ]); /* --psk-with-certs */
1980+ #endif
19691981#ifdef HAVE_RPK
19701982 printf ("%s" , msg [++ msgid ]); /* --rpk */
19711983#endif
@@ -2165,6 +2177,10 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
21652177#endif
21662178#if defined(WOLFSSL_TLS13 ) && defined (HAVE_ECH )
21672179 { "ech" , 1 , 271 },
2180+ #endif
2181+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
2182+ !defined (NO_PSK )
2183+ { "psk-with-certs" , 0 , 272 },
21682184#endif
21692185 { 0 , 0 , 0 }
21702186 };
@@ -2173,6 +2189,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
21732189 int minVersion = CLIENT_INVALID_VERSION ;
21742190 int usePsk = 0 ;
21752191 int opensslPsk = 0 ;
2192+ int usePskWithCerts = 0 ;
21762193 int useAnon = 0 ;
21772194 int sendGET = 0 ;
21782195 int benchmark = 0 ;
@@ -2412,6 +2429,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
24122429 (void )pqcAlg ;
24132430 (void )opensslPsk ;
24142431 (void )fileFormat ;
2432+ (void )usePskWithCerts ;
24152433 StackTrap ();
24162434
24172435 /* Reinitialize the global myVerifyAction. */
@@ -3067,6 +3085,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
30673085 echConfigs64 = myoptarg ;
30683086 break ;
30693087#endif
3088+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
3089+ !defined(NO_PSK )
3090+ case 272 :
3091+ usePskWithCerts = 1 ;
3092+ break ;
3093+ #endif
30703094
30713095 default :
30723096 Usage ();
@@ -3077,6 +3101,18 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
30773101 myoptind = 0 ; /* reset for test cases */
30783102#endif /* !WOLFSSL_VXWORKS */
30793103
3104+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
3105+ !defined(NO_PSK )
3106+ if (usePskWithCerts ) {
3107+ usePsk = 1 ;
3108+ if (noPskDheKe ) {
3109+ LOG_ERROR ("--psk-with-certs requires PSK key exchange with (EC)DHE" );
3110+ Usage ();
3111+ XEXIT_T (MY_EX_USAGE );
3112+ }
3113+ }
3114+ #endif
3115+
30803116 if (externalTest ) {
30813117 /* detect build cases that wouldn't allow test against wolfssl.com */
30823118 int done = 0 ;
@@ -3483,6 +3519,14 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
34833519 wolfSSL_CTX_set_psk_client_tls13_callback (ctx ,
34843520 my_psk_client_tls13_cb );
34853521 }
3522+ #if defined(WOLFSSL_CERT_WITH_EXTERN_PSK )
3523+ if (usePskWithCerts ) {
3524+ if (wolfSSL_CTX_set_cert_with_extern_psk (ctx , 1 ) != WOLFSSL_SUCCESS ) {
3525+ wolfSSL_CTX_free (ctx ); ctx = NULL ;
3526+ err_sys ("client can't enable cert_with_extern_psk" );
3527+ }
3528+ }
3529+ #endif
34863530#endif
34873531 if (defaultCipherList == NULL ) {
34883532 #if defined(HAVE_AESGCM ) && !defined(NO_DH )
@@ -3634,7 +3678,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
36343678 #endif
36353679 }
36363680
3637- if (!usePsk && !useAnon && !useVerifyCb && myVerifyAction != VERIFY_FORCE_FAIL ) {
3681+ if ((!usePsk || usePskWithCerts ) && !useAnon && !useVerifyCb &&
3682+ myVerifyAction != VERIFY_FORCE_FAIL ) {
36383683 #if defined(OPENSSL_ALL ) && defined(WOLFSSL_CERT_GEN ) && \
36393684 (defined(WOLFSSL_CERT_REQ ) || defined(WOLFSSL_CERT_EXT )) && \
36403685 !defined(NO_FILESYSTEM ) && !defined(NO_WOLFSSL_DIR )
@@ -3718,10 +3763,11 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37183763 myVerifyAction == VERIFY_USE_PREVERIFY ) {
37193764 wolfSSL_CTX_set_verify (ctx , WOLFSSL_VERIFY_PEER , myVerify );
37203765 }
3721- else if (!usePsk && !useAnon && doPeerCheck == 0 ) {
3766+ else if (( !usePsk || usePskWithCerts ) && !useAnon && doPeerCheck == 0 ) {
37223767 wolfSSL_CTX_set_verify (ctx , WOLFSSL_VERIFY_NONE , NULL );
37233768 }
3724- else if (!usePsk && !useAnon && myVerifyAction == VERIFY_OVERRIDE_DATE_ERR ) {
3769+ else if ((!usePsk || usePskWithCerts ) && !useAnon &&
3770+ myVerifyAction == VERIFY_OVERRIDE_DATE_ERR ) {
37253771 wolfSSL_CTX_set_verify (ctx , WOLFSSL_VERIFY_PEER , myVerify );
37263772 }
37273773#endif /* !NO_CERTS */
0 commit comments