Skip to content

Comments

Make PrivateKey loading libctx aware#11494

Closed
mattcaswell wants to merge 9 commits intoopenssl:masterfrom
mattcaswell:privkey-libctx
Closed

Make PrivateKey loading libctx aware#11494
mattcaswell wants to merge 9 commits intoopenssl:masterfrom
mattcaswell:privkey-libctx

Conversation

@mattcaswell
Copy link
Member

During loading of a private key it is possible that the implementation will need to use a cryptographic algorithm Notably in decoding an Ed448 private key we automatically derive the public key (because it is not encoded along with the private key). To do so we need to use SHAKE256. This means that we have to make the private key loading functions OPENSSL_CTX aware.

We also update libssl to use the new private key loading functions.

This is needed for alpha1

@mattcaswell mattcaswell added the branch: master Applies to master branch label Apr 8, 2020
Copy link
Member

Choose a reason for hiding this comment

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

So while you're making new public functions out of the others, this one you're making internal... it seems inconsistent, wanna tell me why?

Copy link
Member Author

Choose a reason for hiding this comment

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

It wasn't clear to me whether we wanted to encourage the use of EVP_PKCS82PKEY or not. While I wasn't sure I erred on the side of caution thinking it was easier to make things public later than the other way around.

@mattcaswell
Copy link
Member Author

Fixup pushed addressing the comment above. I also rebased to resolve a conflict with master. Please look again.

@slontis
Copy link
Member

slontis commented Apr 9, 2020

travis error is relevant..

include/openssl/pem.h:353:34: error: unknown type name 'FILE'
EVP_PKEY *PEM_read_PrivateKey_ex(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,

@mattcaswell
Copy link
Member Author

I've rebased this and pushed a fixup to (hopefully) resolve the travis issue. Please take another look.

The Ed448 private key decoding makes algorithm fetches. Therefore we teach
d2i_PrivateKey et al about libctx and make sure it is passed through the
layers.
The Ed448 private key deconding needs to use a library ctx. So we
implement a priv_decode_with_libctx function for it.
We restrict this to just the PrivateKey loading code at the moment.
Now that d2i_PrivateKey_ex() and other similar functions exist we should
use it when loading a PEM PrivateKey.
Since loading a private key might require algorithm fetches we should
make sure the correct libctx is used.
@mattcaswell
Copy link
Member Author

Rebased again to fix conflicts with master. Also another fix up to address travis issues.

Ping?

@slontis slontis added the approval: done This pull request has the required number of approvals label Apr 14, 2020
@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 Apr 15, 2020
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@mattcaswell
Copy link
Member Author

Pushed. Thanks.

openssl-machine pushed a commit that referenced this pull request Apr 15, 2020
The Ed448 private key decoding makes algorithm fetches. Therefore we teach
d2i_PrivateKey et al about libctx and make sure it is passed through the
layers.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from #11494)
openssl-machine pushed a commit that referenced this pull request Apr 15, 2020
The Ed448 private key deconding needs to use a library ctx. So we
implement a priv_decode_with_libctx function for it.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from #11494)
openssl-machine pushed a commit that referenced this pull request Apr 15, 2020
We restrict this to just the PrivateKey loading code at the moment.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from #11494)
openssl-machine pushed a commit that referenced this pull request Apr 15, 2020
Now that d2i_PrivateKey_ex() and other similar functions exist we should
use it when loading a PEM PrivateKey.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from #11494)
openssl-machine pushed a commit that referenced this pull request Apr 15, 2020
Since loading a private key might require algorithm fetches we should
make sure the correct libctx is used.

Reviewed-by: Shane Lontis <[email protected]>
(Merged from #11494)
openssl-machine pushed a commit that referenced this pull request Apr 15, 2020
@slontis
Copy link
Member

slontis commented Apr 15, 2020

Do you have more PR's that you are about to merge? libcrypto.num is a bit of a problem.

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.

6 participants