Created
April 29, 2017 09:35
-
-
Save nizovn/1fcea58c44c1be7d5b771d92d0f396eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configurePalmHD.qt5.5.sh b/configurePalmHD.qt5.5.sh | |
index 7b12e5a..fec3302 100755 | |
--- a/configurePalmHD.qt5.5.sh | |
+++ b/configurePalmHD.qt5.5.sh | |
@@ -1,90 +1,94 @@ | |
-export PKG_CONFIG_PATH=/opt/qt.palm/lib/pkconfig | |
- | |
-### need to mod font path in source code qfontdatabase_qws.cpp | |
-export -n QMAKESPEC | |
- | |
- | |
-./configure \ | |
--sysroot ${SYSROOT} \ | |
--prefix ./runtime \ | |
--extprefix ./runtime \ | |
--hostprefix ./runtime/bin \ | |
--opensource \ | |
--confirm-license \ | |
--openssl \ | |
--skip qtandroidextras -skip qtactiveqt -skip qtdoc \ | |
--skip qtserialport -skip qtwayland \ | |
--skip qtmacextras -skip qtlocation -skip sensors \ | |
--skip qtx11extras -skip qtwinextras \ | |
--skip qttools \ | |
--skip qtenginio -skip qtactiveqt \ | |
--no-feature-accessibility \ | |
--release \ | |
--system-libpng \ | |
--system-zlib \ | |
--system-freetype \ | |
--system-libjpeg \ | |
--alsa \ | |
--qt-pcre \ | |
--no-cups \ | |
--no-nis \ | |
--no-accessibility \ | |
--no-dbus \ | |
--no-gtkstyle \ | |
--no-xinput \ | |
--no-sm \ | |
--no-xshape \ | |
--no-xsync \ | |
--no-xinerama \ | |
--no-xcursor \ | |
--no-xfixes \ | |
--no-pch \ | |
--no-glib \ | |
--no-harfbuzz \ | |
--no-qml-debug \ | |
--force-pkg-config \ | |
--no-largefile \ | |
--no-gstreamer \ | |
--no-xinput2 \ | |
--no-xkbcommon-evdev \ | |
--no-xcb \ | |
--no-xcb-xlib \ | |
--no-xkbcommon-evdev \ | |
--no-kms \ | |
--no-system-proxies \ | |
--no-journald \ | |
--no-mtdev \ | |
--no-c++11 \ | |
--no-separate-debug-info \ | |
--reduce-exports \ | |
--no-android-style-assets \ | |
--I${PalmPDK}/include \ | |
--I${PalmPDK}/include/openssl \ | |
--I${PalmPDK}/include/openpng12 \ | |
--I${PalmPDK}/include/GLES \ | |
--I${PalmPDK}/include/GLES2 \ | |
--I${PalmPDK}/include/SDL \ | |
--L${PalmPDK}/device/lib \ | |
--I${PalmPDK}/arm-gcc/arm-none-linux-gnueabi/libc/usr/include \ | |
--L${PalmPDK}/arm-gcc/arm-none-linux-gnueabi/libc/lib \ | |
--I/opt/dbus/runtime/include \ | |
--I/opt/expat/runtime/include \ | |
--verbose \ | |
--no-compile-examples \ | |
--nomake examples -nomake tests \ | |
--make tools \ | |
--platform linux-g++ \ | |
--make libs \ | |
--xplatform linux-arm-gnueabi-g++ \ | |
--no-qpa-platform-guard \ | |
--D QT_NO_PRINTER \ | |
--D QT_NO_PRINTPREVIEWDIALOG \ | |
--D QT_NO_PRINTDIALOG \ | |
--no-evdev \ | |
--no-rpath \ | |
--lstdc++ -lm \ | |
--opengl es2 \ | |
- | |
- | |
- | |
- | |
+export PKG_CONFIG_PATH=/opt/qt.palm/lib/pkconfig | |
+ | |
+### need to mod font path in source code qfontdatabase_qws.cpp | |
+export -n QMAKESPEC | |
+SYSROOT="/opt/PalmPDK/arm-gcc/sysroot/" | |
+#SYSROOT="" | |
+#SYSROOT="/srv/preware/build/staging/armv7" | |
+PalmPDK="/opt/PalmPDK/" | |
+ | |
+ | |
+./configure -v \ | |
+-sysroot ${SYSROOT} \ | |
+-prefix ./runtime \ | |
+-extprefix ./runtime \ | |
+-hostprefix ./runtime/bin \ | |
+-opensource \ | |
+-confirm-license \ | |
+-openssl \ | |
+-skip qtandroidextras -skip qtactiveqt -skip qtdoc \ | |
+-skip qtserialport -skip qtwayland \ | |
+-skip qtmacextras -skip qtlocation -skip sensors \ | |
+-skip qtx11extras -skip qtwinextras \ | |
+-skip qttools \ | |
+-skip qtenginio -skip qtactiveqt \ | |
+-no-feature-accessibility \ | |
+-release \ | |
+-system-libpng \ | |
+-system-zlib \ | |
+-system-freetype \ | |
+-system-libjpeg \ | |
+-alsa \ | |
+-qt-pcre \ | |
+-no-cups \ | |
+-no-nis \ | |
+-no-accessibility \ | |
+-no-dbus \ | |
+-no-gtkstyle \ | |
+-no-xinput \ | |
+-no-sm \ | |
+-no-xshape \ | |
+-no-xsync \ | |
+-no-xinerama \ | |
+-no-xcursor \ | |
+-no-xfixes \ | |
+-no-pch \ | |
+-no-glib \ | |
+-no-harfbuzz \ | |
+-no-qml-debug \ | |
+-force-pkg-config \ | |
+-no-largefile \ | |
+-no-gstreamer \ | |
+-no-xinput2 \ | |
+-no-xkbcommon-evdev \ | |
+-no-xcb \ | |
+-no-xcb-xlib \ | |
+-no-xkbcommon-evdev \ | |
+-no-kms \ | |
+-no-system-proxies \ | |
+-no-journald \ | |
+-no-mtdev \ | |
+-no-c++11 \ | |
+-no-separate-debug-info \ | |
+-reduce-exports \ | |
+-no-android-style-assets \ | |
+-I${PalmPDK}/include \ | |
+-I${PalmPDK}/include/openssl \ | |
+-I${PalmPDK}/include/openpng12 \ | |
+-I${PalmPDK}/include/GLES \ | |
+-I${PalmPDK}/include/GLES2 \ | |
+-I${PalmPDK}/include/SDL \ | |
+-L${PalmPDK}/device/lib \ | |
+-I${PalmPDK}/arm-gcc/arm-none-linux-gnueabi/libc/usr/include \ | |
+-L${PalmPDK}/arm-gcc/arm-none-linux-gnueabi/libc/lib \ | |
+-I/opt/dbus/runtime/include \ | |
+-I/opt/expat/runtime/include \ | |
+-verbose \ | |
+-no-compile-examples \ | |
+-nomake examples -nomake tests \ | |
+-make tools \ | |
+-platform linux-g++ \ | |
+-make libs \ | |
+-xplatform linux-arm-gnueabi-g++ \ | |
+-no-qpa-platform-guard \ | |
+-D QT_NO_PRINTER \ | |
+-D QT_NO_PRINTPREVIEWDIALOG \ | |
+-D QT_NO_PRINTDIALOG \ | |
+-no-evdev \ | |
+-no-rpath \ | |
+-lstdc++ -lm \ | |
+-opengl es2 \ | |
+ | |
+ | |
+ | |
+ | |
diff --git a/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf b/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf | |
new file mode 100755 | |
index 0000000..eddef66 | |
--- /dev/null | |
+++ b/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf | |
@@ -0,0 +1,43 @@ | |
+# | |
+# qmake configuration for building with arm-linux-gnueabi-g++ | |
+# | |
+ | |
+MAKEFILE_GENERATOR = UNIX | |
+CONFIG += incremental | |
+QMAKE_INCREMENTAL_STYLE = sublib | |
+ | |
+include(../common/linux.conf) | |
+include(../common/gcc-base-unix.conf) | |
+include(../common/g++-unix.conf) | |
+ | |
+# modifications to g++.conf | |
+##QMAKE_CC = arm-linux-gnueabi-gcc | |
+##QMAKE_CXX = arm-linux-gnueabi-g++ | |
+##QMAKE_LINK = arm-linux-gnueabi-g++ | |
+##QMAKE_LINK_SHLIB = arm-linux-gnueabi-g++ | |
+PALM_PDK = /opt/PalmPDK/arm-gcc/bin | |
+PREWARE = /srv/preware/build/staging/armv7 | |
+QMAKE_CC = $$PALM_PDK/arm-none-linux-gnueabi-gcc | |
+QMAKE_CXX = $$PALM_PDK/arm-none-linux-gnueabi-g++ | |
+QMAKE_LINK = $$PALM_PDK/arm-none-linux-gnueabi-g++ | |
+QMAKE_LINK_SHLIB = $$PALM_PDK/arm-none-linux-gnueabi-g++ | |
+QMAKE_CFLAGS = -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp --sysroot=${PalmPDK}/arm-gcc/sysroot | |
+QMAKE_CXXFLAGS = -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp --sysroot=${PalmPDK}/arm-gcc/sysroot | |
+##QMAKE_CFLAGS = --sysroot=${PalmPDK}/arm-gcc/sysroot | |
+##QMAKE_CFLAGS = --sysroot=$$PREWARE | |
+##QMAKE_CXXFLAGS = --sysroot=$$PREWARE | |
+QMAKE_LFLAGS = -Wl,--allow-shlib-undefined | |
+ | |
+ | |
+# modifications to linux.conf | |
+##QMAKE_AR = arm-linux-gnueabi-ar cqs | |
+##QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy | |
+##QMAKE_NM = arm-linux-gnueabi-nm -P | |
+##QMAKE_STRIP = arm-linux-gnueabi-strip | |
+QMAKE_AR = $$PALM_PDK/arm-none-linux-gnueabi-ar cqs | |
+QMAKE_OBJCOPY = $$PALM_PDK/arm-none-linux-gnueabi-objcopy | |
+QMAKE_NM = $$PALM_PDK/arm-none-linux-gnueabi-nm -P | |
+QMAKE_STRIP = $$PALM_PDK/arm-none-linux-gnueabi-strip | |
+ | |
+ | |
+load(qt_config) | |
diff --git a/qtbase/src/3rdparty/sha1/sha1.cpp b/qtbase/src/3rdparty/sha1/sha1.cpp | |
new file mode 100755 | |
index 0000000..23c4275 | |
--- /dev/null | |
+++ b/qtbase/src/3rdparty/sha1/sha1.cpp | |
@@ -0,0 +1,255 @@ | |
+/**************************************************************************** | |
+** | |
+** Copyright (C) 2015 The Qt Company Ltd. | |
+** Contact: http://www.qt.io/licensing/ | |
+** | |
+** This file is part of the Qt Toolkit. | |
+** | |
+** $QT_BEGIN_LICENSE:LGPL21$ | |
+** Commercial License Usage | |
+** Licensees holding valid commercial Qt licenses may use this file in | |
+** accordance with the commercial license agreement provided with the | |
+** Software or, alternatively, in accordance with the terms contained in | |
+** a written agreement between you and The Qt Company. For licensing terms | |
+** and conditions see http://www.qt.io/terms-conditions. For further | |
+** information use the contact form at http://www.qt.io/contact-us. | |
+** | |
+** GNU Lesser General Public License Usage | |
+** Alternatively, this file may be used under the terms of the GNU Lesser | |
+** General Public License version 2.1 or version 3 as published by the Free | |
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and | |
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the | |
+** following information to ensure the GNU Lesser General Public License | |
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | |
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | |
+** | |
+** As a special exception, The Qt Company gives you certain additional | |
+** rights. These rights are described in The Qt Company LGPL Exception | |
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | |
+** | |
+** $QT_END_LICENSE$ | |
+** | |
+****************************************************************************/ | |
+ | |
+/* | |
+ Based on the public domain implementation of the SHA-1 algorithm | |
+ Copyright (C) Dominik Reichl <dominik.reichl@t-online.de> | |
+*/ | |
+#include <QtCore/qendian.h> | |
+ | |
+#ifdef Q_CC_MSVC | |
+# include <stdlib.h> | |
+#endif | |
+ | |
+QT_BEGIN_NAMESPACE | |
+ | |
+// Test Vectors (from FIPS PUB 180-1) | |
+// | |
+// SHA1("abc") = | |
+// A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D | |
+// | |
+// SHA1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = | |
+// 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 | |
+// | |
+// SHA1(A million repetitions of "a") = | |
+// 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F | |
+// | |
+ | |
+ | |
+// #define or #undef this, if you want the to wipe all | |
+// temporary variables after processing | |
+#define SHA1_WIPE_VARIABLES | |
+ | |
+ | |
+struct Sha1State | |
+{ | |
+ quint32 h0; | |
+ quint32 h1; | |
+ quint32 h2; | |
+ quint32 h3; | |
+ quint32 h4; | |
+ | |
+ quint64 messageSize; | |
+ unsigned char buffer[64]; | |
+}; | |
+ | |
+ | |
+typedef union | |
+{ | |
+ quint8 bytes[64]; | |
+ quint32 words[16]; | |
+} Sha1Chunk; | |
+ | |
+static inline quint32 rol32(quint32 value, unsigned int shift) | |
+{ | |
+#ifdef Q_CC_MSVC | |
+ return _rotl(value, shift); | |
+#else | |
+ return ((value << shift) | (value >> (32 - shift))); | |
+#endif | |
+} | |
+ | |
+static inline quint32 sha1Word(Sha1Chunk *chunk, const uint position) | |
+{ | |
+ return (chunk->words[position & 0xf] = rol32( chunk->words[(position+13) & 0xf] | |
+ ^ chunk->words[(position+ 8) & 0xf] | |
+ ^ chunk->words[(position+ 2) & 0xf] | |
+ ^ chunk->words[(position) & 0xf], 1)); | |
+} | |
+ | |
+static inline void sha1Round0(Sha1Chunk *chunk, const uint position, | |
+ quint32 &v, quint32 &w, quint32 &x, quint32 &y, quint32 &z) | |
+{ | |
+ z += ((( w & (x ^ y)) ^ y) + chunk->words[position] + 0x5A827999 + rol32(v, 5)); | |
+ w = rol32(w, 30); | |
+} | |
+ | |
+static inline void sha1Round1(Sha1Chunk *chunk, const uint position, | |
+ quint32 &v, quint32 &w, quint32 &x, quint32 &y, quint32 &z) | |
+{ | |
+ z += ((( w & (x ^ y)) ^ y) + sha1Word(chunk,position) + 0x5A827999 + rol32(v, 5)); | |
+ w = rol32(w, 30); | |
+} | |
+ | |
+static inline void sha1Round2(Sha1Chunk *chunk, const uint position, | |
+ quint32 &v, quint32 &w, quint32 &x, quint32 &y, quint32 &z) | |
+{ | |
+ z += (( w ^ x ^ y) + sha1Word(chunk, position) + 0x6ED9EBA1 + rol32(v, 5)); | |
+ w = rol32(w, 30); | |
+} | |
+ | |
+static inline void sha1Round3(Sha1Chunk *chunk, const uint position, | |
+ quint32 &v, quint32 &w, quint32 &x, quint32 &y, quint32 &z) | |
+{ | |
+ z += (((( w | x) & y) | (w & x)) + sha1Word(chunk, position) + 0x8F1BBCDC + rol32(v, 5)); | |
+ w = rol32(w, 30); | |
+} | |
+ | |
+static inline void sha1Round4(Sha1Chunk *chunk, const uint position, | |
+ quint32 &v, quint32 &w, quint32 &x, quint32 &y, quint32 &z) | |
+{ | |
+ z += ((w ^ x ^ y) + sha1Word(chunk, position) + 0xCA62C1D6 + rol32(v, 5)); | |
+ w = rol32(w, 30); | |
+} | |
+ | |
+static inline void sha1ProcessChunk(Sha1State *state, const unsigned char *buffer) | |
+{ | |
+ // Copy state[] to working vars | |
+ quint32 a = state->h0; | |
+ quint32 b = state->h1; | |
+ quint32 c = state->h2; | |
+ quint32 d = state->h3; | |
+ quint32 e = state->h4; | |
+ | |
+ quint8 chunkBuffer[64]; | |
+ memcpy(chunkBuffer, buffer, 64); | |
+ | |
+ Sha1Chunk *chunk = reinterpret_cast<Sha1Chunk*>(&chunkBuffer); | |
+ | |
+ for (int i = 0; i < 16; ++i) | |
+ chunk->words[i] = qFromBigEndian(chunk->words[i]); | |
+ | |
+ sha1Round0(chunk, 0, a,b,c,d,e); sha1Round0(chunk, 1, e,a,b,c,d); sha1Round0(chunk, 2, d,e,a,b,c); sha1Round0(chunk, 3, c,d,e,a,b); | |
+ sha1Round0(chunk, 4, b,c,d,e,a); sha1Round0(chunk, 5, a,b,c,d,e); sha1Round0(chunk, 6, e,a,b,c,d); sha1Round0(chunk, 7, d,e,a,b,c); | |
+ sha1Round0(chunk, 8, c,d,e,a,b); sha1Round0(chunk, 9, b,c,d,e,a); sha1Round0(chunk, 10, a,b,c,d,e); sha1Round0(chunk, 11, e,a,b,c,d); | |
+ sha1Round0(chunk, 12, d,e,a,b,c); sha1Round0(chunk, 13, c,d,e,a,b); sha1Round0(chunk, 14, b,c,d,e,a); sha1Round0(chunk, 15, a,b,c,d,e); | |
+ sha1Round1(chunk, 16, e,a,b,c,d); sha1Round1(chunk, 17, d,e,a,b,c); sha1Round1(chunk, 18, c,d,e,a,b); sha1Round1(chunk, 19, b,c,d,e,a); | |
+ sha1Round2(chunk, 20, a,b,c,d,e); sha1Round2(chunk, 21, e,a,b,c,d); sha1Round2(chunk, 22, d,e,a,b,c); sha1Round2(chunk, 23, c,d,e,a,b); | |
+ sha1Round2(chunk, 24, b,c,d,e,a); sha1Round2(chunk, 25, a,b,c,d,e); sha1Round2(chunk, 26, e,a,b,c,d); sha1Round2(chunk, 27, d,e,a,b,c); | |
+ sha1Round2(chunk, 28, c,d,e,a,b); sha1Round2(chunk, 29, b,c,d,e,a); sha1Round2(chunk, 30, a,b,c,d,e); sha1Round2(chunk, 31, e,a,b,c,d); | |
+ sha1Round2(chunk, 32, d,e,a,b,c); sha1Round2(chunk, 33, c,d,e,a,b); sha1Round2(chunk, 34, b,c,d,e,a); sha1Round2(chunk, 35, a,b,c,d,e); | |
+ sha1Round2(chunk, 36, e,a,b,c,d); sha1Round2(chunk, 37, d,e,a,b,c); sha1Round2(chunk, 38, c,d,e,a,b); sha1Round2(chunk, 39, b,c,d,e,a); | |
+ sha1Round3(chunk, 40, a,b,c,d,e); sha1Round3(chunk, 41, e,a,b,c,d); sha1Round3(chunk, 42, d,e,a,b,c); sha1Round3(chunk, 43, c,d,e,a,b); | |
+ sha1Round3(chunk, 44, b,c,d,e,a); sha1Round3(chunk, 45, a,b,c,d,e); sha1Round3(chunk, 46, e,a,b,c,d); sha1Round3(chunk, 47, d,e,a,b,c); | |
+ sha1Round3(chunk, 48, c,d,e,a,b); sha1Round3(chunk, 49, b,c,d,e,a); sha1Round3(chunk, 50, a,b,c,d,e); sha1Round3(chunk, 51, e,a,b,c,d); | |
+ sha1Round3(chunk, 52, d,e,a,b,c); sha1Round3(chunk, 53, c,d,e,a,b); sha1Round3(chunk, 54, b,c,d,e,a); sha1Round3(chunk, 55, a,b,c,d,e); | |
+ sha1Round3(chunk, 56, e,a,b,c,d); sha1Round3(chunk, 57, d,e,a,b,c); sha1Round3(chunk, 58, c,d,e,a,b); sha1Round3(chunk, 59, b,c,d,e,a); | |
+ sha1Round4(chunk, 60, a,b,c,d,e); sha1Round4(chunk, 61, e,a,b,c,d); sha1Round4(chunk, 62, d,e,a,b,c); sha1Round4(chunk, 63, c,d,e,a,b); | |
+ sha1Round4(chunk, 64, b,c,d,e,a); sha1Round4(chunk, 65, a,b,c,d,e); sha1Round4(chunk, 66, e,a,b,c,d); sha1Round4(chunk, 67, d,e,a,b,c); | |
+ sha1Round4(chunk, 68, c,d,e,a,b); sha1Round4(chunk, 69, b,c,d,e,a); sha1Round4(chunk, 70, a,b,c,d,e); sha1Round4(chunk, 71, e,a,b,c,d); | |
+ sha1Round4(chunk, 72, d,e,a,b,c); sha1Round4(chunk, 73, c,d,e,a,b); sha1Round4(chunk, 74, b,c,d,e,a); sha1Round4(chunk, 75, a,b,c,d,e); | |
+ sha1Round4(chunk, 76, e,a,b,c,d); sha1Round4(chunk, 77, d,e,a,b,c); sha1Round4(chunk, 78, c,d,e,a,b); sha1Round4(chunk, 79, b,c,d,e,a); | |
+ | |
+ // Add the working vars back into state | |
+ state->h0 += a; | |
+ state->h1 += b; | |
+ state->h2 += c; | |
+ state->h3 += d; | |
+ state->h4 += e; | |
+ | |
+ // Wipe variables | |
+#ifdef SHA1_WIPE_VARIABLES | |
+ a = b = c = d = e = 0; | |
+ memset(chunkBuffer, 0, 64); | |
+#endif | |
+} | |
+ | |
+static inline void sha1InitState(Sha1State *state) | |
+{ | |
+ state->h0 = 0x67452301; | |
+ state->h1 = 0xEFCDAB89; | |
+ state->h2 = 0x98BADCFE; | |
+ state->h3 = 0x10325476; | |
+ state->h4 = 0xC3D2E1F0; | |
+ | |
+ state->messageSize = 0; | |
+} | |
+ | |
+static inline void sha1Update(Sha1State *state, const unsigned char *data, qint64 len) | |
+{ | |
+ quint32 rest = static_cast<quint32>(state->messageSize & Q_UINT64_C(63)); | |
+ | |
+ quint64 availableData = static_cast<quint64>(len) + static_cast<quint64>(rest); | |
+ state->messageSize += len; | |
+ | |
+ if (availableData < Q_UINT64_C(64)) { | |
+ memcpy(&state->buffer[rest], &data[0], len); | |
+ | |
+ } else { | |
+ qint64 i = static_cast<qint64>(64 - rest); | |
+ memcpy(&state->buffer[rest], &data[0], static_cast<qint32>(i)); | |
+ sha1ProcessChunk(state, state->buffer); | |
+ | |
+ qint64 lastI = len - ((len + rest) & Q_INT64_C(63)); | |
+ for( ; i < lastI; i += 64) | |
+ sha1ProcessChunk(state, &data[i]); | |
+ | |
+ memcpy(&state->buffer[0], &data[i], len - i); | |
+ } | |
+} | |
+ | |
+static inline void sha1FinalizeState(Sha1State *state) | |
+{ | |
+ quint64 messageSize = state->messageSize; | |
+ unsigned char sizeInBits[8]; | |
+ qToBigEndian(messageSize << 3, sizeInBits); | |
+ | |
+ sha1Update(state, (const unsigned char *)"\200", 1); | |
+ | |
+ unsigned char zero[64]; | |
+ memset(zero, 0, 64); | |
+ if (static_cast<int>(messageSize & 63) > 56 - 1) { | |
+ sha1Update(state, zero, 64 - 1 - static_cast<int>(messageSize & 63)); | |
+ sha1Update(state, zero, 64 - 8); | |
+ } else { | |
+ sha1Update(state, zero, 64 - 1 - 8 - static_cast<int>(messageSize & 63)); | |
+ } | |
+ | |
+ sha1Update(state, sizeInBits, 8); | |
+#ifdef SHA1_WIPE_VARIABLES | |
+ memset(state->buffer, 0, 64); | |
+ memset(zero, 0, 64); | |
+ state->messageSize = 0; | |
+#endif | |
+} | |
+ | |
+static inline void sha1ToHash(Sha1State *state, unsigned char* buffer) | |
+{ | |
+ qToBigEndian(state->h0, buffer); | |
+ qToBigEndian(state->h1, buffer + 4); | |
+ qToBigEndian(state->h2, buffer + 8); | |
+ qToBigEndian(state->h3, buffer + 12); | |
+ qToBigEndian(state->h4, buffer + 16); | |
+} | |
+ | |
+QT_END_NAMESPACE | |
diff --git a/qtbase/src/corelib/tools/qcryptographichash.cpp b/qtbase/src/corelib/tools/qcryptographichash.cpp | |
new file mode 100755 | |
index 0000000..42877ec | |
--- /dev/null | |
+++ b/qtbase/src/corelib/tools/qcryptographichash.cpp | |
@@ -0,0 +1,441 @@ | |
+/**************************************************************************** | |
+** | |
+** Copyright (C) 2015 The Qt Company Ltd. | |
+** Copyright (C) 2013 Richard J. Moore <rich@kde.org>. | |
+** Contact: http://www.qt.io/licensing/ | |
+** | |
+** This file is part of the QtCore module of the Qt Toolkit. | |
+** | |
+** $QT_BEGIN_LICENSE:LGPL21$ | |
+** Commercial License Usage | |
+** Licensees holding valid commercial Qt licenses may use this file in | |
+** accordance with the commercial license agreement provided with the | |
+** Software or, alternatively, in accordance with the terms contained in | |
+** a written agreement between you and The Qt Company. For licensing terms | |
+** and conditions see http://www.qt.io/terms-conditions. For further | |
+** information use the contact form at http://www.qt.io/contact-us. | |
+** | |
+** GNU Lesser General Public License Usage | |
+** Alternatively, this file may be used under the terms of the GNU Lesser | |
+** General Public License version 2.1 or version 3 as published by the Free | |
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and | |
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the | |
+** following information to ensure the GNU Lesser General Public License | |
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | |
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | |
+** | |
+** As a special exception, The Qt Company gives you certain additional | |
+** rights. These rights are described in The Qt Company LGPL Exception | |
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | |
+** | |
+** $QT_END_LICENSE$ | |
+** | |
+****************************************************************************/ | |
+ | |
+#include <qcryptographichash.h> | |
+#include <qiodevice.h> | |
+ | |
+#include "../../3rdparty/sha1/sha1.cpp" | |
+ | |
+#if defined(QT_BOOTSTRAPPED) && !defined(QT_CRYPTOGRAPHICHASH_ONLY_SHA1) | |
+# error "Are you sure you need the other hashing algorithms besides SHA-1?" | |
+#endif | |
+ | |
+#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 | |
+// qdoc and qmake only need SHA-1 | |
+#include "../../3rdparty/md5/md5.h" | |
+#include "../../3rdparty/md5/md5.cpp" | |
+#include "../../3rdparty/md4/md4.h" | |
+#include "../../3rdparty/md4/md4.cpp" | |
+ | |
+typedef unsigned char BitSequence; | |
+typedef unsigned long long DataLength; | |
+typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn; | |
+ | |
+#include "../../3rdparty/sha3/KeccakSponge.c" | |
+typedef spongeState hashState; | |
+ | |
+#include "../../3rdparty/sha3/KeccakNISTInterface.c" | |
+ | |
+/* | |
+ This lets us choose between SHA3 implementations at build time. | |
+ */ | |
+typedef spongeState SHA3Context; | |
+typedef HashReturn (SHA3Init)(hashState *state, int hashbitlen); | |
+typedef HashReturn (SHA3Update)(hashState *state, const BitSequence *data, DataLength databitlen); | |
+typedef HashReturn (SHA3Final)(hashState *state, BitSequence *hashval); | |
+ | |
+#if QT_POINTER_SIZE == 8 // 64 bit version | |
+ | |
+#include "../../3rdparty/sha3/KeccakF-1600-opt64.c" | |
+ | |
+static SHA3Init * const sha3Init = Init; | |
+static SHA3Update * const sha3Update = Update; | |
+static SHA3Final * const sha3Final = Final; | |
+ | |
+#else // 32 bit optimised fallback | |
+ | |
+#include "../../3rdparty/sha3/KeccakF-1600-opt32.c" | |
+ | |
+static SHA3Init * const sha3Init = Init; | |
+static SHA3Update * const sha3Update = Update; | |
+static SHA3Final * const sha3Final = Final; | |
+ | |
+#endif | |
+ | |
+/* | |
+ These #defines replace the typedefs needed by the RFC6234 code. Normally | |
+ the typedefs would come from from stdint.h, but since this header is not | |
+ available on all platforms (MSVC 2008, for example), we #define them to the | |
+ Qt equivalents. | |
+*/ | |
+#define uint64_t QT_PREPEND_NAMESPACE(quint64) | |
+#define uint32_t QT_PREPEND_NAMESPACE(quint32) | |
+#define uint8_t QT_PREPEND_NAMESPACE(quint8) | |
+#define int_least16_t QT_PREPEND_NAMESPACE(qint16) | |
+ | |
+// 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: | |
+ | |
+ 1. since we are including the sources directly, the declaration of the 2 conflict | |
+ | |
+ 2. static variables are not thread-safe, we do not want multiple threads | |
+ computing a hash to corrupt one another | |
+*/ | |
+static int SHA224_256AddLength(SHA256Context *context, unsigned int length); | |
+static int SHA384_512AddLength(SHA512Context *context, unsigned int length); | |
+ | |
+// Sources from rfc6234, with 4 modifications: | |
+// sha224-256.c - commented out 'static uint32_t addTemp;' on line 68 | |
+// sha224-256.c - appended 'M' to the SHA224_256AddLength macro on line 70 | |
+#include "../../3rdparty/rfc6234/sha224-256.c" | |
+// sha384-512.c - commented out 'static uint64_t addTemp;' on line 302 | |
+// sha384-512.c - appended 'M' to the SHA224_256AddLength macro on line 304 | |
+#include "../../3rdparty/rfc6234/sha384-512.c" | |
+ | |
+#undef uint64_t | |
+#undef uint32_t | |
+#undef uint68_t | |
+#undef int_least16_t | |
+ | |
+static inline int SHA224_256AddLength(SHA256Context *context, unsigned int length) | |
+{ | |
+ QT_PREPEND_NAMESPACE(quint32) addTemp; | |
+ return SHA224_256AddLengthM(context, length); | |
+} | |
+static inline int SHA384_512AddLength(SHA512Context *context, unsigned int length) | |
+{ | |
+ QT_PREPEND_NAMESPACE(quint64) addTemp; | |
+ return SHA384_512AddLengthM(context, length); | |
+} | |
+#endif // QT_CRYPTOGRAPHICHASH_ONLY_SHA1 | |
+ | |
+QT_BEGIN_NAMESPACE | |
+ | |
+class QCryptographicHashPrivate | |
+{ | |
+public: | |
+ QCryptographicHash::Algorithm method; | |
+ union { | |
+ Sha1State sha1Context; | |
+#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 | |
+ MD5Context md5Context; | |
+ md4_context md4Context; | |
+ SHA224Context sha224Context; | |
+ SHA256Context sha256Context; | |
+ SHA384Context sha384Context; | |
+ SHA512Context sha512Context; | |
+ SHA3Context sha3Context; | |
+#endif | |
+ }; | |
+ QByteArray result; | |
+}; | |
+ | |
+/*! | |
+ \class QCryptographicHash | |
+ \inmodule QtCore | |
+ | |
+ \brief The QCryptographicHash class provides a way to generate cryptographic hashes. | |
+ | |
+ \since 4.3 | |
+ | |
+ \ingroup tools | |
+ \reentrant | |
+ | |
+ QCryptographicHash can be used to generate cryptographic hashes of binary or text data. | |
+ | |
+ Currently MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 are supported. | |
+*/ | |
+ | |
+/*! | |
+ \enum QCryptographicHash::Algorithm | |
+ | |
+ \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 Qt 5.0 | |
+ \value Sha256 Generate an SHA-256 hash sum (SHA-2). Introduced in Qt 5.0 | |
+ \value Sha384 Generate an SHA-384 hash sum (SHA-2). Introduced in Qt 5.0 | |
+ \value Sha512 Generate an SHA-512 hash sum (SHA-2). Introduced in Qt 5.0 | |
+ \value Sha3_224 Generate an SHA3-224 hash sum. Introduced in Qt 5.1 | |
+ \value Sha3_256 Generate an SHA3-256 hash sum. Introduced in Qt 5.1 | |
+ \value Sha3_384 Generate an SHA3-384 hash sum. Introduced in Qt 5.1 | |
+ \value Sha3_512 Generate an SHA3-512 hash sum. Introduced in Qt 5.1 | |
+*/ | |
+ | |
+/*! | |
+ Constructs an object that can be used to create a cryptographic hash from data using \a method. | |
+*/ | |
+QCryptographicHash::QCryptographicHash(Algorithm method) | |
+ : d(new QCryptographicHashPrivate) | |
+{ | |
+ d->method = method; | |
+ reset(); | |
+} | |
+ | |
+/*! | |
+ Destroys the object. | |
+*/ | |
+QCryptographicHash::~QCryptographicHash() | |
+{ | |
+ delete d; | |
+} | |
+ | |
+/*! | |
+ Resets the object. | |
+*/ | |
+void QCryptographicHash::reset() | |
+{ | |
+ switch (d->method) { | |
+ case Sha1: | |
+ sha1InitState(&d->sha1Context); | |
+ break; | |
+#ifdef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 | |
+ default: | |
+ Q_ASSERT_X(false, "QCryptographicHash", "Method not compiled in"); | |
+ Q_UNREACHABLE(); | |
+ break; | |
+#else | |
+ case Md4: | |
+ md4_init(&d->md4Context); | |
+ break; | |
+ case Md5: | |
+ MD5Init(&d->md5Context); | |
+ break; | |
+ case Sha224: | |
+ SHA224Reset(&d->sha224Context); | |
+ break; | |
+ case Sha256: | |
+ SHA256Reset(&d->sha256Context); | |
+ break; | |
+ case Sha384: | |
+ SHA384Reset(&d->sha384Context); | |
+ break; | |
+ case Sha512: | |
+ SHA512Reset(&d->sha512Context); | |
+ break; | |
+ case Sha3_224: | |
+ sha3Init(&d->sha3Context, 224); | |
+ break; | |
+ case Sha3_256: | |
+ sha3Init(&d->sha3Context, 256); | |
+ break; | |
+ case Sha3_384: | |
+ sha3Init(&d->sha3Context, 384); | |
+ break; | |
+ case Sha3_512: | |
+ sha3Init(&d->sha3Context, 512); | |
+ break; | |
+#endif | |
+ } | |
+ d->result.clear(); | |
+} | |
+ | |
+/*! | |
+ Adds the first \a length chars of \a data to the cryptographic | |
+ hash. | |
+*/ | |
+void QCryptographicHash::addData(const char *data, int length) | |
+{ | |
+ switch (d->method) { | |
+ case Sha1: | |
+ sha1Update(&d->sha1Context, (const unsigned char *)data, length); | |
+ break; | |
+#ifdef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 | |
+ default: | |
+ Q_ASSERT_X(false, "QCryptographicHash", "Method not compiled in"); | |
+ Q_UNREACHABLE(); | |
+ break; | |
+#else | |
+ case Md4: | |
+ md4_update(&d->md4Context, (const unsigned char *)data, length); | |
+ break; | |
+ case Md5: | |
+ MD5Update(&d->md5Context, (const unsigned char *)data, length); | |
+ break; | |
+ case Sha224: | |
+ SHA224Input(&d->sha224Context, reinterpret_cast<const unsigned char *>(data), length); | |
+ break; | |
+ case Sha256: | |
+ SHA256Input(&d->sha256Context, reinterpret_cast<const unsigned char *>(data), length); | |
+ break; | |
+ case Sha384: | |
+ SHA384Input(&d->sha384Context, reinterpret_cast<const unsigned char *>(data), length); | |
+ break; | |
+ case Sha512: | |
+ SHA512Input(&d->sha512Context, reinterpret_cast<const unsigned char *>(data), length); | |
+ break; | |
+ case Sha3_224: | |
+ sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | |
+ break; | |
+ case Sha3_256: | |
+ sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | |
+ break; | |
+ case Sha3_384: | |
+ sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | |
+ break; | |
+ case Sha3_512: | |
+ sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | |
+ break; | |
+#endif | |
+ } | |
+ d->result.clear(); | |
+} | |
+ | |
+/*! | |
+ \overload addData() | |
+*/ | |
+void QCryptographicHash::addData(const QByteArray &data) | |
+{ | |
+ addData(data.constData(), data.length()); | |
+} | |
+ | |
+/*! | |
+ Reads the data from the open QIODevice \a device until it ends | |
+ and hashes it. Returns \c true if reading was successful. | |
+ \since 5.0 | |
+ */ | |
+bool QCryptographicHash::addData(QIODevice* device) | |
+{ | |
+ if (!device->isReadable()) | |
+ return false; | |
+ | |
+ if (!device->isOpen()) | |
+ return false; | |
+ | |
+ char buffer[1024]; | |
+ int length; | |
+ | |
+ while ((length = device->read(buffer,sizeof(buffer))) > 0) | |
+ addData(buffer,length); | |
+ | |
+ return device->atEnd(); | |
+} | |
+ | |
+ | |
+/*! | |
+ Returns the final hash value. | |
+ | |
+ \sa QByteArray::toHex() | |
+*/ | |
+QByteArray QCryptographicHash::result() const | |
+{ | |
+ if (!d->result.isEmpty()) | |
+ return d->result; | |
+ | |
+ switch (d->method) { | |
+ case Sha1: { | |
+ Sha1State copy = d->sha1Context; | |
+ d->result.resize(20); | |
+ sha1FinalizeState(©); | |
+ sha1ToHash(©, (unsigned char *)d->result.data()); | |
+ break; | |
+ } | |
+#ifdef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 | |
+ default: | |
+ Q_ASSERT_X(false, "QCryptographicHash", "Method not compiled in"); | |
+ Q_UNREACHABLE(); | |
+ break; | |
+#else | |
+ case Md4: { | |
+ md4_context copy = d->md4Context; | |
+ d->result.resize(MD4_RESULTLEN); | |
+ md4_final(©, (unsigned char *)d->result.data()); | |
+ break; | |
+ } | |
+ case Md5: { | |
+ MD5Context copy = d->md5Context; | |
+ d->result.resize(16); | |
+ MD5Final(©, (unsigned char *)d->result.data()); | |
+ break; | |
+ } | |
+ case Sha224: { | |
+ SHA224Context copy = d->sha224Context; | |
+ d->result.resize(SHA224HashSize); | |
+ SHA224Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha256:{ | |
+ SHA256Context copy = d->sha256Context; | |
+ d->result.resize(SHA256HashSize); | |
+ SHA256Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha384:{ | |
+ SHA384Context copy = d->sha384Context; | |
+ d->result.resize(SHA384HashSize); | |
+ SHA384Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha512:{ | |
+ SHA512Context copy = d->sha512Context; | |
+ d->result.resize(SHA512HashSize); | |
+ SHA512Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha3_224: { | |
+ SHA3Context copy = d->sha3Context; | |
+ d->result.resize(224/8); | |
+ sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha3_256: { | |
+ SHA3Context copy = d->sha3Context; | |
+ d->result.resize(256/8); | |
+ sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha3_384: { | |
+ SHA3Context copy = d->sha3Context; | |
+ d->result.resize(384/8); | |
+ sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | |
+ break; | |
+ } | |
+ case Sha3_512: { | |
+ SHA3Context copy = d->sha3Context; | |
+ d->result.resize(512/8); | |
+ sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | |
+ break; | |
+ } | |
+#endif | |
+ } | |
+ return d->result; | |
+} | |
+ | |
+/*! | |
+ Returns the hash of \a data using \a method. | |
+*/ | |
+QByteArray QCryptographicHash::hash(const QByteArray &data, Algorithm method) | |
+{ | |
+ QCryptographicHash hash(method); | |
+ hash.addData(data); | |
+ return hash.result(); | |
+} | |
+ | |
+QT_END_NAMESPACE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment