New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce EVP_PKEY_meth_destroy function #4356
Conversation
This doesn't strike me as the right way to do things... or rather, it was fitting for pre-1.1.0 OpenSSLs, where we asked the application authors to do all the libcrypto cleanup explicitely. Starting with 1.1.0, we've made that an internal matter instead. So I'm thinking that |
If so, |
Good point. |
Sure. |
WAIT, what does remove0 even mean? We have set0/get0 which are explainable in terms of refcounting. Remove0 seems strange. |
Oops, |
Well, the function to add a pmeth to the internal application stack is |
But we could have an add1 if there was need. The 1 and 0 are about refcounts, which make no sense in remove |
004bcd9
to
e2b3704
Compare
I searched the code and seems all functions suffixed with Changes are made in rebased commits. This time the only the last commit is related. |
The 0 and 1 suffixes mostly tell you if the object that's passed will be used as is or "duplicated". Some "duplication" is done by increasing the refcount, when the object has that. If not, the "duplication" is done by copying memory. (note that the 0 / 1 suffix is a relatively new invention, we have APIs that are older and don't use those suffixes) But ok, it was only a suggestion, I don't really have a problem with |
@@ -294,6 +296,21 @@ int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth) | |||
return 1; | |||
} | |||
|
|||
void evp_app_cleanup_int(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps actually add a call to it in OPENSSL_cleanup
? ;-)
(you'll have to add a declaration in crypto/include/internal/evp_int.h
too)
Also, may I suggest a rename to evp_pkey_cleanup_int
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems I've already added this stuff in evp_cleanup_int
which will be called by OPENSSL_cleanup
and the header file evp_int.h
was also updated in the commit.
Also, may I suggest a rename to evp_pkey_cleanup_int
pkey
is too wide, I think evp_pkey_meth_cleanup_int
would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm, now I see the change that adds it... dunno why github didn't show me that earlier...
@@ -90,6 +90,8 @@ void evp_cleanup_int(void) | |||
|
|||
EVP_PBE_cleanup(); | |||
OBJ_sigid_free(); | |||
|
|||
evp_app_cleanup_int(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I know why I was confused. I expected this call to appear in OPENSSL_cleanup
, not here. Frankly, I'm not sure this is the right spot...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All EVP related cleanups should be grouped together and be called once in OPENSSL_cleanup, shouldn't they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, yeah ok...
I am wondering if this is finally approved, should I remove the 'helper' commit (ef64d5e) before merging? Thus it can be more easy to merge the related one(s)...or you may have better ideas. |
I think #4337 should be merged first, then it should be easy to merge only the top commit from this one |
Yes, Paul. Wait for 4337 then rebase and 'push -f' |
Okay |
Ok, time for a rebase here |
Ok, seems like I have wait for this one to be fixed ;-) I am getting the same ci errors in #4328. |
doc/man3/EVP_PKEY_meth_new.pod
Outdated
@@ -369,6 +374,9 @@ object or returns NULL if not found. | |||
EVP_PKEY_meth_add0() returns 1 if method is added successfully or 0 | |||
if an error occurred. | |||
|
|||
EVP_PKEY_meth_remove() returns 1 if method is removed successfully or | |||
0 if the method has not been added previously. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to see: 0 if an error occurred.
here.
I realize the only error possible at the moment is if the item isn't in the stack but that might not be true forever.
1. make app pkey methods cleanup internal 2. add EVP_PKEY_meth_remove Fixes travis-ci failure in openssl#4337
e2b3704
to
6574bae
Compare
Rebased and @paulidale 's suggestion is also taken. |
@levitte to reconfirm. |
doc/man3/EVP_PKEY_meth_new.pod
Outdated
@@ -350,6 +352,9 @@ then the built-in objects. | |||
|
|||
EVP_PKEY_meth_add0() adds B<pmeth> to the user defined stack of methods. | |||
|
|||
EVP_PKEY_meth_remove() removes an B<EVP_PKEY_METHOD> object added by | |||
EVP_PKEY_meth_new(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I think you meant EVP_PKEY_meth_add0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I didn't catch this earlier :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, originally I wanted to express 'created by _new
and added by _add0
'. Now seems just mention _add0
is enough...
[to be squashed] [skip ci]
New commit pushed, please re-review @levitte @paulidale |
[to be squashed] [skip ci] Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from #4356)
This is merged, so now close this PR... |
To address travis failure in #4337 . This function is used to delete all application added pmeth.
Only the last commit is related.Only last two commits are related to this PR. The first commit is loaned from #4337 ...Checklist