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

OSSL_PROVIDER_load_ex #21604

Closed
wants to merge 4 commits into from
Closed

Conversation

beldmit
Copy link
Member

@beldmit beldmit commented Jul 31, 2023

to configure provider in load-time.
The tests are to be written, the documentation is also to be written.

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

@beldmit
Copy link
Member Author

beldmit commented Jul 31, 2023

It's an attempt to implement #21350 function using available API.

@openssl/committers the comments wanted. I tried to implement as an extension of OPENSSL_provider_load but didn't find an easy option to provide configuration options.

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Jul 31, 2023
@beldmit beldmit added branch: master Merge to master branch hold: needs tests The PR needs tests to be added to it hold: needs documentation The PR needs documentation to be added to it and removed severity: fips change The pull request changes FIPS provider sources labels Jul 31, 2023
crypto/provider_conf.c Outdated Show resolved Hide resolved
crypto/provider_conf.c Outdated Show resolved Hide resolved
crypto/provider_conf.c Outdated Show resolved Hide resolved
crypto/provider_conf.c Outdated Show resolved Hide resolved
@beldmit
Copy link
Member Author

beldmit commented Aug 1, 2023

I've pushed a draft of API design for better clarity

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Aug 1, 2023
Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

My feeling is this really needs some active discussion within the OTC to find out what we want to do here. We should avoid requiring changes to existing providers if they would like to use this functionality if at all possible. I assume some changes will be inevitable if we want to support setting the parameters to providers after they are loaded & initialized but at least for the initial load it should be possible to use the current callback.

doc/prov_loadex.md Outdated Show resolved Hide resolved
doc/prov_loadex.md Outdated Show resolved Hide resolved
doc/prov_loadex.md Outdated Show resolved Hide resolved
Copy link
Contributor

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

So having thought about this some more I think I agree with a OSSL_LIB_CTX_load_provider() call where the provider config is entirely provided via the params option.

However I am entirely against OSSL_PROVIDER_set_params_by_name(), I think mixing static and dynamic config or attempting to change config will be error prone, difficult to debug for all involved (openssl, provider and application developers), and ultimately not a good pattern.

@simo5
Copy link
Contributor

simo5 commented Aug 1, 2023

So having thought about this some more I think I agree with a OSSL_LIB_CTX_load_provider() call where the provider config is entirely provided via the params option.

If a provider is already loaded this call should fail, btw, up to the app to decide what to do with it.

However I am entirely against OSSL_PROVIDER_set_params_by_name(), I think mixing static and dynamic config or attempting to change config will be error prone, difficult to debug for all involved (openssl, provider and application developers), and ultimately not a good pattern.

In general I think if the config is in a config file users should tweak the config file.
And if apps load the provider dynamically they should just set the params right at load time.

@simo5
Copy link
Contributor

simo5 commented Aug 1, 2023

Note that if you decide something like OSSL_PROVIDER_set_params() is the way you want to go you really need to also add a OSSL_PROVIDER_settable_params() so the provider can tell you what params can be set, and be prepared for that list to change after initialization...
This way a provider can tell what is changeable after init...

@beldmit beldmit force-pushed the OSSL_PROVIDER_activate branch 2 times, most recently from ece77c3 to a108c78 Compare August 1, 2023 15:23
@beldmit
Copy link
Member Author

beldmit commented Aug 1, 2023

Thanks, added OSSL_PROVIDER_settable_params to the scenario

@beldmit beldmit force-pushed the OSSL_PROVIDER_activate branch 2 times, most recently from a0fcdec to 66c79cd Compare August 2, 2023 15:55
@beldmit
Copy link
Member Author

beldmit commented Aug 2, 2023

OK, I realized how to pass the data to the provider in more or less standard way.
Hopefully will push the tests tomorrow.

@beldmit
Copy link
Member Author

beldmit commented Aug 2, 2023

This test failure seems to be unrelated to the patch but may be of interest for @hlandau https://github.com/openssl/openssl/actions/runs/5741052478/job/15560296780?pr=21604

@beldmit beldmit added tests: present The PR has suitable tests present approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member and removed hold: needs documentation The PR needs documentation to be added to it hold: needs tests The PR needs tests to be added to it labels Aug 3, 2023
@beldmit beldmit changed the title [DRAFT] OSSL_PROVIDER_activate - a strawman attempt OSSL_PROVIDER_load_ex Aug 3, 2023
@beldmit
Copy link
Member Author

beldmit commented Aug 18, 2023

@openssl/committers any review/feedback, please?

@beldmit
Copy link
Member Author

beldmit commented Aug 22, 2023

Rebased to resolve the trivial conflict in util/libcrypto.num

@t-j-h t-j-h 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 Aug 29, 2023
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Aug 30, 2023
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@beldmit
Copy link
Member Author

beldmit commented Aug 30, 2023

Merged. Thanks for the review!

@beldmit beldmit closed this Aug 30, 2023
@beldmit beldmit deleted the OSSL_PROVIDER_activate branch August 30, 2023 19:57
openssl-machine pushed a commit that referenced this pull request Aug 30, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from #21604)
openssl-machine pushed a commit that referenced this pull request Aug 30, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from #21604)
openssl-machine pushed a commit that referenced this pull request Aug 30, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from #21604)
heygauri pushed a commit to heygauri/openssl that referenced this pull request Sep 1, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from openssl#21604)
heygauri pushed a commit to heygauri/openssl that referenced this pull request Sep 1, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from openssl#21604)
heygauri pushed a commit to heygauri/openssl that referenced this pull request Sep 1, 2023
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from openssl#21604)
Copy link
Contributor

@mspncp mspncp left a comment

Choose a reason for hiding this comment

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

Hi @beldmit, sorry once again for my late review, I didn't manage to get it done earlier. Hope you find something useful in it nevertheless.

doc/designs/prov_loadex.md Show resolved Hide resolved
doc/designs/prov_loadex.md Show resolved Hide resolved
doc/designs/prov_loadex.md Show resolved Hide resolved
doc/designs/prov_loadex.md Show resolved Hide resolved
doc/designs/prov_loadex.md Show resolved Hide resolved
Comment on lines +59 to +63
Several instances of the same provider in the same context using different
section names, module names (e.g. via symlinks) and provider names. But unless
the provider does not support some configuration options, the algorithms in
this case will have the same `provider` property and the result of fetching is
not determined. We strongly discourage against this trick.
Copy link
Contributor

Choose a reason for hiding this comment

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

The intention of this paragraph is not obvious to me. Is this a suggested or discouraged scenario?

Suggested change
Several instances of the same provider in the same context using different
section names, module names (e.g. via symlinks) and provider names. But unless
the provider does not support some configuration options, the algorithms in
this case will have the same `provider` property and the result of fetching is
not determined. We strongly discourage against this trick.
Several instances of the same provider can be loaded in the same context using different
section names, module names (e.g. via symlinks) and provider names. But unless
the provider supports some configuration options, the algorithms in
this case will have the same `provider` property and the result of fetching is
not determined. We strongly discourage against this trick.

Copy link
Contributor

@mspncp mspncp Sep 8, 2023

Choose a reason for hiding this comment

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

Added, but is this indeed what you meant to say? (You may answer this question in PR #22029)

doc/designs/prov_loadex.md Show resolved Hide resolved
Comment on lines +172 to +175
OSSL_PARAM_BLD_push_utf8_string(bld, "greeting", custom_buf, strlen(custom_buf));
params = OSSL_PARAM_BLD_to_param(bld);

OSSL_PARAM_BLD_free(bld);
Copy link
Contributor

Choose a reason for hiding this comment

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

This test just passes an unknown parameter to the provider which gets ignored. So it does not actually prove the usefulnes of the api, it's just a "hello world" example.

Would it be possible to add a proof-of-concept test that loads the "default" or "fips" provider using extra parameters that actually changes the behaviour of the provider in a measurable (testable) effect?

Copy link
Member Author

Choose a reason for hiding this comment

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

The parameter is not unknown, but I understand your reasons and yes, a FIPS provider test would be better.

Comment on lines +11 to +12
We need a possibility to initialize providers on per-application level
according to per-application parameters. It's necessary for example for PKCS#11
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at provider-base, it seems possible to dispense of the configuration file entirely using the new extended api.

Additionally, provider specific configuration parameters from the
config file are available, in dotted name form.
The dotted name form is a concatenation of section names and final
config command name separated by periods.

If that's the case, it would be great to have a test case and/or example as a proof-of concept to show that this can be achieved using your new extended API.

Probably some example of its usage could also be added to the ossl-guide-libcrypto-introduction manpage?

(If you agree, I will create a separate issue for this)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree though I totally missed this point

doc/designs/prov_loadex.md Show resolved Hide resolved
@beldmit
Copy link
Member Author

beldmit commented Sep 7, 2023

@mspncp could you please raise your documentation updates as a PR?

mspncp added a commit to mspncp/openssl that referenced this pull request Sep 8, 2023
Late review comments for pull request openssl#21604, sort of.
mspncp added a commit to mspncp/openssl that referenced this pull request Sep 8, 2023
Late review comments for pull request openssl#21604, sort of.
@mspncp
Copy link
Contributor

mspncp commented Sep 8, 2023

See PR #22029. Please also reconsider the conversations which I did not mark as resolved yet.

mspncp added a commit to mspncp/openssl that referenced this pull request Sep 8, 2023
Late review comments for pull request openssl#21604, sort of.
openssl-machine pushed a commit that referenced this pull request Sep 20, 2023
Late review comments for pull request #21604, sort of.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #22029)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch severity: fips change The pull request changes FIPS provider sources tests: present The PR has suitable tests present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants