summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcryptographichash.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-02-25 16:49:14 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-02-26 07:51:13 +0100
commit54a4d4bf7619c4c6acf9fb02c2297fefff94d6e9 (patch)
treece323f91b60c45025c98f3ac8d20974a999f9feb /src/corelib/tools/qcryptographichash.cpp
parentec2c27d59635e123a3c159fd30d90ec30a6d63cb (diff)
QCryptographicHash: implement non-OpenSSL3 part of supportsAlgorithm()
Unconditionally returning true is incorrect, not only just since NumAlgorithms was added in 0411d98192ede84b115618ece876579fd79252f8. The values may have gaps, we might be compiling with SHA1_ONLY, and, on a language-lawyer level, enums can legally contain values other than those explicitly enumerated, so give the right answer in all of these cases. Pick-to: 6.5 Change-Id: I705d4f759b2572b8b3d1cee18b7939939eedbbac Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qcryptographichash.cpp')
-rw-r--r--src/corelib/tools/qcryptographichash.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 3ed2ebcab4..9b2022020b 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -952,9 +952,37 @@ bool QCryptographicHashPrivate::supportsAlgorithm(QCryptographicHash::Algorithm
return algorithm != nullptr;
#else
- Q_UNUSED(method);
- return true;
+ switch (method) {
+ case QCryptographicHash::Sha1:
+#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
+ case QCryptographicHash::Md4:
+ case QCryptographicHash::Md5:
+ case QCryptographicHash::Sha224:
+ case QCryptographicHash::Sha256:
+ case QCryptographicHash::Sha384:
+ case QCryptographicHash::Sha512:
+ case QCryptographicHash::RealSha3_224:
+ case QCryptographicHash::Keccak_224:
+ case QCryptographicHash::RealSha3_256:
+ case QCryptographicHash::Keccak_256:
+ case QCryptographicHash::RealSha3_384:
+ case QCryptographicHash::Keccak_384:
+ case QCryptographicHash::RealSha3_512:
+ case QCryptographicHash::Keccak_512:
+ case QCryptographicHash::Blake2b_160:
+ case QCryptographicHash::Blake2b_256:
+ case QCryptographicHash::Blake2b_384:
+ case QCryptographicHash::Blake2b_512:
+ case QCryptographicHash::Blake2s_128:
+ case QCryptographicHash::Blake2s_160:
+ case QCryptographicHash::Blake2s_224:
+ case QCryptographicHash::Blake2s_256:
#endif
+ return true;
+ case QCryptographicHash::NumAlgorithms: ;
+ };
+ return false;
+#endif // !USING_OPENSSL3
}
static constexpr int qt_hash_block_size(QCryptographicHash::Algorithm method)