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

Adding signature algorithms via provider interface #19312

Closed
wants to merge 5 commits into from

Conversation

baentsch
Copy link
Contributor

@baentsch baentsch commented Sep 30, 2022

First cut tackling Fixing #10512 as per discussion there. Fixing #19369.

Still considered WIP: Missing e.g. is a test within the OpenSSL test harness. Testing right now done via oqs-provider. Testing available in https://github.com/baentsch/openssl/compare/sigload...baentsch:openssl:sigload-test?expand=1

Copy link
Contributor

@paulidale paulidale left a comment

Choose a reason for hiding this comment

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

Looks pretty good for the most part.


The "TLS-SIGALG" capability can be queried by libssl to discover the list of
TLS signature algorithms that a provider can support. Each signature supported
can be used for client- or server-authentication in addition to the build-in
Copy link
Contributor

Choose a reason for hiding this comment

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

built-in not build-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so changed in e558217

Copy link
Member

Choose a reason for hiding this comment

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

This seems not to be fixed after all?

Copy link
Member

Choose a reason for hiding this comment

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

In this case, what's not done is s/build-in/built-in/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now done.

doc/man7/provider-base.pod Show resolved Hide resolved
doc/man7/provider-base.pod Outdated Show resolved Hide resolved
ssl/ssl_cert.c Outdated Show resolved Hide resolved
ssl/ssl_cert.c Show resolved Hide resolved
ssl/ssl_cert.c Show resolved Hide resolved
ssl/ssl_ciph.c Outdated Show resolved Hide resolved
ssl/t1_lib.c Show resolved Hide resolved
@baentsch
Copy link
Contributor Author

Thanks for the review, @paulidale. I'd like to ask for advice on one more thing: How much effort should be put in the development of a dedicated "fetchable sigalgs" test case for this functionality within the test directory?

Background: The oqsprovider has tests that exercize these code paths much more than anything "artificial" in the test directory: When comparing the test code for fetchable KEMs via tls-provider and what oqsprovider does, the test in the main OpenSSL test folder doesn't seem more comprehensive. It obviously pre-dates oqsprovider and thus was key to ensure (our) smooth OQS-KEM integration, so this is a moot point.

With fetchable sigalgs it's now different, though: oqsprovider already does (X.509) encode/decode --for which there are even (OQS-)OpenSSL1.1.1 interop tests and this PR now uses those certificates with the new dynamically fetched signature algorithms. This "external" testing even discovered --by the sheer number of algorithms added-- previously unseen OpenSSL bugs.

--> Should all of this ("artificial" sign/verify combined with encode/decode for cert/key file generation) be re-created in the test directory or could you agree that presence of oqsprovider as a test facility --beyond all the other tests already existent and already triggering (nearly) all the new code paths-- is sufficient to move this PR to "Ready for Review"?

@paulidale
Copy link
Contributor

paulidale commented Oct 10, 2022

I'll flag the testing for OTC discussion, relying on OQS testing requires an exception to the testing required rule.

OTC: is the OQS testing sufficient or does there need to be an artifical test in OpenSSL?

@paulidale paulidale added hold: need otc decision The OTC needs to make a decision branch: master Merge to master branch triaged: feature The issue/pr requests/adds a feature labels Oct 10, 2022
@mattcaswell
Copy link
Member

IMO external testing should only ever be supplementary. We should have our own tests that we can easily extend and modify as required over time. For example, lets say we encounter a bug at some point in the future for this feature that was not picked up by the oqsprovider external testing. Without our own tests to build from we cannot easily add a regression test for the bug. Also consider the case where the maintainers of an external test decide to take things in a different technical direction and no longer maintain the old external test code. Without our own testing we could lose the test coverage we get there.

@beldmit
Copy link
Member

beldmit commented Oct 10, 2022

I agree that we need our own tests here but don't think we are to put this burden on the developer of this PR

@baentsch
Copy link
Contributor Author

We should have our own tests that we can easily extend and modify as required over time. For example, lets say we encounter a bug at some point in the future for this feature that was not picked up by the oqsprovider external testing. Without our own tests to build from we cannot easily add a regression test for the bug.

Agreed -- but this is not time-critical now, right? This could be done as and when the need arises.

Also consider the case where the maintainers of an external test decide to take things in a different technical direction and no longer maintain the old external test code. Without our own testing we could lose the test coverage we get there.

Completely understandable. I can promise to move all required code (basically gutted to not use liboqs calls but using "dummy" KEM/SIG "algs") from oqsprovider into the test directory should such event occur. But then again, I'd understand such willingness to be considered "unreliable" -- particularly if the proverbial truck runs me over...

So what about creating a new issue for this and I (or anyone else with too much time :) works on this separately along the lines of

I agree that we need our own tests here but don't think we are to put this burden on the developer of this PR

@mattcaswell
Copy link
Member

The test policy says this:

All Pull Requests adding new functionality to the applications, libraries, providers or engines must include suitable tests.

But it also says:

It is acceptable for the tests to be added via a different Pull Request to the main Pull Request.

https://www.openssl.org/policies/technical/testing.html

So I would be ok if the tests are not added in this PR but are instead added via a follow up PR - as long as there is a real commitment to actual produce such a PR!

@baentsch
Copy link
Contributor Author

as long as there is a real commitment to actual produce such a PR!

There definitely is. My goal is to be a trusted contributor -- not just to OQS but also to OpenSSL. FWIW, I started doing OSS when at university in the last century (sigh :) and "only" had to suspend it during the time my (ex-)employer prescribed what I do. But now I'm free again to make good on my words!

Splitting things has the great benefit that different activities can proceed in parallel:

  • This PR can move forward -- and we can next have "hands-on" discussions on message lengths -- benefitting the OQS and OpenSSL communities as well as standardization efforts.
  • Further down-stream integration work can be meaningfully tackled (e.g., nginx serving all these algorithms via the oqsprovider) -- benefitting interop testing (e.g., at https://test.openquantumsafe.org).
  • Adding standalone provider testing as per the above -- providing the benefits you're listing above.

The separate issue for this is now opened: #19369: Please comment/amend as you see fit. In turn, I'm now asking for Review on this PR.

@baentsch baentsch marked this pull request as ready for review October 10, 2022 13:06
@paulidale paulidale removed the hold: need otc decision The OTC needs to make a decision label Oct 10, 2022
@paulidale
Copy link
Contributor

Removing the hold since the decision seems to have been made in favour of having our own test.

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.

This looks good. Mostly minor comments below. I am surprised not to see any changes in the X.509 code....do we already have everything we need there for certs with provider based sig algs? Is it just a case of the provider registering the correct sigalg oid? I know we talked about this previously but I forget where we ended up.

Also - I'm looking forward to seeing a test for this (in a separate PR). There's quite a lot of code here that I'm anxious about in the absence of that test.

doc/man7/provider-base.pod Outdated Show resolved Hide resolved
doc/man7/provider-base.pod Outdated Show resolved Hide resolved
ssl/ssl_cert.c Outdated Show resolved Hide resolved
ssl/ssl_cert.c Outdated Show resolved Hide resolved
ssl/ssl_ciph.c Outdated Show resolved Hide resolved
ssl/t1_lib.c Show resolved Hide resolved
ssl/t1_lib.c Show resolved Hide resolved
ssl/t1_lib.c Outdated Show resolved Hide resolved
ssl/t1_lib.c Outdated Show resolved Hide resolved
ssl/t1_lib.c Outdated Show resolved Hide resolved
@mattcaswell
Copy link
Member

Oh....this is a significant feature, so it should have an entry in CHANGES.md

@baentsch
Copy link
Contributor Author

baentsch commented Nov 4, 2022

@mattcaswell Thanks for the review.

Also - I'm looking forward to seeing a test for this (in a separate PR). There's quite a lot of code here that I'm anxious about in the absence of that test.

Working on it -- but it's an even bigger piece of work than I originally anticipated: The updated test tls-provider not only will "invent" a sig alg and encode/decode logic but also has to have an additional test hash alg as oqs-provider doesn't trigger the "additional hash alg" logic (none of the PQ sigalgs needs a digest).

Your feedback above tempted me briefly to completely eliminate (the already optional) support for a pluggable sigalg provider to set a hash alg: oqsprovider doesn't need it, the current openssl core logic isn't quite geared to handle the situation and the new tests are pretty convoluted. But then again, I don't want to shy back from a conceptually sensible/logical feature just because of the effort involved. All thoughts/preferences/suggestions from your side welcome.

Edit/Add: The more I think about it, the more I am (now also) convinced that #19369 needs to be fixed within this PR. The only reason speaking against that would be if OpenSSL3.2 would be released before I get that done: Can you share your timeline for that?

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.

Your feedback above tempted me briefly to completely eliminate (the already optional) support for a pluggable sigalg provider to set a hash alg: oqsprovider doesn't need it, the current openssl core logic isn't quite geared to handle the situation and the new tests are pretty convoluted. But then again, I don't want to shy back from a conceptually sensible/logical feature just because of the effort involved. All thoughts/preferences/suggestions from your side welcome.

Yeah - conceptually it seems to make sense to have this capability.

Edit/Add: The more I think about it, the more I am (now also) convinced that #19369 needs to be fixed within this PR. The only reason speaking against that would be if OpenSSL3.2 would be released before I get that done: Can you share your timeline for that?

That would be great. The 3.2 freeze won't be for some months yet so you've got some time.

CHANGES.md Outdated Show resolved Hide resolved
doc/man7/provider-base.pod Outdated Show resolved Hide resolved
ssl/statem/statem_clnt.c Outdated Show resolved Hide resolved
ssl/t1_lib.c Outdated
sinf->hash_algorithm = NULL;
}
else if (p->data_type != OSSL_PARAM_UTF8_STRING)
Copy link
Member

Choose a reason for hiding this comment

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

Since one else branch uses {} our coding style says that all branches should use {} even if they are only one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So done in all places in 8be6985

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be actually done?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, @mattcaswell is correct. Since the else body a couple of lines down is bracketed, all of the if ... else if ... else bodies must be bracketed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now done

ssl/t1_lib.c Outdated
ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_INVALID_ARGUMENT);
if (p == NULL)
sinf->oid = NULL;
else if (p->data_type != OSSL_PARAM_UTF8_STRING)
Copy link
Member

Choose a reason for hiding this comment

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

All branches should use {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 8be6985

Copy link
Member

Choose a reason for hiding this comment

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

Not done?

Copy link
Member

Choose a reason for hiding this comment

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

Here, all of the if ... else if ... else bodies must be bracketed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

ssl/t1_lib.c Outdated Show resolved Hide resolved
@t8m t8m added tests: present The PR has suitable tests present and removed tests: present The PR has suitable tests present labels Nov 25, 2022
@baentsch
Copy link
Contributor Author

@paulidale @mattcaswell @levitte Thanks again for your feedback. With the latest commit all of it should be addressed. Instead of commenting on each of your comments, may I ask you this time to mark things resolved as you see fit and let me know if/when anything still needs to be addressed?

There should be an option to the list command (apps/list.c) to list sigalgs and their parameters. I'm okay if this isn't part of this PR (but it would be nice if it were).

This already works:

openssl list -signature-algorithms -provider oqsprovider
  dilithium2 @ oqsprovider
  p256_dilithium2 @ oqsprovider
  rsa3072_dilithium2 @ oqsprovider
  dilithium3 @ oqsprovider
  p384_dilithium3 @ oqsprovider
  dilithium5 @ oqsprovider
  p521_dilithium5 @ oqsprovider
  falcon512 @ oqsprovider
  p256_falcon512 @ oqsprovider
  rsa3072_falcon512 @ oqsprovider
  falcon1024 @ oqsprovider
  p521_falcon1024 @ oqsprovider
  sphincssha256128ssimple @ oqsprovider
  p256_sphincssha256128ssimple @ oqsprovider
  rsa3072_sphincssha256128ssimple @ oqsprovider
  sphincsshake256128fsimple @ oqsprovider
  p256_sphincsshake256128fsimple @ oqsprovider
  rsa3072_sphincsshake256128fsimple @ oqsprovider

@mattcaswell
Copy link
Member

All of my comments seem to be addressed with the exception of the one seeking input from @levitte. I have marked them as resolved.

@levitte
Copy link
Member

levitte commented Feb 22, 2023

All of my comments seem to be addressed with the exception of the one seeking input from @levitte. I have marked them as resolved.

Uhmmm, I did comment on that: #19312 (comment)

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.

LGTM

@mattcaswell mattcaswell removed the approval: otc review pending This pull request needs review by an OTC member label Feb 22, 2023
@paulidale paulidale 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 Feb 22, 2023
@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but this PR has failing CI tests. Once the tests pass it will get moved to 'approval: ready to merge' automatically, alternatively please review and set the label manually.

@paulidale
Copy link
Contributor

Merged, thanks for the contribution.

@paulidale paulidale closed this Feb 24, 2023
openssl-machine pushed a commit that referenced this pull request Feb 24, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #19312)
@mattcaswell
Copy link
Member

Woop! Thanks to @baentsch for this cool feature!

@baentsch
Copy link
Contributor Author

Woop! Thanks to @baentsch for this cool feature!

Also very glad to see this. Thanks in turn particularly to @levitte @mattcaswell @paulidale to "shepard" this through. Only little concern remaining: Why is there a "symbol error" in cross-compilation CI now?

@mattcaswell
Copy link
Member

Also very glad to see this. Thanks in turn particularly to @levitte @mattcaswell @paulidale to "shepard" this through. Only little concern remaining: Why is there a "symbol error" in cross-compilation CI now?

Seems somehow related to #20331 which was also recently merged.

@mattcaswell
Copy link
Member

@levitte?

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Jun 13, 2023
https://build.opensuse.org/request/show/1092835
by user msmeissn + dimstar_suse
- updated to 0.5.0:
  - oqs-provider now also enables use of QSC algorithms during TLS1.3
    handshake. The required OpenSSL code updates are contained in
    openssl/openssl#19312.
  * Algorithm updates
    All algorithms no longer supported in the NIST PQC competition
    and not under consideration for standardization by ISO have been
    removed. All remaining algorithms with the exception of McEliece
    have been lifted to their final round 3 variants as documented in
    liboqs. Most notably, algorithm names for Sphincs+ have been changed
    to the naming chosen by its authors.
  * Functional updates
  - Enablement of oqs-provider as a (first) dynamically fetchable OpenSSL3 TLS1.3 signature provider.
  - OSX support
  - Full support for CA functionality
  - Algorithms can now be se
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 Merge to master branch severity: fips change The pull request changes FIPS provider sources tests: present The PR has suitable tests present triaged: feature The issue/pr requests/adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants