Skip to content

Rethink the EVP_PKEY cache of provider side keys#11148

Merged
openssl-machine merged 4 commits intoopenssl:masterfrom
levitte:refactor-evp_pkey-provider-cache
Feb 29, 2020
Merged

Rethink the EVP_PKEY cache of provider side keys#11148
openssl-machine merged 4 commits intoopenssl:masterfrom
levitte:refactor-evp_pkey-provider-cache

Conversation

@levitte
Copy link
Member

@levitte levitte commented Feb 22, 2020

The role of this cache was two-fold:

  1. It was a cache of key copies exported to providers with which an
    operation was initiated.
  2. If the EVP_PKEY didn't have a legacy key, item 0 of the cache was
    the corresponding provider side origin, while the rest was the
    actual cache.

This dual role for item 0 made the code a bit confusing, so we now
make a separate keymgmt / keydata pair outside of that cache, which is
the provider side "origin" key.

A hard rule is that an EVP_PKEY cannot hold a legacy "origin" and a
provider side "origin" at the same time.

This also adds evp_pkey_upgrade_to_provider(), for EVP_PKEY upgrades

@levitte levitte added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Feb 22, 2020
@levitte levitte added this to the 3.0.0 milestone Feb 22, 2020
@levitte
Copy link
Member Author

levitte commented Feb 22, 2020

A small note on evp_pkey_upgrade_to_provider(): This should never become a public function, for the simple reason that it's temporary, even though it's obvious that it will be around for a few years. The reason is that this duality between legacy keys and provider side keys is planned to go away when all the legacy stuff is gone, at which point the idea of an "upgrade" will be moot.

@levitte
Copy link
Member Author

levitte commented Feb 22, 2020

This is WIP because I haven't updated the documentation yet.

Copy link
Member

@slontis slontis left a comment

Choose a reason for hiding this comment

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

Much cleaner..

@levitte
Copy link
Member Author

levitte commented Feb 22, 2020

I'm pondering if the separation between legacy "origin" and provider "origin" is a bit too strong. A slightly different model would be to have an upgrade simply use the legacy key as a template, and keep it around in case someone changes something in it...

@levitte
Copy link
Member Author

levitte commented Feb 24, 2020

My pondering lead to mods, not here, but in #11158. Key upgrades must be used very carefully, the majority of cases only need to have a cached export.

@levitte levitte force-pushed the refactor-evp_pkey-provider-cache branch from bce4d61 to 690e195 Compare February 24, 2020 12:58
@levitte
Copy link
Member Author

levitte commented Feb 24, 2020

I did some squashing, for cleanup

@levitte levitte changed the title [WIP] Rethink the EVP_PKEY cache of provider side keys Rethink the EVP_PKEY cache of provider side keys Feb 24, 2020
@levitte
Copy link
Member Author

levitte commented Feb 24, 2020

Docs have been added, this is no longer WIP

@slontis
Copy link
Member

slontis commented Feb 26, 2020

travis errors are relevant..

@levitte
Copy link
Member Author

levitte commented Feb 27, 2020

travis errors are relevant..

Fixed

Copy link
Member

@slontis slontis left a comment

Choose a reason for hiding this comment

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

Approved - Provided the appveyor tests pass.

@slontis slontis 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 27, 2020
@openssl-machine openssl-machine removed the approval: done This pull request has the required number of approvals label Feb 28, 2020
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@openssl-machine openssl-machine added the approval: ready to merge The 24 hour grace period has passed, ready to merge label Feb 28, 2020
The role of this cache was two-fold:

1.  It was a cache of key copies exported to providers with which an
    operation was initiated.
2.  If the EVP_PKEY didn't have a legacy key, item 0 of the cache was
    the corresponding provider side origin, while the rest was the
    actual cache.

This dual role for item 0 made the code a bit confusing, so we now
make a separate keymgmt / keydata pair outside of that cache, which is
the provider side "origin" key.

A hard rule is that an EVP_PKEY cannot hold a legacy "origin" and a
provider side "origin" at the same time.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from openssl#11148)
This function "upgrades" a key from a legacy key container to a
provider side key container.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from openssl#11148)
Functions covered:

- evp_pkey_export_to_provider()
- evp_pkey_upgrade_to_provider()

Reviewed-by: Shane Lontis <[email protected]>
(Merged from openssl#11148)
@levitte levitte force-pushed the refactor-evp_pkey-provider-cache branch from 0026dbc to e32c608 Compare February 29, 2020 04:41
@openssl-machine openssl-machine merged commit e32c608 into openssl:master Feb 29, 2020
@levitte levitte deleted the refactor-evp_pkey-provider-cache branch February 29, 2020 04:42
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 Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants