From 34798b22f371603e1f00ab63b6681ee78849e7cf Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 23 Jul 2021 12:00:40 +0300 Subject: [PATCH] drop support for SHA-224 and SHA-384 hash sum Signed-off-by: Ivailo Monev --- README | 2 +- src/network/kernel/qcryptographichash.cpp | 48 ------------------- src/network/kernel/qcryptographichash.h | 2 - .../kernel/qcryptographichash/main.cpp | 2 - 4 files changed, 1 insertion(+), 53 deletions(-) diff --git a/README b/README index 800457c66..327edcf9a 100644 --- a/README +++ b/README @@ -58,7 +58,7 @@ There are several things you should be aware before considering Katie: - support for AArch64 architecture - support for PostgreSQL v9.1+ - support for locale aliases - - support for generating SHA-224, SHA-256, SHA-384, SHA-512 hash sums (SHA-2) + - support for generating SHA-256 and SHA-512 hash sums (SHA-2) - support for generating CRC-32 checksums via qChecksum32() function - verification section for plugins build with Clang - faster alternatives to qCompress() and qUncompress() diff --git a/src/network/kernel/qcryptographichash.cpp b/src/network/kernel/qcryptographichash.cpp index c2750a69c..e54a355c0 100644 --- a/src/network/kernel/qcryptographichash.cpp +++ b/src/network/kernel/qcryptographichash.cpp @@ -36,9 +36,7 @@ public: MD4_CTX md4Context; MD5_CTX md5Context; SHA_CTX sha1Context; - SHA256_CTX sha224Context; SHA256_CTX sha256Context; - SHA512_CTX sha384Context; SHA512_CTX sha512Context; QCryptographicHash::Algorithm method; QByteArray result; @@ -66,9 +64,7 @@ public: \value Md4 Generate an MD4 hash sum \value Md5 Generate an MD5 hash sum \value Sha1 Generate an SHA-1 hash sum - \value Sha224 Generate an SHA-224 hash sum (SHA-2). Introduced in Katie 4.9 \value Sha256 Generate an SHA-256 hash sum (SHA-2). Introduced in Katie 4.9 - \value Sha384 Generate an SHA-384 hash sum (SHA-2). Introduced in Katie 4.9 \value Sha512 Generate an SHA-512 hash sum (SHA-2). Introduced in Katie 4.9 */ @@ -108,18 +104,10 @@ void QCryptographicHash::reset() SHA1_Init(&d->sha1Context); break; } - case QCryptographicHash::Sha224: { - SHA224_Init(&d->sha224Context); - break; - } case QCryptographicHash::Sha256: { SHA256_Init(&d->sha256Context); break; } - case QCryptographicHash::Sha384: { - SHA384_Init(&d->sha384Context); - break; - } case QCryptographicHash::Sha512: { SHA512_Init(&d->sha512Context); break; @@ -147,18 +135,10 @@ void QCryptographicHash::addData(const char *data, int length) SHA1_Update(&d->sha1Context, data, length); break; } - case QCryptographicHash::Sha224: { - SHA224_Update(&d->sha224Context, data, length); - break; - } case QCryptographicHash::Sha256: { SHA256_Update(&d->sha256Context, data, length); break; } - case QCryptographicHash::Sha384: { - SHA384_Update(&d->sha384Context, data, length); - break; - } case QCryptographicHash::Sha512: { SHA512_Update(&d->sha512Context, data, length); break; @@ -219,24 +199,12 @@ QByteArray QCryptographicHash::result() const SHA1_Final(reinterpret_cast(d->result.data()), ©); break; } - case QCryptographicHash::Sha224: { - SHA256_CTX copy = d->sha224Context; - d->result.resize(SHA224_DIGEST_LENGTH); - SHA224_Final(reinterpret_cast(d->result.data()), ©); - break; - } case QCryptographicHash::Sha256:{ SHA256_CTX copy = d->sha256Context; d->result.resize(SHA256_DIGEST_LENGTH); SHA256_Final(reinterpret_cast(d->result.data()), ©); break; } - case QCryptographicHash::Sha384:{ - SHA512_CTX copy = d->sha384Context; - d->result.resize(SHA384_DIGEST_LENGTH); - SHA384_Final(reinterpret_cast(d->result.data()), ©); - break; - } case QCryptographicHash::Sha512:{ SHA512_CTX copy = d->sha512Context; d->result.resize(SHA512_DIGEST_LENGTH); @@ -277,14 +245,6 @@ QByteArray QCryptographicHash::hash(const QByteArray &data, QCryptographicHash:: SHA1_Final(result, &sha1Context); return QByteArray(reinterpret_cast(result), SHA_DIGEST_LENGTH); } - case QCryptographicHash::Sha224: { - QSTACKARRAY(unsigned char, result, SHA224_DIGEST_LENGTH); - SHA256_CTX sha224Context; - SHA224_Init(&sha224Context); - SHA224_Update(&sha224Context, data.constData(), data.length()); - SHA224_Final(result, &sha224Context); - return QByteArray(reinterpret_cast(result), SHA224_DIGEST_LENGTH); - } case QCryptographicHash::Sha256: { QSTACKARRAY(unsigned char, result, SHA256_DIGEST_LENGTH); SHA256_CTX sha256Context; @@ -293,14 +253,6 @@ QByteArray QCryptographicHash::hash(const QByteArray &data, QCryptographicHash:: SHA256_Final(result, &sha256Context); return QByteArray(reinterpret_cast(result), SHA256_DIGEST_LENGTH); } - case QCryptographicHash::Sha384: { - QSTACKARRAY(unsigned char, result, SHA384_DIGEST_LENGTH); - SHA512_CTX sha384Context; - SHA384_Init(&sha384Context); - SHA384_Update(&sha384Context, data.constData(), data.length()); - SHA384_Final(result, &sha384Context); - return QByteArray(reinterpret_cast(result), SHA384_DIGEST_LENGTH); - } case QCryptographicHash::Sha512: { QSTACKARRAY(unsigned char, result, SHA512_DIGEST_LENGTH); SHA512_CTX sha512Context; diff --git a/src/network/kernel/qcryptographichash.h b/src/network/kernel/qcryptographichash.h index 354a5c258..d6651e35f 100644 --- a/src/network/kernel/qcryptographichash.h +++ b/src/network/kernel/qcryptographichash.h @@ -38,9 +38,7 @@ public: Md4, Md5, Sha1, - Sha224, Sha256, - Sha384, Sha512 }; diff --git a/tests/benchmarks/network/kernel/qcryptographichash/main.cpp b/tests/benchmarks/network/kernel/qcryptographichash/main.cpp index 861fe5395..82d0c232b 100644 --- a/tests/benchmarks/network/kernel/qcryptographichash/main.cpp +++ b/tests/benchmarks/network/kernel/qcryptographichash/main.cpp @@ -92,9 +92,7 @@ void tst_qcryptographichash::algorithms_data() QTest::newRow("Md4") << QCryptographicHash::Md4; QTest::newRow("Md5") << QCryptographicHash::Md5; QTest::newRow("Sha1") << QCryptographicHash::Sha1; - QTest::newRow("Sha224") << QCryptographicHash::Sha224; QTest::newRow("Sha256") << QCryptographicHash::Sha256; - QTest::newRow("Sha384") << QCryptographicHash::Sha384; QTest::newRow("Sha512") << QCryptographicHash::Sha512; }