\section{KNTLM Class Reference}
\label{classKNTLM}\index{KNTLM@{KNTLM}}
KNTLM class implements the NTLM authentication protocol.  


{\tt \#include $<$kntlm.h$>$}

\subsection*{Public Types}
\begin{CompactItemize}
\item 
enum {\bf Flags} \{ \par
{\bf Negotiate\_\-Unicode} =  0x00000001, 
{\bf Negotiate\_\-OEM} =  0x00000002, 
{\bf Request\_\-Target} =  0x00000004, 
{\bf Negotiate\_\-Sign} =  0x00000010, 
\par
{\bf Negotiate\_\-Seal} =  0x00000020, 
{\bf Negotiate\_\-Datagram\_\-Style} =  0x00000040, 
{\bf Negotiate\_\-LM\_\-Key} =  0x00000080, 
{\bf Negotiate\_\-Netware} =  0x00000100, 
\par
{\bf Negotiate\_\-NTLM} =  0x00000200, 
{\bf Negotiate\_\-Domain\_\-Supplied} =  0x00001000, 
{\bf Negotiate\_\-WS\_\-Supplied} =  0x00002000, 
{\bf Negotiate\_\-Local\_\-Call} =  0x00004000, 
\par
{\bf Negotiate\_\-Always\_\-Sign} =  0x00008000, 
{\bf Target\_\-Type\_\-Domain} =  0x00010000, 
{\bf Target\_\-Type\_\-Server} =  0x00020000, 
{\bf Target\_\-Type\_\-Share} =  0x00040000, 
\par
{\bf Negotiate\_\-NTLM2\_\-Key} =  0x00080000, 
{\bf Request\_\-Init\_\-Response} =  0x00100000, 
{\bf Request\_\-Accept\_\-Response} =  0x00200000, 
{\bf Request\_\-Non\-NT\_\-Key} =  0x00400000, 
\par
{\bf Negotiate\_\-Target\_\-Info} =  0x00800000, 
{\bf Negotiate\_\-128} =  0x20000000, 
{\bf Negotiate\_\-Key\_\-Exchange} =  0x40000000, 
{\bf Negotiate\_\-56} =  0x80000000
 \}
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static bool {\bf get\-Negotiate} ({\bf QByte\-Array} \&negotiate, const {\bf QString} \&domain=QString::null, const {\bf QString} \&workstation=QString::null, Q\_\-UINT32 flags=Negotiate\_\-Unicode$|$Request\_\-Target$|$Negotiate\_\-NTLM)
\item 
static bool {\bf get\-Auth} ({\bf QByte\-Array} \&auth, const {\bf QByte\-Array} \&challenge, const {\bf QString} \&user, const {\bf QString} \&password, const {\bf QString} \&domain=QString::null, const {\bf QString} \&workstation=QString::null, bool force\-NTLM=false, bool force\-NTLMv2=false)
\item 
static {\bf QByte\-Array} {\bf get\-LMResponse} (const {\bf QString} \&password, const unsigned char $\ast$challenge)
\item 
static {\bf QByte\-Array} {\bf lm\-Hash} (const {\bf QString} \&password)
\item 
static {\bf QByte\-Array} {\bf lm\-Response} (const {\bf QByte\-Array} \&hash, const unsigned char $\ast$challenge)
\item 
static {\bf QByte\-Array} {\bf get\-NTLMResponse} (const {\bf QString} \&password, const unsigned char $\ast$challenge)
\item 
static {\bf QByte\-Array} {\bf ntlm\-Hash} (const {\bf QString} \&password)
\item 
static {\bf QByte\-Array} {\bf get\-NTLMv2Response} (const {\bf QString} \&target, const {\bf QString} \&user, const {\bf QString} \&password, const {\bf QByte\-Array} \&target\-Information, const unsigned char $\ast$challenge)
\item 
static {\bf QByte\-Array} {\bf get\-LMv2Response} (const {\bf QString} \&target, const {\bf QString} \&user, const {\bf QString} \&password, const unsigned char $\ast$challenge)
\item 
static {\bf QByte\-Array} {\bf ntlmv2Hash} (const {\bf QString} \&target, const {\bf QString} \&user, const {\bf QString} \&password)
\item 
static {\bf QByte\-Array} {\bf lmv2Response} (const {\bf QByte\-Array} \&hash, const {\bf QByte\-Array} \&client\-Data, const unsigned char $\ast$challenge)
\item 
static {\bf QString} {\bf get\-String} (const {\bf QByte\-Array} \&buf, const Sec\-Buf \&secbuf, bool unicode)
\item 
static {\bf QByte\-Array} {\bf get\-Buf} (const {\bf QByte\-Array} \&buf, const Sec\-Buf \&secbuf)
\item 
static {\bf QByte\-Array} {\bf create\-Blob} (const {\bf QByte\-Array} \&targetinfo)\label{classKNTLM_e13}

\item 
static {\bf QByte\-Array} {\bf hmac\-MD5} (const {\bf QByte\-Array} \&data, const {\bf QByte\-Array} \&key)\label{classKNTLM_e14}

\end{CompactItemize}
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct {\bf Auth}
\begin{CompactList}\small\item\em The NTLM Type 3 structure. \item\end{CompactList}\item 
struct {\bf Challenge}
\begin{CompactList}\small\item\em The NTLM Type 2 structure. \item\end{CompactList}\item 
struct {\bf Negotiate}
\begin{CompactList}\small\item\em The NTLM Type 1 structure. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
KNTLM class implements the NTLM authentication protocol. 

The KNTLM class is useful for creating the authentication structures which can be used for various servers which implements NTLM type authentication. A comprehensive description of the NTLM authentication protocol can be found at {\tt http://davenport.sourceforge.net/ntlm.html} The class also contains methods to create the Lan\-Manager and NT (MD4) hashes of a password. This class doesn't maintain any state information, so all methods are static. 



Definition at line 41 of file kntlm.h.

\subsection{Member Function Documentation}
\index{KNTLM@{KNTLM}!getNegotiate@{getNegotiate}}
\index{getNegotiate@{getNegotiate}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KNTLM::get\-Negotiate ({\bf QByte\-Array} \& {\em negotiate}, const {\bf QString} \& {\em domain} = {\tt QString::null}, const {\bf QString} \& {\em workstation} = {\tt QString::null}, Q\_\-UINT32 {\em flags} = {\tt Negotiate\_\-Unicode$|$Request\_\-Target$|$Negotiate\_\-NTLM})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e0}


Creates the initial message (type 1) which should be sent to the server. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em negotiate}]- a buffer where the Type 1 message will returned. \item[{\em domain}]- the domain name which should be send with the message. \item[{\em workstation}]- the workstation name which should be send with the message. \item[{\em flags}]- various flags, in most cases the defaults will good.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if creating the structure succeeds, false otherwise. \end{Desc}


Definition at line 87 of file kntlm.cpp.

References KFrom\-To\-Little\-Endian().\index{KNTLM@{KNTLM}!getAuth@{getAuth}}
\index{getAuth@{getAuth}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KNTLM::get\-Auth ({\bf QByte\-Array} \& {\em auth}, const {\bf QByte\-Array} \& {\em challenge}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em password}, const {\bf QString} \& {\em domain} = {\tt QString::null}, const {\bf QString} \& {\em workstation} = {\tt QString::null}, bool {\em force\-NTLM} = {\tt false}, bool {\em force\-NTLMv2} = {\tt false})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e1}


Creates the type 3 message which should be sent to the server after the challenge (type 2) received. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em auth}]- a buffer where the Type 3 message will returned. \item[{\em challenge}]- the Type 2 message returned by the server. \item[{\em user}]- user's name. \item[{\em password}]- user's password. \item[{\em domain}]- the target domain. If left empty, it will be extracted from the challenge. \item[{\em workstation}]- the user's workstation. \item[{\em force\-NTLM}]- force the use of NTLM authentication (either v1 or v2). \item[{\em force\-NTLMv2}]- force the use of NTLMv2 or LMv2 authentication. If false, NTLMv2 support is autodetected from the challenge.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if auth filled with the Type 3 message, false if an error occured (challenge data invalid, or NTLM authentication forced, but the challenge data says no NTLM supported). \end{Desc}


Definition at line 107 of file kntlm.cpp.

References KNTLM::Challenge::challenge\-Data, KNTLM::Challenge::flags, get\-Buf(), get\-LMResponse(), get\-LMv2Response(), get\-NTLMResponse(), get\-NTLMv2Response(), get\-String(), QString::is\-Empty(), KFrom\-To\-Little\-Endian(), KNTLM::Challenge::target\-Info, and KNTLM::Challenge::target\-Name.\index{KNTLM@{KNTLM}!getLMResponse@{getLMResponse}}
\index{getLMResponse@{getLMResponse}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::get\-LMResponse (const {\bf QString} \& {\em password}, const unsigned char $\ast$ {\em challenge})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e2}


Returns the Lan\-Manager response from the password and the server challenge. 



Definition at line 168 of file kntlm.cpp.

References lm\-Hash(), and lm\-Response().

Referenced by get\-Auth().\index{KNTLM@{KNTLM}!lmHash@{lmHash}}
\index{lmHash@{lmHash}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::lm\-Hash (const {\bf QString} \& {\em password})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e3}


Calculates the Lan\-Manager hash of the specified password. 



Definition at line 180 of file kntlm.cpp.

Referenced by get\-LMResponse().\index{KNTLM@{KNTLM}!lmResponse@{lmResponse}}
\index{lmResponse@{lmResponse}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::lm\-Response (const {\bf QByte\-Array} \& {\em hash}, const unsigned char $\ast$ {\em challenge})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e4}


Calculates the Lan\-Manager response from the Lan\-Manager hash and the server challenge. 



Definition at line 202 of file kntlm.cpp.

Referenced by get\-LMResponse(), and get\-NTLMResponse().\index{KNTLM@{KNTLM}!getNTLMResponse@{getNTLMResponse}}
\index{getNTLMResponse@{getNTLMResponse}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::get\-NTLMResponse (const {\bf QString} \& {\em password}, const unsigned char $\ast$ {\em challenge})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e5}


Returns the NTLM response from the password and the server challenge. 



Definition at line 220 of file kntlm.cpp.

References lm\-Response(), and ntlm\-Hash().

Referenced by get\-Auth().\index{KNTLM@{KNTLM}!ntlmHash@{ntlmHash}}
\index{ntlmHash@{ntlmHash}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::ntlm\-Hash (const {\bf QString} \& {\em password})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e6}


Returns the NTLM hash (MD4) from the password. 



Definition at line 232 of file kntlm.cpp.

References KMD4::raw\-Digest().

Referenced by get\-NTLMResponse(), and ntlmv2Hash().\index{KNTLM@{KNTLM}!getNTLMv2Response@{getNTLMv2Response}}
\index{getNTLMv2Response@{getNTLMv2Response}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::get\-NTLMv2Response (const {\bf QString} \& {\em target}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em password}, const {\bf QByte\-Array} \& {\em target\-Information}, const unsigned char $\ast$ {\em challenge})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e7}


Calculates the NTLMv2 response. 



Definition at line 244 of file kntlm.cpp.

References lmv2Response(), and ntlmv2Hash().

Referenced by get\-Auth().\index{KNTLM@{KNTLM}!getLMv2Response@{getLMv2Response}}
\index{getLMv2Response@{getLMv2Response}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::get\-LMv2Response (const {\bf QString} \& {\em target}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em password}, const unsigned char $\ast$ {\em challenge})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e8}


Calculates the LMv2 response. 



Definition at line 253 of file kntlm.cpp.

References lmv2Response(), ntlmv2Hash(), and KApplication::random().

Referenced by get\-Auth().\index{KNTLM@{KNTLM}!ntlmv2Hash@{ntlmv2Hash}}
\index{ntlmv2Hash@{ntlmv2Hash}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::ntlmv2Hash (const {\bf QString} \& {\em target}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em password})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e9}


Returns the NTLMv2 hash. 



Definition at line 264 of file kntlm.cpp.

References ntlm\-Hash().

Referenced by get\-LMv2Response(), and get\-NTLMv2Response().\index{KNTLM@{KNTLM}!lmv2Response@{lmv2Response}}
\index{lmv2Response@{lmv2Response}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::lmv2Response (const {\bf QByte\-Array} \& {\em hash}, const {\bf QByte\-Array} \& {\em client\-Data}, const unsigned char $\ast$ {\em challenge})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e10}


Calculates the LMv2 response. 



Definition at line 274 of file kntlm.cpp.

Referenced by get\-LMv2Response(), and get\-NTLMv2Response().\index{KNTLM@{KNTLM}!getString@{getString}}
\index{getString@{getString}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KNTLM::get\-String (const {\bf QByte\-Array} \& {\em buf}, const Sec\-Buf \& {\em secbuf}, bool {\em unicode})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e11}


Extracts a string field from an NTLM structure. 



Definition at line 35 of file kntlm.cpp.

References QString::from\-Latin1().

Referenced by get\-Auth().\index{KNTLM@{KNTLM}!getBuf@{getBuf}}
\index{getBuf@{getBuf}!KNTLM@{KNTLM}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KNTLM::get\-Buf (const {\bf QByte\-Array} \& {\em buf}, const Sec\-Buf \& {\em secbuf})\hspace{0.3cm}{\tt  [static]}}\label{classKNTLM_e12}


Extracts a byte array from an NTLM structure. 



Definition at line 52 of file kntlm.cpp.

Referenced by get\-Auth().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kntlm.h\item 
kntlm.cpp\end{CompactItemize}
