Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Net::NTLMCredentials Class Reference

#include <NTLMCredentials.h>

Classes

struct  AuthenticateMessage
 
struct  BufferDesc
 
struct  ChallengeMessage
 This message is sent back by the server and contains the NTLM challenge. More...
 
struct  NegotiateMessage
 This message is sent from the client to initiate NTLM authentication. More...
 

Public Types

enum  { NTLM_MESSAGE_TYPE_NEGOTIATE = 0x01 , NTLM_MESSAGE_TYPE_CHALLENGE = 0x02 , NTLM_MESSAGE_TYPE_AUTHENTICATE = 0x03 }
 
enum  {
  NTLM_FLAG_NEGOTIATE_UNICODE = 0x00000001 , NTLM_FLAG_NEGOTIATE_OEM = 0x00000002 , NTLM_FLAG_REQUEST_TARGET = 0x00000004 , NTLM_FLAG_NEGOTIATE_NTLM = 0x00000200 ,
  NTLM_FLAG_DOMAIN_SUPPLIED = 0x00001000 , NTLM_FLAG_WORKST_SUPPLIED = 0x00002000 , NTLM_FLAG_NEGOTIATE_LOCAL = 0x00004000 , NTLM_FLAG_NEGOTIATE_ALWAYS_SIGN = 0x00008000 ,
  NTLM_FLAG_NEGOTIATE_NTLM2_KEY = 0x00080000 , NTLM_FLAG_TARGET_DOMAIN = 0x00010000 , NTLM_FLAG_TARGET_SERVER = 0x00020000 , NTLM_FLAG_TARGET_SHARE = 0x00040000 ,
  NTLM_FLAG_NEGOTIATE_TARGET = 0x00800000 , NTLM_FLAG_NEGOTIATE_128 = 0x20000000 , NTLM_FLAG_NEGOTIATE_56 = 0x80000000
}
 

Static Public Member Functions

static std::vector< unsigned char > createNonce ()
 
static Poco::UInt64 createTimestamp ()
 Creates an 8-byte client nonce for NTLM authentication.
 
static std::vector< unsigned char > createPasswordHash (const std::string &password)
 
static std::vector< unsigned char > createNTLMv2Hash (const std::string &username, const std::string &target, const std::string &password)
 Creates the NTLM password hash (MD4 of UTF-16-converted password).
 
static std::vector< unsigned char > createLMv2Response (const std::vector< unsigned char > &ntlm2Hash, const std::vector< unsigned char > &challenge, const std::vector< unsigned char > &nonce)
 
static std::vector< unsigned char > createNTLMv2Response (const std::vector< unsigned char > &ntlm2Hash, const std::vector< unsigned char > &challenge, const std::vector< unsigned char > &nonce, const std::vector< unsigned char > &targetInfo, Poco::UInt64 timestamp)
 
static std::vector< unsigned char > formatNegotiateMessage (const NegotiateMessage &message)
 Creates the NTLMv2 response by creating the "blob" and prepending its HMAC-MD5, using the ntlm2Hash as HMAC passphrase.
 
static bool parseChallengeMessage (const unsigned char *buffer, std::size_t size, ChallengeMessage &message)
 Creates the NTLM Type 1 Negotiate message used for initiating NTLM authentication from the client.
 
static std::vector< unsigned char > formatAuthenticateMessage (const AuthenticateMessage &message)
 
static void readBufferDesc (Poco::BinaryReader &reader, BufferDesc &desc)
 Creates the NTLM Type 3 Authenticate message used for sending the response to the challenge.
 
static void writeBufferDesc (Poco::BinaryWriter &writer, const BufferDesc &desc)
 Reads a buffer descriptor.
 
static void splitUsername (const std::string &usernameAndDomain, std::string &username, std::string &domain)
 Writes a buffer descriptor.
 
static std::string toBase64 (const std::vector< unsigned char > &buffer)
 
static std::vector< unsigned char > fromBase64 (const std::string &base64)
 Converts the buffer to a base64-encoded string.
 

Static Public Attributes

static const std::string NTLMSSP
 Decodes the given base64-encoded string.
 

Detailed Description

This is a utility class for working with NTLMv2 Authentication.

Note: This implementation is based on the "The NTLM Authentication Protocol and Security Support Provider" document written by Eric Glass and avilable from http://davenport.sourceforge.net/ntlm.html and the NT LAN Manager (NTLM) Authentication Protocol [MS-NLMP] document by Microsoft.

Definition at line 31 of file NTLMCredentials.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NTLM_MESSAGE_TYPE_NEGOTIATE 
NTLM_MESSAGE_TYPE_CHALLENGE 
NTLM_MESSAGE_TYPE_AUTHENTICATE 

Definition at line 43 of file NTLMCredentials.h.

◆ anonymous enum

anonymous enum
Enumerator
NTLM_FLAG_NEGOTIATE_UNICODE 
NTLM_FLAG_NEGOTIATE_OEM 
NTLM_FLAG_REQUEST_TARGET 
NTLM_FLAG_NEGOTIATE_NTLM 
NTLM_FLAG_DOMAIN_SUPPLIED 
NTLM_FLAG_WORKST_SUPPLIED 
NTLM_FLAG_NEGOTIATE_LOCAL 
NTLM_FLAG_NEGOTIATE_ALWAYS_SIGN 
NTLM_FLAG_NEGOTIATE_NTLM2_KEY 
NTLM_FLAG_TARGET_DOMAIN 
NTLM_FLAG_TARGET_SERVER 
NTLM_FLAG_TARGET_SHARE 
NTLM_FLAG_NEGOTIATE_TARGET 
NTLM_FLAG_NEGOTIATE_128 
NTLM_FLAG_NEGOTIATE_56 

Definition at line 50 of file NTLMCredentials.h.

Member Function Documentation

◆ createLMv2Response()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::createLMv2Response ( const std::vector< unsigned char > & ntlm2Hash,
const std::vector< unsigned char > & challenge,
const std::vector< unsigned char > & nonce )
static

Creates the NTLMv2 hash, which is the HMAC-MD5 of the concatenated UTF-16 uppercase username and target, using the password hash as HMAC passphrase.

◆ createNonce()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::createNonce ( )
static

◆ createNTLMv2Hash()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::createNTLMv2Hash ( const std::string & username,
const std::string & target,
const std::string & password )
static

Creates the NTLM password hash (MD4 of UTF-16-converted password).

◆ createNTLMv2Response()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::createNTLMv2Response ( const std::vector< unsigned char > & ntlm2Hash,
const std::vector< unsigned char > & challenge,
const std::vector< unsigned char > & nonce,
const std::vector< unsigned char > & targetInfo,
Poco::UInt64 timestamp )
static

Creates the LMv2 response by computing the HMAC-MD5 of the challenge and nonce, using the ntlm2Hash (see createNTLMv2Hash()) as HMAC passphrase.

◆ createPasswordHash()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::createPasswordHash ( const std::string & password)
static

Creates the NTLM timestamp in tenths of a microsecond since January 1, 1601, using the current system time.

◆ createTimestamp()

static Poco::UInt64 Poco::Net::NTLMCredentials::createTimestamp ( )
static

Creates an 8-byte client nonce for NTLM authentication.

◆ formatAuthenticateMessage()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::formatAuthenticateMessage ( const AuthenticateMessage & message)
static

Parses a NTLM Type 2 Challenge message.

Returns true if the message was parsed successfully, otherwise false.

◆ formatNegotiateMessage()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::formatNegotiateMessage ( const NegotiateMessage & message)
static

Creates the NTLMv2 response by creating the "blob" and prepending its HMAC-MD5, using the ntlm2Hash as HMAC passphrase.

◆ fromBase64()

static std::vector< unsigned char > Poco::Net::NTLMCredentials::fromBase64 ( const std::string & base64)
static

Converts the buffer to a base64-encoded string.

◆ parseChallengeMessage()

static bool Poco::Net::NTLMCredentials::parseChallengeMessage ( const unsigned char * buffer,
std::size_t size,
ChallengeMessage & message )
static

Creates the NTLM Type 1 Negotiate message used for initiating NTLM authentication from the client.

◆ readBufferDesc()

static void Poco::Net::NTLMCredentials::readBufferDesc ( Poco::BinaryReader & reader,
BufferDesc & desc )
static

Creates the NTLM Type 3 Authenticate message used for sending the response to the challenge.

◆ splitUsername()

static void Poco::Net::NTLMCredentials::splitUsername ( const std::string & usernameAndDomain,
std::string & username,
std::string & domain )
static

Writes a buffer descriptor.

◆ toBase64()

static std::string Poco::Net::NTLMCredentials::toBase64 ( const std::vector< unsigned char > & buffer)
static

Splits a username containing a domain into plain username and domain. Supported formats are <DOMAIN><username> and <username><DOMAIN>.

◆ writeBufferDesc()

static void Poco::Net::NTLMCredentials::writeBufferDesc ( Poco::BinaryWriter & writer,
const BufferDesc & desc )
static

Reads a buffer descriptor.

Member Data Documentation

◆ NTLMSSP

const std::string Poco::Net::NTLMCredentials::NTLMSSP
static

Decodes the given base64-encoded string.

Definition at line 173 of file NTLMCredentials.h.


The documentation for this class was generated from the following file: