@@ -3100,3 +3100,92 @@ int test_tls13_plaintext_alert(void)
31003100 return EXPECT_RESULT ();
31013101}
31023102
3103+ /* Test that wolfSSL_set1_sigalgs_list() is honored in TLS 1.3
3104+ * CertificateRequest. Server restricts to RSA-PSS+SHA256:
3105+ * - ECC client cert → handshake FAILS
3106+ * - RSA client cert → handshake PASSES
3107+ */
3108+ int test_tls13_cert_req_sigalgs (void )
3109+ {
3110+ EXPECT_DECLS ;
3111+ #if defined(WOLFSSL_TLS13 ) && defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && \
3112+ !defined(NO_CERTS ) && !defined(NO_RSA ) && defined(WC_RSA_PSS ) && \
3113+ defined(HAVE_ECC ) && !defined(NO_WOLFSSL_CLIENT ) && \
3114+ !defined(NO_WOLFSSL_SERVER ) && defined(OPENSSL_EXTRA ) && \
3115+ !defined(NO_FILESYSTEM )
3116+ WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
3117+ WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
3118+ struct test_memio_ctx test_ctx ;
3119+
3120+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
3121+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
3122+ wolfTLSv1_3_client_method , wolfTLSv1_3_server_method ), 0 );
3123+
3124+ /* Server: require client cert and load ECC client cert for verification */
3125+ if (EXPECT_SUCCESS ()) {
3126+ wolfSSL_set_verify (ssl_s ,
3127+ WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT , NULL );
3128+ ExpectIntEQ (wolfSSL_CTX_load_verify_locations (ctx_s ,
3129+ cliEccCertFile , 0 ), WOLFSSL_SUCCESS );
3130+ }
3131+
3132+ /* Server: restrict CertificateRequest to RSA-PSS+SHA256 only */
3133+ if (EXPECT_SUCCESS ()) {
3134+ ExpectIntEQ (wolfSSL_set1_sigalgs_list (ssl_s , "RSA-PSS+SHA256" ),
3135+ WOLFSSL_SUCCESS );
3136+ }
3137+
3138+ /* Client: load ECC cert/key */
3139+ if (EXPECT_SUCCESS ()) {
3140+ ExpectIntEQ (wolfSSL_use_certificate_file (ssl_c , cliEccCertFile ,
3141+ CERT_FILETYPE ), WOLFSSL_SUCCESS );
3142+ ExpectIntEQ (wolfSSL_use_PrivateKey_file (ssl_c , cliEccKeyFile ,
3143+ CERT_FILETYPE ), WOLFSSL_SUCCESS );
3144+ }
3145+
3146+ /* Handshake must fail: ECC client cannot match RSA-PSS+SHA256 */
3147+ ExpectIntNE (test_memio_do_handshake (ssl_c , ssl_s , 10 , NULL ), 0 );
3148+
3149+ wolfSSL_free (ssl_c ); ssl_c = NULL ;
3150+ wolfSSL_free (ssl_s ); ssl_s = NULL ;
3151+ wolfSSL_CTX_free (ctx_c ); ctx_c = NULL ;
3152+ wolfSSL_CTX_free (ctx_s ); ctx_s = NULL ;
3153+
3154+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
3155+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
3156+ wolfTLSv1_3_client_method , wolfTLSv1_3_server_method ), 0 );
3157+
3158+ /* Server: require client cert and load RSA client cert for verification */
3159+ if (EXPECT_SUCCESS ()) {
3160+ wolfSSL_set_verify (ssl_s ,
3161+ WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT , NULL );
3162+ ExpectIntEQ (wolfSSL_CTX_load_verify_locations (ctx_s ,
3163+ cliCertFile , 0 ), WOLFSSL_SUCCESS );
3164+ }
3165+
3166+ /* Server: restrict CertificateRequest to RSA-PSS+SHA256 only */
3167+ if (EXPECT_SUCCESS ()) {
3168+ ExpectIntEQ (wolfSSL_set1_sigalgs_list (ssl_s , "RSA-PSS+SHA256" ),
3169+ WOLFSSL_SUCCESS );
3170+ }
3171+
3172+ /* Client: load RSA cert/key */
3173+ if (EXPECT_SUCCESS ()) {
3174+ ExpectIntEQ (wolfSSL_use_certificate_file (ssl_c , cliCertFile ,
3175+ CERT_FILETYPE ), WOLFSSL_SUCCESS );
3176+ ExpectIntEQ (wolfSSL_use_PrivateKey_file (ssl_c , cliKeyFile ,
3177+ CERT_FILETYPE ), WOLFSSL_SUCCESS );
3178+ }
3179+
3180+ /* Handshake must succeed: RSA client satisfies RSA-PSS+SHA256 */
3181+ ExpectIntEQ (test_memio_do_handshake (ssl_c , ssl_s , 10 , NULL ), 0 );
3182+
3183+ wolfSSL_free (ssl_c ); ssl_c = NULL ;
3184+ wolfSSL_free (ssl_s ); ssl_s = NULL ;
3185+ wolfSSL_CTX_free (ctx_c ); ctx_c = NULL ;
3186+ wolfSSL_CTX_free (ctx_s ); ctx_s = NULL ;
3187+ #endif
3188+
3189+ return EXPECT_RESULT ();
3190+ }
3191+
0 commit comments