Skip to content

Enable brainpool curves for TLS1.3 - #11782

Closed
bernd-edlinger wants to merge 1 commit into
openssl:OpenSSL_1_1_1-stablefrom
bernd-edlinger:enable_brainpool_for_tls13_1
Closed

bernd-edlinger wants to merge 1 commit into
openssl:OpenSSL_1_1_1-stablefrom
bernd-edlinger:enable_brainpool_for_tls13_1

Conversation

@bernd-edlinger

Copy link
Copy Markdown
Member

This adds (optional) support for brainpool curves in TLS1.3

Checklist
  • documentation is added or updated
  • tests are added or updated

back-port of #7485 for 1.1.1

@bernd-edlinger bernd-edlinger added the branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) label May 9, 2020
@bernd-edlinger

Copy link
Copy Markdown
Member Author

try it out this way:
apps/openssl s_server -accept 1234 -cert test/certs/server-ecdsa-brainpoolP256r1-cert.pem -key test/certs/server-ecdsa-brainpoolP256r1-key.pem -curves brainpoolP256r1
apps/openssl s_client -connect localhost:1234 -curves brainpoolP256r1 -tls1_3

@bernd-edlinger

Copy link
Copy Markdown
Member Author

Talking to myself:

the latest fixup was necessary, becaus the following setup failed to connect:
apps/openssl s_server -cert ../openssl/apps/server.pem -curves brainpoolP256r1
apps/openssl s_client -curves P-256:brainpoolP256r1

this involves a Hello Retry Request (whatever that is good for)
and it failed since TLS1.3 needs different group ids for the same curve,
here brainpool, but probably that is just a symptom that all other curves
will need similar hacks.
I mean, once one of X25519/X448/P-256/P-384/P-521 is broken
and needs to be replaced, everyone will notice that it will not be as
easy as expected, since nobody even is allowed to think about it....
Matter of fact brainpool256r1 curve ids are 26 for TLS1.2 and 31 for TLS1.3
that causes lots of trouble to make it work.

@mattcaswell

Copy link
Copy Markdown
Member

Matter of fact brainpool256r1 curve ids are 26 for TLS1.2 and 31 for TLS1.3

Really??? That's horrible. Any idea what the reasoning behind that decision was?

Do you have a reference to the relevant standard?

@mattcaswell mattcaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some comments below.

I'm not convinced this is the way to go. All of this swapping around between the TLSv1.3 and TLSv1.2 ids is horrible. Why do we not just treat them as entirely different curve ids which you can get and set independently of each other? That would seem a lot simpler to me.

Comment thread ssl/statem/extensions_clnt.c Resolved
Comment thread ssl/statem/extensions_clnt.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: spurious space after function name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we move this function call to before the "for" loop - so we don't have to call it every time? The ver_min and ver max values won't change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The function is only rarely needed, I was kind of trying not to add overhead to
the normal case, which is no brainpool curves. These are only meant as
a fallback for people who do not trust in the NIST curves, and might like
to have a different fallback instead. So I think that is at most called 3 times,
once for each brainpool curve NID.
But I can do that if it is considered too ugly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Additionally it is an error path that is not needed when no brainpool
curve is to be enabled.

Comment thread ssl/statem/extensions_clnt.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would rather have the SSLfatal call replicated on each location an error occurs. This means we actually will know the exact line that the error occurred on - rather than "somewhere in this function".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay. Good point.

Comment thread test/ssl-tests/20-cert-select.conf.in Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like we should introduce some new tests for brainpool in TLSv1.3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can add a second test here, but it does not seem to do the full handshake,
for tls1.2 yes, but tls1.3 does not have the server certificate ready when the
test expects to see it, the certificate is only there after the new session ticket arrives.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand what is meant by "tls1.3 does not have the server certificate ready when the test expects to see it, the certificate is only there after the new session ticket arrives" -- in TLS 1.3, the NewSessionTicket message is not sent until after the server Finished, which is after the Certificate is sent (though can be in the same flight).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just a vague idea. Since it is impossible for me to debug into this test case,
I tried to print the server certificate in s_client and the certificate was NULL
at the point where tls1.2 had it available, but very short after that there
is a new session callback and the certificate is available there.
It is funny that s_client does not seem to show the server certificate, since
I think I remember that was once the case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@kaduk I think everything woks as expected, I was just confused since this did not work:

         test   => {
+            "ExpectedClientCertType" => "brainpoolP256r1",
+            "ExpectedClientSignHash" => "SHA256",
+            "ExpectedClientSignType" => "EC",
             "ExpectedResult" => "Success"

I thought that would test the cert received by the client.
but instead it tests the client cert received by the server.
but since there is no client brainpool cert available that did not work.
No idea what I did wrong with the s_client test I cannot reproduce
what I saw there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, thanks for clarifying.
I trust you found the ExpectedserverCertType and related directives that would apply for the server's certificate.

@t8m

t8m commented May 15, 2020

Copy link
Copy Markdown
Member

Some comments below.

I'm not convinced this is the way to go. All of this swapping around between the TLSv1.3 and TLSv1.2 ids is horrible. Why do we not just treat them as entirely different curve ids which you can get and set independently of each other? That would seem a lot simpler to me.

@t8m t8m closed this May 15, 2020
@t8m t8m reopened this May 15, 2020
@t8m

t8m commented May 15, 2020

Copy link
Copy Markdown
Member

I am sorry for mistakenly closing the PR. I mis-clicked the button.

I just wonder if treating them as completely separate curves for TLS-1.3 and 1.2 would not be too confusing to users as usually would want to enable both. I do not even see a reason why you would want to enable it just for one of the protocol versions.

@mattcaswell

Copy link
Copy Markdown
Member

I just wonder if treating them as completely separate curves for TLS-1.3 and 1.2 would not be too confusing to users as usually would want to enable both. I do not even see a reason why you would want to enable it just for one of the protocol versions.

I actually think the opposite is true. I think there will be more confusion by trying to hide the fact that there are actually 2 different group ids. If people use OpenSSL in conjunction with other software (wireshark, other clients/servers etc) these two different groups will become very visible. Where did that extra group from? Why don't I see group x when I "get" the list of groups - but I can see it on the wire? What happens when the peer sends one of the groups but not the other - this will get very confusing when you "get" the group list and the required group is there - but for some reason it isn't being used in your protocol version.

By trying to hide all of this I think we are just storing up problems for ourselves. Much better IMO is to just be up front and explain that there are 2 groups for the different protocol versions and get people to set both if they want both.

@bernd-edlinger

Copy link
Copy Markdown
Member Author

@mattcaswell

Matter of fact brainpool256r1 curve ids are 26 for TLS1.2 and 31 for TLS1.3

Really??? That's horrible. Any idea what the reasoning behind that decision was?

Do you have a reference to the relevant standard?

Yes, as mentioned in the commit message:

See the recently assigned brainpool code points at:
https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml

Table TLS Supported Groups contains these

26 | brainpoolP256r1      | Y | N | [RFC7027] |  
27 | brainpoolP384r1      | Y | N | [RFC7027] |  
28 | brainpoolP512r1      | Y | N | [RFC7027] |  
29 | x25519               | Y | Y | [RFC8446][RFC8422] |  
30 | x448                 | Y | Y | [RFC8446][RFC8422] |  
31 | brainpoolP256r1tls13 | Y | N | [RFC8734] |  
32 | brainpoolP384r1tls13 | Y | N | [RFC8734] |  
33 | brainpoolP512r1tls13 | Y | N | [RFC8734]

But adding another NID for brainpool did not seem like a really compelling option
either, since it would need much more rewrite of the application,
and normally we should not try to break the applications unless absolutely necessary.

@kaduk

kaduk commented May 15, 2020

Copy link
Copy Markdown
Contributor

Matter of fact brainpool256r1 curve ids are 26 for TLS1.2 and 31 for TLS1.3

Really??? That's horrible. Any idea what the reasoning behind that decision was?

Do you have a reference to the relevant standard?

This is a side effect of how RFC 8446 was done. There was a desire to provide a small "clean slate" of known-good parameters for TLS 1.3 use (across cipher suites, signature schemes, groups, everything) and as part of the cleanup for how that was expressed in the document, the old brainpool group IDs got marked as "obsolete_RESERVED" for TLS 1.3 usage -- see Appendix B.3.1.4 in RFC 8446. It was pointed out somewhat later that this designation burns the TLS 1.2 codepoints from being resuable for TLS 1.3, but to some extent that is necessary.
In particular, the semantics for what a group is and how to use it are not quite drop-in between TLS 1.2 and TLS 1.3, so something would have to specify the TLS 1.3 semantics for brainpool usage. There was definitely not WG consensus to do so in the core TLS 1.3 spec, so it would have to be a separate document. And once it's in a separate document, you need some signal for the two endpoints to negotiatie whether they support the TLS 1.3 semantics for brainpool or not -- anything other than a new group ID for that would be even more awkward than the new group ID is. Thus, RFC 8734 comes into define the new group and signature codepoints, allowing for accurate negotiation of both TLS 1.2 and 1.3 support for the brainpool functionality.

@mattcaswell

Copy link
Copy Markdown
Member

Thanks @kaduk - that's useful background.

The more I think about it the more I tend to think that we should keep very clear separation between the 2 codepoints within OpenSSL as well. I'm actually doing some work at the moment to refactor how the group code works anyway - so I'd suggest not spending too much time on this feature at this stage until the dust has settled with that refactoring. The way to add new groups is likely to look very different after I have finished.

Something I hadn't appreciated when I reviewed this PR is that it is targeting 1.1.1 and is a backport of #7485. I guess my comments should have been made against the master version of this. I don't this PR is going to be acceptable against 1.1.1 because it is a new feature.

@bernd-edlinger
bernd-edlinger force-pushed the enable_brainpool_for_tls13_1 branch from 649d8f9 to d354c90 Compare May 16, 2020 09:38
@fschmidberger

Copy link
Copy Markdown

What is the current status of this change request?

@kaduk

kaduk commented Feb 2, 2021

Copy link
Copy Markdown
Contributor

What is the current status of this change request?

It's still targeting 1.1.1, and still unlikely to get OTC approval.

@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR is waiting for the creator to make requested changes but it has not been updated for 105 days. If you have made changes or commented to the reviewer please make sure you re-request a review (see icon in the 'reviewers' section).

@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR has been closed. It was waiting for the creator to make requested changes but it has not been updated for 120 days.

@bernd-edlinger

Copy link
Copy Markdown
Member Author

#7485 was re-based to current master, so re-opening this PR

@bernd-edlinger
bernd-edlinger force-pushed the enable_brainpool_for_tls13_1 branch from d354c90 to fd768e5 Compare October 23, 2021 19:40
@t8m t8m added the triaged: feature The issue/pr requests/adds a feature label Oct 25, 2021
@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR is waiting for the creator to make requested changes but it has not been updated for 30 days. If you have made changes or commented to the reviewer please make sure you re-request a review (see icon in the 'reviewers' section).

@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR is waiting for the creator to make requested changes but it has not been updated for 61 days. If you have made changes or commented to the reviewer please make sure you re-request a review (see icon in the 'reviewers' section).

@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR has been closed. It was waiting for the creator to make requested changes but it has not been updated for 90 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) triaged: feature The issue/pr requests/adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants