From 080f2654bb3742e82ed909babfdd3db5f53d4df8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 26 Feb 2023 00:25:49 +0100 Subject: [PATCH] QCryptographicHash: don't include openssl/sha.h ... it conflicts with rfc6234/sha.h's SHA{1,224,256,384,512} symbols. We can't drop the rfc6234/sha.h header, as openssl/sha.h doesn't give us the algorithm's block sizes, necessary for HMAC (QMessageAuthenticationCode). But we can drop openssl/sha.h. The only reason we included the header was to get access to SHA_DIGEST_LENGTH, but this is a well-known value and easily obtained from rfc6234/sha.h as SHAHashSize, so use that. Even reduces #ifdef'ery. Amends d9f9d03fd34d951eb587fe082a0dbda33b8df248. Fixes: QTBUG-111467 Change-Id: Ice19ad8c788fb2828666647cc40abb894cd7af2b Reviewed-by: Fabian Kosmale (cherry picked from commit e388d219a4a29e7a5a81ff1a6dcf995662177b43) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qcryptographichash.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 2b45033a967..0a9b6d5d622 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -116,7 +116,6 @@ static inline int SHA384_512AddLength(SHA512Context *context, unsigned int lengt #define USING_OPENSSL30 #include #include -#include #endif QT_BEGIN_NAMESPACE @@ -158,17 +157,10 @@ static constexpr int hashLengthInternal(QCryptographicHash::Algorithm method) no #ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 CASE(Md4, 16); CASE(Md5, 16); -#ifdef USING_OPENSSL30 - CASE(Sha224, SHA224_DIGEST_LENGTH); - CASE(Sha256, SHA256_DIGEST_LENGTH); - CASE(Sha384, SHA384_DIGEST_LENGTH); - CASE(Sha512, SHA512_DIGEST_LENGTH); -#else CASE(Sha224, SHA224HashSize); CASE(Sha256, SHA256HashSize); CASE(Sha384, SHA384HashSize); CASE(Sha512, SHA512HashSize); -#endif CASE(Blake2s_128, 128 / 8); case QCryptographicHash::Blake2b_160: case QCryptographicHash::Blake2s_160: