diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index b63f0408..778c2ee2 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -57,7 +57,6 @@ install( KCmdLineArgs KCmdLineOptions KCodecAction - KCodecs KColor KColorButton KColorCells @@ -201,7 +200,6 @@ install( KLocalizedDate KLocalizedString KLockFile - KMD5 KMacroExpanderBase KMainWindow KMenu diff --git a/includes/KCodecs b/includes/KCodecs deleted file mode 100644 index 294179fb..00000000 --- a/includes/KCodecs +++ /dev/null @@ -1 +0,0 @@ -#include "../kcodecs.h" diff --git a/includes/KMD5 b/includes/KMD5 deleted file mode 100644 index 294179fb..00000000 --- a/includes/KMD5 +++ /dev/null @@ -1 +0,0 @@ -#include "../kcodecs.h" diff --git a/kcddb/libkcddb/musicbrainz/musicbrainzlookup.cpp b/kcddb/libkcddb/musicbrainz/musicbrainzlookup.cpp index f3971e1f..a06590f2 100644 --- a/kcddb/libkcddb/musicbrainz/musicbrainzlookup.cpp +++ b/kcddb/libkcddb/musicbrainz/musicbrainzlookup.cpp @@ -21,7 +21,6 @@ #include "musicbrainzlookup.h" #include -#include #include #include #include diff --git a/kdecore/CMakeLists.txt b/kdecore/CMakeLists.txt index c789f08b..20ddb2eb 100644 --- a/kdecore/CMakeLists.txt +++ b/kdecore/CMakeLists.txt @@ -275,7 +275,6 @@ set(kdecore_LIB_SRCS sycoca/kprotocolinfofactory.cpp sycoca/kmemfile.cpp text/kascii.cpp - text/kcodecs.cpp text/kstringhandler.cpp util/kallocator.cpp util/kautostart.cpp @@ -501,7 +500,6 @@ install( sycoca/ksycocaentry.h sycoca/ksycocatype.h text/kascii.h - text/kcodecs.h text/kstringhandler.h util/kallocator.h util/kautostart.h diff --git a/kdecore/MAINTAINERS b/kdecore/MAINTAINERS index 999629cc..9737e8e3 100644 --- a/kdecore/MAINTAINERS +++ b/kdecore/MAINTAINERS @@ -153,7 +153,6 @@ sycoca/ text/ kascii.cpp - kcodecs.cpp kstringhandler.cpp util/ diff --git a/kdecore/date/ksystemtimezone.cpp b/kdecore/date/ksystemtimezone.cpp index adb21c1b..b517dc7b 100644 --- a/kdecore/date/ksystemtimezone.cpp +++ b/kdecore/date/ksystemtimezone.cpp @@ -50,7 +50,6 @@ #include #include -#include #include #include #include diff --git a/kdecore/kernel/ktoolinvocation_x11.cpp b/kdecore/kernel/ktoolinvocation_x11.cpp index d9dc46ea..975c0629 100644 --- a/kdecore/kernel/ktoolinvocation_x11.cpp +++ b/kdecore/kernel/ktoolinvocation_x11.cpp @@ -32,7 +32,6 @@ #include "kcmdlineargs.h" #include "kconfig.h" -#include "kcodecs.h" #include "kdebug.h" #include "kglobal.h" #include "kshell.h" diff --git a/kdecore/tests/CMakeLists.txt b/kdecore/tests/CMakeLists.txt index 224322f5..c6f1056b 100644 --- a/kdecore/tests/CMakeLists.txt +++ b/kdecore/tests/CMakeLists.txt @@ -66,7 +66,6 @@ KDECORE_UNIT_TESTS( qcoreapptest kdebug_qcoreapptest kmimetype_nomimetypes - kmd5benchmark ) KDECORE_UNIT_TESTS( @@ -83,7 +82,6 @@ KDECORE_EXECUTABLE_TESTS( kcmdlineargstest kmemtest dbuscalltest - kmdcodectest startserviceby klockfile_testlock # helper for klockfiletest ) diff --git a/kdecore/tests/kmd5benchmark.cpp b/kdecore/tests/kmd5benchmark.cpp deleted file mode 100644 index 793b6cf5..00000000 --- a/kdecore/tests/kmd5benchmark.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (C) 2011 Volker Krause - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include - -class KMd5Test : public QObject { - Q_OBJECT - -private: - static QByteArray makeByteArray( int size ) - { - QByteArray b; - b.resize( size ); - for ( int i = 0; i < size; ++i ) - b[i] = static_cast( i % 255 ); - return b; - } - - static void makeData() - { - QTest::addColumn("input"); - QTest::newRow("empty") << QByteArray(); - QTest::newRow("32") << makeByteArray(32); - QTest::newRow("128") << makeByteArray(128); - QTest::newRow("1024") << makeByteArray(1 << 10); - QTest::newRow("1M") << makeByteArray(1 << 20); - QTest::newRow("16M") << makeByteArray(1 << 24); - } - -private Q_SLOTS: - void benchmarkKMd5_data() - { - makeData(); - } - - void benchmarkKMd5() - { - QFETCH( QByteArray, input ); - QBENCHMARK { - KMD5 md5( input ); - md5.rawDigest(); - } - } - - void benchmarkKMd5WithReset_data() - { - makeData(); - } - - void benchmarkKMd5WithReset() - { - QFETCH( QByteArray, input ); - KMD5 md5; - QBENCHMARK { - md5.reset(); - md5.update( input ); - md5.rawDigest(); - } - } - - void benchmarkQCH_data() - { - makeData(); - } - - void benchmarkQCH() - { - QFETCH( QByteArray, input ); - QBENCHMARK { - QCryptographicHash h( QCryptographicHash::Md5 ); - h.addData( input ); - h.result(); - } - } - - void benchmarkQCHWithReset_data() - { - makeData(); - } - - void benchmarkQCHWithReset() - { - QFETCH( QByteArray, input ); - QCryptographicHash h( QCryptographicHash::Md5 ); - QBENCHMARK { - h.reset(); - h.addData( input ); - h.result(); - } - } - -}; - -QTEST_KDEMAIN_CORE( KMd5Test ) - -#include "kmd5benchmark.moc" diff --git a/kdecore/tests/kmdcodectest.cpp b/kdecore/tests/kmdcodectest.cpp deleted file mode 100644 index 31d081ab..00000000 --- a/kdecore/tests/kmdcodectest.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000,2001 Dawit Alemayehu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -//#include - -#include - -using namespace std; - -#define TEST_BLOCK_LEN 1000 // Length of test blocks. -#define TEST_BLOCK_COUNT 10000 // Number of test blocks. -#define MAX_READ_BUF_SIZE 8192 - -enum Codec -{ - Unspecified=0, - Base64Encode, - Base64Decode, - UUEncode, - UUDecode, - QPEncode, - QPDecode -}; - -void MD5_timeTrial (); -void MD5_testSuite (); -void testCodec (const char*, Codec, bool); -void MD5_verify (const char*, const char*, bool); -void MD5_file (const char * , bool rawOutput = false); -void MD5_string (const char *, const char *expected = 0, bool rawOutput = false); - -long readContent (const QFile& f, long count, QByteArray& buf) -{ - long result; - int old_size; - - old_size = buf.size(); - buf.resize(old_size+count); - - result = read (f.handle (), buf.data()+old_size, count); - - if ( result > 0 && result < count ) - { - buf.resize( old_size + result ); - } - else if ( result == 0 ) - { - buf.resize( old_size ); - } - else if ( result == -1 ) - { - kError() << "Could not read the file!" << endl; - } - - return result; -} - -void testCodec (const char* msg, Codec type, bool isFile) -{ - QByteArray output; - - if ( isFile ) - { - int count; - QByteArray data; - - QFile f (QFile::encodeName(msg)); - - if (!f.exists()) - { - kError() << "Could not find: " << qPrintable(f.fileName()) << endl; - return; - } - - if (!f.open(QIODevice::ReadOnly)) - { - f.close (); - kError() << "Could not open: " << qPrintable(f.fileName()) << endl; - return; - } - - // Read contents of file... - count = 0; - - while ((count= readContent(f, MAX_READ_BUF_SIZE, data)) > 0) { - ; - } - - // Error! Exit! - if ( count == -1 ) - { - kError () << "Error reading from: " << qPrintable(f.fileName()) << endl; - f.close (); - return; - } - - f.close (); - - // Perform the requested encoding or decoding... - switch (type) - { - case Base64Encode: - KCodecs::base64Encode(data, output, true); - break; - case Base64Decode: - KCodecs::base64Decode(data, output); - break; - case UUEncode: - KCodecs::uuencode(data, output); - break; - case UUDecode: - KCodecs::uudecode(data, output); - break; - case QPEncode: - KCodecs::quotedPrintableEncode(data, output, true); - break; - case QPDecode: - KCodecs::quotedPrintableDecode(data, output); - break; - default: - break; - } - - cout << "Result: " << endl << output.data() << endl; - } - else - { - QByteArray result; - - memcpy (output.data(), msg, strlen(msg)); - - switch (type) - { - case Base64Encode: - result = KCodecs::base64Encode(output); - break; - case Base64Decode: - result = KCodecs::base64Decode(output); - break; - case UUEncode: - result = KCodecs::uuencode(output); - break; - case UUDecode: - result = KCodecs::uudecode(output); - break; - case QPEncode: - result = KCodecs::quotedPrintableEncode(output); - break; - case QPDecode: - result = KCodecs::quotedPrintableDecode(output); - break; - default: - break; - } - cout << result.data() << endl; - } -} - -void MD5_timeTrial () -{ - KMD5 context; - - time_t endTime; - time_t startTime; - - quint8 block[TEST_BLOCK_LEN]; - quint32 i; - - cout << "Timing test. Digesting " << TEST_BLOCK_COUNT << " blocks of " - << TEST_BLOCK_LEN << "-byte..." << endl; - - // Initialize block - for (i = 0; i < TEST_BLOCK_LEN; ++i) - block[i] = (quint8)(i & 0xff); - - // Start timer - time (&startTime); - - // Digest blocks - for (i = 0; i < TEST_BLOCK_COUNT; ++i) - context.update (block, TEST_BLOCK_LEN); - - // Stop timer - time (&endTime); - - long duration = endTime - startTime; - long speed; - if (duration) - speed = (TEST_BLOCK_LEN * (TEST_BLOCK_COUNT/duration)); - else - speed = TEST_BLOCK_COUNT; - - cout << "Result: " << endl; - cout << " Time = " << duration << " seconds" << endl; - cout << " Speed = " << speed << " bytes/second" << endl; - cout << " Digest = " << context.hexDigest().data() << endl; -} - -void MD5_testSuite () -{ - cout << "MD5 preset test suite as defined in RFC 1321:" << endl; - MD5_string ( "", "d41d8cd98f00b204e9800998ecf8427e" ); - MD5_string ( "a", "0cc175b9c0f1b6a831c399e269772661" ); - MD5_string ( "abc", "900150983cd24fb0d6963f7d28e17f72" ); - MD5_string ( "message digest", "f96b697d7cb7938d525a2f31aaf161d0" ); - MD5_string ( "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b" ); - MD5_string ( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "d174ab98d277d9f5a5611c2c9f419d9f" ); - MD5_string ( "12345678901234567890123456789012345678901234567890123456789012" - "345678901234567890", "57edf4a22be3c955ac49da2e2107b67a" ); -} - -void MD5_verify( const char *input, const char *digest, bool isFile ) -{ - bool result; - KMD5 context; - - if ( !isFile ) - { - context.update (QByteArray(input)); - result = context.verify( digest ); - cout << "Input string: " << input << endl; - } - else - { - QFile f (input); - - if (!f.open (QIODevice::ReadOnly)) - { - f.close (); - kFatal() << "Cannot open file for reading!"; - } - - result = context.verify (digest); - f.close (); - - cout << "Input filename: " << input << endl; - } - - cout << "Calculated Digest = " << context.hexDigest().data() << endl; - cout << "Supplied Digest = " << digest << endl; - cout << "Matches: " << (result ? "TRUE":"FALSE") << endl; -} - -void MD5_file (const char *filename, bool rawOutput ) -{ - QFile f (QFile::encodeName(filename)); - - if (!f.open(QIODevice::ReadOnly)) - { - f.close(); - kError() << "(" << filename << ") cannot be opened!" << endl; - return; - } - - KMD5 context; - context.update( f ); - - if ( rawOutput ) - cout << "MD5 (" << filename << ") = " << context.rawDigest() << endl; - else - cout << "MD5 (" << filename << ") = " << context.hexDigest().data() << endl; - - f.close (); -} - -void MD5_string (const char *input, const char* expected, bool rawOutput ) -{ - KMD5 context; - context.update (QByteArray(input)); - - cout << "Checking MD5 for: " << input << endl; - - if ( rawOutput ) - cout << "Result: " << context.rawDigest() << endl; - else - cout << "Result: " << context.hexDigest().data() << endl; - - if ( expected ) - { - cout << "Expected: " << expected << endl; - cout << "Status: " << context.verify (expected) << endl; - } -} - -int main (int argc, char *argv[]) -{ - KCmdLineOptions options; - options.add("c ", ki18n("compare with the calculated digest for a string or file.")); - options.add("d", ki18n("decode the given string or file using base64")); - options.add("e", ki18n("encode the given string or file using base64")); - options.add("f", ki18n("the filename to be used as input"), "default"); - options.add("p", ki18n("encode the given string or file using quoted-printable")); - options.add("q", ki18n("decode the given string or file using quoted-printable")); - options.add("r", ki18n("calculate the raw md5 for the given string or file")); - options.add("s", ki18n("the string to be used as input")); - options.add("t", ki18n("perform a timed message-digest test")); - options.add("u", ki18n("uuencode the given string or file")); - options.add("x", ki18n("uudecode the given string or file")); - options.add("z", ki18n("run a preset message-digest test")); - options.add("+command", ki18n("[input1, input2,...]")); - - KCmdLineArgs::init( argc, argv, "kmdcodectest", 0, - ki18n("KMDCodecTest"), "1.0", - ki18n("Unit test for md5, base64 encode/decode " - "and uuencode/decode facilities" ) ); - KCmdLineArgs::addCmdLineOptions( options ); - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - int count = args->count(); - - //KApplication app; - - if (!count) - { - if ( args->isSet("t") ) - MD5_timeTrial (); - else if ( args->isSet("z") ) - MD5_testSuite (); - else - args->usage(); - } - else - { - bool isVerify = args->isSet("c"); - bool isString = args->isSet("s"); - bool isFile = args->isSet( "f" ); - Codec type = Unspecified; - if ( args->isSet("d") ) - type = Base64Decode; - else if ( args->isSet("e") ) - type = Base64Encode; - else if ( args->isSet("u") ) - type = UUEncode; - else if ( args->isSet("x") ) - type = UUDecode; - else if ( args->isSet("p") ) - type = QPEncode; - else if ( args->isSet("q") ) - type = QPDecode; - if ( isVerify ) - { - const char* opt = args->getOption( "c" ).toLocal8Bit().data(); - for ( int i=0 ; i < count; i++ ) - MD5_verify ( args->arg(i).toLocal8Bit(), opt, (isString || !isFile) ); - } - else - { - for ( int i=0 ; i < count; i++ ) - { - if ( type != Unspecified ) - testCodec( args->arg(i).toLocal8Bit(), type, isFile ); - else - { - if ( isString ) - MD5_string( args->arg(i).toLocal8Bit(), 0, args->isSet("r") ); - else - MD5_file( args->arg(i).toLocal8Bit(), args->isSet("r") ); - } - } - } - } - args->clear(); - return (0); -} diff --git a/kdecore/text/kcodecs.cpp b/kdecore/text/kcodecs.cpp deleted file mode 100644 index ace95bd6..00000000 --- a/kdecore/text/kcodecs.cpp +++ /dev/null @@ -1,1114 +0,0 @@ -/* - Copyright (C) 2000-2001 Dawit Alemayehu - Copyright (C) 2001 Rik Hemsley (rikkus) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License (LGPL) - version 2 as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. // krazy:exclude=copyright - RSA Data Security, Inc. Created 1991. All rights reserved. - - The KMD5 class is based on a C++ implementation of - "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by - Mordechai T. Abzug, Copyright (c) 1995. This implementation // krazy:exclude=copyright - passes the test-suite as defined in RFC 1321. - - The encoding and decoding utilities in KCodecs with the exception of - quoted-printable are based on the java implementation in HTTPClient - package by Ronald Tschalär Copyright (C) 1996-1999. // krazy:exclude=copyright - - The quoted-printable codec as described in RFC 2045, section 6.7. is by - Rik Hemsley (C) 2001. -*/ - -#include "kcodecs.h" - -#include -#include -#include - -#include -#include -#include - -#define KMD5_S11 7 -#define KMD5_S12 12 -#define KMD5_S13 17 -#define KMD5_S14 22 -#define KMD5_S21 5 -#define KMD5_S22 9 -#define KMD5_S23 14 -#define KMD5_S24 20 -#define KMD5_S31 4 -#define KMD5_S32 11 -#define KMD5_S33 16 -#define KMD5_S34 23 -#define KMD5_S41 6 -#define KMD5_S42 10 -#define KMD5_S43 15 -#define KMD5_S44 21 - -namespace KCodecs -{ - -static const char Base64EncMap[64] = -{ - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, - 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, - 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, - 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F -}; - -static const char Base64DecMap[128] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, - 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static const char UUEncMap[64] = -{ - 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F -}; - -static const char UUDecMap[128] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static const char hexChars[16] = -{ - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' -}; - -static const unsigned int maxQPLineLength = 70; - -} // namespace KCodecs - - -/******************************** KCodecs ********************************/ -// strchr(3) for broken systems. -static int rikFindChar(register const char * _s, const char c) -{ - register const char * s = _s; - - while (true) - { - if ((0 == *s) || (c == *s)) break; ++s; - if ((0 == *s) || (c == *s)) break; ++s; - if ((0 == *s) || (c == *s)) break; ++s; - if ((0 == *s) || (c == *s)) break; ++s; - } - - return s - _s; -} - -QByteArray KCodecs::quotedPrintableEncode(const QByteArray& in, bool useCRLF) -{ - QByteArray out; - quotedPrintableEncode (in, out, useCRLF); - return out; -} - -void KCodecs::quotedPrintableEncode(const QByteArray& in, QByteArray& out, bool useCRLF) -{ - out.resize (0); - if (in.isEmpty()) - return; - - char *cursor; - const char *data; - unsigned int lineLength; - unsigned int pos; - - const unsigned int length = in.size(); - const unsigned int end = length - 1; - - - // Reasonable guess for output size when we're encoding - // mostly-ASCII data. It doesn't really matter, because - // the underlying allocation routines are quite efficient, - // but it's nice to have 0 allocations in many cases. - out.resize ((length*12)/10); - cursor = out.data(); - data = in.data(); - lineLength = 0; - - for (unsigned int i = 0; i < length; i++) - { - unsigned char c (data[i]); - - // check if we have to enlarge the output buffer, use - // a safety margin of 16 byte - pos = cursor-out.data(); - if (out.size()-pos < 16) { - out.resize(out.size()+4096); - cursor = out.data()+pos; - } - - // Plain ASCII chars just go straight out. - - if ((c >= 33) && (c <= 126) && ('=' != c)) - { - *cursor++ = c; - ++lineLength; - } - - // Spaces need some thought. We have to encode them at eol (or eof). - - else if (' ' == c) - { - if - ( - (i >= length) - || - ((i < end) && ((useCRLF && ('\r' == data[i + 1]) && ('\n' == data[i + 2])) - || - (!useCRLF && ('\n' == data[i + 1])))) - ) - { - *cursor++ = '='; - *cursor++ = '2'; - *cursor++ = '0'; - - lineLength += 3; - } - else - { - *cursor++ = ' '; - ++lineLength; - } - } - // If we find a line break, just let it through. - else if ((useCRLF && ('\r' == c) && (i < end) && ('\n' == data[i + 1])) || - (!useCRLF && ('\n' == c))) - { - lineLength = 0; - - if (useCRLF) { - *cursor++ = '\r'; - *cursor++ = '\n'; - ++i; - } else { - *cursor++ = '\n'; - } - } - - // Anything else is converted to =XX. - - else - { - *cursor++ = '='; - *cursor++ = hexChars[c / 16]; - *cursor++ = hexChars[c % 16]; - - lineLength += 3; - } - - // If we're approaching the maximum line length, do a soft line break. - - if ((lineLength > maxQPLineLength) && (i < end)) - { - if (useCRLF) { - *cursor++ = '='; - *cursor++ = '\r'; - *cursor++ = '\n'; - } else { - *cursor++ = '='; - *cursor++ = '\n'; - } - - lineLength = 0; - } - } - - out.truncate(cursor - out.data()); -} - -QByteArray KCodecs::quotedPrintableDecode(const QByteArray & in) -{ - QByteArray out; - quotedPrintableDecode (in, out); - return out; -} - - -void KCodecs::quotedPrintableDecode(const QByteArray& in, QByteArray& out) -{ - // clear out the output buffer - out.resize (0); - if (in.isEmpty()) - return; - - char *cursor; - const unsigned int length = in.size(); - - out.resize (length); - cursor = out.data(); - - for (unsigned int i = 0; i < length; i++) - { - char c(in[i]); - - if ('=' == c) - { - if (i < length - 2) - { - char c1 = in[i + 1]; - char c2 = in[i + 2]; - - if (('\n' == c1) || ('\r' == c1 && '\n' == c2)) - { - // Soft line break. No output. - if ('\r' == c1) - i += 2; // CRLF line breaks - else - i += 1; - } - else - { - // =XX encoded byte. - - int hexChar0 = rikFindChar(hexChars, c1); - int hexChar1 = rikFindChar(hexChars, c2); - - if (hexChar0 < 16 && hexChar1 < 16) - { - *cursor++ = char((hexChar0 * 16) | hexChar1); - i += 2; - } - } - } - } - else - { - *cursor++ = c; - } - } - - out.truncate(cursor - out.data()); -} - -QByteArray KCodecs::base64Encode( const QByteArray& in, bool insertLFs ) -{ - QByteArray out; - base64Encode( in, out, insertLFs ); - return out; -} - -void KCodecs::base64Encode( const QByteArray& in, QByteArray& out, - bool insertLFs ) -{ - // clear out the output buffer - out.resize (0); - if ( in.isEmpty() ) - return; - - unsigned int sidx = 0; - int didx = 0; - const char* data = in.data(); - const unsigned int len = in.size(); - - unsigned int out_len = ((len+2)/3)*4; - - // Deal with the 76 characters or less per - // line limit specified in RFC 2045 on a - // pre request basis. - insertLFs = (insertLFs && out_len > 76); - if ( insertLFs ) - out_len += ((out_len-1)/76); - - int count = 0; - out.resize( out_len ); - - // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion - if ( len > 1 ) - { - while (sidx < len-2) - { - if ( insertLFs ) - { - if ( count && (count%76) == 0 ) - out[didx++] = '\n'; - count += 4; - } - out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; - out[didx++] = Base64EncMap[((data[sidx+1] >> 4) & 017) | - ((data[sidx] << 4) & 077)]; - out[didx++] = Base64EncMap[((data[sidx+2] >> 6) & 003) | - ((data[sidx+1] << 2) & 077)]; - out[didx++] = Base64EncMap[data[sidx+2] & 077]; - sidx += 3; - } - } - - if (sidx < len) - { - if ( insertLFs && (count > 0) && (count%76) == 0 ) - out[didx++] = '\n'; - - out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; - if (sidx < len-1) - { - out[didx++] = Base64EncMap[((data[sidx+1] >> 4) & 017) | - ((data[sidx] << 4) & 077)]; - out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077]; - } - else - { - out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; - } - } - - // Add padding - while (didx < out.size()) - { - out[didx] = '='; - didx++; - } -} - -QByteArray KCodecs::base64Decode( const QByteArray& in ) -{ - QByteArray out; - base64Decode( in, out ); - return out; -} - -void KCodecs::base64Decode( const QByteArray& in, QByteArray& out ) -{ - out.resize(0); - if ( in.isEmpty() ) - return; - - int count = 0; - int len = in.size(), tail = len; - const char* data = in.data(); - - // Deal with possible *nix "BEGIN" marker!! - while ( count < len && (data[count] == '\n' || data[count] == '\r' || - data[count] == '\t' || data[count] == ' ') ) - count++; - - if ( strncasecmp(data+count, "begin", 5) == 0 ) - { - count += 5; - while ( count < len && data[count] != '\n' && data[count] != '\r' ) - count++; - - while ( count < len && (data[count] == '\n' || data[count] == '\r') ) - count ++; - - data += count; - tail = (len -= count); - } - - // Find the tail end of the actual encoded data even if - // there is/are trailing CR and/or LF. - while ( data[tail-1] == '=' || data[tail-1] == '\n' || - data[tail-1] == '\r' ) - if ( data[--tail] != '=' ) len = tail; - - unsigned int outIdx = 0; - out.resize( (count=len) ); - for (int idx = 0; idx < count; idx++) - { - // Adhere to RFC 2045 and ignore characters - // that are not part of the encoding table. - unsigned char ch = data[idx]; - if ((ch > 47 && ch < 58) || (ch > 64 && ch < 91) || - (ch > 96 && ch < 123) || ch == '+' || ch == '/' || ch == '=') - { - out[outIdx++] = Base64DecMap[ch]; - } - else - { - len--; - tail--; - } - } - - // kDebug() << "Tail size = " << tail << ", Length size = " << len; - - // 4-byte to 3-byte conversion - len = (tail>(len/4)) ? tail-(len/4) : 0; - int sidx = 0, didx = 0; - if ( len > 1 ) - { - while (didx < len-2) - { - out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); - out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); - out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); - sidx += 4; - didx += 3; - } - } - - if (didx < len) - out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); - - if (++didx < len ) - out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); - - // Resize the output buffer - if ( len == 0 || len < out.size() ) - out.resize(len); -} - -QByteArray KCodecs::uuencode( const QByteArray& in ) -{ - QByteArray out; - uuencode( in, out ); - return QByteArray( out.data(), out.size()+1 ); -} - -void KCodecs::uuencode( const QByteArray& in, QByteArray& out ) -{ - out.resize( 0 ); - if( in.isEmpty() ) - return; - - unsigned int sidx = 0; - int didx = 0; - unsigned int line_len = 45; - - const char nl[] = "\n"; - const char* data = in.data(); - const unsigned int nl_len = strlen(nl); - const unsigned int len = in.size(); - - out.resize( (len+2)/3*4 + ((len+line_len-1)/line_len)*(nl_len+1) ); - // split into lines, adding line-length and line terminator - while (sidx+line_len < len) - { - // line length - out[didx++] = UUEncMap[line_len]; - - // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion - for (unsigned int end = sidx+line_len; sidx < end; sidx += 3) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[((data[sidx+1] >> 4) & 017) | - ((data[sidx] << 4) & 077)]; - out[didx++] = UUEncMap[((data[sidx+2] >> 6) & 003) | - ((data[sidx+1] << 2) & 077)]; - out[didx++] = UUEncMap[data[sidx+2] & 077]; - } - - // line terminator - //for (unsigned int idx=0; idx < nl_len; idx++) - //out[didx++] = nl[idx]; - memcpy(out.data()+didx, nl, nl_len); - didx += nl_len; - } - - // line length - out[didx++] = UUEncMap[len-sidx]; - // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion - while (sidx+2 < len) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[((data[sidx+1] >> 4) & 017) | - ((data[sidx] << 4) & 077)]; - out[didx++] = UUEncMap[((data[sidx+2] >> 6) & 003) | - ((data[sidx+1] << 2) & 077)]; - out[didx++] = UUEncMap[data[sidx+2] & 077]; - sidx += 3; - } - - if (sidx < len-1) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[((data[sidx+1] >> 4) & 017) | - ((data[sidx] << 4) & 077)]; - out[didx++] = UUEncMap[(data[sidx+1] << 2) & 077]; - out[didx++] = UUEncMap[0]; - } - else if (sidx < len) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[(data[sidx] << 4) & 077]; - out[didx++] = UUEncMap[0]; - out[didx++] = UUEncMap[0]; - } - - // line terminator - memcpy(out.data()+didx, nl, nl_len); - didx += nl_len; - - // sanity check - if ( didx != out.size() ) - out.resize( 0 ); -} - -QByteArray KCodecs::uudecode( const QByteArray& in ) -{ - QByteArray out; - uudecode( in, out ); - return out; -} - -void KCodecs::uudecode( const QByteArray& in, QByteArray& out ) -{ - out.resize( 0 ); - if( in.isEmpty() ) - return; - - int sidx = 0; - int didx = 0; - int len = in.size(); - int line_len, end; - const char* data = in.data(); - - // Deal with *nix "BEGIN"/"END" separators!! - int count = 0; - while ( count < len && (data[count] == '\n' || data[count] == '\r' || - data[count] == '\t' || data[count] == ' ') ) - count ++; - - bool hasLF = false; - if ( strncasecmp( data+count, "begin", 5) == 0 ) - { - count += 5; - while ( count < len && data[count] != '\n' && data[count] != '\r' ) - count ++; - - while ( count < len && (data[count] == '\n' || data[count] == '\r') ) - count ++; - - data += count; - len -= count; - hasLF = true; - } - - out.resize( len/4*3 ); - while ( sidx < len ) - { - // get line length (in number of encoded octets) - line_len = UUDecMap[ (unsigned char) data[sidx++]]; - // ascii printable to 0-63 and 4-byte to 3-byte conversion - end = didx+line_len; - char A, B, C, D; - if (end > 2) { - while (didx < end-2) - { - A = UUDecMap[(unsigned char) data[sidx]]; - B = UUDecMap[(unsigned char) data[sidx+1]]; - C = UUDecMap[(unsigned char) data[sidx+2]]; - D = UUDecMap[(unsigned char) data[sidx+3]]; - out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) ); - out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) ); - out[didx++] = ( ((C << 6) & 255) | (D & 077) ); - sidx += 4; - } - } - - if (didx < end) - { - A = UUDecMap[(unsigned char) data[sidx]]; - B = UUDecMap[(unsigned char) data[sidx+1]]; - out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) ); - } - - if (didx < end) - { - B = UUDecMap[(unsigned char) data[sidx+1]]; - C = UUDecMap[(unsigned char) data[sidx+2]]; - out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) ); - } - - // skip padding - while (sidx < len && data[sidx] != '\n' && data[sidx] != '\r') - sidx++; - - // skip end of line - while (sidx < len && (data[sidx] == '\n' || data[sidx] == '\r')) - sidx++; - - // skip the "END" separator when present. - if ( hasLF && strncasecmp( data+sidx, "end", 3) == 0 ) - break; - } - - if ( didx < out.size() ) - out.resize( didx ); -} - - - -QString KCodecs::decodeRFC2047String(const QString &msg) -{ - QString charset; - QChar encoding; - QString notEncodedText; - QString encodedText; - QString decodedText; - int encEnd=0; - if(!msg.startsWith(QLatin1String("=?")) || (encEnd=msg.lastIndexOf(QLatin1String("?=")))==-1) - return msg; - - notEncodedText=msg.mid(encEnd+2); - encodedText=msg.left(encEnd); - encodedText=encodedText.mid(2,encodedText.length()-2); - int questionMark=encodedText.indexOf(QLatin1Char('?')); - if (questionMark==-1) - return msg; - charset=encodedText.left(questionMark).toLower(); - encoding=encodedText.at(questionMark+1).toLower(); - if (encoding != QLatin1Char('b') && encoding != QLatin1Char('q')) - return msg; - encodedText=encodedText.mid(questionMark+3); - if(charset.indexOf(QLatin1Char(' '))!=-1 && encodedText.indexOf(QLatin1Char(' '))!=-1) - return msg; - QByteArray tmpOut; - QByteArray tmpIn = encodedText.toLocal8Bit(); - if(encoding == QLatin1Char('q')) - tmpOut = KCodecs::quotedPrintableDecode(tmpIn); - else - tmpOut = KCodecs::base64Decode(tmpIn); - if (charset != QLatin1String("us-ascii")) { - QTextCodec *codec = QTextCodec::codecForName(charset.toLocal8Bit()); - if(!codec) - return msg; - decodedText = codec->toUnicode(tmpOut); - decodedText = decodedText.replace(QLatin1Char('_'), QLatin1Char(' ')); - } else { - decodedText = QString::fromLocal8Bit(tmpOut.replace('_', ' ')); - } - - return decodedText + notEncodedText; -} - - - - - -/******************************** KMD5 ********************************/ -KMD5::KMD5() -{ - init(); -} - -KMD5::KMD5(const char *in, int len) -{ - init(); - update(in, len); -} - -KMD5::KMD5(const QByteArray& in) -{ - init(); - update( in ); -} - -KMD5::~KMD5() -{ -} - -void KMD5::update(const QByteArray& in) -{ - update(in.data(), int(in.size())); -} - -void KMD5::update(const char* in, int len) -{ - update(reinterpret_cast(in), len); -} - -void KMD5::update(const unsigned char* in, int len) -{ - if (len < 0) - len = qstrlen(reinterpret_cast(in)); - - if (!len) - return; - - if (m_finalized) { - kWarning() << "KMD5::update called after state was finalized!"; - return; - } - - quint32 in_index; - quint32 buffer_index; - quint32 buffer_space; - quint32 in_length = static_cast( len ); - - buffer_index = static_cast((m_count[0] >> 3) & 0x3F); - - if ( (m_count[0] += (in_length << 3))<(in_length << 3) ) - m_count[1]++; - - m_count[1] += (in_length >> 29); - buffer_space = 64 - buffer_index; - - if (in_length >= buffer_space) - { - memcpy (m_buffer + buffer_index, in, buffer_space); - transform (m_buffer); - - for (in_index = buffer_space; in_index + 63 < in_length; - in_index += 64) - transform (reinterpret_cast(in+in_index)); - - buffer_index = 0; - } - else - in_index=0; - - memcpy(m_buffer+buffer_index, in+in_index, in_length-in_index); -} - -bool KMD5::update(QIODevice& file) -{ - char buffer[1024]; - int len; - - while ((len=file.read(buffer, sizeof(buffer))) > 0) - update(buffer, len); - - return file.atEnd(); -} - -void KMD5::finalize () -{ - if (m_finalized) return; - - quint8 bits[8]; - quint32 index, padLen; - static const unsigned char PADDING[64]= - { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - encode (bits, m_count, 8); - //memcpy( bits, m_count, 8 ); - - // Pad out to 56 mod 64. - index = static_cast((m_count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - update (reinterpret_cast(PADDING), padLen); - - // Append length (before padding) - update (reinterpret_cast(bits), 8); - - // Store state in digest - encode (m_digest, m_state, 16); - //memcpy( m_digest, m_state, 16 ); - - // Fill sensitive information with zero's - memset ( (void *)m_buffer, 0, sizeof(*m_buffer)); - - m_finalized = true; -} - - -bool KMD5::verify( const KMD5::Digest& digest) -{ - finalize(); - return (0 == memcmp(rawDigest(), digest, sizeof(KMD5::Digest))); -} - -bool KMD5::verify( const QByteArray& hexdigest) -{ - finalize(); - return (0 == strcmp(hexDigest().data(), hexdigest)); -} - -const KMD5::Digest& KMD5::rawDigest() -{ - finalize(); - return m_digest; -} - -void KMD5::rawDigest( KMD5::Digest& bin ) -{ - finalize(); - memcpy( bin, m_digest, 16 ); -} - - -QByteArray KMD5::hexDigest() -{ - QByteArray s(32, 0); - - finalize(); - sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], - m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], - m_digest[12], m_digest[13], m_digest[14], m_digest[15]); - - return s; -} - -void KMD5::hexDigest(QByteArray& s) -{ - finalize(); - s.resize(32); - sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], - m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], - m_digest[12], m_digest[13], m_digest[14], m_digest[15]); -} - -QByteArray KMD5::base64Digest() -{ - finalize(); - return QByteArray::fromRawData(reinterpret_cast(m_digest),16).toBase64(); -} - -void KMD5::init() -{ - d = 0; - reset(); -} - -void KMD5::reset() -{ - m_finalized = false; - - m_count[0] = 0; - m_count[1] = 0; - - m_state[0] = 0x67452301; - m_state[1] = 0xefcdab89; - m_state[2] = 0x98badcfe; - m_state[3] = 0x10325476; - - memset ( m_buffer, 0, sizeof(*m_buffer)); - memset ( m_digest, 0, sizeof(*m_digest)); -} - -void KMD5::transform( const unsigned char block[64] ) -{ - - quint32 a = m_state[0], b = m_state[1], c = m_state[2], d = m_state[3], x[16]; - - decode (x, block, 64); - //memcpy( x, block, 64 ); - - Q_ASSERT(!m_finalized); // not just a user error, since the method is private - - /* Round 1 */ - FF (a, b, c, d, x[ 0], KMD5_S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], KMD5_S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], KMD5_S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], KMD5_S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], KMD5_S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], KMD5_S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], KMD5_S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], KMD5_S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], KMD5_S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], KMD5_S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], KMD5_S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], KMD5_S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], KMD5_S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], KMD5_S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], KMD5_S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], KMD5_S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], KMD5_S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], KMD5_S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], KMD5_S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], KMD5_S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], KMD5_S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], KMD5_S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], KMD5_S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], KMD5_S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], KMD5_S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], KMD5_S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], KMD5_S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], KMD5_S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], KMD5_S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], KMD5_S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], KMD5_S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], KMD5_S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], KMD5_S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], KMD5_S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], KMD5_S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], KMD5_S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], KMD5_S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], KMD5_S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], KMD5_S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], KMD5_S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], KMD5_S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], KMD5_S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], KMD5_S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], KMD5_S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], KMD5_S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], KMD5_S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], KMD5_S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], KMD5_S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], KMD5_S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], KMD5_S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], KMD5_S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], KMD5_S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], KMD5_S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], KMD5_S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], KMD5_S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], KMD5_S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], KMD5_S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], KMD5_S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], KMD5_S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], KMD5_S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], KMD5_S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], KMD5_S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], KMD5_S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], KMD5_S44, 0xeb86d391); /* 64 */ - - m_state[0] += a; - m_state[1] += b; - m_state[2] += c; - m_state[3] += d; - - memset ( static_cast(x), 0, sizeof(x) ); -} - -inline quint32 KMD5::rotate_left (quint32 x, quint32 n) -{ - return (x << n) | (x >> (32-n)) ; -} - -inline quint32 KMD5::F (quint32 x, quint32 y, quint32 z) -{ - return (x & y) | (~x & z); -} - -inline quint32 KMD5::G (quint32 x, quint32 y, quint32 z) -{ - return (x & z) | (y & ~z); -} - -inline quint32 KMD5::H (quint32 x, quint32 y, quint32 z) -{ - return x ^ y ^ z; -} - -inline quint32 KMD5::I (quint32 x, quint32 y, quint32 z) -{ - return y ^ (x | ~z); -} - -void KMD5::FF ( quint32& a, quint32 b, quint32 c, quint32 d, - quint32 x, quint32 s, quint32 ac ) -{ - a += F(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -void KMD5::GG ( quint32& a, quint32 b, quint32 c, quint32 d, - quint32 x, quint32 s, quint32 ac) -{ - a += G(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -void KMD5::HH ( quint32& a, quint32 b, quint32 c, quint32 d, - quint32 x, quint32 s, quint32 ac ) -{ - a += H(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -void KMD5::II ( quint32& a, quint32 b, quint32 c, quint32 d, - quint32 x, quint32 s, quint32 ac ) -{ - a += I(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - - -void KMD5::encode ( unsigned char* output, quint32 *in, quint32 len ) -{ -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - memcpy(output, in, len); -#else - quint32 i, j; - for (i = 0, j = 0; j < len; i++, j += 4) - { - output[j] = static_cast((in[i] & 0xff)); - output[j+1] = static_cast(((in[i] >> 8) & 0xff)); - output[j+2] = static_cast(((in[i] >> 16) & 0xff)); - output[j+3] = static_cast(((in[i] >> 24) & 0xff)); - } -#endif -} - -// Decodes in (quint8) into output (quint32). Assumes len is a -// multiple of 4. -void KMD5::decode (quint32 *output, const unsigned char* in, quint32 len) -{ -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - memcpy(output, in, len); - -#else - quint32 i, j; - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = static_cast(in[j]) | - (static_cast(in[j+1]) << 8) | - (static_cast(in[j+2]) << 16) | - (static_cast(in[j+3]) << 24); -#endif -} - - - -/**************************************************************/ diff --git a/kdecore/text/kcodecs.h b/kdecore/text/kcodecs.h deleted file mode 100644 index ed8e6d57..00000000 --- a/kdecore/text/kcodecs.h +++ /dev/null @@ -1,488 +0,0 @@ -/* - Copyright (C) 2000-2001 Dawit Alemayehu - Copyright (C) 2001 Rik Hemsley (rikkus) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License (LGPL) - version 2 as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. // krazy:exclude=copyright - RSA Data Security, Inc. Created 1991. All rights reserved. - - The KMD5 class is based on a C++ implementation of - "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by - Mordechai T. Abzug, Copyright (c) 1995. This implementation // krazy:exclude=copyright - passes the test-suite as defined in RFC 1321. - - The encoding and decoding utilities in KCodecs with the exception of - quoted-printable are based on the java implementation in HTTPClient - package by Ronald Tschalär Copyright (C) 1996-1999. // krazy:exclude=copyright - - The quoted-printable codec as described in RFC 2045, section 6.7. is by - Rik Hemsley (C) 2001. -*/ - -#ifndef KCODECS_H -#define KCODECS_H - -#define KBase64 KCodecs - -#include - -class QByteArray; -class QIODevice; - -/** - * A wrapper class for the most commonly used encoding and - * decoding algorithms. Currently there is support for encoding - * and decoding input using base64, uu and the quoted-printable - * specifications. - * - * \b Usage: - * - * \code - * QByteArray input = "Aladdin:open sesame"; - * QByteArray result = KCodecs::base64Encode(input); - * cout << "Result: " << result.data() << endl; - * \endcode - * - *
- * Output should be
- * Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ==
- * 
- * - * The above example makes use of the convenience functions - * (ones that accept/return null-terminated strings) to encode/decode - * a string. If what you need is to encode or decode binary data, then - * it is highly recommended that you use the functions that take an input - * and output QByteArray as arguments. These functions are specifically - * tailored for encoding and decoding binary data. - * - * @short A collection of commonly used encoding and decoding algorithms. - * @author Dawit Alemayehu - * @author Rik Hemsley - */ -namespace KCodecs -{ - /** - * Encodes the given data using the quoted-printable algorithm. - * - * @param in data to be encoded. - * @param useCRLF if true the input data is expected to have - * CRLF line breaks and the output will have CRLF line - * breaks, too. - * @return quoted-printable encoded string. - */ - KDECORE_EXPORT QByteArray quotedPrintableEncode(const QByteArray & in, - bool useCRLF = true); - - /** - * Encodes the given data using the quoted-printable algorithm. - * - * Use this function if you want the result of the encoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for encoding binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be encoded. - * @param out encoded data. - * @param useCRLF if true the input data is expected to have - * CRLF line breaks and the output will have CRLF line - * breaks, too. - */ - KDECORE_EXPORT void quotedPrintableEncode(const QByteArray & in, QByteArray& out, - bool useCRLF); - - /** - * Decodes a quoted-printable encoded data. - * - * Accepts data with CRLF or standard unix line breaks. - * - * @param in data to be decoded. - * @return decoded string. - */ - KDECORE_EXPORT QByteArray quotedPrintableDecode(const QByteArray & in); - - /** - * Decodes a quoted-printable encoded data. - * - * Accepts data with CRLF or standard unix line breaks. - * Use this function if you want the result of the decoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for decoding an encoded - * binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be decoded. - * @param out decoded data. - */ - KDECORE_EXPORT void quotedPrintableDecode(const QByteArray & in, QByteArray& out); - - - /** - * Encodes the given data using the uuencode algorithm. - * - * The output is split into lines starting with the number of - * encoded octets in the line and ending with a newline. No - * line is longer than 45 octets (60 characters), excluding the - * line terminator. - * - * @param in data to be uuencoded - * @return uuencoded string. - */ - KDECORE_EXPORT QByteArray uuencode( const QByteArray& in ); - - /** - * Encodes the given data using the uuencode algorithm. - * - * Use this function if you want the result of the encoding - * to be placed in another array and cut down the number of - * copy operation that have to be performed in the process. - * This is the preffered method for encoding binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be uuencoded. - * @param out uudecoded data. - */ - KDECORE_EXPORT void uuencode( const QByteArray& in, QByteArray& out ); - - /** - * Decodes the given data using the uudecode algorithm. - * - * Any 'begin' and 'end' lines like those generated by - * the utilities in unix and unix-like OS will be - * automatically ignored. - * - * @param in data to be decoded. - * @return decoded string. - */ - KDECORE_EXPORT QByteArray uudecode( const QByteArray& in ); - - /** - * Decodes the given data using the uudecode algorithm. - * - * Use this function if you want the result of the decoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is the preferred method for decoding binary data. - * - * Any 'begin' and 'end' lines like those generated by - * the utilities in unix and unix-like OS will be - * automatically ignored. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be decoded. - * @param out uudecoded data. - */ - KDECORE_EXPORT void uudecode( const QByteArray& in, QByteArray& out ); - - - /** - * Encodes the given data using the base64 algorithm. - * - * The boolean argument determines if the encoded data is - * going to be restricted to 76 characters or less per line - * as specified by RFC 2045. If @p insertLFs is true, then - * there will be 76 characters or less per line. - * - * @param in data to be encoded. - * @param insertLFs limit the number of characters per line. - * - * @return base64 encoded string. - */ - KDECORE_EXPORT QByteArray base64Encode( const QByteArray& in, bool insertLFs = false); - - /** - * Encodes the given data using the base64 algorithm. - * - * Use this function if you want the result of the encoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for encoding binary data. - * - * The boolean argument determines if the encoded data is going - * to be restricted to 76 characters or less per line as specified - * by RFC 2045. If @p insertLFs is true, then there will be 76 - * characters or less per line. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be encoded. - * @param out encoded data. - * @param insertLFs limit the number of characters per line. - */ - KDECORE_EXPORT void base64Encode( const QByteArray& in, QByteArray& out, - bool insertLFs = false ); - - /** - * Decodes the given data that was encoded using the - * base64 algorithm. - * - * @param in data to be decoded. - * @return decoded string. - */ - KDECORE_EXPORT QByteArray base64Decode( const QByteArray& in ); - - /** - * Decodes the given data that was encoded with the base64 - * algorithm. - * - * Use this function if you want the result of the decoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for decoding an encoded - * binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be decoded. - * @param out decoded data. - */ - KDECORE_EXPORT void base64Decode( const QByteArray& in, QByteArray& out ); - - - /** - * Decodes string @p text according to RFC2047, - * i.e., the construct =?charset?[qb]?encoded?= - * - * Note: a more rubust version of this function is included in kdepimlibs/libkmime - * - * @param text source string - * @returns the decoded string - */ - KDECORE_EXPORT QString decodeRFC2047String(const QString &text); - - -} - -class KMD5Private; -/** - * @short An adapted C++ implementation of RSA Data Securities MD5 algorithm. - * - * The default constructor is designed to provide much the same - * functionality as the most commonly used C-implementation, while - * the other three constructors are meant to further simplify the - * process of obtaining a digest by calculating the result in a - * single step. - * - * KMD5 is state-based, that means you can add new contents with - * update() as long as you didn't request the digest value yet. - * After the digest value was requested, the object is "finalized" - * and you have to call reset() to be able to do another calculation - * with it. The reason for this behavior is that upon requesting - * the message digest KMD5 has to pad the received contents up to a - * 64 byte boundary to calculate its value. After this operation it - * is not possible to resume consuming data. - * - * \b Usage: - * - * A common usage of this class: - * - * \code - * const char* test1; - * KMD5::Digest rawResult; - * - * test1 = "This is a simple test."; - * KMD5 context (test1); - * cout << "Hex Digest output: " << context.hexDigest().data() << endl; - * \endcode - * - * To cut down on the unnecessary overhead of creating multiple KMD5 - * objects, you can simply invoke reset() to reuse the same object - * in making another calculation: - * - * \code - * context.reset (); - * context.update ("TWO"); - * context.update ("THREE"); - * cout << "Hex Digest output: " << context.hexDigest().data() << endl; - * \endcode - * - * @author Dirk Mueller , Dawit Alemayehu - */ - -class KDECORE_EXPORT KMD5 -{ -public: - - typedef unsigned char Digest[16]; - - KMD5(); - ~KMD5(); - - /** - * Constructor that updates the digest for the given string. - * - * @param in C string or binary data - * @param len if negative, calculates the length by using - * strlen on the first parameter, otherwise - * it trusts the given length (does not stop on NUL byte). - */ - explicit KMD5(const char* in, int len = -1); - - /** - * @overload - * - * Same as above except it accepts a QByteArray as its argument. - */ - explicit KMD5(const QByteArray& a ); - - /** - * Updates the message to be digested. Be sure to add all data - * before you read the digest. After reading the digest, you - * can not add more data! - * - * @param in message to be added to digest - * @param len the length of the given message. - */ - void update(const char* in, int len = -1); - - /** - * @overload - */ - void update(const unsigned char* in, int len = -1); - - /** - * @overload - * - * @param in message to be added to the digest (QByteArray). - */ - void update(const QByteArray& in ); - - /** - * @overload - * - * reads the data from an I/O device, i.e. from a file (QFile). - * - * NOTE that the file must be open for reading. - * - * @param file a QIODevice opened for reading - * - * @returns false if an error occurred during reading. - */ - bool update(QIODevice& file); - - /** - * Calling this function will reset the calculated message digest. - * Use this method to perform another message digest calculation - * without recreating the KMD5 object. - */ - void reset(); - - /** - * @return the raw representation of the digest - */ - const Digest& rawDigest (); //krazy:exclude=constref (simple array) - - /** - * Fills the given array with the binary representation of the - * message digest. - * - * Use this method if you do not want to worry about making - * copy of the digest once you obtain it. - * - * @param bin an array of 16 characters ( char[16] ) - */ - void rawDigest( KMD5::Digest& bin ); - - /** - * Returns the value of the calculated message digest in - * a hexadecimal representation. - */ - QByteArray hexDigest (); - - /** - * @overload - */ - void hexDigest(QByteArray&); - - /** - * Returns the value of the calculated message digest in - * a base64-encoded representation. - */ - QByteArray base64Digest (); - - /** - * returns true if the calculated digest for the given - * message matches the given one. - */ - bool verify( const KMD5::Digest& digest); - - /** - * @overload - */ - bool verify(const QByteArray&); - -protected: - /** - * Performs the real update work. Note - * that length is implied to be 64. - */ - void transform( const unsigned char buffer[64] ); - - /** - * finalizes the digest - */ - void finalize(); - -private: - KMD5(const KMD5& u); - KMD5& operator=(const KMD5& md); - - void init(); - void encode( unsigned char* output, quint32 *in, quint32 len ); - void decode( quint32 *output, const unsigned char* in, quint32 len ); - - quint32 rotate_left( quint32 x, quint32 n ); - quint32 F( quint32 x, quint32 y, quint32 z ); - quint32 G( quint32 x, quint32 y, quint32 z ); - quint32 H( quint32 x, quint32 y, quint32 z ); - quint32 I( quint32 x, quint32 y, quint32 z ); - void FF( quint32& a, quint32 b, quint32 c, quint32 d, quint32 x, - quint32 s, quint32 ac ); - void GG( quint32& a, quint32 b, quint32 c, quint32 d, quint32 x, - quint32 s, quint32 ac ); - void HH( quint32& a, quint32 b, quint32 c, quint32 d, quint32 x, - quint32 s, quint32 ac ); - void II( quint32& a, quint32 b, quint32 c, quint32 d, quint32 x, - quint32 s, quint32 ac ); - -private: - quint32 m_state[4]; - quint32 m_count[2]; - quint8 m_buffer[64]; - Digest m_digest; - bool m_finalized; - - KMD5Private* d; -}; - - -#endif // KCODECS_H diff --git a/khtml/ecma/debugger/debugdocument.cpp b/khtml/ecma/debugger/debugdocument.cpp index 02614caa..777acc25 100644 --- a/khtml/ecma/debugger/debugdocument.cpp +++ b/khtml/ecma/debugger/debugdocument.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "kjs_binding.h" #include "khtml_part.h" @@ -16,7 +17,6 @@ #include #include #include -#include using namespace KJS; using namespace KJSDebugger; @@ -167,8 +167,8 @@ QVector& DebugDocument::breakpoints() if (m_md5.isEmpty()) { - KMD5 hash(m_sourceLines.join("\n").toUtf8()); - m_md5 = QString::fromLatin1(hash.hexDigest()); + QByteArray hash = QCryptographicHash::hash(m_sourceLines.join("\n").toUtf8(), QCryptographicHash::Md5); + m_md5 = QString::fromLatin1(hash.toHex()); } return (*s_perHashBreakPoints)[m_md5]; diff --git a/khtml/ecma/kjs_window.cpp b/khtml/ecma/kjs_window.cpp index 25259c0e..626fdc0c 100644 --- a/khtml/ecma/kjs_window.cpp +++ b/khtml/ecma/kjs_window.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/kio/httpfilter/httpfilter.cc b/kio/httpfilter/httpfilter.cc index f16e872e..3678561d 100644 --- a/kio/httpfilter/httpfilter.cc +++ b/kio/httpfilter/httpfilter.cc @@ -79,18 +79,19 @@ HTTPFilterChain::slotInput(const QByteArray &d) HTTPFilterMD5::HTTPFilterMD5() { + context = new QCryptographicHash(QCryptographicHash::Md5); } QString HTTPFilterMD5::md5() { - return QString::fromLatin1(context.base64Digest()); + return QString::fromLatin1(context->result().toHex()); } void HTTPFilterMD5::slotInput(const QByteArray &d) { - context.update(d); + context->addData(d); emit output(d); } diff --git a/kio/httpfilter/httpfilter.h b/kio/httpfilter/httpfilter.h index a5c2f470..1af9b885 100644 --- a/kio/httpfilter/httpfilter.h +++ b/kio/httpfilter/httpfilter.h @@ -27,7 +27,7 @@ class KGzipFilter; #include #include -#include +#include class HTTPFilterBase : public QObject { @@ -76,7 +76,7 @@ public Q_SLOTS: void slotInput(const QByteArray &d); private: - KMD5 context; + QCryptographicHash *context; }; diff --git a/kio/kio/previewjob.cpp b/kio/kio/previewjob.cpp index e434c3b5..0518b765 100644 --- a/kio/kio/previewjob.cpp +++ b/kio/kio/previewjob.cpp @@ -37,16 +37,16 @@ #include #include #include +#include +#include #include #include #include #include -#include #include #include #include -#include #include #include @@ -501,8 +501,8 @@ bool PreviewJobPrivate::statResultThumbnail() url.setPass(QString()); origName = url.url(); - KMD5 md5( QFile::encodeName( origName ) ); - thumbName = QFile::encodeName( md5.hexDigest() ) + ".png"; + QByteArray md5 = QCryptographicHash::hash( QFile::encodeName( origName ), QCryptographicHash::Md5 ); + thumbName = QFile::encodeName( md5.toHex() ) + ".png"; QImage thumb; if ( !thumb.load( thumbPath + thumbName ) ) return false; diff --git a/kio/kssl/ksslcertificate.cpp b/kio/kssl/ksslcertificate.cpp index 024d8130..75937fd1 100644 --- a/kio/kssl/ksslcertificate.cpp +++ b/kio/kssl/ksslcertificate.cpp @@ -36,7 +36,6 @@ #include "ksslutils.h" #include -#include #include #include #include diff --git a/kio/kssl/ksslpkcs12.cpp b/kio/kssl/ksslpkcs12.cpp index d5111141..b4e9fde6 100644 --- a/kio/kssl/ksslpkcs12.cpp +++ b/kio/kssl/ksslpkcs12.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include diff --git a/kio/kssl/ksslpkcs7.cpp b/kio/kssl/ksslpkcs7.cpp index d33438d6..a0b5736c 100644 --- a/kio/kssl/ksslpkcs7.cpp +++ b/kio/kssl/ksslpkcs7.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include diff --git a/kio/kssl/ksslsession.cpp b/kio/kssl/ksslsession.cpp index 19b4cd3a..f59fc4de 100644 --- a/kio/kssl/ksslsession.cpp +++ b/kio/kssl/ksslsession.cpp @@ -24,7 +24,6 @@ #include #include -#include KSSLSession::KSSLSession() : _session(0L) { } diff --git a/kioslave/http/httpauthentication.cpp b/kioslave/http/httpauthentication.cpp index dd6461ac..1db56951 100644 --- a/kioslave/http/httpauthentication.cpp +++ b/kioslave/http/httpauthentication.cpp @@ -38,13 +38,12 @@ #include #include #include -#include #include #include #include #include - +#include static bool isWhiteSpace(char ch) { @@ -449,7 +448,7 @@ struct DigestAuthInfo //calculateResponse() from the original HTTPProtocol static QByteArray calculateResponse(const DigestAuthInfo &info, const KUrl &resource) { - KMD5 md; + QCryptographicHash md(QCryptographicHash::Md5); QByteArray HA1; QByteArray HA2; @@ -459,19 +458,19 @@ static QByteArray calculateResponse(const DigestAuthInfo &info, const KUrl &reso authStr += info.realm; authStr += ':'; authStr += info.password; - md.update( authStr ); + md.addData( authStr ); if ( info.algorithm.toLower() == "md5-sess" ) { - authStr = md.hexDigest(); + authStr = md.result().toHex(); authStr += ':'; authStr += info.nonce; authStr += ':'; authStr += info.cnonce; md.reset(); - md.update( authStr ); + md.addData( authStr ); } - HA1 = md.hexDigest(); + HA1 = md.result().toHex(); kDebug(7113) << "A1 => " << HA1; @@ -483,12 +482,12 @@ static QByteArray calculateResponse(const DigestAuthInfo &info, const KUrl &reso { authStr += ':'; md.reset(); - md.update(info.entityBody); - authStr += md.hexDigest(); + md.addData(info.entityBody); + authStr += md.result().toHex(); } md.reset(); - md.update( authStr ); - HA2 = md.hexDigest(); + md.addData( authStr ); + HA2 = md.result().toHex(); kDebug(7113) << "A2 => " << HA2; @@ -508,9 +507,9 @@ static QByteArray calculateResponse(const DigestAuthInfo &info, const KUrl &reso } authStr += HA2; md.reset(); - md.update( authStr ); + md.addData( authStr ); - const QByteArray response = md.hexDigest(); + const QByteArray response = md.result().toHex(); kDebug(7113) << "Response =>" << response; return response; } diff --git a/kioslave/http/kcookiejar/tests/kcookiejartest.cpp b/kioslave/http/kcookiejar/tests/kcookiejartest.cpp index 1191576e..c054fdc7 100644 --- a/kioslave/http/kcookiejar/tests/kcookiejartest.cpp +++ b/kioslave/http/kcookiejar/tests/kcookiejartest.cpp @@ -153,9 +153,7 @@ static void processCheck(QString &line) QString expectedCookies = line; QString cookies = jar->findCookies(urlStr, false, windowId, 0).trimmed(); - if (cookies != expectedCookies) - FAIL(urlStr+QString("\nGot '%1' expected '%2'") - .arg(cookies, expectedCookies)); + QCOMPARE(cookies, expectedCookies); } static void processClear(QString &line) diff --git a/kioslave/http/parsinghelpers.cpp b/kioslave/http/parsinghelpers.cpp index a6729583..6af51bc6 100644 --- a/kioslave/http/parsinghelpers.cpp +++ b/kioslave/http/parsinghelpers.cpp @@ -25,7 +25,6 @@ #include #include -#include #include // Advance *pos beyond spaces / tabs diff --git a/kioslave/http/tests/httpauthenticationtest.cpp b/kioslave/http/tests/httpauthenticationtest.cpp index 1166b132..e6a14c62 100644 --- a/kioslave/http/tests/httpauthenticationtest.cpp +++ b/kioslave/http/tests/httpauthenticationtest.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/plasma/dataenginemanager.cpp b/plasma/dataenginemanager.cpp index 361ecee1..26b7212d 100644 --- a/plasma/dataenginemanager.cpp +++ b/plasma/dataenginemanager.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/security/crypto/crypto.cpp b/security/crypto/crypto.cpp index f447b873..8068603f 100644 --- a/security/crypto/crypto.cpp +++ b/security/crypto/crypto.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -1924,7 +1923,7 @@ void KCryptoConfig::slotCAImport() { cr = new char[qf.size()+1]; qf.read(cr, qf.size()); QByteArray qba(cr, qf.size()); - certtext = KCodecs::base64Encode(qba); + certtext = qba.toBase64(); delete [] cr; }