Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up selecting a signature algorithm #4285

Merged
merged 9 commits into from
Nov 29, 2023
Merged

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Nov 13, 2023

Resolved issues:

Related to #4257

Description of changes:

s2n-tls's logic for choosing a signature algorithm is difficult to follow, particularly the handling of defaults. We made it worse with the rather hacky fix for the SHA1 issue.

This cleanup should make the difference between pre-TLS1.2 and TLS1.2 default behavior clearer, and makes our non-RFC fallback logic more explicit. It also makes the signature algorithm selection logic follow the same pattern as our cipher suite selection logic, providing some nice consistency.

Call-outs

I'm only refactoring signature algorithm selection. See #4257 for other outstanding issues with s2n_signature_algorithms.c.

Testing:

I wrote completely new tests. Because I didn't use the old tests, I'd appreciate if reviewers paid particular attention to my new tests.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines 82 to +83
ERR_ENTRY(S2N_ERR_INVALID_SIGNATURE_SCHEME, "Invalid signature scheme") \
ERR_ENTRY(S2N_ERR_NO_VALID_SIGNATURE_SCHEME, "Unable to negotiate a supported signature scheme") \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to differentiate "no valid options to choose from" from "the option chosen by the peer is invalid". I'm not sure about this wording though :/

Comment on lines -90 to -95
/* If only unknown algorithms are offered, expect choosing a scheme to fail for TLS1.3 */
conn->actual_protocol_version = S2N_TLS13;
EXPECT_SUCCESS(s2n_client_signature_algorithms_extension.recv(conn, &signature_algorithms_extension));
EXPECT_EQUAL(conn->handshake_params.client_sig_hash_algs.len, sig_hash_algs.len);
EXPECT_FAILURE(s2n_choose_sig_scheme_from_peer_preference_list(conn, &conn->handshake_params.client_sig_hash_algs,
&conn->handshake_params.server_cert_sig_scheme));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't actually what is happening in this test. If only unknown algorithms are offered, TLS1.3 should choose a fallback option instead of failing-- see the tests in s2n_signature_algorithms_test.

What's happening here is actually that the default config is being used, so there are no certificates configured. With no certificates, there are no valid signature schemes to choose from. The peer's preferences aren't even considered.

I just removed this test rather than fixing it. We already test this correctly in s2n_signature_algorithms_test, and it isn't really relevant to the extension's parsing.

@lrstewart lrstewart marked this pull request as ready for review November 14, 2023 20:39
@lrstewart lrstewart requested a review from goatgoose November 22, 2023 23:09
Co-authored-by: Sam Clark <[email protected]>
@lrstewart lrstewart requested a review from camshaft November 29, 2023 02:21
@lrstewart lrstewart enabled auto-merge (squash) November 29, 2023 06:55
@lrstewart lrstewart merged commit ea337a4 into aws:main Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants