QCryptographicHash: Do not rely on auto-loading of the default provider

When using OpenSSL implementation, we were assuming the default provider
will be automatically loaded, but this is not going to happen after it
gets unloaded. Even the documentation says that automatic loading of the
default provider occurs max once and if it's explicitly unloaded, it
will not be automatically loaded again. In our case we are explicitly
loading and unloading the provider after MD4 hash is used so using it
afterwards we will always fail.

Fixes: QTBUG-118227
Pick-to: 6.5 6.6
Change-Id: I8107b9ab02321b57978c3d25a061672fd2a7aee8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Jan Grulich 2023-10-30 18:17:33 +01:00
parent 93a6cd8bdf
commit ddb1c75afe

View File

@ -593,12 +593,15 @@ QCryptographicHashPrivate::EVP::EVP(QCryptographicHash::Algorithm method)
* algorithm available.
*/
legacyProvider = OSSL_PROVIDER_ptr(OSSL_PROVIDER_load(nullptr, "legacy"));
defaultProvider = OSSL_PROVIDER_ptr(OSSL_PROVIDER_load(nullptr, "default"));
if (!legacyProvider || !defaultProvider)
if (!legacyProvider)
return;
}
defaultProvider = OSSL_PROVIDER_ptr(OSSL_PROVIDER_load(nullptr, "default"));
if (!defaultProvider)
return;
context = EVP_MD_CTX_ptr(EVP_MD_CTX_new());
if (!context) {