summaryrefslogtreecommitdiffstats
path: root/kio/misc/kntlm
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:46:43 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:46:43 +0000
commitffe8a83e053396df448e9413828527613ca3bd46 (patch)
treea73d4169e02df4a50f9a12cb165fcd0ab5bac7c6 /kio/misc/kntlm
parent682bf3bfdcbcbb1fca85e8a36ed03e062e0555d5 (diff)
downloadtdelibs-ffe8a83e053396df448e9413828527613ca3bd46.tar.gz
tdelibs-ffe8a83e053396df448e9413828527613ca3bd46.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1157647 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/misc/kntlm')
-rw-r--r--kio/misc/kntlm/des.h2
-rw-r--r--kio/misc/kntlm/kntlm.cpp112
-rw-r--r--kio/misc/kntlm/kntlm.h56
-rw-r--r--kio/misc/kntlm/kswap.h2
4 files changed, 86 insertions, 86 deletions
diff --git a/kio/misc/kntlm/des.h b/kio/misc/kntlm/des.h
index 4125791b3..1cb2f27e5 100644
--- a/kio/misc/kntlm/des.h
+++ b/kio/misc/kntlm/des.h
@@ -1,7 +1,7 @@
#ifndef KNTLM_DES_H
#define KNTLM_DES_H
-#include <qglobal.h>
+#include <tqglobal.h>
typedef struct des_key
{
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() );
}
diff --git a/kio/misc/kntlm/kntlm.h b/kio/misc/kntlm/kntlm.h
index 6dbb62139..9be4ea357 100644
--- a/kio/misc/kntlm/kntlm.h
+++ b/kio/misc/kntlm/kntlm.h
@@ -20,9 +20,9 @@
#ifndef KNTLM_H
#define KNTLM_H
-#include <qglobal.h>
-#include <qcstring.h>
-#include <qstring.h>
+#include <tqglobal.h>
+#include <tqcstring.h>
+#include <tqstring.h>
#include <kdelibs_export.h>
@@ -137,8 +137,8 @@ public:
*
* @return true if creating the structure succeeds, false otherwise.
*/
- static bool getNegotiate( QByteArray &negotiate, const QString &domain = QString::null,
- const QString &workstation = QString::null,
+ static bool getNegotiate( TQByteArray &negotiate, const TQString &domain = TQString::null,
+ const TQString &workstation = TQString::null,
Q_UINT32 flags = Negotiate_Unicode | Request_Target | Negotiate_NTLM );
/**
* Creates the type 3 message which should be sent to the server after
@@ -159,74 +159,74 @@ public:
* (challenge data invalid, or NTLM authentication forced, but the challenge data says
* no NTLM supported).
*/
- static bool getAuth( QByteArray &auth, const QByteArray &challenge, const QString &user,
- const QString &password, const QString &domain = QString::null,
- const QString &workstation = QString::null, bool forceNTLM = false, bool forceNTLMv2 = false );
+ static bool getAuth( TQByteArray &auth, const TQByteArray &challenge, const TQString &user,
+ const TQString &password, const TQString &domain = TQString::null,
+ const TQString &workstation = TQString::null, bool forceNTLM = false, bool forceNTLMv2 = false );
/**
* Returns the LanManager response from the password and the server challenge.
*/
- static QByteArray getLMResponse( const QString &password, const unsigned char *challenge );
+ static TQByteArray getLMResponse( const TQString &password, const unsigned char *challenge );
/**
* Calculates the LanManager hash of the specified password.
*/
- static QByteArray lmHash( const QString &password );
+ static TQByteArray lmHash( const TQString &password );
/**
* Calculates the LanManager response from the LanManager hash and the server challenge.
*/
- static QByteArray lmResponse( const QByteArray &hash, const unsigned char *challenge );
+ static TQByteArray lmResponse( const TQByteArray &hash, const unsigned char *challenge );
/**
* Returns the NTLM response from the password and the server challenge.
*/
- static QByteArray getNTLMResponse( const QString &password, const unsigned char *challenge );
+ static TQByteArray getNTLMResponse( const TQString &password, const unsigned char *challenge );
/**
* Returns the NTLM hash (MD4) from the password.
*/
- static QByteArray ntlmHash( const QString &password );
+ static TQByteArray ntlmHash( const TQString &password );
/**
* Calculates the NTLMv2 response.
*/
- static QByteArray getNTLMv2Response( const QString &target, const QString &user,
- const QString &password, const QByteArray &targetInformation,
+ static TQByteArray getNTLMv2Response( const TQString &target, const TQString &user,
+ const TQString &password, const TQByteArray &targetInformation,
const unsigned char *challenge );
/**
* Calculates the LMv2 response.
*/
- static QByteArray getLMv2Response( const QString &target, const QString &user,
- const QString &password, const unsigned char *challenge );
+ static TQByteArray getLMv2Response( const TQString &target, const TQString &user,
+ const TQString &password, const unsigned char *challenge );
/**
* Returns the NTLMv2 hash.
*/
- static QByteArray ntlmv2Hash( const QString &target, const QString &user, const QString &password );
+ static TQByteArray ntlmv2Hash( const TQString &target, const TQString &user, const TQString &password );
/**
* Calculates the LMv2 response.
*/
- static QByteArray lmv2Response( const QByteArray &hash,
- const QByteArray &clientData, const unsigned char *challenge );
+ static TQByteArray lmv2Response( const TQByteArray &hash,
+ const TQByteArray &clientData, const unsigned char *challenge );
/**
* Extracts a string field from an NTLM structure.
*/
- static QString getString( const QByteArray &buf, const SecBuf &secbuf, bool unicode );
+ static TQString getString( const TQByteArray &buf, const SecBuf &secbuf, bool unicode );
/**
* Extracts a byte array from an NTLM structure.
*/
- static QByteArray getBuf( const QByteArray &buf, const SecBuf &secbuf );
+ static TQByteArray getBuf( const TQByteArray &buf, const SecBuf &secbuf );
- static QByteArray createBlob( const QByteArray &targetinfo );
+ static TQByteArray createBlob( const TQByteArray &targetinfo );
- static QByteArray hmacMD5( const QByteArray &data, const QByteArray &key );
+ static TQByteArray hmacMD5( const TQByteArray &data, const TQByteArray &key );
private:
- static QByteArray QString2UnicodeLE( const QString &target );
- static QString UnicodeLE2QString( const QChar* data, uint len );
+ static TQByteArray QString2UnicodeLE( const TQString &target );
+ static TQString UnicodeLE2TQString( const TQChar* data, uint len );
- static void addBuf( QByteArray &buf, SecBuf &secbuf, QByteArray &data );
- static void addString( QByteArray &buf, SecBuf &secbuf, const QString &str, bool unicode = false );
+ static void addBuf( TQByteArray &buf, SecBuf &secbuf, TQByteArray &data );
+ static void addString( TQByteArray &buf, SecBuf &secbuf, const TQString &str, bool unicode = false );
static void convertKey( unsigned char *key_56, void* ks );
};
diff --git a/kio/misc/kntlm/kswap.h b/kio/misc/kntlm/kswap.h
index e9db968ed..336321fd4 100644
--- a/kio/misc/kntlm/kswap.h
+++ b/kio/misc/kntlm/kswap.h
@@ -24,7 +24,7 @@
#include <config.h>
#endif
-#include <qglobal.h>
+#include <tqglobal.h>
/**
* \defgroup KSWAP Byte-swapping functions