@@ -2318,3 +2318,92 @@ int test_tls13_hrr_different_cs(void)
23182318#endif
23192319 return EXPECT_RESULT ();
23202320}
2321+
2322+ #if defined(WOLFSSL_TLS13 ) && !defined(NO_WOLFSSL_SERVER ) && \
2323+ defined(HAVE_ECC )
2324+ /* Called when writing. */
2325+ static int DESend (WOLFSSL * ssl , char * buf , int sz , void * ctx )
2326+ {
2327+ (void )ssl ;
2328+ (void )buf ;
2329+ (void )sz ;
2330+ (void )ctx ;
2331+
2332+ return sz ;
2333+ }
2334+ /* Called when reading. */
2335+ static int DERecv (WOLFSSL * ssl , char * buf , int sz , void * ctx )
2336+ {
2337+ WOLFSSL_BUFFER_INFO * msg = (WOLFSSL_BUFFER_INFO * )ctx ;
2338+ int len = (int )msg -> length ;
2339+
2340+ (void )ssl ;
2341+ (void )sz ;
2342+
2343+ /* Pass back as much of message as will fit in buffer. */
2344+ if (len > sz )
2345+ len = sz ;
2346+ XMEMCPY (buf , msg -> buffer , len );
2347+ /* Move over returned data. */
2348+ msg -> buffer += len ;
2349+ msg -> length -= len ;
2350+
2351+ /* Amount actually copied. */
2352+ return len ;
2353+ }
2354+ #endif
2355+
2356+ int test_tls13_duplicate_extension (void )
2357+ {
2358+ EXPECT_DECLS ;
2359+ #if defined(WOLFSSL_TLS13 ) && !defined(NO_WOLFSSL_SERVER ) && \
2360+ defined(HAVE_ECC )
2361+ WOLFSSL_CTX * ctx = NULL ;
2362+ WOLFSSL * ssl = NULL ;
2363+ byte serverHello [] = {
2364+ 0x16 , 0x03 , 0x03 , 0x00 , 0x81 , 0x02 , 0x00 , 0x00 ,
2365+ 0x7d , 0x03 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2366+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2367+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2368+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2369+ 0x01 , 0x01 , 0x01 , 0x00 , 0x13 , 0x01 , 0x00 , 0x00 ,
2370+ 0x55 , 0x00 , 0x2b , 0x00 , 0x02 , 0x03 , 0x04 , 0x00 ,
2371+ 0x33 , 0x00 , 0x45 , 0x00 , 0x17 , 0x00 , 0x41 , 0x04 ,
2372+ 0x0c , 0x90 , 0x1d , 0x42 , 0x3c , 0x83 , 0x1c , 0xa8 ,
2373+ 0x5e , 0x27 , 0xc7 , 0x3c , 0x26 , 0x3b , 0xa1 , 0x32 ,
2374+ 0x72 , 0x1b , 0xb9 , 0xd7 , 0xa8 , 0x4c , 0x4f , 0x03 ,
2375+ 0x80 , 0xb2 , 0xa6 , 0x75 , 0x6f , 0xd6 , 0x01 , 0x33 ,
2376+ 0x1c , 0x88 , 0x70 , 0x23 , 0x4d , 0xec , 0x87 , 0x85 ,
2377+ 0x04 , 0xc1 , 0x74 , 0x14 , 0x4f , 0xa4 , 0xb1 , 0x4b ,
2378+ 0x66 , 0xa6 , 0x51 , 0x69 , 0x16 , 0x06 , 0xd8 , 0x17 ,
2379+ 0x3e , 0x55 , 0xbd , 0x37 , 0xe3 , 0x81 , 0x56 , 0x9e ,
2380+ 0x00 , 0x2b , 0x00 , 0x02 , 0x03 , 0x04
2381+ };
2382+ WOLFSSL_BUFFER_INFO msg ;
2383+ WOLFSSL_ALERT_HISTORY h ;
2384+
2385+ /* Set up wolfSSL context. */
2386+ ExpectNotNull (ctx = wolfSSL_CTX_new (wolfTLSv1_3_client_method ()));
2387+ /* Read from 'msg'. */
2388+ wolfSSL_SetIORecv (ctx , DERecv );
2389+ /* No where to send to - dummy sender. */
2390+ wolfSSL_SetIOSend (ctx , DESend );
2391+
2392+ /* Test cipher suite list with many copies of a cipher suite. */
2393+ ExpectNotNull (ssl = wolfSSL_new (ctx ));
2394+ msg .buffer = serverHello ;
2395+ msg .length = (unsigned int )sizeof (serverHello );
2396+ wolfSSL_SetIOReadCtx (ssl , & msg );
2397+
2398+ ExpectIntEQ (wolfSSL_connect_TLSv13 (ssl ),
2399+ WC_NO_ERR_TRACE (WOLFSSL_FATAL_ERROR ));
2400+ ExpectIntEQ (wolfSSL_get_alert_history (ssl , & h ), WOLFSSL_SUCCESS );
2401+ ExpectIntEQ (h .last_tx .code , illegal_parameter );
2402+ ExpectIntEQ (h .last_tx .level , alert_fatal );
2403+ wolfSSL_free (ssl );
2404+ wolfSSL_CTX_free (ctx );
2405+ #endif
2406+ return EXPECT_RESULT ();
2407+ }
2408+
2409+
0 commit comments