Skip to content

Add TLS support for X448 and Ed448 - #5470

Closed
mattcaswell wants to merge 5 commits into
openssl:masterfrom
mattcaswell:curve448-tls
Closed

mattcaswell wants to merge 5 commits into
openssl:masterfrom
mattcaswell:curve448-tls

Conversation

@mattcaswell

@mattcaswell mattcaswell commented Feb 27, 2018 •

Copy link
Copy Markdown
Member

This PR adds support for X448 and Ed448 into libssl.

Note I'm planning to get all of this merged before beta1 (in 2 weeks!) if at all possible!!

@kroeckx

kroeckx commented Feb 27, 2018

Copy link
Copy Markdown
Member

Do you know about an other implementation that supports them and have you tried talking to it?

@mattcaswell

Copy link
Copy Markdown
Member Author

No, I haven't tried. I'll look into it.

@kroeckx

kroeckx commented Feb 28, 2018 •

Copy link
Copy Markdown
Member

https://gitlab.com/ilari_l/btls claims to support X448 and experimental Ed448, it's the only thing I could find.

Comment thread test/clienthellotest.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.

Does that else belong to just the "currtest == TEST_ADD_PADDING"?

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.

Yes, good catch. Fixed.

Comment thread test/ecdsatest.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.

Should NID_ipsec3 get excluded here too?

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.

It actually does get excluded a few lines below in the EC_GROUP_get_degree() check.

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.

Should we have a TLS 1.3 check with it?

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.

Do you mean should we have a check with Ed448 signing in TLSv1.3? If so there is one a bit later on (in the TLSv1.3 group of tests).

@mattcaswell mattcaswell changed the title WIP: Add TLS support for X448 and Ed448 Add TLS support for X448 and Ed448 Mar 2, 2018
@mattcaswell

Copy link
Copy Markdown
Member Author

I rebased this now that #5481 is merged. Also made one change as per the comments above.

@mattcaswell

Copy link
Copy Markdown
Member Author

Oh...and I took this out of WIP.

@richsalz richsalz left a comment

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'd wait for @kroeckx, but I'm okay with this after the nits.

Comment thread CHANGES Outdated

*) Added support for X448 and Ed448. Currently this is only supported in
libcrypto (not libssl). Heavily based on original work by Mike Hamburg.
*) Added support for X448 and Ed448 to both libcrypto and libssl. Heavily

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.

get rid of "to both librypto and libssl"

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.

Ok - done.

Comment thread apps/s_cb.c
return "Ed25519";

case NID_ED448:
return "Ed448";

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 thought we call it X448 ?

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.

In this context we are specifically referring to it as a signature algorithm. Which means Ed448. We only use X448 if referring to it in the context of a Diffie-Hellman key exchange.

Comment thread test/ossl_shim/ossl_shim.cc Outdated
if (config->enable_all_curves) {
static const int kAllCurves[] = {
NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1, NID_X25519,
NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1, NID_X25519, NID_X448

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.

If only to avoid questions like this one, should this be in the same order as eccurves_default?

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.

Ok - done.

"secp224r1", "secp256k1", "prime256v1", "secp384r1",
"secp521r1", "brainpoolP256r1", "brainpoolP384r1",
"brainpoolP512r1", "X25519");
"brainpoolP512r1", "X25519", "X448");

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.

Same ordering question.

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.

This one is slightly different. It is a complete list of all the curves (not just default ones). Therefore it seems to make more sense to me to be in the order of the full nid_list (just above eccurves_default in t1_lib.c). This list is in that order.

@mattcaswell

Copy link
Copy Markdown
Member Author

https://gitlab.com/ilari_l/btls claims to support X448 and experimental Ed448

I tested against that. Note this only supports TLSv1.2 (although it does seem to have some TLSv1.3 awareness as it validates the key_share extension - even though it doesn't use it (see below)).

After much frustration (there are no instructions) I successfully created a connection using both X448 and Ed448 blts-clienttest -> s_server. Connections using Ed448 s_client -> btls-servertest also fine. Initially connections using X448 s_client -> btls-servertest failed. This seems to be due to a bug in btls. I forced X448 on s_client by using "-groups X448". This sends a supported_groups extension containing exactly one group. However the btls server always seems to fail if the key_share uses a group which is the last one listed in supported_groups. Looking at the btls source code I was able to find the erroneous code. Sending more than one group solves the issues and X448 s_client -> btls-servertest works.

@mattcaswell

Copy link
Copy Markdown
Member Author

tested against that. Note this only supports TLSv1.2

Ah. Although it only claims TLSv1.2 in the README, looking around the source code it does seem to know about TLSv1.3, but I think it is for a different draft version. Checking that out...

@mattcaswell

Copy link
Copy Markdown
Member Author

Ah. Although it only claims TLSv1.2 in the README, looking around the source code it does seem to know about TLSv1.3, but I think it is for a different draft version. Checking that out...

It does support draft23/draft24. After hacking the source files to turn this on (surely there must be an easier way?) I encountered an OpenSSL bug that prevented a handshake from completing. This was nothing to do with X448/Ed448 - it was in our extension processing code (PR coming up). After fixing that I was able to confirm inter-operability for X448/Ed448 in both directions in TLSv1.3.

@mattcaswell

Copy link
Copy Markdown
Member Author

I have also tested haskell client to s_server using X448. Also X448 in both directions for mint based on this PR:

bifurcation/mint#179

Note, in spite of the title of the PR, it only adds X448 support not Ed448.

All of the above tests passed.

@mattcaswell

Copy link
Copy Markdown
Member Author

Fix up commits pushed addressing @richsalz's nits (where appropriate).

@richsalz

richsalz commented Mar 2, 2018

Copy link
Copy Markdown
Contributor

Your changes and comments make sense; reconfirmed.

@richsalz richsalz closed this Mar 2, 2018
@richsalz richsalz reopened this Mar 2, 2018
@mattcaswell

Copy link
Copy Markdown
Member Author

Pushed. Thanks.

@mattcaswell mattcaswell closed this Mar 5, 2018
@mspncp mspncp mentioned this pull request Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants