Use OSSL_STORE in apps, generalizing and simplifying load_key() etc.#11755
Use OSSL_STORE in apps, generalizing and simplifying load_key() etc.#11755DDvO wants to merge 3 commits intoopenssl:masterfrom
Conversation
|
Using OSSL_STORE for loading private keys in DER format gives a couple of strange failures of The loader reports on How can this be fixed? |
|
Oh, what a surprise! It turns out that
However, looking at actual code, you'll notice that when it has decoded a PKCS#8 structure, *it doesn't care about Lines 46 to 65 in 90fc2c2 Of course, the file loader is implemented according to documentation 😉 |
|
Try and see what happens if you add this patch: diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c
index c7346f5424..3ddc56d408 100644
--- a/crypto/asn1/d2i_pr.c
+++ b/crypto/asn1/d2i_pr.c
@@ -58,6 +58,8 @@ EVP_PKEY *d2i_PrivateKey_ex(int type, EVP_PKEY **a, const unsigned char **pp,
goto err;
EVP_PKEY_free(ret);
ret = tmp;
+ if (EVP_PKEY_type(type) != EVP_PKEY_base_id(ret))
+ goto err;
} else {
ASN1err(0, ERR_R_ASN1_LIB);
goto err; |
Great, this fixes the test failures - thanks @levitte |
477e358 to
2a16046
Compare
8258354 to
16b6afa
Compare
16b6afa to
50c3db5
Compare
|
This PR meanwhile reflects also the extended @FdaSilvaYY, thanks for your yesterday's review. Maybe you wanna have a look also at this addendum. |
43b7df1 to
9b0a075
Compare
|
I've partly squashed the commits and |
9b0a075 to
0c672fe
Compare
|
I again caught the unrelated Travis failure "No space left on device", |
|
Unfortunately, I was not well yesterday, and won't be able to look before this evening today. Considering that #11756 has only been approved today, time is running very short anyway. |
|
That being said, we've internally decided to make fairly frequent alphas, with about three weeks' interval between them, so the wait for alpha3 isn't going to be huge. I think it's better to iron out whatever there is to iron out than to rush it in for alpha2. Do you agree? |
Please no. |
It just causes the cut'n'pasting these functions when needed :( |
What would make sense IHMO is a slight abstraction (without the stdin feature, and more general password input) of for convenient library-level use of the OSSL_STORE API, for instance: where either the |
Indeed. Any why not even more directly usable |
|
Then we can also obsolete/replace/integrate |
|
BTW, is it possible with OSSL_STORE to set a timeout value in case HTTP-based fetching is used? |
There is a ctrl function, isn't there? |
|
I really don't think that application specific routines belong in libcrypto. If you absolutely want to make them into a public library, it should be a separate one. |
I agree with this position. |
This brings us back to a discussion started pretty exactly four years back: #6986. In my view also the OSSL_STORE would better be placed in such an application-level lib. |
|
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. |
I disagree, especially in light if it being used internally in a few places in libcrypto, but also because it's a central ENGINE (and soon provider) interface.
I agree completely! There's a lot that's been shoved into libcrypto that's more like protocol libraries (interestingly, we have a separate libssl, go figure!) or application utility libraries. |
Given this insight I agree. |
11b7bad to
cf2e871
Compare
This also adds the more flexible and general load_key_cert_crl() as well as helper functions get_passwd(), cleanse(), and clear_free() to be used also in apps/cmp.c etc.
cf2e871 to
a2847b1
Compare
…ib/apps.c Reviewed-by: Richard Levitte <[email protected]> Reviewed-by: David von Oheimb <[email protected]> (Merged from #11755)
…warning Reviewed-by: Richard Levitte <[email protected]> Reviewed-by: David von Oheimb <[email protected]> (Merged from #11755)
This also adds the more flexible and general load_key_cert_crl() as well as helper functions get_passwd(), cleanse(), and clear_free() to be used also in apps/cmp.c etc. Reviewed-by: Richard Levitte <[email protected]> Reviewed-by: David von Oheimb <[email protected]> (Merged from #11755)
|
Pushed - thanks! |
This is the continuation of #11745, a further spin-off of PR #11470 according to #11470 (comment).
This adds a flexible apps-internal function
load_key_cert_crl()now usedload_key(),load_pubkey(), andload_cert(), making use of OSSL_STORE.This also adds the app-internal functions
get_passwd(),cleanse(), andclear_free()to be used also in apps/cmp.c etc.This PR also updates the help texts and the documentation of those apps using
load-key()etc.