Skip to content

Comments

Add EVP_PKEY_get_params support for accessing key fields#11365

Closed
slontis wants to merge 3 commits intoopenssl:masterfrom
slontis:pkey_get_params_ec
Closed

Add EVP_PKEY_get_params support for accessing key fields#11365
slontis wants to merge 3 commits intoopenssl:masterfrom
slontis:pkey_get_params_ec

Conversation

@slontis
Copy link
Member

@slontis slontis commented Mar 19, 2020

Currently only RSA, EC and ECX are supported (DH and DSA need to be added to the keygen
PR's seperately because the fields supported have changed significantly).

Also added EVP_PKEY_gettable_params. Neither of these functions are dependant on any
particular operation - but they do require the keys to be provider based.

Made the export and get_params functions share the same code by supplying
support functions that work for both a OSSL_PARAM_BLD as well as a OSSL_PARAM[].
This approach means that complex code is not required to build an
empty OSSL_PARAM[] with the correct sized fields before then doing a second
pass to populate the array.

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

@slontis slontis added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Mar 19, 2020
@slontis
Copy link
Member Author

slontis commented Mar 19, 2020

This is a replacement of #11352. It started out as just adding EC support, but quite a few changes also applied to the RSA code so it is easier just to merge them into a single cleaned up PR.

@slontis slontis force-pushed the pkey_get_params_ec branch 4 times, most recently from 7e788e9 to 295e398 Compare March 19, 2020 20:24
@slontis
Copy link
Member Author

slontis commented Mar 19, 2020

@levitte I have reverted the multiprime changes in this PR.

@slontis slontis force-pushed the pkey_get_params_ec branch 2 times, most recently from 4096508 to 1e96783 Compare March 19, 2020 23:50
@slontis slontis force-pushed the pkey_get_params_ec branch from 1e96783 to a996d8e Compare March 23, 2020 04:58
@slontis slontis requested a review from levitte March 23, 2020 05:15
@levitte
Copy link
Member

levitte commented Mar 23, 2020

If you're introducing numbered OSSL_PARAM key names, then you should probably revert 45211c5
(MPRSA keys were uniquely the driving force)

@slontis
Copy link
Member Author

slontis commented Mar 23, 2020

If you're introducing numbered OSSL_PARAM key names, then you should probably revert 45211c5
(MPRSA keys were uniquely the driving force)

Although this doesnt actually exclude it from being used that way.
I think the KDF's still do this also?

For the RSA case it didnt sit well to do it as an unordered array - considering they are kind of ordered (since there is a triplet mapping going on for each index).

@levitte
Copy link
Member

levitte commented Mar 23, 2020

For the RSA case it didnt sit well to do it as an unordered array

I'm lost, what was the unordered part?

@slontis
Copy link
Member Author

slontis commented Mar 23, 2020

For the RSA case it didnt sit well to do it as an unordered array

I'm lost, what was the unordered part?

You are correct - There was no unordered part for them :)
Giving them unique names makes it a very simple interface for the end user (i.e we dont need a stack or index reference) as well as not requiring extra args being passed down to the keymanagement get_params method() (OR yet another method to do this). The trade off being that a table of const names is required (since the names are just pointed to during param building).

@slontis
Copy link
Member Author

slontis commented Mar 23, 2020

ping

@paulidale
Copy link
Contributor

I think the KDF's still do this also?

Several of the PRFs replicate the same named item.

@slontis slontis force-pushed the pkey_get_params_ec branch from 1b3d820 to c5f0f4c Compare March 25, 2020 23:33
@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@slontis slontis force-pushed the pkey_get_params_ec branch from 502fb92 to 0af6b25 Compare March 27, 2020 22:06
@slontis
Copy link
Member Author

slontis commented Mar 27, 2020

Rebased.
Why is travis not showing up here???

@slontis
Copy link
Member Author

slontis commented Mar 27, 2020

@levitte - has to rebase (also addressed your nits). Does your approval still hold?

@levitte
Copy link
Member

levitte commented Mar 28, 2020

Did you need to adjust more than util/libcrypto.num? If not, it still stands

@slontis
Copy link
Member Author

slontis commented Mar 28, 2020

Sigh - Got a merge error in ec_kmgmt.c - so it does need another review now

@slontis slontis requested a review from levitte March 28, 2020 10:35
@slontis slontis added approval: review pending This pull request needs review by a committer and removed approval: done This pull request has the required number of approvals labels Mar 28, 2020
@slontis slontis force-pushed the pkey_get_params_ec branch from ded070d to b728b11 Compare March 29, 2020 23:25
@slontis
Copy link
Member Author

slontis commented Mar 29, 2020

Rebased yet again.
Modified EVP_PKEY_get_bn_param so that it optionally used an allocated buffer and added a test for this case.

@slontis slontis force-pushed the pkey_get_params_ec branch from b728b11 to efecd1c Compare March 29, 2020 23:46
@slontis
Copy link
Member Author

slontis commented Mar 29, 2020

collapsed the commits so that if someone causes me yet another merge it wont be as bad.

Changed EVP_PKEY_get_bn_param() so it cleanses the buffers it uses (Since it could be retrieving private data).

@levitte levitte 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 Mar 30, 2020
slontis added 3 commits March 31, 2020 11:18
…fields

Currently only RSA, EC and ECX are supported (DH and DSA need to be added to the keygen
PR's seperately because the fields supported have changed significantly).

The API's require the keys to be provider based.

Made the keymanagement export and get_params functions share the same code by supplying
support functions that work for both a OSSL_PARAM_BLD as well as a OSSL_PARAM[].
This approach means that complex code is not required to build an
empty OSSL_PARAM[] with the correct sized fields before then doing a second
pass to populate the array.

The RSA factor arrays have been changed to use unique key names to simplify the interface
needed by the user.
@slontis slontis force-pushed the pkey_get_params_ec branch from efecd1c to b7b155c Compare March 31, 2020 01:22
@slontis
Copy link
Member Author

slontis commented Mar 31, 2020

rebased to fix libcrypto.num - no reapproval is required.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@t8m t8m 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 Mar 31, 2020
openssl-machine pushed a commit that referenced this pull request Apr 1, 2020
…fields

Currently only RSA, EC and ECX are supported (DH and DSA need to be added to the keygen
PR's seperately because the fields supported have changed significantly).

The API's require the keys to be provider based.

Made the keymanagement export and get_params functions share the same code by supplying
support functions that work for both a OSSL_PARAM_BLD as well as a OSSL_PARAM[].
This approach means that complex code is not required to build an
empty OSSL_PARAM[] with the correct sized fields before then doing a second
pass to populate the array.

The RSA factor arrays have been changed to use unique key names to simplify the interface
needed by the user.

Reviewed-by: Richard Levitte <[email protected]>
(Merged from #11365)
@slontis
Copy link
Member Author

slontis commented Apr 1, 2020

Thanks.. Merged.

@slontis slontis closed this Apr 1, 2020
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.

8 participants