Skip to content

ssl: accept TLS 1.2 rsa_pss_rsae signature algorithms#10672

Merged
ronald-cron-arm merged 6 commits intoMbed-TLS:developmentfrom
Maokaman1:fix/tls12-rsa-pss-sigalgs
Apr 20, 2026
Merged

ssl: accept TLS 1.2 rsa_pss_rsae signature algorithms#10672
ronald-cron-arm merged 6 commits intoMbed-TLS:developmentfrom
Maokaman1:fix/tls12-rsa-pss-sigalgs

Conversation

@Maokaman1
Copy link
Copy Markdown
Contributor

@Maokaman1 Maokaman1 commented Apr 4, 2026

Description

Fixes #10668

Fix a TLS 1.2 client regression introduced by the signature-algorithm validation added in commit 9f19fe1.

The new validation correctly rejects signature algorithms that are invalid for TLS 1.2 or were not offered by the client, but it also rejects valid rsa_pss_rsae_* SignatureScheme values even when RSA-PSS support is compiled in. As a result, handshakes with TLS 1.2 servers using RSA-PSS signatures can fail with MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER (-0x6600).

This PR updates the TLS 1.2 support check to accept rsa_pss_rsae_sha256/384/512 when the corresponding RSA-PSS and hash support is available, and adds regression tests for these values.

PR checklist

Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
@gilles-peskine-arm
Copy link
Copy Markdown
Contributor

Thank you very much for providing a fix! We'll review it ASAP since it's a regression that causes a major interoperability problem.

@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most) labels Apr 4, 2026
@gilles-peskine-arm gilles-peskine-arm added the needs-backports Backports are missing or are pending review and approval. label Apr 4, 2026
@gilles-peskine-arm gilles-peskine-arm self-requested a review April 4, 2026 20:43
Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for contributing this!

The fix looks plausible to me, but I'm not sure it's complete. We really should have a non-regression test in ssl-opt.sh. I'm not sure how to write it.

Comment thread ChangeLog.d/fix-tls12-rsa-pss-sigalgs.txt Outdated
Comment thread library/ssl_misc.h Outdated
Comment thread tests/suites/test_suite_ssl.data Outdated
Comment thread tests/suites/test_suite_ssl.function Outdated
@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review labels Apr 7, 2026
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review and removed needs-work labels Apr 7, 2026
@gilles-peskine-arm gilles-peskine-arm self-requested a review April 7, 2026 18:47
@ronald-cron-arm ronald-cron-arm self-requested a review April 8, 2026 06:32
@ronald-cron-arm ronald-cron-arm removed the needs-reviewer This PR needs someone to pick it up for review label Apr 8, 2026
Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with perhaps a question of whether we're doing enough testing in ssl-opt.sh. I'll defer to Ronald on this as he's much more familiar than I am with sigalgs-related testing.

Comment thread tests/ssl-opt.sh Outdated
Copy link
Copy Markdown
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, please find my comments below.

Comment thread library/ssl_misc.h Outdated
Comment thread tests/ssl-opt.sh Outdated
Comment thread tests/ssl-opt.sh Outdated
Comment thread ChangeLog.d/fix-tls12-rsa-pss-sigalgs.txt Outdated
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
Copy link
Copy Markdown
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my comments. LGTM.

Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Can you please update the 3.6 backport, and also make a backport for the new LTS branch mbedtls-4.1?

Comment thread library/ssl_tls12_client.c
@github-project-automation github-project-automation Bot moved this from In Development to Has Approval in Roadmap pull requests (new board) Apr 16, 2026
@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Apr 16, 2026
@Maokaman1
Copy link
Copy Markdown
Contributor Author

Do you think the patch below is warranted for this PR?

@@ -2069,13 +2073,13 @@ start_processing:
         }
 #endif

-#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
+#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) || defined(PSA_WANT_ALG_RSA_PSS)
         if (pk_alg == MBEDTLS_PK_SIGALG_RSA_PSS) {
             ret = mbedtls_pk_verify_ext((mbedtls_pk_sigalg_t) pk_alg, peer_pk,
                                         md_alg, hash, hashlen,
                                         p, sig_len);
         } else
-#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
+#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT || PSA_WANT_ALG_RSA_PSS */
         ret = mbedtls_pk_verify_restartable(peer_pk,
                                             md_alg, hash, hashlen, p, sig_len, rs_ctx);

@@ -2090,7 +2094,14 @@ start_processing:
                     MBEDTLS_SSL_ALERT_LEVEL_FATAL,
                     MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR);
             }
-            MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_verify_restartable", ret);
+#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) || defined(PSA_WANT_ALG_RSA_PSS)
+            if (pk_alg == MBEDTLS_PK_SIGALG_RSA_PSS) {
+                MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_verify_ext", ret);
+            } else
+#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT || PSA_WANT_ALG_RSA_PSS */
+            {
+                MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_verify_restartable", ret);
+            }
 #if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED)
             if (ret == MBEDTLS_ERR_ECP_IN_PROGRESS) {
                 ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS;

@gilles-peskine-arm
Copy link
Copy Markdown
Contributor

Regarding MBEDTLS_X509_RSASSA_PSS_SUPPORT, we are aware that it's misused in places in the TLS code. But I would strongly prefer to keep it a separate concern. This patch is already a subtle balance between interoperability and security, so I don't want to add more complexity.

Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
@Maokaman1 Maokaman1 changed the title ssl: accept TLS 1.2 rsa_pss_rsae signature schemes ssl: accept TLS 1.2 rsa_pss_rsae signature algorithms Apr 17, 2026
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, and removed approved Design and code approved - may be waiting for CI or backports labels Apr 17, 2026
Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the merge.

For future reference, please don't add merge commits to a pull request unless there's a merge conflict.

Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ronald-cron-arm ronald-cron-arm added this pull request to the merge queue Apr 20, 2026
Merged via the queue into Mbed-TLS:development with commit 518ed03 Apr 20, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Has Approval to Done in Roadmap pull requests (new board) Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-backports Backports are missing or are pending review and approval. needs-review Every commit must be reviewed by at least two team members, priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most)

Development

Successfully merging this pull request may close these issues.

4.1.0 breaks curl tests with TLSv1.2

3 participants