Skip to content

Replumbing: offer a core upcall to get the provider object's library context#9160

Closed
levitte wants to merge 7 commits intoopenssl:masterfrom
levitte:core-offer-library-context
Closed

Replumbing: offer a core upcall to get the provider object's library context#9160
levitte wants to merge 7 commits intoopenssl:masterfrom
levitte:core-offer-library-context

Conversation

@levitte
Copy link
Member

@levitte levitte commented Jun 14, 2019

The FIPS module currently has "magic" support to have the library
context become the provider context within the core code, for the FIPS
module's inner provider.

We replace that with a core upcall that returns the library context
associated with a provider object. That way, the FIPS module can
handle the assignment of the inner provider context itself. This
allows the FIPS module (and any other provider module that wishes to
use a similar mechanism) to define for itself what the provider
context is. It's currently simply a pointer to a library context,
but may contain other stuff as well in the future.

…context

The FIPS module currently has "magic" support to have the library
context become the provider context within the core code, for the FIPS
module's inner provider.

We replace that with a core upcall that returns the library context
associated with a provider object.  That way, the FIPS module can
handle the assignment of the inner provider context itself.  This
allows the FIPS module (and any other provider module that wishes to
use a similar mechanism) to define for itself what the provider
context is.  It's currently simply a pointer to a library context,
but may contain other stuff as well in the future.
@levitte levitte added the branch: master Applies to master branch label Jun 14, 2019
@levitte levitte requested a review from mattcaswell June 14, 2019 08:28
@levitte
Copy link
Member Author

levitte commented Jun 14, 2019

The link that chains this whole thing together is that for the FIPS module, every call of functions taking an OPENSSL_CTX * argument should be passed PROV_LIBRARY_CONTEXT_OF(provctx).

Why that macro? Well yeah, for the moment it's a no-op, but imagine a future where the provider context we use is a structure in its own right, that contains more than just the library context... if we don't nip that bud now, we'll have a hell of a fun time chasing down every use of the provider context some time in the future.

* To be used anywhere the library context needs to be passed, such as to
* fetching functions.
*/
#define PROV_LIBRARY_CONTEXT_OF(provctx) (provctx)
Copy link
Member

Choose a reason for hiding this comment

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

I'm missing the point of this macro

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I get it now. Perhaps add an explicit cast to OPENSSL_CTX?

Copy link
Member Author

Choose a reason for hiding this comment

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

Dunno... I'll leave that alone for now, I have some ideas on how to make the provider context more secure, type wise. That's a matter for another PR

@levitte
Copy link
Member Author

levitte commented Jun 14, 2019

We might as well use PROV_LIBRARY_CONTEXT_OF in the default and legacy providers as well. It's harmless now, and may prove useful in the future (again, the idea of having to chase down all the uses later...)

@levitte
Copy link
Member Author

levitte commented Jun 14, 2019

Ping

@levitte
Copy link
Member Author

levitte commented Jun 17, 2019

Merged.

8013a93 Replumbing: Adapt the default and legacy providers to use library context upcall
bb751e1 Replumbing: Adapt the FIPS module to use the library context upcall
e7706e6 Replumbing: offer a core upcall to get the provider object's library context

@levitte levitte closed this Jun 17, 2019
levitte added a commit that referenced this pull request Jun 17, 2019
…context

The FIPS module currently has "magic" support to have the library
context become the provider context within the core code, for the FIPS
module's inner provider.

We replace that with a core upcall that returns the library context
associated with a provider object.  That way, the FIPS module can
handle the assignment of the inner provider context itself.  This
allows the FIPS module (and any other provider module that wishes to
use a similar mechanism) to define for itself what the provider
context is.  It's currently simply a pointer to a library context,
but may contain other stuff as well in the future.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #9160)
levitte added a commit that referenced this pull request Jun 17, 2019
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #9160)
levitte added a commit that referenced this pull request Jun 17, 2019
…text upcall

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #9160)
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.

2 participants