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<N>_DIGEST_LENGTH, but this is a well-known
value and easily obtained from rfc6234/sha.h as SHA<N>HashSize, so use
that.

Even reduces #ifdef'ery.

Amends d9f9d03fd3.

Fixes: QTBUG-111467
Pick-to: 6.5
Change-Id: Ice19ad8c788fb2828666647cc40abb894cd7af2b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Marc Mutz 2023-02-26 00:25:49 +01:00
parent 863eb576c8
commit e388d219a4

View File

@ -116,7 +116,6 @@ static inline int SHA384_512AddLength(SHA512Context *context, unsigned int lengt
#define USING_OPENSSL30 #define USING_OPENSSL30
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/provider.h> #include <openssl/provider.h>
#include <openssl/sha.h>
#endif #endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -174,17 +173,10 @@ static constexpr int hashLengthInternal(QCryptographicHash::Algorithm method) no
#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 #ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
CASE(Md4, 16); CASE(Md4, 16);
CASE(Md5, 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(Sha224, SHA224HashSize);
CASE(Sha256, SHA256HashSize); CASE(Sha256, SHA256HashSize);
CASE(Sha384, SHA384HashSize); CASE(Sha384, SHA384HashSize);
CASE(Sha512, SHA512HashSize); CASE(Sha512, SHA512HashSize);
#endif
CASE(Blake2s_128, 128 / 8); CASE(Blake2s_128, 128 / 8);
case QCryptographicHash::Blake2b_160: case QCryptographicHash::Blake2b_160:
case QCryptographicHash::Blake2s_160: case QCryptographicHash::Blake2s_160: