kio Library: kntlm.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kntlm.h

    00001 /*
    00002    This file is part of the KDE libraries.
    00003    Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
    00004
    00005    This library is free software; you can redistribute it and/or
    00006    modify it under the terms of the GNU Library General Public
    00007    License version 2 as published by the Free Software Foundation.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    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]; /* "NTLMSSP\0" */
    00084     Q_UINT32 msgType; /* 1 */
    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; /* 2 */
    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; /* 3 */
    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     //Target info block - variable length
    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 /* KNTLM_H */

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:01 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003