@@ -666,3 +666,60 @@ int test_tls12_bad_cv_sig_alg(void)
666666 return EXPECT_RESULT ();
667667}
668668
669+ int test_tls12_no_null_compression (void )
670+ {
671+ EXPECT_DECLS ;
672+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && !defined(WOLFSSL_NO_TLS12 )
673+ /* ClientHello with compression list missing the required null method (RFC
674+ * 5246 7.4.1.2: the list MUST include the null compression method). */
675+ const byte badClientHello [] = {
676+ /* record header */
677+ 0x16 , 0x03 , 0x03 , 0x00 , 0x2d ,
678+ /* handshake header: ClientHello, length 41 */
679+ 0x01 , 0x00 , 0x00 , 0x29 ,
680+ /* client version: TLS 1.2 */
681+ 0x03 , 0x03 ,
682+ /* random: 32 bytes */
683+ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 ,
684+ 0x08 , 0x09 , 0x0a , 0x0b , 0x0c , 0x0d , 0x0e , 0x0f ,
685+ 0x10 , 0x11 , 0x12 , 0x13 , 0x14 , 0x15 , 0x16 , 0x17 ,
686+ 0x18 , 0x19 , 0x1a , 0x1b , 0x1c , 0x1d , 0x1e , 0x1f ,
687+ /* session id length: 0 */
688+ 0x00 ,
689+ /* cipher suites length: 2, TLS_RSA_WITH_AES_128_CBC_SHA */
690+ 0x00 , 0x02 , 0x00 , 0x2f ,
691+ /* compression methods: 1 entry, ZLIB only (null is absent) */
692+ 0x01 , 0xdd ,
693+ };
694+ WOLFSSL_CTX * ctx_s = NULL ;
695+ WOLFSSL * ssl_s = NULL ;
696+ struct test_memio_ctx test_ctx ;
697+
698+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
699+ ExpectIntEQ (test_memio_inject_message (& test_ctx , 0 ,
700+ (const char * )badClientHello , sizeof (badClientHello )), 0 );
701+ ExpectIntEQ (test_memio_setup (& test_ctx , NULL , & ctx_s , NULL , & ssl_s ,
702+ NULL , wolfTLSv1_2_server_method ), 0 );
703+ ExpectIntEQ (wolfSSL_accept (ssl_s ), WOLFSSL_FATAL_ERROR );
704+ ExpectIntEQ (wolfSSL_get_error (ssl_s , WOLFSSL_FATAL_ERROR ),
705+ WC_NO_ERR_TRACE (COMPRESSION_ERROR ));
706+ #ifdef WOLFSSL_EXTRA_ALERTS
707+ {
708+ const byte illegalParamAlert [] = {
709+ 0x15 , /* alert content type */
710+ 0x03 , 0x03 , /* version: TLS 1.2 */
711+ 0x00 , 0x02 , /* length: 2 */
712+ 0x02 , /* level: fatal */
713+ 0x2f , /* description: illegal_parameter (47) */
714+ };
715+ ExpectIntEQ (test_ctx .c_len , (int )sizeof (illegalParamAlert ));
716+ ExpectBufEQ (test_ctx .c_buff , illegalParamAlert ,
717+ sizeof (illegalParamAlert ));
718+ }
719+ #endif
720+ wolfSSL_free (ssl_s );
721+ wolfSSL_CTX_free (ctx_s );
722+ #endif
723+ return EXPECT_RESULT ();
724+ }
725+
0 commit comments