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. Pick-to: 6.5 Change-Id: If76d4ec56f8846d6ef55ed7ec7cbab440d43edd0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
94e474b48e
commit
698c7696eb
@ -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