Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qauthenticator.cpp File Reference

(dc4fe2947dd92b50b7ce306ec015a8bdeb6b6cae)

#include <qauthenticator.h>
#include <qauthenticator_p.h>
#include <qdebug.h>
#include <qloggingcategory.h>
#include <qhash.h>
#include <qbytearray.h>
#include <qcryptographichash.h>
#include <qiodevice.h>
#include <qdatastream.h>
#include <qendian.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qrandom.h>
#include <QtNetwork/qhttpheaders.h>
#include "moc_qauthenticator.cpp"
Include dependency graph for qauthenticator.cpp:

Go to the source code of this file.

Classes

class  QNtlmBuffer
class  QNtlmPhase1Block
class  QNtlmPhase2Block
class  QNtlmPhase3Block

Macros

#define NTLMSSP_NEGOTIATE_UNICODE   0x00000001
#define NTLMSSP_NEGOTIATE_OEM   0x00000002
#define NTLMSSP_REQUEST_TARGET   0x00000004
#define NTLMSSP_NEGOTIATE_SIGN   0x00000010
#define NTLMSSP_NEGOTIATE_SEAL   0x00000020
#define NTLMSSP_NEGOTIATE_DATAGRAM   0x00000040
#define NTLMSSP_NEGOTIATE_LM_KEY   0x00000080
#define NTLMSSP_NEGOTIATE_NTLM   0x00000200
#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED   0x00001000
#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED   0x00002000
#define NTLMSSP_NEGOTIATE_LOCAL_CALL   0x00004000
#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN   0x00008000
#define NTLMSSP_TARGET_TYPE_DOMAIN   0x00010000
#define NTLMSSP_TARGET_TYPE_SERVER   0x00020000
#define NTLMSSP_TARGET_TYPE_SHARE   0x00040000
#define NTLMSSP_NEGOTIATE_NTLM2   0x00080000
#define NTLMSSP_NEGOTIATE_TARGET_INFO   0x00800000
#define NTLMSSP_NEGOTIATE_128   0x20000000
#define NTLMSSP_NEGOTIATE_KEY_EXCHANGE   0x40000000
#define NTLMSSP_NEGOTIATE_56   0x80000000
#define AVTIMESTAMP   7

Functions

 Q_DECLARE_LOGGING_CATEGORY (lcAuthenticator)
 Q_LOGGING_CATEGORY (lcAuthenticator, "qt.network.authenticator")
static QByteArray qNtlmPhase1 ()
static QByteArray qNtlmPhase3 (QAuthenticatorPrivate *ctx, const QByteArray &phase2data)
static bool verifyDigestMD5 (QByteArrayView value)
static int methodStrength (QAuthenticatorPrivate::Method method)
static const char * methodName (QAuthenticatorPrivate::Method method)
static bool containsAuth (QByteArrayView data)
static QByteArray digestMd5ResponseHelper (QByteArrayView alg, QByteArrayView userName, QByteArrayView realm, QByteArrayView password, QByteArrayView nonce, QByteArrayView nonceCount, QByteArrayView cNonce, QByteArrayView qop, QByteArrayView method, QByteArrayView digestUri, QByteArrayView hEntity)
static void qStreamNtlmBuffer (QDataStream &ds, const QByteArray &s)
static void qStreamNtlmString (QDataStream &ds, const QString &s, bool unicode)
static int qEncodeNtlmBuffer (QNtlmBuffer &buf, int offset, const QByteArray &s)
static int qEncodeNtlmString (QNtlmBuffer &buf, int offset, const QString &s, bool unicode)
static QDataStreamoperator<< (QDataStream &s, const QNtlmBuffer &b)
static QDataStreamoperator>> (QDataStream &s, QNtlmBuffer &b)
static QDataStreamoperator<< (QDataStream &s, const QNtlmPhase1Block &b)
static QDataStreamoperator<< (QDataStream &s, const QNtlmPhase3Block &b)
static QByteArray qStringAsUcs2Le (const QString &src)
static QString qStringFromUcs2Le (QByteArray src)
QByteArray qEncodeHmacMd5 (QByteArray &key, QByteArrayView message)
static QByteArray qCreatev2Hash (const QAuthenticatorPrivate *ctx, QNtlmPhase3Block *phase3)
static QByteArray clientChallenge (const QAuthenticatorPrivate *ctx)
static QByteArray qExtractServerTime (const QByteArray &targetInfoBuff)
static QByteArray qEncodeNtlmv2Response (const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block &ch, QNtlmPhase3Block *phase3)
static QByteArray qEncodeLmv2Response (const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block &ch, QNtlmPhase3Block *phase3)
static bool qNtlmDecodePhase2 (const QByteArray &data, QNtlmPhase2Block &ch)

Variables

const int blockSize = 64
const quint8 respversion = 1
const quint8 hirespversion = 1
static constexpr quint16 NtlmFileTimeSize = 8

Macro Definition Documentation

◆ AVTIMESTAMP

#define AVTIMESTAMP   7

Definition at line 1077 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_128

#define NTLMSSP_NEGOTIATE_128   0x20000000

Definition at line 1059 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_56

#define NTLMSSP_NEGOTIATE_56   0x80000000

Definition at line 1072 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_ALWAYS_SIGN

#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN   0x00008000

Definition at line 1020 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_DATAGRAM

#define NTLMSSP_NEGOTIATE_DATAGRAM   0x00000040

Definition at line 981 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED

#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED   0x00001000

Definition at line 1000 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_KEY_EXCHANGE

#define NTLMSSP_NEGOTIATE_KEY_EXCHANGE   0x40000000

Definition at line 1067 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_LM_KEY

#define NTLMSSP_NEGOTIATE_LM_KEY   0x00000080

Definition at line 987 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_LOCAL_CALL

#define NTLMSSP_NEGOTIATE_LOCAL_CALL   0x00004000

Definition at line 1014 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_NTLM

#define NTLMSSP_NEGOTIATE_NTLM   0x00000200

Definition at line 992 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_NTLM2

#define NTLMSSP_NEGOTIATE_NTLM2   0x00080000

Definition at line 1047 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_OEM

#define NTLMSSP_NEGOTIATE_OEM   0x00000002

Definition at line 958 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_SEAL

#define NTLMSSP_NEGOTIATE_SEAL   0x00000020

Definition at line 976 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_SIGN

#define NTLMSSP_NEGOTIATE_SIGN   0x00000010

Definition at line 970 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_TARGET_INFO

#define NTLMSSP_NEGOTIATE_TARGET_INFO   0x00800000

Definition at line 1054 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_UNICODE

#define NTLMSSP_NEGOTIATE_UNICODE   0x00000001

Definition at line 953 of file qauthenticator.cpp.

◆ NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED

#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED   0x00002000

Definition at line 1007 of file qauthenticator.cpp.

◆ NTLMSSP_REQUEST_TARGET

#define NTLMSSP_REQUEST_TARGET   0x00000004

Definition at line 964 of file qauthenticator.cpp.

◆ NTLMSSP_TARGET_TYPE_DOMAIN

#define NTLMSSP_TARGET_TYPE_DOMAIN   0x00010000

Definition at line 1026 of file qauthenticator.cpp.

◆ NTLMSSP_TARGET_TYPE_SERVER

#define NTLMSSP_TARGET_TYPE_SERVER   0x00020000

Definition at line 1032 of file qauthenticator.cpp.

◆ NTLMSSP_TARGET_TYPE_SHARE

#define NTLMSSP_TARGET_TYPE_SHARE   0x00040000

Definition at line 1039 of file qauthenticator.cpp.

Function Documentation

◆ clientChallenge()

QByteArray clientChallenge ( const QAuthenticatorPrivate * ctx)
static

Definition at line 1396 of file qauthenticator.cpp.

Referenced by qEncodeLmv2Response(), and qEncodeNtlmv2Response().

Here is the caller graph for this function:

◆ containsAuth()

bool containsAuth ( QByteArrayView data)
static

Definition at line 744 of file qauthenticator.cpp.

◆ digestMd5ResponseHelper()

QByteArray digestMd5ResponseHelper ( QByteArrayView alg,
QByteArrayView userName,
QByteArrayView realm,
QByteArrayView password,
QByteArrayView nonce,
QByteArrayView nonceCount,
QByteArrayView cNonce,
QByteArrayView qop,
QByteArrayView method,
QByteArrayView digestUri,
QByteArrayView hEntity )
static

Definition at line 830 of file qauthenticator.cpp.

◆ methodName()

const char * methodName ( QAuthenticatorPrivate::Method method)
static

Definition at line 519 of file qauthenticator.cpp.

Referenced by org.qtproject.qt.android.QtQuickView::invokeMethod(), and org.qtproject.qt.android.QtQuickView::invokeMethod().

Here is the caller graph for this function:

◆ methodStrength()

int methodStrength ( QAuthenticatorPrivate::Method method)
static

Definition at line 506 of file qauthenticator.cpp.

◆ operator<<() [1/3]

QDataStream & operator<< ( QDataStream & s,
const QNtlmBuffer & b )
static

Definition at line 1147 of file qauthenticator.cpp.

◆ operator<<() [2/3]

QDataStream & operator<< ( QDataStream & s,
const QNtlmPhase1Block & b )
static

Definition at line 1214 of file qauthenticator.cpp.

References QNtlmPhase1Block::magic.

◆ operator<<() [3/3]

QDataStream & operator<< ( QDataStream & s,
const QNtlmPhase3Block & b )
static

Definition at line 1230 of file qauthenticator.cpp.

References QNtlmPhase3Block::magic.

◆ operator>>()

QDataStream & operator>> ( QDataStream & s,
QNtlmBuffer & b )
static

Definition at line 1153 of file qauthenticator.cpp.

◆ Q_DECLARE_LOGGING_CATEGORY()

Q_DECLARE_LOGGING_CATEGORY ( lcAuthenticator )

◆ Q_LOGGING_CATEGORY()

Q_LOGGING_CATEGORY ( lcAuthenticator ,
"qt.network.authenticator"  )

◆ qCreatev2Hash()

QByteArray qCreatev2Hash ( const QAuthenticatorPrivate * ctx,
QNtlmPhase3Block * phase3 )
static

Definition at line 1373 of file qauthenticator.cpp.

Referenced by qEncodeLmv2Response(), and qEncodeNtlmv2Response().

Here is the caller graph for this function:

◆ qEncodeHmacMd5()

QByteArray qEncodeHmacMd5 ( QByteArray & key,
QByteArrayView message )

Definition at line 1314 of file qauthenticator.cpp.

References blockSize.

◆ qEncodeLmv2Response()

QByteArray qEncodeLmv2Response ( const QAuthenticatorPrivate * ctx,
const QNtlmPhase2Block & ch,
QNtlmPhase3Block * phase3 )
static

Definition at line 1501 of file qauthenticator.cpp.

References QNtlmPhase2Block::challenge, clientChallenge(), and qCreatev2Hash().

Referenced by qNtlmPhase3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qEncodeNtlmBuffer()

int qEncodeNtlmBuffer ( QNtlmBuffer & buf,
int offset,
const QByteArray & s )
static

Definition at line 1127 of file qauthenticator.cpp.

◆ qEncodeNtlmString()

int qEncodeNtlmString ( QNtlmBuffer & buf,
int offset,
const QString & s,
bool unicode )
static

Definition at line 1136 of file qauthenticator.cpp.

◆ qEncodeNtlmv2Response()

QByteArray qEncodeNtlmv2Response ( const QAuthenticatorPrivate * ctx,
const QNtlmPhase2Block & ch,
QNtlmPhase3Block * phase3 )
static

Definition at line 1434 of file qauthenticator.cpp.

References QNtlmPhase2Block::challenge, clientChallenge(), and qCreatev2Hash().

Referenced by qNtlmPhase3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qExtractServerTime()

QByteArray qExtractServerTime ( const QByteArray & targetInfoBuff)
static

Definition at line 1404 of file qauthenticator.cpp.

References NtlmFileTimeSize.

◆ qNtlmDecodePhase2()

bool qNtlmDecodePhase2 ( const QByteArray & data,
QNtlmPhase2Block & ch )
static

Definition at line 1520 of file qauthenticator.cpp.

References QNtlmPhase2Block::challenge, QNtlmPhase2Block::magic, and QNtlmPhase2Block::Size.

Referenced by qNtlmPhase3().

Here is the caller graph for this function:

◆ qNtlmPhase1()

QByteArray qNtlmPhase1 ( )
static

Definition at line 1259 of file qauthenticator.cpp.

◆ qNtlmPhase3()

QByteArray qNtlmPhase3 ( QAuthenticatorPrivate * ctx,
const QByteArray & phase2data )
static

Definition at line 1568 of file qauthenticator.cpp.

References qEncodeLmv2Response(), qEncodeNtlmv2Response(), qNtlmDecodePhase2(), and QNtlmPhase3Block::Size.

Here is the call graph for this function:

◆ qStreamNtlmBuffer()

void qStreamNtlmBuffer ( QDataStream & ds,
const QByteArray & s )
static

Definition at line 1108 of file qauthenticator.cpp.

◆ qStreamNtlmString()

void qStreamNtlmString ( QDataStream & ds,
const QString & s,
bool unicode )
static

Definition at line 1114 of file qauthenticator.cpp.

◆ qStringAsUcs2Le()

QByteArray qStringAsUcs2Le ( const QString & src)
static

Definition at line 1270 of file qauthenticator.cpp.

◆ qStringFromUcs2Le()

QString qStringFromUcs2Le ( QByteArray src)
static

Definition at line 1281 of file qauthenticator.cpp.

◆ verifyDigestMD5()

bool verifyDigestMD5 ( QByteArrayView value)
static

Definition at line 481 of file qauthenticator.cpp.

Variable Documentation

◆ blockSize

const int blockSize = 64

Definition at line 1082 of file qauthenticator.cpp.

Referenced by qEncodeHmacMd5().

◆ hirespversion

const quint8 hirespversion = 1

Definition at line 1084 of file qauthenticator.cpp.

◆ NtlmFileTimeSize

constexpr quint16 NtlmFileTimeSize = 8
staticconstexpr

Definition at line 1086 of file qauthenticator.cpp.

Referenced by qExtractServerTime().

◆ respversion

const quint8 respversion = 1

Definition at line 1083 of file qauthenticator.cpp.