From 5d69aa3ee1214cf689e2357bff8688f2ff138471 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Thu, 28 Nov 2019 19:42:23 +0100 Subject: QCryptographicHash: Add BLAKE2b and BLAKE2s hashing algorithms BLAKE2 does not specify requirements about specific hash sizes and since QCryptographicHash does not support dynamic hash sizes, only the most common hash sizes could be covered by this. The supported hash sizes were chosen to match the ones supported by the Linux kernel. The new hashing algorithms for QCryptographicHash are: * BLAKE2b (160 bit, 256 bit, 384 bit, 512 bit) * BLAKE2s (128 bit, 160 bit, 224 bit, 256 bit) [ChangeLog][QtCore][QCryptographicHash] Added BLAKE2b and BLAKE2s hashing algorithms. Fixes: QTBUG-78198 Change-Id: Id9e0180a974093982fdf1cdd6180988a2e5e9f4f Reviewed-by: Thiago Macieira --- src/corelib/tools/qmessageauthenticationcode.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/corelib/tools/qmessageauthenticationcode.cpp') diff --git a/src/corelib/tools/qmessageauthenticationcode.cpp b/src/corelib/tools/qmessageauthenticationcode.cpp index 40a11936220..d84b1b0b6cb 100644 --- a/src/corelib/tools/qmessageauthenticationcode.cpp +++ b/src/corelib/tools/qmessageauthenticationcode.cpp @@ -75,6 +75,8 @@ // sha1.h - commented out '#include ' on line 74 #include "../../3rdparty/rfc6234/sha.h" +#include "../../3rdparty/blake2/src/blake2.h" + #undef uint64_t #undef uint32_t #undef uint68_t @@ -111,6 +113,16 @@ static int qt_hash_block_size(QCryptographicHash::Algorithm method) case QCryptographicHash::RealSha3_512: case QCryptographicHash::Keccak_512: return 72; + case QCryptographicHash::Blake2b_160: + case QCryptographicHash::Blake2b_256: + case QCryptographicHash::Blake2b_384: + case QCryptographicHash::Blake2b_512: + return BLAKE2B_BLOCKBYTES; + case QCryptographicHash::Blake2s_128: + case QCryptographicHash::Blake2s_160: + case QCryptographicHash::Blake2s_224: + case QCryptographicHash::Blake2s_256: + return BLAKE2S_BLOCKBYTES; } return 0; } -- cgit v1.2.3