kntlm.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#ifndef KNTLM_H
00021
#define KNTLM_H
00022
00023
#include <qglobal.h>
00024
#include <qcstring.h>
00025
#include <qstring.h>
00026
00027
#include <kdelibs_export.h>
00028
00041 class KIO_EXPORT KNTLM {
00042
public:
00043
00044
enum Flags {
00045 Negotiate_Unicode = 0x00000001,
00046 Negotiate_OEM = 0x00000002,
00047 Request_Target = 0x00000004,
00048 Negotiate_Sign = 0x00000010,
00049 Negotiate_Seal = 0x00000020,
00050 Negotiate_Datagram_Style = 0x00000040,
00051 Negotiate_LM_Key = 0x00000080,
00052 Negotiate_Netware = 0x00000100,
00053 Negotiate_NTLM = 0x00000200,
00054 Negotiate_Domain_Supplied = 0x00001000,
00055 Negotiate_WS_Supplied = 0x00002000,
00056 Negotiate_Local_Call = 0x00004000,
00057 Negotiate_Always_Sign = 0x00008000,
00058 Target_Type_Domain = 0x00010000,
00059 Target_Type_Server = 0x00020000,
00060 Target_Type_Share = 0x00040000,
00061 Negotiate_NTLM2_Key = 0x00080000,
00062 Request_Init_Response = 0x00100000,
00063 Request_Accept_Response = 0x00200000,
00064 Request_NonNT_Key = 0x00400000,
00065 Negotiate_Target_Info = 0x00800000,
00066 Negotiate_128 = 0x20000000,
00067 Negotiate_Key_Exchange = 0x40000000,
00068 Negotiate_56 = 0x80000000
00069 };
00070
00071
typedef struct
00072
{
00073 Q_UINT16 len;
00074 Q_UINT16 maxlen;
00075 Q_UINT32 offset;
00076 } SecBuf;
00077
00081 typedef struct
00082
{
00083
char signature[8];
00084 Q_UINT32 msgType;
00085 Q_UINT32 flags;
00086 SecBuf domain;
00087 SecBuf workstation;
00088 }
Negotiate;
00089
00093 typedef struct
00094
{
00095
char signature[8];
00096 Q_UINT32 msgType;
00097 SecBuf targetName;
00098 Q_UINT32 flags;
00099 Q_UINT8 challengeData[8];
00100 Q_UINT32 context[2];
00101 SecBuf targetInfo;
00102 }
Challenge;
00103
00107 typedef struct
00108
{
00109
char signature[8];
00110 Q_UINT32 msgType;
00111 SecBuf lmResponse;
00112 SecBuf ntResponse;
00113 SecBuf domain;
00114 SecBuf user;
00115 SecBuf workstation;
00116 SecBuf sessionKey;
00117 Q_UINT32 flags;
00118 }
Auth;
00119
00120
typedef struct
00121
{
00122 Q_UINT32 signature;
00123 Q_UINT32 reserved;
00124 Q_UINT64 timestamp;
00125 Q_UINT8 challenge[8];
00126 Q_UINT8 unknown[4];
00127
00128 } Blob;
00129
00140
static bool getNegotiate(
QByteArray &negotiate,
const QString &domain = QString::null,
00141
const QString &workstation = QString::null,
00142 Q_UINT32 flags = Negotiate_Unicode | Request_Target | Negotiate_NTLM );
00162
static bool getAuth(
QByteArray &auth,
const QByteArray &challenge,
const QString &user,
00163
const QString &password,
const QString &domain = QString::null,
00164
const QString &workstation = QString::null,
bool forceNTLM =
false,
bool forceNTLMv2 =
false );
00165
00169
static QByteArray getLMResponse(
const QString &password,
const unsigned char *challenge );
00173
static QByteArray lmHash(
const QString &password );
00177
static QByteArray lmResponse(
const QByteArray &hash,
const unsigned char *challenge );
00178
00182
static QByteArray getNTLMResponse(
const QString &password,
const unsigned char *challenge );
00186
static QByteArray ntlmHash(
const QString &password );
00187
00191
static QByteArray getNTLMv2Response(
const QString &target,
const QString &user,
00192
const QString &password,
const QByteArray &targetInformation,
00193
const unsigned char *challenge );
00194
00198
static QByteArray getLMv2Response(
const QString &target,
const QString &user,
00199
const QString &password,
const unsigned char *challenge );
00200
00204
static QByteArray ntlmv2Hash(
const QString &target,
const QString &user,
const QString &password );
00205
00209
static QByteArray lmv2Response(
const QByteArray &hash,
00210
const QByteArray &clientData,
const unsigned char *challenge );
00211
00215
static QString getString(
const QByteArray &buf,
const SecBuf &secbuf,
bool unicode );
00219
static QByteArray getBuf(
const QByteArray &buf,
const SecBuf &secbuf );
00220
00221
static QByteArray createBlob(
const QByteArray &targetinfo );
00222
00223
static QByteArray hmacMD5(
const QByteArray &data,
const QByteArray &key );
00224
private:
00225
static QByteArray QString2UnicodeLE(
const QString &target );
00226
static QString UnicodeLE2QString(
const QChar* data, uint len );
00227
00228
static void addBuf(
QByteArray &buf, SecBuf &secbuf,
QByteArray &data );
00229
static void addString(
QByteArray &buf, SecBuf &secbuf,
const QString &str,
bool unicode =
false );
00230
static void convertKey(
unsigned char *key_56,
void* ks );
00231 };
00232
00233
#endif
This file is part of the documentation for kio Library Version 3.4.0.