QCryptographicHash[OpenSSL]: allow to get intermediary result
OpenSSL doesn't allow to add additional data when the hash has been finalized. To fix that, we just make a copy of the current context and call EVP_DigestFinal_ex() on the copy so we can still later add additional data. Change-Id: If76d4ec56f8846d6ef55ed7ec7cbab440d43edd0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 698c7696ebff4868c695bb6d7ca66ed17b5c2f3b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0700f561b0
commit
f025428d5b
@ -752,9 +752,11 @@ void QCryptographicHashPrivate::finalize() noexcept
|
||||
tmpresult.resizeForOverwrite(length);
|
||||
blake2s_final(©, tmpresult.data(), length);
|
||||
} else if (!initializationFailed) {
|
||||
EVP_MD_CTX_ptr copy = EVP_MD_CTX_ptr(EVP_MD_CTX_new());
|
||||
EVP_MD_CTX_copy_ex(copy.get(), context.get());
|
||||
tmpresult.resizeForOverwrite(EVP_MD_get_size(algorithm.get()));
|
||||
const int ret = EVP_DigestFinal_ex(context.get(), tmpresult.data(), nullptr);
|
||||
Q_UNUSED(ret);
|
||||
const int ret = EVP_DigestFinal_ex(copy.get(), tmpresult.data(), nullptr);
|
||||
Q_UNUSED(ret)
|
||||
}
|
||||
#else
|
||||
switch (method) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user