@@ -2141,3 +2141,50 @@ int test_tls13_early_data(void)
21412141 return EXPECT_RESULT ();
21422142}
21432143
2144+
2145+ /* Check that the client won't send the same CH after a HRR. An HRR without
2146+ * a KeyShare or a Cookie extension will trigger the error. */
2147+ int test_tls13_same_ch (void )
2148+ {
2149+ EXPECT_DECLS ;
2150+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && \
2151+ defined(WOLFSSL_TLS13 )
2152+ WOLFSSL_CTX * ctx_c = NULL ;
2153+ WOLFSSL * ssl_c = NULL ;
2154+ struct test_memio_ctx test_ctx ;
2155+ /* Transport Layer Security
2156+ * TLSv1.3 Record Layer: Handshake Protocol: Hello Retry Request
2157+ * Content Type: Handshake (22)
2158+ * Version: TLS 1.2 (0x0303)
2159+ * Length: 50
2160+ * Handshake Protocol: Hello Retry Request
2161+ * Handshake Type: Server Hello (2)
2162+ * Length: 46
2163+ * Version: TLS 1.2 (0x0303)
2164+ * Random: cf21ad74e59a6111be1d8c021e65b891c2a211167abb8c5e079e09e2c8a8339c (HelloRetryRequest magic)
2165+ * Session ID Length: 0
2166+ * Cipher Suite: TLS_AES_128_GCM_SHA256 (0x1301)
2167+ * Compression Method: null (0)
2168+ * Extensions Length: 6
2169+ * Extension: supported_versions (len=2) TLS 1.3 */
2170+ unsigned char hrr [] = {
2171+ 0x16 , 0x03 , 0x03 , 0x00 , 0x32 , 0x02 , 0x00 , 0x00 , 0x2e , 0x03 , 0x03 , 0xcf ,
2172+ 0x21 , 0xad , 0x74 , 0xe5 , 0x9a , 0x61 , 0x11 , 0xbe , 0x1d , 0x8c , 0x02 , 0x1e ,
2173+ 0x65 , 0xb8 , 0x91 , 0xc2 , 0xa2 , 0x11 , 0x16 , 0x7a , 0xbb , 0x8c , 0x5e , 0x07 ,
2174+ 0x9e , 0x09 , 0xe2 , 0xc8 , 0xa8 , 0x33 , 0x9c , 0x00 , 0x13 , 0x01 , 0x00 , 0x00 ,
2175+ 0x06 , 0x00 , 0x2b , 0x00 , 0x02 , 0x03 , 0x04
2176+ };
2177+
2178+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
2179+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , NULL , & ssl_c , NULL ,
2180+ wolfTLSv1_3_client_method , NULL ), 0 );
2181+ ExpectIntEQ (test_memio_inject_message (& test_ctx , 1 , (char * )hrr ,
2182+ sizeof (hrr )), 0 );
2183+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
2184+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), DUPLICATE_MSG_E );
2185+
2186+ wolfSSL_free (ssl_c );
2187+ wolfSSL_CTX_free (ctx_c );
2188+ #endif
2189+ return EXPECT_RESULT ();
2190+ }
0 commit comments