@@ -2483,3 +2483,92 @@ int test_tls13_ks_missing(void)
24832483#endif
24842484 return EXPECT_RESULT ();
24852485}
2486+
2487+ #if defined(WOLFSSL_TLS13 ) && !defined(NO_WOLFSSL_CLIENT ) && \
2488+ defined(HAVE_ECC )
2489+ /* Called when writing. */
2490+ static int DESend (WOLFSSL * ssl , char * buf , int sz , void * ctx )
2491+ {
2492+ (void )ssl ;
2493+ (void )buf ;
2494+ (void )sz ;
2495+ (void )ctx ;
2496+
2497+ return sz ;
2498+ }
2499+ /* Called when reading. */
2500+ static int DERecv (WOLFSSL * ssl , char * buf , int sz , void * ctx )
2501+ {
2502+ WOLFSSL_BUFFER_INFO * msg = (WOLFSSL_BUFFER_INFO * )ctx ;
2503+ int len = (int )msg -> length ;
2504+
2505+ (void )ssl ;
2506+ (void )sz ;
2507+
2508+ /* Pass back as much of message as will fit in buffer. */
2509+ if (len > sz )
2510+ len = sz ;
2511+ XMEMCPY (buf , msg -> buffer , len );
2512+ /* Move over returned data. */
2513+ msg -> buffer += len ;
2514+ msg -> length -= len ;
2515+
2516+ /* Amount actually copied. */
2517+ return len ;
2518+ }
2519+ #endif
2520+
2521+ int test_tls13_duplicate_extension (void )
2522+ {
2523+ EXPECT_DECLS ;
2524+ #if defined(WOLFSSL_TLS13 ) && !defined(NO_WOLFSSL_CLIENT ) && \
2525+ defined(HAVE_ECC )
2526+ WOLFSSL_CTX * ctx = NULL ;
2527+ WOLFSSL * ssl = NULL ;
2528+ byte serverHello [] = {
2529+ 0x16 , 0x03 , 0x03 , 0x00 , 0x81 , 0x02 , 0x00 , 0x00 ,
2530+ 0x7d , 0x03 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2531+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2532+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2533+ 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
2534+ 0x01 , 0x01 , 0x01 , 0x00 , 0x13 , 0x01 , 0x00 , 0x00 ,
2535+ 0x55 , 0x00 , 0x2b , 0x00 , 0x02 , 0x03 , 0x04 , 0x00 ,
2536+ 0x33 , 0x00 , 0x45 , 0x00 , 0x17 , 0x00 , 0x41 , 0x04 ,
2537+ 0x0c , 0x90 , 0x1d , 0x42 , 0x3c , 0x83 , 0x1c , 0xa8 ,
2538+ 0x5e , 0x27 , 0xc7 , 0x3c , 0x26 , 0x3b , 0xa1 , 0x32 ,
2539+ 0x72 , 0x1b , 0xb9 , 0xd7 , 0xa8 , 0x4c , 0x4f , 0x03 ,
2540+ 0x80 , 0xb2 , 0xa6 , 0x75 , 0x6f , 0xd6 , 0x01 , 0x33 ,
2541+ 0x1c , 0x88 , 0x70 , 0x23 , 0x4d , 0xec , 0x87 , 0x85 ,
2542+ 0x04 , 0xc1 , 0x74 , 0x14 , 0x4f , 0xa4 , 0xb1 , 0x4b ,
2543+ 0x66 , 0xa6 , 0x51 , 0x69 , 0x16 , 0x06 , 0xd8 , 0x17 ,
2544+ 0x3e , 0x55 , 0xbd , 0x37 , 0xe3 , 0x81 , 0x56 , 0x9e ,
2545+ 0x00 , 0x2b , 0x00 , 0x02 , 0x03 , 0x04
2546+ };
2547+ WOLFSSL_BUFFER_INFO msg ;
2548+ WOLFSSL_ALERT_HISTORY h ;
2549+
2550+ /* Set up wolfSSL context. */
2551+ ExpectNotNull (ctx = wolfSSL_CTX_new (wolfTLSv1_3_client_method ()));
2552+ /* Read from 'msg'. */
2553+ wolfSSL_SetIORecv (ctx , DERecv );
2554+ /* No where to send to - dummy sender. */
2555+ wolfSSL_SetIOSend (ctx , DESend );
2556+
2557+ /* Test cipher suite list with many copies of a cipher suite. */
2558+ ExpectNotNull (ssl = wolfSSL_new (ctx ));
2559+ msg .buffer = serverHello ;
2560+ msg .length = (unsigned int )sizeof (serverHello );
2561+ wolfSSL_SetIOReadCtx (ssl , & msg );
2562+
2563+ ExpectIntEQ (wolfSSL_connect_TLSv13 (ssl ),
2564+ WC_NO_ERR_TRACE (WOLFSSL_FATAL_ERROR ));
2565+ ExpectIntEQ (wolfSSL_get_alert_history (ssl , & h ), WOLFSSL_SUCCESS );
2566+ ExpectIntEQ (h .last_tx .code , illegal_parameter );
2567+ ExpectIntEQ (h .last_tx .level , alert_fatal );
2568+ wolfSSL_free (ssl );
2569+ wolfSSL_CTX_free (ctx );
2570+ #endif
2571+ return EXPECT_RESULT ();
2572+ }
2573+
2574+
0 commit comments