@@ -2927,28 +2927,28 @@ int test_tls13_duplicate_extension(void)
29272927 (!defined(NO_RSA ) || defined(HAVE_ECC ))
29282928static int DupEchSend (WOLFSSL * ssl , char * buf , int sz , void * ctx )
29292929{
2930- (void )ssl ;
2931- (void )buf ;
2932- (void )sz ;
2933- (void )ctx ;
2930+ (void )ssl ;
2931+ (void )buf ;
2932+ (void )sz ;
2933+ (void )ctx ;
29342934
2935- return sz ;
2935+ return sz ;
29362936}
29372937static int DupEchRecv (WOLFSSL * ssl , char * buf , int sz , void * ctx )
29382938{
2939- WOLFSSL_BUFFER_INFO * msg = (WOLFSSL_BUFFER_INFO * )ctx ;
2940- int len = (int )msg -> length ;
2939+ WOLFSSL_BUFFER_INFO * msg = (WOLFSSL_BUFFER_INFO * )ctx ;
2940+ int len = (int )msg -> length ;
29412941
2942- (void )ssl ;
2943- (void )sz ;
2942+ (void )ssl ;
2943+ (void )sz ;
29442944
2945- if (len > sz )
2946- len = sz ;
2947- XMEMCPY (buf , msg -> buffer , len );
2948- msg -> buffer += len ;
2949- msg -> length -= len ;
2945+ if (len > sz )
2946+ len = sz ;
2947+ XMEMCPY (buf , msg -> buffer , len );
2948+ msg -> buffer += len ;
2949+ msg -> length -= len ;
29502950
2951- return len ;
2951+ return len ;
29522952}
29532953#endif
29542954
@@ -2959,68 +2959,68 @@ static int DupEchRecv(WOLFSSL* ssl, char* buf, int sz, void* ctx)
29592959 */
29602960int test_tls13_duplicate_ech_extension (void )
29612961{
2962- EXPECT_DECLS ;
2962+ EXPECT_DECLS ;
29632963#if defined(WOLFSSL_TLS13 ) && defined(HAVE_ECH ) && \
29642964 !defined(NO_WOLFSSL_SERVER ) && !defined(NO_FILESYSTEM ) && \
29652965 (!defined(NO_RSA ) || defined(HAVE_ECC ))
2966- /* TLS 1.3 ClientHello with two ECH extensions (type 0xfe0d).
2967- * Extensions block contains: supported_versions + ECH + ECH (dup). */
2968- const unsigned char clientHelloDupEch [] = {
2969- 0x16 , 0x03 , 0x03 , 0x00 , 0x40 , 0x01 , 0x00 , 0x00 ,
2970- 0x3c , 0x03 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2971- 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2972- 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2973- 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2974- 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x02 , 0x13 , 0x01 ,
2975- 0x01 , 0x00 , 0x00 , 0x11 , 0x00 , 0x2b , 0x00 , 0x03 ,
2976- 0x02 , 0x03 , 0x04 , 0xfe , 0x0d , 0x00 , 0x01 , 0x00 ,
2977- 0xfe , 0x0d , 0x00 , 0x01 , 0x00
2978- };
2979- WOLFSSL_BUFFER_INFO msg ;
2980- const char * testCertFile ;
2981- const char * testKeyFile ;
2982- WOLFSSL_CTX * ctx = NULL ;
2983- WOLFSSL * ssl = NULL ;
2966+ /* TLS 1.3 ClientHello with two ECH extensions (type 0xfe0d).
2967+ * Extensions block contains: supported_versions + ECH + ECH (dup). */
2968+ const unsigned char clientHelloDupEch [] = {
2969+ 0x16 , 0x03 , 0x03 , 0x00 , 0x40 , 0x01 , 0x00 , 0x00 ,
2970+ 0x3c , 0x03 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2971+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2972+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2973+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2974+ 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x02 , 0x13 , 0x01 ,
2975+ 0x01 , 0x00 , 0x00 , 0x11 , 0x00 , 0x2b , 0x00 , 0x03 ,
2976+ 0x02 , 0x03 , 0x04 , 0xfe , 0x0d , 0x00 , 0x01 , 0x00 ,
2977+ 0xfe , 0x0d , 0x00 , 0x01 , 0x00
2978+ };
2979+ WOLFSSL_BUFFER_INFO msg ;
2980+ const char * testCertFile ;
2981+ const char * testKeyFile ;
2982+ WOLFSSL_CTX * ctx = NULL ;
2983+ WOLFSSL * ssl = NULL ;
29842984
29852985#ifndef NO_RSA
2986- testCertFile = svrCertFile ;
2987- testKeyFile = svrKeyFile ;
2986+ testCertFile = svrCertFile ;
2987+ testKeyFile = svrKeyFile ;
29882988#elif defined(HAVE_ECC )
2989- testCertFile = eccCertFile ;
2990- testKeyFile = eccKeyFile ;
2989+ testCertFile = eccCertFile ;
2990+ testKeyFile = eccKeyFile ;
29912991#endif
29922992
2993- ExpectNotNull (ctx = wolfSSL_CTX_new (wolfTLSv1_3_server_method ()));
2993+ ExpectNotNull (ctx = wolfSSL_CTX_new (wolfTLSv1_3_server_method ()));
29942994
2995- ExpectTrue (wolfSSL_CTX_use_certificate_file (ctx , testCertFile ,
2996- CERT_FILETYPE ));
2997- ExpectTrue (wolfSSL_CTX_use_PrivateKey_file (ctx , testKeyFile ,
2998- CERT_FILETYPE ));
2995+ ExpectTrue (wolfSSL_CTX_use_certificate_file (ctx , testCertFile ,
2996+ CERT_FILETYPE ));
2997+ ExpectTrue (wolfSSL_CTX_use_PrivateKey_file (ctx , testKeyFile ,
2998+ CERT_FILETYPE ));
29992999
3000- /* Read from 'msg'. */
3001- wolfSSL_SetIORecv (ctx , DupEchRecv );
3002- /* No where to send to - dummy sender. */
3003- wolfSSL_SetIOSend (ctx , DupEchSend );
3000+ /* Read from 'msg'. */
3001+ wolfSSL_SetIORecv (ctx , DupEchRecv );
3002+ /* No where to send to - dummy sender. */
3003+ wolfSSL_SetIOSend (ctx , DupEchSend );
30043004
3005- ssl = wolfSSL_new (ctx );
3006- ExpectNotNull (ssl );
3005+ ssl = wolfSSL_new (ctx );
3006+ ExpectNotNull (ssl );
30073007
3008- msg .buffer = (unsigned char * )clientHelloDupEch ;
3009- msg .length = (unsigned int )sizeof (clientHelloDupEch );
3010- wolfSSL_SetIOReadCtx (ssl , & msg );
3008+ msg .buffer = (unsigned char * )clientHelloDupEch ;
3009+ msg .length = (unsigned int )sizeof (clientHelloDupEch );
3010+ wolfSSL_SetIOReadCtx (ssl , & msg );
30113011
3012- ExpectIntNE (wolfSSL_accept (ssl ), WOLFSSL_SUCCESS );
3013- /* Can return duplicate ext error or socket error if the peer closed
3014- * down while sending alert. */
3015- if (wolfSSL_get_error (ssl , 0 ) != WC_NO_ERR_TRACE (SOCKET_ERROR_E )) {
3016- ExpectIntEQ (wolfSSL_get_error (ssl , 0 ),
3017- WC_NO_ERR_TRACE (DUPLICATE_TLS_EXT_E ));
3018- }
3012+ ExpectIntNE (wolfSSL_accept (ssl ), WOLFSSL_SUCCESS );
3013+ /* Can return duplicate ext error or socket error if the peer closed
3014+ * down while sending alert. */
3015+ if (wolfSSL_get_error (ssl , 0 ) != WC_NO_ERR_TRACE (SOCKET_ERROR_E )) {
3016+ ExpectIntEQ (wolfSSL_get_error (ssl , 0 ),
3017+ WC_NO_ERR_TRACE (DUPLICATE_TLS_EXT_E ));
3018+ }
30193019
3020- wolfSSL_free (ssl );
3021- wolfSSL_CTX_free (ctx );
3020+ wolfSSL_free (ssl );
3021+ wolfSSL_CTX_free (ctx );
30223022#endif
3023- return EXPECT_RESULT ();
3023+ return EXPECT_RESULT ();
30243024}
30253025
30263026
@@ -3893,12 +3893,15 @@ int test_tls13_empty_record_limit(void)
38933893 }
38943894
38953895 /* Build 1 non-empty record */
3896- XMEMSET (dataRec , 0 , sizeof (dataRec ));
3897- XMEMCPY (dataRec + RECORD_HEADER_SZ , payload , sizeof (payload ));
3898- ExpectIntEQ (BuildTls13Message (ssl_c , dataRec , (int )sizeof (dataRec ),
3899- dataRec + RECORD_HEADER_SZ , 1 , application_data ,
3900- 0 , 0 , 0 ), dataRecSz );
3901- XMEMCPY (allRecs + emptyBefore * recSz , dataRec , (size_t )dataRecSz );
3896+ if (EXPECT_SUCCESS ()) {
3897+ XMEMSET (dataRec , 0 , sizeof (dataRec ));
3898+ XMEMCPY (dataRec + RECORD_HEADER_SZ , payload , sizeof (payload ));
3899+ ExpectIntEQ (BuildTls13Message (ssl_c , dataRec , (int )sizeof (dataRec ),
3900+ dataRec + RECORD_HEADER_SZ , 1 , application_data ,
3901+ 0 , 0 , 0 ), dataRecSz );
3902+ XMEMCPY (allRecs + emptyBefore * recSz , dataRec ,
3903+ (size_t )dataRecSz );
3904+ }
39023905
39033906 /* Build (limit - 1) more empty records */
39043907 for (i = 0 ; i < emptyAfter && EXPECT_SUCCESS (); i ++ ) {
0 commit comments