@@ -2141,3 +2141,53 @@ 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 ) && defined(WOLFSSL_AES_128 ) && \
2152+ defined(HAVE_AESGCM ) && !defined(NO_SHA256 ) && \
2153+ /* middlebox compat requires that the session ID is echoed */ \
2154+ !defined(WOLFSSL_TLS13_MIDDLEBOX_COMPAT )
2155+ WOLFSSL_CTX * ctx_c = NULL ;
2156+ WOLFSSL * ssl_c = NULL ;
2157+ struct test_memio_ctx test_ctx ;
2158+ /* Transport Layer Security
2159+ * TLSv1.3 Record Layer: Handshake Protocol: Hello Retry Request
2160+ * Content Type: Handshake (22)
2161+ * Version: TLS 1.2 (0x0303)
2162+ * Length: 50
2163+ * Handshake Protocol: Hello Retry Request
2164+ * Handshake Type: Server Hello (2)
2165+ * Length: 46
2166+ * Version: TLS 1.2 (0x0303)
2167+ * Random: cf21ad74e59a6111be1d8c021e65b891c2a211167abb8c5e079e09e2c8a8339c (HelloRetryRequest magic)
2168+ * Session ID Length: 0
2169+ * Cipher Suite: TLS_AES_128_GCM_SHA256 (0x1301)
2170+ * Compression Method: null (0)
2171+ * Extensions Length: 6
2172+ * Extension: supported_versions (len=2) TLS 1.3 */
2173+ unsigned char hrr [] = {
2174+ 0x16 , 0x03 , 0x03 , 0x00 , 0x32 , 0x02 , 0x00 , 0x00 , 0x2e , 0x03 , 0x03 , 0xcf ,
2175+ 0x21 , 0xad , 0x74 , 0xe5 , 0x9a , 0x61 , 0x11 , 0xbe , 0x1d , 0x8c , 0x02 , 0x1e ,
2176+ 0x65 , 0xb8 , 0x91 , 0xc2 , 0xa2 , 0x11 , 0x16 , 0x7a , 0xbb , 0x8c , 0x5e , 0x07 ,
2177+ 0x9e , 0x09 , 0xe2 , 0xc8 , 0xa8 , 0x33 , 0x9c , 0x00 , 0x13 , 0x01 , 0x00 , 0x00 ,
2178+ 0x06 , 0x00 , 0x2b , 0x00 , 0x02 , 0x03 , 0x04
2179+ };
2180+
2181+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
2182+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , NULL , & ssl_c , NULL ,
2183+ wolfTLSv1_3_client_method , NULL ), 0 );
2184+ ExpectIntEQ (test_memio_inject_message (& test_ctx , 1 , (char * )hrr ,
2185+ sizeof (hrr )), 0 );
2186+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
2187+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), DUPLICATE_MSG_E );
2188+
2189+ wolfSSL_free (ssl_c );
2190+ wolfSSL_CTX_free (ctx_c );
2191+ #endif
2192+ return EXPECT_RESULT ();
2193+ }
0 commit comments