diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2012-02-28 09:25:20 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-28 18:53:32 +0100 |
commit | c7a059e376bd0105ad470017a774715b112de8b4 (patch) | |
tree | 0983c38a88e715e2b45221906d659c332e53e644 /src/corelib/tools/qcryptographichash.cpp | |
parent | f3b68e352e4ce3d9a725f57e33ab6c479c27720c (diff) |
Compile SHA-2 code on systems without stdint.h
stdint.h is a C99-ism, which isn't available everywhere. The sha.h
header tells us we need 4 typedefs. Add these to qcryptographichash.cpp
before including sha.h and comment out the stdint.h include in sha.h.
Change-Id: I1ede9569fa7eaa84de3befeb3c58cc6a05aa522c
Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib/tools/qcryptographichash.cpp')
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 9c27af032f..31a0fdc5e6 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -48,6 +48,19 @@ #include "../../3rdparty/sha1/sha1.cpp" /* + These typedefs are needed by the RFC6234 code. Normally they would come + from from stdint.h, but since this header is not available on all platforms + (MSVC 2008, for example), we need to define them ourselves. +*/ +typedef QT_PREPEND_NAMESPACE(quint64) uint64_t; +typedef QT_PREPEND_NAMESPACE(quint32) uint32_t; +typedef QT_PREPEND_NAMESPACE(quint8) uint8_t; +typedef QT_PREPEND_NAMESPACE(qint16) int_least16_t; +// Header from rfc6234 with 1 modification: +// sha1.h - commented out '#include <stdint.h>' on line 74 +#include "../../3rdparty/rfc6234/sha.h" + +/* These 2 functions replace macros of the same name in sha224-256.c and sha384-512.c. Originally, these macros relied on a global static 'addTemp' variable. We do not want this for 2 reasons: @@ -57,8 +70,6 @@ 2. static variables are not thread-safe, we do not want multiple threads computing a hash to corrupt one another */ -// Header from rfc6234 without modifications -#include "../../3rdparty/rfc6234/sha.h" static int SHA224_256AddLength(SHA256Context *context, unsigned int length); static int SHA384_512AddLength(SHA512Context *context, unsigned int length); |