mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
generic: use QCryptographicHash instead of KMD5
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
cd441bc501
commit
b4a354b74b
28 changed files with 27 additions and 2159 deletions
|
@ -57,7 +57,6 @@ install(
|
|||
KCmdLineArgs
|
||||
KCmdLineOptions
|
||||
KCodecAction
|
||||
KCodecs
|
||||
KColor
|
||||
KColorButton
|
||||
KColorCells
|
||||
|
@ -201,7 +200,6 @@ install(
|
|||
KLocalizedDate
|
||||
KLocalizedString
|
||||
KLockFile
|
||||
KMD5
|
||||
KMacroExpanderBase
|
||||
KMainWindow
|
||||
KMenu
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../kcodecs.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../kcodecs.h"
|
|
@ -21,7 +21,6 @@
|
|||
#include "musicbrainzlookup.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kcodecs.h>
|
||||
#include <klocale.h>
|
||||
#include <qcryptographichash.h>
|
||||
#include <cstdio>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -153,7 +153,6 @@ sycoca/
|
|||
|
||||
text/
|
||||
kascii.cpp
|
||||
kcodecs.cpp
|
||||
kstringhandler.cpp
|
||||
|
||||
util/
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
#include <kcodecs.h>
|
||||
#include <kstringhandler.h>
|
||||
#include <ktemporaryfile.h>
|
||||
#include <ktoolinvocation.h>
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "kcmdlineargs.h"
|
||||
#include "kconfig.h"
|
||||
#include "kcodecs.h"
|
||||
#include "kdebug.h"
|
||||
#include "kglobal.h"
|
||||
#include "kshell.h"
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
Copyright (C) 2011 Volker Krause <vkrause@kde.org>
|
||||
|
||||
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 <kcodecs.h>
|
||||
#include <qtest_kde.h>
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
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<char>( i % 255 );
|
||||
return b;
|
||||
}
|
||||
|
||||
static void makeData()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("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"
|
|
@ -1,392 +0,0 @@
|
|||
/* This file is part of the KDE libraries
|
||||
Copyright (C) 2000,2001 Dawit Alemayehu <adawit@kde.org>
|
||||
|
||||
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 <config.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kcmdlineargs.h>
|
||||
//#include <kapplication.h>
|
||||
|
||||
#include <kcodecs.h>
|
||||
|
||||
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 <digest>", ki18n("compare <digest> 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);
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,488 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
|
||||
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
|
||||
|
||||
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 <kdecore_export.h>
|
||||
|
||||
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
|
||||
*
|
||||
* <pre>
|
||||
* Output should be
|
||||
* Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ==
|
||||
* </pre>
|
||||
*
|
||||
* 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 <adawit@kde.org>
|
||||
* @author Rik Hemsley <rik@kde.org>
|
||||
*/
|
||||
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 <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org>
|
||||
*/
|
||||
|
||||
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 <b>not</b> 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
|
|
@ -5,6 +5,7 @@
|
|||
#include <QVector>
|
||||
#include <QStringList>
|
||||
#include <QApplication>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#include "kjs_binding.h"
|
||||
#include "khtml_part.h"
|
||||
|
@ -16,7 +17,6 @@
|
|||
#include <ktexteditor/markinterface.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kcodecs.h>
|
||||
|
||||
using namespace KJS;
|
||||
using namespace KJSDebugger;
|
||||
|
@ -167,8 +167,8 @@ QVector<int>& 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];
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <kmessagebox.h>
|
||||
#include <kinputdialog.h>
|
||||
#include <klocale.h>
|
||||
#include <kcodecs.h>
|
||||
#include <kparts/browserinterface.h>
|
||||
#include <kwindowsystem.h>
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class KGzipFilter;
|
|||
#include <QBuffer>
|
||||
|
||||
#include <QObject>
|
||||
#include <kcodecs.h>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
class HTTPFilterBase : public QObject
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ public Q_SLOTS:
|
|||
void slotInput(const QByteArray &d);
|
||||
|
||||
private:
|
||||
KMD5 context;
|
||||
QCryptographicHash *context;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -37,16 +37,16 @@
|
|||
#include <QtGui/QImage>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <QtCore/QLinkedList>
|
||||
|
||||
#include <kfileitem.h>
|
||||
#include <kde_file.h>
|
||||
#include <ktemporaryfile.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kcodecs.h>
|
||||
#include <kglobal.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kservice.h>
|
||||
#include <QtCore/QLinkedList>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kprotocolinfo.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "ksslutils.h"
|
||||
|
||||
#include <kstandarddirs.h>
|
||||
#include <kcodecs.h>
|
||||
#include <kde_file.h>
|
||||
#include <klocale.h>
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <ksslall.h>
|
||||
#include <kdebug.h>
|
||||
#include <ktemporaryfile.h>
|
||||
#include <kcodecs.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <ksslall.h>
|
||||
#include <kdebug.h>
|
||||
#include <ktemporaryfile.h>
|
||||
#include <kcodecs.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <ksslconfig.h>
|
||||
|
||||
#include <kopenssl.h>
|
||||
#include <kcodecs.h>
|
||||
|
||||
KSSLSession::KSSLSession() : _session(0L) {
|
||||
}
|
||||
|
|
|
@ -38,13 +38,12 @@
|
|||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kglobal.h>
|
||||
#include <kcodecs.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kio/authinfo.h>
|
||||
#include <misc/kntlm/kntlm.h>
|
||||
|
||||
#include <QtCore/QTextCodec>
|
||||
|
||||
#include <QtCore/QCryptographicHash>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <QTextCodec>
|
||||
#include <QUrl>
|
||||
|
||||
#include <kcodecs.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
// Advance *pos beyond spaces / tabs
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <qtest_kde.h>
|
||||
#include <kdebug.h>
|
||||
#include <kcodecs.h>
|
||||
#include <krandom.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <misc/kntlm/kntlm.h>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include <kglobal.h>
|
||||
#include <klineedit.h>
|
||||
#include <klocale.h>
|
||||
#include <kcodecs.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kpassworddialog.h>
|
||||
#include <knewpassworddialog.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue