Skip to content

Add EVP_PKEY_supports_digest_nid() and use it for TLS CertificateVerify#7408

Closed
dwmw2 wants to merge 3 commits intoopenssl:masterfrom
dwmw2:pkey_md
Closed

Add EVP_PKEY_supports_digest_nid() and use it for TLS CertificateVerify#7408
dwmw2 wants to merge 3 commits intoopenssl:masterfrom
dwmw2:pkey_md

Conversation

@dwmw2
Copy link
Contributor

@dwmw2 dwmw2 commented Oct 16, 2018

Fixes #7348

I think it's correct not to filter our outbound advertisement. We can check the peer's signature with any digest; it's only our own signature where we're limited to what the EVP_PKEY can support.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 16, 2018

Hm, this should check for EVP_PKEY_get_default_digest_nid() returning a "mandatory" result too. And that much could be done as a bug fix all the way back to 1.0.2 without introducing the new supports_digest_nid ctrl.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 16, 2018

Hm, this should check for EVP_PKEY_get_default_digest_nid() returning a "mandatory" result too.

Done.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 16, 2018

Hm, and now it appears to fail because our default software EC keys say that SHA256 is mandatory and they can't do anything else?

@dwmw2 dwmw2 force-pushed the pkey_md branch 2 times, most recently from ca6aec5 to 6418082 Compare October 16, 2018 15:52
@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 16, 2018

Added backports (without the new EVP_PKEY_supports_digest_nid() function)

https://github.com/dwmw2/openssl/commits/pkey_md_1.1.1
https://github.com/dwmw2/openssl/commits/pkey_md_1.1.0

@romen
Copy link
Member

romen commented Oct 17, 2018

Also, I believe the backports should be in different PRs.

@romen romen added the branch: master Applies to master branch label Oct 17, 2018
@romen
Copy link
Member

romen commented Oct 17, 2018

Ping to @mattcaswell that reviewed the original issue for more comments.

romen
romen previously requested changes Oct 17, 2018
@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 18, 2018

@romen does this look more like what you were expecting?

Copy link
Member

@romen romen left a comment

Choose a reason for hiding this comment

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

I would say most of my expectations have been met, thanks @dwmw2 for sticking with me!

I have a few more remarks, but it's mostly either about comments, or ping more knowledgeable reviewers on specific issues I am not entirely familiar with.

@romen romen added the approval: review pending This pull request needs review by a committer label Oct 20, 2018
Copy link
Contributor

@kaduk kaduk left a comment

Choose a reason for hiding this comment

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

Just chiming in where summoned; I didn't review the whole thing.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 22, 2018

My intent is to push the first two of these as bug fixes for older versions of OpenSSL as far back as you'll have them, and the third only for 1.1.2 (or 1.2.0 or whatever's next).

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 28, 2018

I can't work out how to make it stop saying that changes were requested. To my knowledge, nothing is outstanding.

@richsalz
Copy link
Contributor

You have to "dismiss" the review, and in the text say "all requested changes were done" or similar.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 28, 2018

I have done so to all but the one which is 404 because the commits that were commented on are gone.

@mspncp
Copy link
Contributor

mspncp commented Oct 28, 2018

Does this mean you don't have a button to dismiss the review? If not, maybe it's a matter of permissions. In this case, I can dismiss it for you. Or you just ping @romen.

image

@dwmw2
Copy link
Contributor Author

dwmw2 commented Oct 28, 2018

Indeed, I don't have that button. Dismissing the stale review (especially if it's holding up the PR being merged) would be appreciated; thanks!

dwmw2 added 3 commits November 4, 2018 16:34
ASN1_PKEY_CTRL_DEFAULT_MD_NID is documented to return 2 for a mandatory
digest algorithm, when the key can't support any others. That isn't true
here, so return 1 instead.

Partially fixes openssl#7348
If the private key says it can only support one specific digest, then
don't ask it to perform a different one.

Fixes: openssl#7348
Rather than relying only on mandatory default digests, add a way for
the EVP_PKEY to individually report whether each digest algorithm is
supported.
@mattcaswell
Copy link
Member

Is this good to go? What branches is this for?

@dwmw2
Copy link
Contributor Author

dwmw2 commented Nov 8, 2018

This is for master. I was planning to update my backports once the dust was settled and it was merged; it needs massaging for 1.1.0 and I haven't even looked at 1.0.2 yet.

For the backports, I would appreciate guidance: how far back should we backport it, and do we do just the first two commits which have a limited fix for the bug without adding the new API? Or is it OK to add the new EVP_PKEY_supports_digest_nid() too?

@mattcaswell
Copy link
Member

1.1.0 is in security-fix only mode. So I'd suggest 1.1.1 and 1.0.2 only. Bug fixes only to stable branches so you shouldn't be adding the new function in those branches.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Nov 8, 2018

OK, thanks. I'll do those once this is merged to master so I can reference the stable commit IDs.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Nov 9, 2018

Backports (which will need the "cherry picked from…" commit IDs updated after this origiinal PR is merged:

https://github.com/dwmw2/openssl/commits/pkey_md_1.1.1
https://github.com/dwmw2/openssl/commits/pkey_md_1.0.2

The first is a trivial cherry-pick but for 1.0.2 it looks a little different. I was planning to submit a new PR for each once this one is merged and the commit IDs are known. In the meantime, @romen can you opine on dwmw2@ede8375 please?

@romen
Copy link
Member

romen commented Nov 10, 2018

I can merge this to master now, and then we can discuss other commits in the 2 separate PRs for 1.0.2 and 1.1.1.

@dwmw2 I had a look at dwmw2/openssl@ede8375 : it seems fine, even if a little bit confusing at first; but again I am not that familiar with libssl code, so I'll rely on better reviewers than me for that!

levitte pushed a commit that referenced this pull request Nov 10, 2018
ASN1_PKEY_CTRL_DEFAULT_MD_NID is documented to return 2 for a mandatory
digest algorithm, when the key can't support any others. That isn't true
here, so return 1 instead.

Partially fixes #7348

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #7408)
levitte pushed a commit that referenced this pull request Nov 10, 2018
If the private key says it can only support one specific digest, then
don't ask it to perform a different one.

Fixes: #7348

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #7408)
levitte pushed a commit that referenced this pull request Nov 10, 2018
Rather than relying only on mandatory default digests, add a way for
the EVP_PKEY to individually report whether each digest algorithm is
supported.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #7408)
@romen
Copy link
Member

romen commented Nov 10, 2018

Merged to master, commits: eb7eb13, 2d263a4 and ecbb2fc .

Thanks once again @dwmw2 for your contribution, and apologies for the latency lately on my part!

@romen romen closed this Nov 10, 2018
dwmw2 added a commit to dwmw2/openssl that referenced this pull request Nov 10, 2018
ASN1_PKEY_CTRL_DEFAULT_MD_NID is documented to return 2 for a mandatory
digest algorithm, when the key can't support any others. That isn't true
here, so return 1 instead.

Partially fixes openssl#7348

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from openssl#7408)

(cherry picked from commit eb7eb13)
dwmw2 added a commit to dwmw2/openssl that referenced this pull request Nov 10, 2018
If the private key says it can only support one specific digest, then
don't ask it to perform a different one.

Fixes: openssl#7348

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from openssl#7408)

(cherry picked from commit 2d263a4)
dwmw2 added a commit to dwmw2/openssl that referenced this pull request Nov 10, 2018
ASN1_PKEY_CTRL_DEFAULT_MD_NID is documented to return 2 for a mandatory
digest algorithm, when the key can't support any others. That isn't true
here, so return 1 instead.

Partially fixes openssl#7348

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from openssl#7408)

(cherry picked from commit eb7eb13)
dwmw2 added a commit to dwmw2/openssl that referenced this pull request Nov 10, 2018
If the private key says it can only support one specific digest, then
don't ask it to perform a different one.

Fixes: openssl#7348

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from openssl#7408)

(cherry picked from commit 2d263a4
 and reworked for 1.0.2)
@dwmw2
Copy link
Contributor Author

dwmw2 commented Nov 10, 2018

Thanks. Now I have commit IDs, backport PRs for
1.0.2: #7610
1.1.1: #7609

t8m added a commit to t8m/openssl that referenced this pull request May 27, 2019
The openssl#7408 implemented mandatory digest checking in TLS.
However this broke compatibility of DSS support with GnuTLS
which supports only SHA1 with DSS.

There is no reason why SHA256 would be a mandatory digest
for DSA as other digests in SHA family can be used as well.
levitte pushed a commit that referenced this pull request May 28, 2019
The #7408 implemented mandatory digest checking in TLS.
However this broke compatibility of DSS support with GnuTLS
which supports only SHA1 with DSS.

There is no reason why SHA256 would be a mandatory digest
for DSA as other digests in SHA family can be used as well.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from #9015)
levitte pushed a commit that referenced this pull request May 28, 2019
The #7408 implemented mandatory digest checking in TLS.
However this broke compatibility of DSS support with GnuTLS
which supports only SHA1 with DSS.

There is no reason why SHA256 would be a mandatory digest
for DSA as other digests in SHA family can be used as well.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from #9015)

(cherry picked from commit cd4c83b)
@kaduk kaduk mentioned this pull request Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants