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

ssl: Avoid unnecessary duplicates #9288

Conversation

IngelaAndin
Copy link
Contributor

No description provided.

@IngelaAndin IngelaAndin self-assigned this Jan 13, 2025
@IngelaAndin IngelaAndin added team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI labels Jan 13, 2025
Copy link
Contributor

github-actions bot commented Jan 13, 2025

CT Test Results

  1 files   11 suites   4m 4s ⏱️
 93 tests  91 ✅ 2 💤 0 ❌
109 runs  107 ✅ 2 💤 0 ❌

Results for commit 05bced8.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

Copy link
Contributor

@williamthome williamthome left a comment

Choose a reason for hiding this comment

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

Not tested, but in my mind produces the same result and avoids the use of lists:reverse/1:

signature_schemes_1_2(SigAlgs) ->
    Schemes = lists:filtermap(fun
        (Alg) when is_atom(Alg) ->
            case scheme_to_components(Alg) of
                {Hash, Sign = rsa_pss_pss, _} ->
                    {true, {Hash, Sign}};
                {Hash, Sign = rsa_pss_rsae, _} ->
                    {true, {Hash, Sign}};
                %% TLS-1.2 do not constraint the
                %% curve, however must be one
                %% present in "supported groups" (eccs)
                {Hash, ecdsa = Sign, _} ->
                    {true, {Hash, Sign}};
                {Hash, Sign, undefined} ->
                    {true, {Hash, format_sign(Sign)}};
                {_, _, _} ->
                    false
            end;
        (_Alg) ->
            true
    end, SigAlgs),
    %% Make sure that if ECDSA TLS-1.2 names are specified do not duplicate them
    %% earlier in list by allowing TLS-1.3 schemes to be interpreted as TLS-1.2 algs
    %% unless the ECDSA TLS-1.2 representation is missing and we want to work around it.
    lists:uniq(Schemes).

lib/ssl/src/ssl_cipher.erl Outdated Show resolved Hide resolved
lib/ssl/src/ssl_cipher.erl Outdated Show resolved Hide resolved
@IngelaAndin IngelaAndin force-pushed the ingela/ssl/avoid/duplicate-sign-algos/OTP-19428 branch from 345d22d to f58740c Compare January 13, 2025 19:51
@IngelaAndin IngelaAndin force-pushed the ingela/ssl/avoid/duplicate-sign-algos/OTP-19428 branch from f58740c to 05bced8 Compare January 13, 2025 21:46
@IngelaAndin
Copy link
Contributor Author

Not tested, but in my mind produces the same result and avoids the use of lists:reverse/1:

signature_schemes_1_2(SigAlgs) ->
    Schemes = lists:filtermap(fun
        (Alg) when is_atom(Alg) ->
            case scheme_to_components(Alg) of
                {Hash, Sign = rsa_pss_pss, _} ->
                    {true, {Hash, Sign}};
                {Hash, Sign = rsa_pss_rsae, _} ->
                    {true, {Hash, Sign}};
                %% TLS-1.2 do not constraint the
                %% curve, however must be one
                %% present in "supported groups" (eccs)
                {Hash, ecdsa = Sign, _} ->
                    {true, {Hash, Sign}};
                {Hash, Sign, undefined} ->
                    {true, {Hash, format_sign(Sign)}};
                {_, _, _} ->
                    false
            end;
        (_Alg) ->
            true
    end, SigAlgs),
    %% Make sure that if ECDSA TLS-1.2 names are specified do not duplicate them
    %% earlier in list by allowing TLS-1.3 schemes to be interpreted as TLS-1.2 algs
    %% unless the ECDSA TLS-1.2 representation is missing and we want to work around it.
    lists:uniq(Schemes).

This solution will not preserver the the order of the initial configuration if the TLS-1.2 version names are configured by the user, which I think it should. The workaround will perhaps make these algorithms more preferred with the tradeoff that interoperability is better. But if the user configures something explicitly I think we should adhere to that. These lists are fairly small so I do not think the extra reverse is a big deal in the bigger picture.

@IngelaAndin IngelaAndin requested review from dgud and u3s January 21, 2025 13:24
@IngelaAndin IngelaAndin merged commit 1d0da94 into erlang:maint Jan 22, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants