summaryrefslogtreecommitdiffstats
path: root/kio/misc/kntlm/kntlm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kio/misc/kntlm/kntlm.cpp')
-rw-r--r--kio/misc/kntlm/kntlm.cpp112
1 files changed, 56 insertions, 56 deletions
diff --git a/kio/misc/kntlm/kntlm.cpp b/kio/misc/kntlm/kntlm.cpp
index 20c9f2a0c..a3eca3bdd 100644
--- a/kio/misc/kntlm/kntlm.cpp
+++ b/kio/misc/kntlm/kntlm.cpp
@@ -23,7 +23,7 @@
#include <string.h>
-#include <qdatetime.h>
+#include <tqdatetime.h>
#include <kapplication.h>
#include <kswap.h>
#include <kmdcodec.h>
@@ -32,7 +32,7 @@
#include "des.h"
#include "kntlm.h"
-QString KNTLM::getString( const QByteArray &buf, const SecBuf &secbuf, bool unicode )
+TQString KNTLM::getString( const TQByteArray &buf, const SecBuf &secbuf, bool unicode )
{
//watch for buffer overflows
Q_UINT32 offset;
@@ -40,22 +40,22 @@ QString KNTLM::getString( const QByteArray &buf, const SecBuf &secbuf, bool unic
offset = KFromToLittleEndian((Q_UINT32)secbuf.offset);
len = KFromToLittleEndian(secbuf.len);
if ( offset > buf.size() ||
- offset + len > buf.size() ) return QString::null;
+ offset + len > buf.size() ) return TQString::null;
- QString str;
+ TQString str;
const char *c = buf.data() + offset;
if ( unicode ) {
- str = UnicodeLE2QString( (QChar*) c, len >> 1 );
+ str = UnicodeLE2TQString( (TQChar*) c, len >> 1 );
} else {
- str = QString::fromLatin1( c, len );
+ str = TQString::fromLatin1( c, len );
}
return str;
}
-QByteArray KNTLM::getBuf( const QByteArray &buf, const SecBuf &secbuf )
+TQByteArray KNTLM::getBuf( const TQByteArray &buf, const SecBuf &secbuf )
{
- QByteArray ret;
+ TQByteArray ret;
Q_UINT32 offset;
Q_UINT16 len;
offset = KFromToLittleEndian((Q_UINT32)secbuf.offset);
@@ -67,9 +67,9 @@ QByteArray KNTLM::getBuf( const QByteArray &buf, const SecBuf &secbuf )
return ret;
}
-void KNTLM::addString( QByteArray &buf, SecBuf &secbuf, const QString &str, bool unicode )
+void KNTLM::addString( TQByteArray &buf, SecBuf &secbuf, const TQString &str, bool unicode )
{
- QByteArray tmp;
+ TQByteArray tmp;
if ( unicode ) {
tmp = QString2UnicodeLE( str );
@@ -83,7 +83,7 @@ void KNTLM::addString( QByteArray &buf, SecBuf &secbuf, const QString &str, bool
}
}
-void KNTLM::addBuf( QByteArray &buf, SecBuf &secbuf, QByteArray &data )
+void KNTLM::addBuf( TQByteArray &buf, SecBuf &secbuf, TQByteArray &data )
{
Q_UINT32 offset;
Q_UINT16 len, maxlen;
@@ -98,9 +98,9 @@ void KNTLM::addBuf( QByteArray &buf, SecBuf &secbuf, QByteArray &data )
memcpy( buf.data() + offset, data.data(), data.size() );
}
-bool KNTLM::getNegotiate( QByteArray &negotiate, const QString &domain, const QString &workstation, Q_UINT32 flags )
+bool KNTLM::getNegotiate( TQByteArray &negotiate, const TQString &domain, const TQString &workstation, Q_UINT32 flags )
{
- QByteArray rbuf( sizeof(Negotiate) );
+ TQByteArray rbuf( sizeof(Negotiate) );
rbuf.fill( 0 );
memcpy( rbuf.data(), "NTLMSSP", 8 );
@@ -118,16 +118,16 @@ bool KNTLM::getNegotiate( QByteArray &negotiate, const QString &domain, const QS
return true;
}
-bool KNTLM::getAuth( QByteArray &auth, const QByteArray &challenge, const QString &user,
- const QString &password, const QString &domain, const QString &workstation,
+bool KNTLM::getAuth( TQByteArray &auth, const TQByteArray &challenge, const TQString &user,
+ const TQString &password, const TQString &domain, const TQString &workstation,
bool forceNTLM, bool forceNTLMv2 )
{
- QByteArray rbuf( sizeof(Auth) );
+ TQByteArray rbuf( sizeof(Auth) );
Challenge *ch = (Challenge *) challenge.data();
- QByteArray response;
+ TQByteArray response;
uint chsize = challenge.size();
bool unicode = false;
- QString dom;
+ TQString dom;
//challenge structure too small
if ( chsize < 32 ) return false;
@@ -142,7 +142,7 @@ bool KNTLM::getAuth( QByteArray &auth, const QByteArray &challenge, const QStrin
memcpy( rbuf.data(), "NTLMSSP", 8 );
((Auth*) rbuf.data())->msgType = KFromToLittleEndian( (Q_UINT32)3 );
((Auth*) rbuf.data())->flags = ch->flags;
- QByteArray targetInfo = getBuf( challenge, ch->targetInfo );
+ TQByteArray targetInfo = getBuf( challenge, ch->targetInfo );
// if ( forceNTLMv2 || (!targetInfo.isEmpty() && (KFromToLittleEndian(ch->flags) & Negotiate_Target_Info)) /* may support NTLMv2 */ ) {
// if ( KFromToLittleEndian(ch->flags) & Negotiate_NTLM ) {
@@ -174,9 +174,9 @@ bool KNTLM::getAuth( QByteArray &auth, const QByteArray &challenge, const QStrin
return true;
}
-QByteArray KNTLM::getLMResponse( const QString &password, const unsigned char *challenge )
+TQByteArray KNTLM::getLMResponse( const TQString &password, const unsigned char *challenge )
{
- QByteArray hash, answer;
+ TQByteArray hash, answer;
hash = lmHash( password );
hash.resize( 21 );
@@ -186,10 +186,10 @@ QByteArray KNTLM::getLMResponse( const QString &password, const unsigned char *c
return answer;
}
-QByteArray KNTLM::lmHash( const QString &password )
+TQByteArray KNTLM::lmHash( const TQString &password )
{
- QByteArray keyBytes( 14 );
- QByteArray hash( 16 );
+ TQByteArray keyBytes( 14 );
+ TQByteArray hash( 16 );
DES_KEY ks;
const char *magic = "KGS!@#$%";
@@ -208,10 +208,10 @@ QByteArray KNTLM::lmHash( const QString &password )
return hash;
}
-QByteArray KNTLM::lmResponse( const QByteArray &hash, const unsigned char *challenge )
+TQByteArray KNTLM::lmResponse( const TQByteArray &hash, const unsigned char *challenge )
{
DES_KEY ks;
- QByteArray answer( 24 );
+ TQByteArray answer( 24 );
convertKey( (unsigned char*) hash.data(), &ks );
ntlm_des_ecb_encrypt( challenge, 8, &ks, (unsigned char*) answer.data() );
@@ -226,9 +226,9 @@ QByteArray KNTLM::lmResponse( const QByteArray &hash, const unsigned char *chall
return answer;
}
-QByteArray KNTLM::getNTLMResponse( const QString &password, const unsigned char *challenge )
+TQByteArray KNTLM::getNTLMResponse( const TQString &password, const unsigned char *challenge )
{
- QByteArray hash, answer;
+ TQByteArray hash, answer;
hash = ntlmHash( password );
hash.resize( 21 );
@@ -238,10 +238,10 @@ QByteArray KNTLM::getNTLMResponse( const QString &password, const unsigned char
return answer;
}
-QByteArray KNTLM::ntlmHash( const QString &password )
+TQByteArray KNTLM::ntlmHash( const TQString &password )
{
KMD4::Digest digest;
- QByteArray ret, unicode;
+ TQByteArray ret, unicode;
unicode = QString2UnicodeLE( password );
KMD4 md4( unicode );
@@ -250,56 +250,56 @@ QByteArray KNTLM::ntlmHash( const QString &password )
return ret;
}
-QByteArray KNTLM::getNTLMv2Response( const QString &target, const QString &user,
- const QString &password, const QByteArray &targetInformation,
+TQByteArray KNTLM::getNTLMv2Response( const TQString &target, const TQString &user,
+ const TQString &password, const TQByteArray &targetInformation,
const unsigned char *challenge )
{
- QByteArray hash = ntlmv2Hash( target, user, password );
- QByteArray blob = createBlob( targetInformation );
+ TQByteArray hash = ntlmv2Hash( target, user, password );
+ TQByteArray blob = createBlob( targetInformation );
return lmv2Response( hash, blob, challenge );
}
-QByteArray KNTLM::getLMv2Response( const QString &target, const QString &user,
- const QString &password, const unsigned char *challenge )
+TQByteArray KNTLM::getLMv2Response( const TQString &target, const TQString &user,
+ const TQString &password, const unsigned char *challenge )
{
- QByteArray hash = ntlmv2Hash( target, user, password );
- QByteArray clientChallenge( 8 );
+ TQByteArray hash = ntlmv2Hash( target, user, password );
+ TQByteArray clientChallenge( 8 );
for ( uint i = 0; i<8; i++ ) {
clientChallenge.data()[i] = KApplication::random() % 0xff;
}
return lmv2Response( hash, clientChallenge, challenge );
}
-QByteArray KNTLM::ntlmv2Hash( const QString &target, const QString &user, const QString &password )
+TQByteArray KNTLM::ntlmv2Hash( const TQString &target, const TQString &user, const TQString &password )
{
- QByteArray hash1 = ntlmHash( password );
- QByteArray key, ret;
- QString id = user.upper() + target.upper();
+ TQByteArray hash1 = ntlmHash( password );
+ TQByteArray key, ret;
+ TQString id = user.upper() + target.upper();
key = QString2UnicodeLE( id );
ret = hmacMD5( key, hash1 );
return ret;
}
-QByteArray KNTLM::lmv2Response( const QByteArray &hash,
- const QByteArray &clientData, const unsigned char *challenge )
+TQByteArray KNTLM::lmv2Response( const TQByteArray &hash,
+ const TQByteArray &clientData, const unsigned char *challenge )
{
- QByteArray data( 8 + clientData.size() );
+ TQByteArray data( 8 + clientData.size() );
memcpy( data.data(), challenge, 8 );
memcpy( data.data() + 8, clientData.data(), clientData.size() );
- QByteArray mac = hmacMD5( data, hash );
+ TQByteArray mac = hmacMD5( data, hash );
mac.resize( 16 + clientData.size() );
memcpy( mac.data() + 16, clientData.data(), clientData.size() );
return mac;
}
-QByteArray KNTLM::createBlob( const QByteArray &targetinfo )
+TQByteArray KNTLM::createBlob( const TQByteArray &targetinfo )
{
- QByteArray blob( sizeof(Blob) + 4 + targetinfo.size() );
+ TQByteArray blob( sizeof(Blob) + 4 + targetinfo.size() );
blob.fill( 0 );
Blob *bl = (Blob *) blob.data();
bl->signature = KFromToBigEndian( (Q_UINT32) 0x01010000 );
- Q_UINT64 now = QDateTime::currentDateTime().toTime_t();
+ Q_UINT64 now = TQDateTime::currentDateTime().toTime_t();
now += (Q_UINT64)3600*(Q_UINT64)24*(Q_UINT64)134774;
now *= (Q_UINT64)10000000;
bl->timestamp = KFromToLittleEndian( now );
@@ -310,11 +310,11 @@ QByteArray KNTLM::createBlob( const QByteArray &targetinfo )
return blob;
}
-QByteArray KNTLM::hmacMD5( const QByteArray &data, const QByteArray &key )
+TQByteArray KNTLM::hmacMD5( const TQByteArray &data, const TQByteArray &key )
{
Q_UINT8 ipad[64], opad[64];
KMD5::Digest digest;
- QByteArray ret;
+ TQByteArray ret;
memset( ipad, 0x36, sizeof(ipad) );
memset( opad, 0x5c, sizeof(opad) );
@@ -323,7 +323,7 @@ QByteArray KNTLM::hmacMD5( const QByteArray &data, const QByteArray &key )
opad[i] ^= key[i];
}
- QByteArray content( data.size()+64 );
+ TQByteArray content( data.size()+64 );
memcpy( content.data(), ipad, 64 );
memcpy( content.data() + 64, data.data(), data.size() );
KMD5 md5( content );
@@ -370,18 +370,18 @@ void KNTLM::convertKey( unsigned char *key_56, void* ks )
memset (&key, 0, sizeof (key));
}
-QByteArray KNTLM::QString2UnicodeLE( const QString &target )
+TQByteArray KNTLM::QString2UnicodeLE( const TQString &target )
{
- QByteArray unicode( target.length() * 2 );
+ TQByteArray unicode( target.length() * 2 );
for ( uint i = 0; i < target.length(); i++ ) {
((Q_UINT16*)unicode.data())[ i ] = KFromToLittleEndian( target[i].unicode() );
}
return unicode;
}
-QString KNTLM::UnicodeLE2QString( const QChar* data, uint len )
+TQString KNTLM::UnicodeLE2TQString( const TQChar* data, uint len )
{
- QString ret;
+ TQString ret;
for ( uint i = 0; i < len; i++ ) {
ret += KFromToLittleEndian( data[ i ].unicode() );
}