Skip to content

Commit

Permalink
QCryptographicHash: Do not rely on auto-loading of the default provider
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
grulja committed Nov 6, 2023
1 parent 93a6cd8 commit ddb1c75
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/corelib/tools/qcryptographichash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ddb1c75

Please sign in to comment.