@@ -3909,17 +3909,6 @@ int test_tls13_mcdc_hrr_coverage(void)
39093909 WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
39103910 WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
39113911 struct test_memio_ctx test_ctx ;
3912- (void )ctx_c ;
3913- (void )ssl_c ;
3914- (void )ctx_s ;
3915- (void )ssl_s ;
3916- (void )test_ctx ;
3917-
3918- /* Client offers P-384 (or P-521) key_share in CH1 but also advertises
3919- * P-256 as a supported group; server prefers P-256 -> server sends HRR
3920- * with key_share extension selecting P-256 -> client retries with P-256.
3921- * When client_grp == server_grp both sides agree immediately; HRR is
3922- * still triggered by the stateless cookie mechanism. */
39233912 int server_grp = WOLFSSL_ECC_SECP256R1 ;
39243913#if defined(HAVE_ECC384 ) && (ECC_MIN_KEY_SZ <= 384 )
39253914 int client_grp = WOLFSSL_ECC_SECP384R1 ;
@@ -3940,6 +3929,11 @@ int test_tls13_mcdc_hrr_coverage(void)
39403929 int client_grps [2 ] = { client_grp , 0 };
39413930 int client_grps_cnt = 1 ;
39423931#endif
3932+ (void )ctx_c ;
3933+ (void )ssl_c ;
3934+ (void )ctx_s ;
3935+ (void )ssl_s ;
3936+ (void )test_ctx ;
39433937
39443938 XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
39453939 ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
@@ -4334,13 +4328,15 @@ int test_tls13_mcdc_batch2_post_handshake_auth(void)
43344328 WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
43354329 WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
43364330 struct test_memio_ctx test_ctx ;
4331+ char buf [64 ];
4332+ int err ;
4333+ int rounds ;
4334+ int ret ;
43374335 (void )ctx_c ;
43384336 (void )ssl_c ;
43394337 (void )ctx_s ;
43404338 (void )ssl_s ;
43414339 (void )test_ctx ;
4342- char buf [64 ];
4343- int err ;
43444340
43454341 XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
43464342 ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
@@ -4365,24 +4361,44 @@ int test_tls13_mcdc_batch2_post_handshake_auth(void)
43654361 /* Phase 1: complete the main TLS 1.3 handshake. */
43664362 ExpectIntEQ (test_memio_do_handshake (ssl_c , ssl_s , 10 , NULL ), 0 );
43674363
4368- /* Drain any NewSessionTicket records at the client. */
4369- ExpectIntEQ (wolfSSL_read (ssl_c , buf , sizeof (buf )), -1 );
4370- err = wolfSSL_get_error (ssl_c , -1 );
4371- ExpectTrue (err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE );
4364+ /* Drain any NewSessionTicket records at the client. */
4365+ rounds = 0 ;
4366+ do {
4367+ ret = wolfSSL_read (ssl_c , buf , sizeof (buf ));
4368+ if (ret > 0 )
4369+ continue ;
4370+ err = wolfSSL_get_error (ssl_c , -1 );
4371+ rounds ++ ;
4372+ } while (err != WOLFSSL_ERROR_WANT_READ && err != WOLFSSL_ERROR_NONE &&
4373+ err != WOLFSSL_ERROR_WANT_WRITE && rounds < 32 && !EXPECT_FAIL ());
4374+ ExpectTrue (err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE ||
4375+ err == WOLFSSL_ERROR_WANT_WRITE );
43724376
43734377 /* Phase 2: server sends a post-handshake CertificateRequest. */
43744378 ExpectIntEQ (wolfSSL_request_certificate (ssl_s ), WOLFSSL_SUCCESS );
43754379
4376- /* Pump client-side: read CertificateRequest, produce Certificate +
4377- * CertificateVerify + Finished. */
4378- ExpectIntEQ (wolfSSL_read (ssl_c , buf , sizeof (buf )), -1 );
4379- err = wolfSSL_get_error (ssl_c , -1 );
4380- ExpectTrue (err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE );
4380+ /* Pump both sides until post-handshake auth traffic quiesces. */
4381+ for (rounds = 0 ; rounds < 32 && !EXPECT_FAIL (); rounds ++ ) {
4382+ ret = wolfSSL_read (ssl_c , buf , sizeof (buf ));
4383+ if (ret <= 0 ) {
4384+ err = wolfSSL_get_error (ssl_c , -1 );
4385+ ExpectTrue (err == WOLFSSL_ERROR_WANT_READ ||
4386+ err == WOLFSSL_ERROR_WANT_WRITE ||
4387+ err == WOLFSSL_ERROR_NONE );
4388+ }
43814389
4382- /* Pump server-side: receive the client certificate messages. */
4383- ExpectIntEQ (wolfSSL_read (ssl_s , buf , sizeof (buf )), -1 );
4384- err = wolfSSL_get_error (ssl_s , -1 );
4385- ExpectTrue (err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE );
4390+ ret = wolfSSL_read (ssl_s , buf , sizeof (buf ));
4391+ if (ret <= 0 ) {
4392+ err = wolfSSL_get_error (ssl_s , -1 );
4393+ ExpectTrue (err == WOLFSSL_ERROR_WANT_READ ||
4394+ err == WOLFSSL_ERROR_WANT_WRITE ||
4395+ err == WOLFSSL_ERROR_NONE );
4396+ }
4397+
4398+ if (test_ctx .c_len == 0 && test_ctx .s_len == 0 ) {
4399+ break ;
4400+ }
4401+ }
43864402
43874403 /* App-data round-trip after post-handshake auth verifies keys intact. */
43884404 ExpectIntEQ (wolfSSL_write (ssl_s , "pha-ok" , 6 ), 6 );
@@ -4424,15 +4440,15 @@ int test_tls13_mcdc_batch2_early_data(void)
44244440 WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
44254441 WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
44264442 struct test_memio_ctx test_ctx ;
4443+ WOLFSSL_SESSION * sess = NULL ;
4444+ char msgBuf [64 ];
4445+ int written = 0 ;
4446+ int readSz = 0 ;
44274447 (void )ctx_c ;
44284448 (void )ssl_c ;
44294449 (void )ctx_s ;
44304450 (void )ssl_s ;
44314451 (void )test_ctx ;
4432- WOLFSSL_SESSION * sess = NULL ;
4433- char msgBuf [64 ];
4434- int written = 0 ;
4435- int readSz = 0 ;
44364452
44374453 /* ---- pass 1: establish session ticket -------------------------------- */
44384454 XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
@@ -4803,10 +4819,9 @@ int test_tls13_mcdc_batch2_alpn(void)
48034819 defined(WOLFSSL_TLS13 ) && \
48044820 !defined(NO_WOLFSSL_CLIENT ) && !defined(NO_WOLFSSL_SERVER ) && \
48054821 defined(HAVE_ALPN )
4806- struct test_memio_ctx test_ctx ;
4807- (void )test_ctx ;
48084822 WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
48094823 WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
4824+ struct test_memio_ctx test_ctx ;
48104825 (void )ctx_c ;
48114826 (void )ssl_c ;
48124827 (void )ctx_s ;
@@ -4815,6 +4830,7 @@ int test_tls13_mcdc_batch2_alpn(void)
48154830 unsigned short protoSz = 0 ;
48164831 char alpn_h2 [] = "h2" ;
48174832 char alpn_http11 [] = "http/1.1" ;
4833+ (void )test_ctx ;
48184834
48194835 /* ---- sub-test A: matching ALPN protocol "h2" -------------------------- */
48204836 XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
0 commit comments