drop support for SHA-224 and SHA-384 hash sum

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-07-23 12:00:40 +03:00
parent 67a6a29fc0
commit 34798b22f3
4 changed files with 1 additions and 53 deletions

2
README
View file

@ -58,7 +58,7 @@ There are several things you should be aware before considering Katie:
- support for AArch64 architecture - support for AArch64 architecture
- support for PostgreSQL v9.1+ - support for PostgreSQL v9.1+
- support for locale aliases - 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 - support for generating CRC-32 checksums via qChecksum32() function
- verification section for plugins build with Clang - verification section for plugins build with Clang
- faster alternatives to qCompress() and qUncompress() - faster alternatives to qCompress() and qUncompress()

View file

@ -36,9 +36,7 @@ public:
MD4_CTX md4Context; MD4_CTX md4Context;
MD5_CTX md5Context; MD5_CTX md5Context;
SHA_CTX sha1Context; SHA_CTX sha1Context;
SHA256_CTX sha224Context;
SHA256_CTX sha256Context; SHA256_CTX sha256Context;
SHA512_CTX sha384Context;
SHA512_CTX sha512Context; SHA512_CTX sha512Context;
QCryptographicHash::Algorithm method; QCryptographicHash::Algorithm method;
QByteArray result; QByteArray result;
@ -66,9 +64,7 @@ public:
\value Md4 Generate an MD4 hash sum \value Md4 Generate an MD4 hash sum
\value Md5 Generate an MD5 hash sum \value Md5 Generate an MD5 hash sum
\value Sha1 Generate an SHA-1 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 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 \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); SHA1_Init(&d->sha1Context);
break; break;
} }
case QCryptographicHash::Sha224: {
SHA224_Init(&d->sha224Context);
break;
}
case QCryptographicHash::Sha256: { case QCryptographicHash::Sha256: {
SHA256_Init(&d->sha256Context); SHA256_Init(&d->sha256Context);
break; break;
} }
case QCryptographicHash::Sha384: {
SHA384_Init(&d->sha384Context);
break;
}
case QCryptographicHash::Sha512: { case QCryptographicHash::Sha512: {
SHA512_Init(&d->sha512Context); SHA512_Init(&d->sha512Context);
break; break;
@ -147,18 +135,10 @@ void QCryptographicHash::addData(const char *data, int length)
SHA1_Update(&d->sha1Context, data, length); SHA1_Update(&d->sha1Context, data, length);
break; break;
} }
case QCryptographicHash::Sha224: {
SHA224_Update(&d->sha224Context, data, length);
break;
}
case QCryptographicHash::Sha256: { case QCryptographicHash::Sha256: {
SHA256_Update(&d->sha256Context, data, length); SHA256_Update(&d->sha256Context, data, length);
break; break;
} }
case QCryptographicHash::Sha384: {
SHA384_Update(&d->sha384Context, data, length);
break;
}
case QCryptographicHash::Sha512: { case QCryptographicHash::Sha512: {
SHA512_Update(&d->sha512Context, data, length); SHA512_Update(&d->sha512Context, data, length);
break; break;
@ -219,24 +199,12 @@ QByteArray QCryptographicHash::result() const
SHA1_Final(reinterpret_cast<unsigned char *>(d->result.data()), &copy); SHA1_Final(reinterpret_cast<unsigned char *>(d->result.data()), &copy);
break; break;
} }
case QCryptographicHash::Sha224: {
SHA256_CTX copy = d->sha224Context;
d->result.resize(SHA224_DIGEST_LENGTH);
SHA224_Final(reinterpret_cast<unsigned char *>(d->result.data()), &copy);
break;
}
case QCryptographicHash::Sha256:{ case QCryptographicHash::Sha256:{
SHA256_CTX copy = d->sha256Context; SHA256_CTX copy = d->sha256Context;
d->result.resize(SHA256_DIGEST_LENGTH); d->result.resize(SHA256_DIGEST_LENGTH);
SHA256_Final(reinterpret_cast<unsigned char *>(d->result.data()), &copy); SHA256_Final(reinterpret_cast<unsigned char *>(d->result.data()), &copy);
break; break;
} }
case QCryptographicHash::Sha384:{
SHA512_CTX copy = d->sha384Context;
d->result.resize(SHA384_DIGEST_LENGTH);
SHA384_Final(reinterpret_cast<unsigned char *>(d->result.data()), &copy);
break;
}
case QCryptographicHash::Sha512:{ case QCryptographicHash::Sha512:{
SHA512_CTX copy = d->sha512Context; SHA512_CTX copy = d->sha512Context;
d->result.resize(SHA512_DIGEST_LENGTH); d->result.resize(SHA512_DIGEST_LENGTH);
@ -277,14 +245,6 @@ QByteArray QCryptographicHash::hash(const QByteArray &data, QCryptographicHash::
SHA1_Final(result, &sha1Context); SHA1_Final(result, &sha1Context);
return QByteArray(reinterpret_cast<char *>(result), SHA_DIGEST_LENGTH); return QByteArray(reinterpret_cast<char *>(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<char *>(result), SHA224_DIGEST_LENGTH);
}
case QCryptographicHash::Sha256: { case QCryptographicHash::Sha256: {
QSTACKARRAY(unsigned char, result, SHA256_DIGEST_LENGTH); QSTACKARRAY(unsigned char, result, SHA256_DIGEST_LENGTH);
SHA256_CTX sha256Context; SHA256_CTX sha256Context;
@ -293,14 +253,6 @@ QByteArray QCryptographicHash::hash(const QByteArray &data, QCryptographicHash::
SHA256_Final(result, &sha256Context); SHA256_Final(result, &sha256Context);
return QByteArray(reinterpret_cast<char *>(result), SHA256_DIGEST_LENGTH); return QByteArray(reinterpret_cast<char *>(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<char *>(result), SHA384_DIGEST_LENGTH);
}
case QCryptographicHash::Sha512: { case QCryptographicHash::Sha512: {
QSTACKARRAY(unsigned char, result, SHA512_DIGEST_LENGTH); QSTACKARRAY(unsigned char, result, SHA512_DIGEST_LENGTH);
SHA512_CTX sha512Context; SHA512_CTX sha512Context;

View file

@ -38,9 +38,7 @@ public:
Md4, Md4,
Md5, Md5,
Sha1, Sha1,
Sha224,
Sha256, Sha256,
Sha384,
Sha512 Sha512
}; };

View file

@ -92,9 +92,7 @@ void tst_qcryptographichash::algorithms_data()
QTest::newRow("Md4") << QCryptographicHash::Md4; QTest::newRow("Md4") << QCryptographicHash::Md4;
QTest::newRow("Md5") << QCryptographicHash::Md5; QTest::newRow("Md5") << QCryptographicHash::Md5;
QTest::newRow("Sha1") << QCryptographicHash::Sha1; QTest::newRow("Sha1") << QCryptographicHash::Sha1;
QTest::newRow("Sha224") << QCryptographicHash::Sha224;
QTest::newRow("Sha256") << QCryptographicHash::Sha256; QTest::newRow("Sha256") << QCryptographicHash::Sha256;
QTest::newRow("Sha384") << QCryptographicHash::Sha384;
QTest::newRow("Sha512") << QCryptographicHash::Sha512; QTest::newRow("Sha512") << QCryptographicHash::Sha512;
} }