-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Replace in-tree MD5 with OpenSSL #9585
base: master
Are you sure you want to change the base?
Conversation
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.
There should be calls to free the ctx
? Ideally using a std::unique_ptr
with custom deleter.
The original problem with #8272 remains - MD5 is deprecated since OpenSSL 3.0 and there are no guarantees that it will be present at any particular site. If you're going to go ahead and remove the embedded MD5 code, you should modify all its callers to use a modern/supported hash algorithm instead. |
I have addressed that concern in my commit message by writing "non-dreprecated EVP facility". In fact, only the md5.h interface is deprecated in OpenSSL 3+. The documentation reads: "All of the functions described on this page are deprecated. Applications should instead use EVP_DigestInit_ex(3), EVP_DigestUpdate(3) and EVP_DigestFinal_ex(3)." And I am using these (actually not the _ex version but I can change this easily). MD5 being deprecated by RFC 6151 for some applications is a different issue but replacing it with something else is a design decision that was asked for in other issues but not solved for now. |
EVP_MD-MD5 is still in the default OpenSSL algorithm provider. |
You can allocate all of these digest instances on the stack (they don't require much space), that's what the prior implementation did and that's what the OpenSSL examples do. In theory, it's a good idea to reset the stack-allocated context when you're done with it (via |
I think the primary blocker is no real support for other hash algorithms. We're probably better off nudging people towards SSL cert checking. |
You cannot allocate the EVP types on the stack since OpenSSL 1.1. |
To expand a bit on what @bgermann said in his initial comment as to the motivation for this change, as described in feather-wallet/feather#218, the code that @bgermann is proposing to replace is licensed under the RSA-MD, which is incompatible with the GPL. Feather Wallet includes other code licensed under the GPL, meaning that currently it is not legal to distribute the |
Still need to free the memory. |
You definitely can, and they work fine, otherwise
I don't have a strong view on cross-major-revision compatibility, though I suppose it doesn't hurt; but then, if you want it, the allocations need to be paired with free. |
It is not helpful to point to a function that was removed in 1.1 to counter a point that was made about 1.1 or later. Yes, I know that OpenSSL supported it in the old days. I am going to free the mem when I have time for it. |
This uses OpenSSL's non-deprecated EVP digest facility to calculate MD5 in HTTP digest authentication.
The RSA-MD licensed implementation that originated from RFC 1321 and got into epee via Cyrus SASL and libEtPan! is not a good fit for epee, which also links to the GPL licensed readline. RSA-MD has an advertisement clause that is known to be incompatible with GPL.
f347c8d
to
c744496
Compare
Freeing the mem with a unique_ptr is done. I think, I have addressed every comment. |
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.
LGTM. I am usually in support of using well audited third party libraries instead of our own. I was afraid of MD5 deprecation issue in OpenSSL.
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.
Agreed that support was removed for stack allocation in OpenSSL 3.0 (https://docs.openssl.org/master/man7/ossl-guide-migration/#upgrading-from-openssl-111), which is the relevant minimum version (not 1.1).
This is a follow-up for #8272 with a different OpenSSL interface used.
The original PR was rejected because it used a deprecated interface.
The performance properties should be the same but I have not measured them.
My main motivation for this is getting rid of the RSA-MD code.