@@ -1209,7 +1209,7 @@ static int ClientWriteRead(WOLFSSL* ssl, const char* msg, int msgSz,
12091209/* 4. add the same message into Japanese section */
12101210/* (will be translated later) */
12111211/* 5. add printf() into suitable position of Usage() */
1212- static const char * client_usage_msg [][80 ] = {
1212+ static const char * client_usage_msg [][81 ] = {
12131213 /* English */
12141214 {
12151215 " NOTE: All files relative to wolfSSL home dir\n" , /* 0 */
@@ -1454,24 +1454,28 @@ static const char* client_usage_msg[][80] = {
14541454#ifndef NO_PSK
14551455 "--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n" , /* 73 */
14561456#endif
1457+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
1458+ !defined (NO_PSK )
1459+ "--psk-with-certs Use TLS 1.3 PSK with certificates\n" , /* 74 */
1460+ #endif
14571461#ifdef HAVE_RPK
1458- "--rpk Use RPK for the defined certificates\n" , /* 74 */
1462+ "--rpk Use RPK for the defined certificates\n" , /* 75 */
14591463#endif
1460- "--files-are-der Specified files are in DER, not PEM format\n" , /* 75 */
1464+ "--files-are-der Specified files are in DER, not PEM format\n" , /* 76 */
14611465#ifdef WOLFSSL_SYS_CRYPTO_POLICY
1462- "--crypto-policy <path to crypto policy file>\n" , /* 76 */
1466+ "--crypto-policy <path to crypto policy file>\n" , /* 77 */
14631467#endif
14641468#ifdef HAVE_ECC_BRAINPOOL
1465- "--bpKs Use Brainpool ECC group for key share\n" , /* 77 */
1469+ "--bpKs Use Brainpool ECC group for key share\n" , /* 78 */
14661470#endif
14671471#if defined(WOLFSSL_TLS13 ) && defined (HAVE_ECH )
14681472 "--ech <base64> Use Encrypted Client Hello with base64 encoded "
14691473 "ECH configs\n" ,
1470- /* 78 */
1474+ /* 79 */
14711475#endif
14721476 "\n"
14731477 "For simpler wolfSSL TLS client examples, visit\n"
1474- "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 79 */
1478+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 80 */
14751479 NULL ,
14761480 },
14771481#ifndef NO_MULTIBYTE_PRINT
@@ -1720,20 +1724,24 @@ static const char* client_usage_msg[][80] = {
17201724#ifndef NO_PSK
17211725 "--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n" , /* 73 */
17221726#endif
1727+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
1728+ !defined (NO_PSK )
1729+ "--psk-with-certs Use TLS 1.3 PSK with certificates\n" , /* 74 */
1730+ #endif
17231731#ifdef HAVE_RPK
1724- "--rpk Use RPK for the defined certificates\n" , /* 74 */
1732+ "--rpk Use RPK for the defined certificates\n" , /* 75 */
17251733#endif
1726- "--files-are-der Specified files are in DER, not PEM format\n" , /* 75 */
1734+ "--files-are-der Specified files are in DER, not PEM format\n" , /* 76 */
17271735#ifdef WOLFSSL_SYS_CRYPTO_POLICY
1728- "--crypto-policy <path to crypto policy file>\n" , /* 76 */
1736+ "--crypto-policy <path to crypto policy file>\n" , /* 77 */
17291737#endif
17301738#ifdef HAVE_ECC_BRAINPOOL
1731- "--bpKs Use Brainpool ECC group for key share\n" , /* 77 */
1739+ "--bpKs Use Brainpool ECC group for key share\n" , /* 78 */
17321740#endif
17331741 "\n"
17341742 "より簡単なwolfSSL TLS クライアントの例については"
17351743 "下記にアクセスしてください\n"
1736- "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 78 */
1744+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 79 */
17371745 NULL ,
17381746 },
17391747#endif
@@ -1969,6 +1977,10 @@ static void Usage(void)
19691977#ifndef NO_PSK
19701978 printf ("%s" , msg [++ msgid ]); /* --openssl-psk */
19711979#endif
1980+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
1981+ !defined(NO_PSK )
1982+ printf ("%s" , msg [++ msgid ]); /* --psk-with-certs */
1983+ #endif
19721984#ifdef HAVE_RPK
19731985 printf ("%s" , msg [++ msgid ]); /* --rpk */
19741986#endif
@@ -2168,6 +2180,10 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
21682180#endif
21692181#if defined(WOLFSSL_TLS13 ) && defined (HAVE_ECH )
21702182 { "ech" , 1 , 271 },
2183+ #endif
2184+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
2185+ !defined (NO_PSK )
2186+ { "psk-with-certs" , 0 , 272 },
21712187#endif
21722188 { 0 , 0 , 0 }
21732189 };
@@ -2176,6 +2192,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
21762192 int minVersion = CLIENT_INVALID_VERSION ;
21772193 int usePsk = 0 ;
21782194 int opensslPsk = 0 ;
2195+ int usePskWithCerts = 0 ;
21792196 int useAnon = 0 ;
21802197 int sendGET = 0 ;
21812198 int benchmark = 0 ;
@@ -3070,6 +3087,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
30703087 echConfigs64 = myoptarg ;
30713088 break ;
30723089#endif
3090+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
3091+ !defined(NO_PSK )
3092+ case 272 :
3093+ usePskWithCerts = 1 ;
3094+ break ;
3095+ #endif
30733096
30743097 default :
30753098 Usage ();
@@ -3080,6 +3103,18 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
30803103 myoptind = 0 ; /* reset for test cases */
30813104#endif /* !WOLFSSL_VXWORKS */
30823105
3106+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_CERT_WITH_EXTERN_PSK ) && \
3107+ !defined(NO_PSK )
3108+ if (usePskWithCerts ) {
3109+ usePsk = 1 ;
3110+ if (noPskDheKe ) {
3111+ LOG_ERROR ("--psk-with-certs requires PSK key exchange with (EC)DHE" );
3112+ Usage ();
3113+ XEXIT_T (MY_EX_USAGE );
3114+ }
3115+ }
3116+ #endif
3117+
30833118 if (externalTest ) {
30843119 /* detect build cases that wouldn't allow test against wolfssl.com */
30853120 int done = 0 ;
@@ -3486,6 +3521,14 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
34863521 wolfSSL_CTX_set_psk_client_tls13_callback (ctx ,
34873522 my_psk_client_tls13_cb );
34883523 }
3524+ #if defined(WOLFSSL_CERT_WITH_EXTERN_PSK )
3525+ if (usePskWithCerts ) {
3526+ if (wolfSSL_CTX_set_cert_with_extern_psk (ctx , 1 ) != WOLFSSL_SUCCESS ) {
3527+ wolfSSL_CTX_free (ctx ); ctx = NULL ;
3528+ err_sys ("client can't enable cert_with_extern_psk" );
3529+ }
3530+ }
3531+ #endif
34893532#endif
34903533 if (defaultCipherList == NULL ) {
34913534 #if defined(HAVE_AESGCM ) && !defined(NO_DH )
@@ -3637,7 +3680,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
36373680 #endif
36383681 }
36393682
3640- if (!usePsk && !useAnon && !useVerifyCb && myVerifyAction != VERIFY_FORCE_FAIL ) {
3683+ if ((!usePsk || usePskWithCerts ) && !useAnon && !useVerifyCb &&
3684+ myVerifyAction != VERIFY_FORCE_FAIL ) {
36413685 #if defined(OPENSSL_ALL ) && defined(WOLFSSL_CERT_GEN ) && \
36423686 (defined(WOLFSSL_CERT_REQ ) || defined(WOLFSSL_CERT_EXT )) && \
36433687 !defined(NO_FILESYSTEM ) && !defined(NO_WOLFSSL_DIR )
@@ -3721,10 +3765,11 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37213765 myVerifyAction == VERIFY_USE_PREVERIFY ) {
37223766 wolfSSL_CTX_set_verify (ctx , WOLFSSL_VERIFY_PEER , myVerify );
37233767 }
3724- else if (!usePsk && !useAnon && doPeerCheck == 0 ) {
3768+ else if (( !usePsk || usePskWithCerts ) && !useAnon && doPeerCheck == 0 ) {
37253769 wolfSSL_CTX_set_verify (ctx , WOLFSSL_VERIFY_NONE , NULL );
37263770 }
3727- else if (!usePsk && !useAnon && myVerifyAction == VERIFY_OVERRIDE_DATE_ERR ) {
3771+ else if ((!usePsk || usePskWithCerts ) && !useAnon &&
3772+ myVerifyAction == VERIFY_OVERRIDE_DATE_ERR ) {
37283773 wolfSSL_CTX_set_verify (ctx , WOLFSSL_VERIFY_PEER , myVerify );
37293774 }
37303775#endif /* !NO_CERTS */
0 commit comments