Skip to content

Commit

Permalink
QCryptographicHash: don't include openssl/sha.h
Browse files Browse the repository at this point in the history
... 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 d9f9d03.

Fixes: QTBUG-111467
Pick-to: 6.5
Change-Id: Ice19ad8c788fb2828666647cc40abb894cd7af2b
Reviewed-by: Fabian Kosmale <[email protected]>
  • Loading branch information
marcmutz committed Feb 27, 2023
1 parent 863eb57 commit e388d21
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/corelib/tools/qcryptographichash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ static inline int SHA384_512AddLength(SHA512Context *context, unsigned int lengt
#define USING_OPENSSL30
#include <openssl/evp.h>
#include <openssl/provider.h>
#include <openssl/sha.h>
#endif

QT_BEGIN_NAMESPACE
Expand Down Expand Up @@ -174,17 +173,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:
Expand Down

0 comments on commit e388d21

Please sign in to comment.