Skip to content

Comments

EVP & TLS: Add necessary EC_KEY data extraction functions, and use them#11358

Closed
levitte wants to merge 7 commits intoopenssl:masterfrom
levitte:ec-tls-fixes
Closed

EVP & TLS: Add necessary EC_KEY data extraction functions, and use them#11358
levitte wants to merge 7 commits intoopenssl:masterfrom
levitte:ec-tls-fixes

Conversation

@levitte
Copy link
Member

@levitte levitte commented Mar 18, 2020

libssl code uses EVP_PKEY_get0_EC_KEY() to extract certain basic data
from the EC_KEY. We replace that with EVP_PKEY functions.

This may or may not be refactored later on.

@levitte levitte added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Mar 18, 2020
@levitte levitte requested a review from mattcaswell March 18, 2020 15:04
@levitte
Copy link
Member Author

levitte commented Mar 18, 2020

If nothing else, this can be an interim solution until #11340 has been merged.
#11328 depends on something like this.

@mattcaswell
Copy link
Member

Hmmm. I can't say I'm keen on this. This seems to just sidestep the problem of what to do with the EVP_PKEY_get0_EC_KEY et al functions - and fixes it for us. But does so by polluting the EVP_PKEY API with algorithm specific functions.

@levitte
Copy link
Member Author

levitte commented Mar 18, 2020

Yes, that's true. However, as soon as we get EC key generation, we get issues with this, so the question is how long that should be stuck waiting for "the right thing" to happen.

I could make those functions internal but still exported, if that helps matters

@levitte
Copy link
Member Author

levitte commented Mar 18, 2020

This is an interim solution

@levitte levitte changed the title EVP & TLS: Add necessary EC_KEY data extraction functions, and use them [WIP] EVP & TLS: Add necessary EC_KEY data extraction functions, and use them Mar 18, 2020
@levitte
Copy link
Member Author

levitte commented Mar 18, 2020

Marked as WIP for obvious reasons

@mattcaswell
Copy link
Member

I could make those functions internal but still exported, if that helps matters

That would definitely help I think.

@levitte
Copy link
Member Author

levitte commented Mar 19, 2020

Although, I think EVP_PKEY_can_sign() is more generally useful...

@levitte
Copy link
Member Author

levitte commented Mar 19, 2020

There. I've also added EVP_PKEY_is_a(), which has been floating a more than one branch I juggled with

@mattcaswell
Copy link
Member

Could you push the latest version of your local branch here? I'm experimenting with your ec key gen stuff...

@levitte
Copy link
Member Author

levitte commented Mar 19, 2020

Done, and in #11328 as well

@levitte levitte changed the title [WIP] EVP & TLS: Add necessary EC_KEY data extraction functions, and use them [WIP, pending on #11375] EVP & TLS: Add necessary EC_KEY data extraction functions, and use them Mar 23, 2020
@levitte levitte force-pushed the ec-tls-fixes branch 2 times, most recently from 8184f4c to 1763fdf Compare March 25, 2020 17:27
@levitte levitte changed the title [WIP, pending on #11375] EVP & TLS: Add necessary EC_KEY data extraction functions, and use them [WIP] EVP & TLS: Add necessary EC_KEY data extraction functions, and use them Mar 25, 2020
@levitte
Copy link
Member Author

levitte commented Mar 25, 2020

Rebased on master, now that #11375 is in.

@levitte levitte changed the title [WIP] EVP & TLS: Add necessary EC_KEY data extraction functions, and use them EVP & TLS: Add necessary EC_KEY data extraction functions, and use them Mar 25, 2020
@levitte
Copy link
Member Author

levitte commented Mar 27, 2020

Ping!

@levitte
Copy link
Member Author

levitte commented Mar 27, 2020

UPDATE: it's the other way around, which is much better, so never mind!

Travis failure re documentation:

doc/man3/EVP_PKEY_is_a.pod:1: EXAMPLE not EXAMPLES section.

That document contains two examples, so I'm starting to wonder if find-doc-nits isn't a little too picky in this case.

@levitte
Copy link
Member Author

levitte commented Mar 27, 2020

Ping!

@mattcaswell
Copy link
Member

Needs rebase!

@t8m
Copy link
Member

t8m commented Mar 27, 2020

There are now conflicts and the Travis failure is probably relevant

levitte added 4 commits April 7, 2020 11:36
EVP_PKEY_is_a() is the provider side key checking function corresponding
to checking EVP_PKEY_id() or an EVP_PKEY against macros like EVP_PKEY_EC.
It also works with legacy internal keys.

We also add a warning indoc/man3/EVP_PKEY_set1_RSA.pod regarding the
reliability of certain functions that only understand legacy keys.

Finally, we take the opportunity to clean up doc/man3/EVP_PKEY_set1_RSA.pod
to better conform with man-page layout norms, see man-pages(7) on Linux.
libssl code uses EVP_PKEY_get0_EC_KEY() to extract certain basic data
from the EC_KEY.  We replace that with internal EVP_PKEY functions.

This may or may not be refactored later on.
The exporter freed a buffer too soon, and there were attempts to use
its data later, which was overwritten by something else at that
point.
The transfer of TLS encodedpoint to backends isn't yet fully supported
in provider implementations.  This is a temporary measure so as not to
get stuck in other development.
@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

Ah, the CI failure was due to a merge error with duplicate definition of the same local variable.
Fixed, and I took the opportunity to squash and rebase.

@mattcaswell mattcaswell added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Apr 7, 2020
@mattcaswell
Copy link
Member

Approved assuming CIs pass.

@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

... it only takes a rebase for hell to break loose 😒

@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

With @mattcaswell's assistance, I was able to put in a workable hack. It turned out that legacy key support needed some hard coding.

@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

One failure left... I didn't account for no-ec

@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

... at least not everywhere

@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

Fixed

Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

Reconfirm assuming CIs are ok

@levitte
Copy link
Member Author

levitte commented Apr 7, 2020

Apart from the usual timeout, CIs are fine

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

openssl-machine pushed a commit that referenced this pull request Apr 8, 2020
EVP_PKEY_is_a() is the provider side key checking function corresponding
to checking EVP_PKEY_id() or an EVP_PKEY against macros like EVP_PKEY_EC.
It also works with legacy internal keys.

We also add a warning indoc/man3/EVP_PKEY_set1_RSA.pod regarding the
reliability of certain functions that only understand legacy keys.

Finally, we take the opportunity to clean up doc/man3/EVP_PKEY_set1_RSA.pod
to better conform with man-page layout norms, see man-pages(7) on Linux.

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #11358)
openssl-machine pushed a commit that referenced this pull request Apr 8, 2020
libssl code uses EVP_PKEY_get0_EC_KEY() to extract certain basic data
from the EC_KEY.  We replace that with internal EVP_PKEY functions.

This may or may not be refactored later on.

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #11358)
openssl-machine pushed a commit that referenced this pull request Apr 8, 2020
The exporter freed a buffer too soon, and there were attempts to use
its data later, which was overwritten by something else at that
point.

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #11358)
openssl-machine pushed a commit that referenced this pull request Apr 8, 2020
The transfer of TLS encodedpoint to backends isn't yet fully supported
in provider implementations.  This is a temporary measure so as not to
get stuck in other development.

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #11358)
@levitte
Copy link
Member Author

levitte commented Apr 8, 2020

Merged.

4f76d62 EVP: add EVP_PKEY_is_a() and EVP_PKEY_can_sign()
c2041da EVP & TLS: Add necessary EC_KEY data extraction functions, and use them
e3be0f4 Fix export of provided EC keys
afce590 TLS: Temporarly downgrade newly generated EVP_PKEYs to legacy

@levitte levitte closed this Apr 8, 2020
@levitte
Copy link
Member Author

levitte commented Apr 8, 2020

Oh damn, now I see that the last approval came after the "approval: done" label was set, so I cut the grace period short... by 3hrs, I hope it's not too bad.

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

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants