FreeRDP
winpr/libwinpr/sspi/NTLM/ntlm.c File Reference
#include <winpr/crt.h>
#include <winpr/sspi.h>
#include <winpr/print.h>
#include <winpr/tchar.h>
#include <winpr/sysinfo.h>
#include <winpr/registry.h>
#include <winpr/endian.h>
#include <freerdp/build-config.h>
#include "ntlm.h"
#include "../sspi.h"
#include "ntlm_message.h"
#include "../../log.h"

Macros

#define TAG   WINPR_TAG("sspi.NTLM")
 
#define WINPR_KEY   "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\WinPR\\NTLM"
 

Functions

static int ntlm_SetContextWorkstation (NTLM_CONTEXT *context, char *Workstation)
 
static int ntlm_SetContextServicePrincipalNameW (NTLM_CONTEXT *context, LPWSTR ServicePrincipalName)
 
static int ntlm_SetContextTargetName (NTLM_CONTEXT *context, char *TargetName)
 
static NTLM_CONTEXT * ntlm_ContextNew (void)
 
static void ntlm_ContextFree (NTLM_CONTEXT *context)
 
static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW (SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse, void *pvLogonID, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 
static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA (SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse, void *pvLogonID, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 
static SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle (PCredHandle phCredential)
 
static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW (PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
 
static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA (PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
 
static SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext (PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
 
static SECURITY_STATUS SEC_ENTRY ntlm_ImpersonateSecurityContext (PCtxtHandle phContext)
 
static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW (PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 
static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA (PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 
static SECURITY_STATUS SEC_ENTRY ntlm_CompleteAuthToken (PCtxtHandle phContext, PSecBufferDesc pToken)
 
static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext (PCtxtHandle phContext)
 
SECURITY_STATUS ntlm_computeProofValue (NTLM_CONTEXT *ntlm, SecBuffer *ntproof)
 
SECURITY_STATUS ntlm_computeMicValue (NTLM_CONTEXT *ntlm, SecBuffer *micvalue)
 
static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW (PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
 
static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA (PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
 
static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesW (PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
 
static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesA (PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
 
static SECURITY_STATUS SEC_ENTRY ntlm_RevertSecurityContext (PCtxtHandle phContext)
 
static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage (PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 
static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage (PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 
static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature (PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 
static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature (PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 

Variables

static const char * NTLM_PACKAGE_NAME = "NTLM"
 
const SecurityFunctionTableA NTLM_SecurityFunctionTableA
 
const SecurityFunctionTableW NTLM_SecurityFunctionTableW
 
const SecPkgInfoA NTLM_SecPkgInfoA
 
static WCHAR NTLM_SecPkgInfoW_Name [] = { 'N', 'T', 'L', 'M', '\0' }
 
static WCHAR NTLM_SecPkgInfoW_Comment []
 
const SecPkgInfoW NTLM_SecPkgInfoW
 

Macro Definition Documentation

◆ TAG

#define TAG   WINPR_TAG("sspi.NTLM")

WinPR: Windows Portable Runtime NTLM Security Package

Copyright 2011-2014 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ WINPR_KEY

#define WINPR_KEY   "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\WinPR\\NTLM"

Function Documentation

◆ ntlm_AcceptSecurityContext()

static SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext ( PCredHandle  phCredential,
PCtxtHandle  phContext,
PSecBufferDesc  pInput,
ULONG  fContextReq,
ULONG  TargetDataRep,
PCtxtHandle  phNewContext,
PSecBufferDesc  pOutput,
PULONG  pfContextAttr,
PTimeStamp  ptsTimeStamp 
)
static
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/aa374707
Here is the call graph for this function:

◆ ntlm_AcquireCredentialsHandleA()

static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA ( SEC_CHAR pszPrincipal,
SEC_CHAR pszPackage,
ULONG  fCredentialUse,
void *  pvLogonID,
void *  pAuthData,
SEC_GET_KEY_FN  pGetKeyFn,
void *  pvGetKeyArgument,
PCredHandle  phCredential,
PTimeStamp  ptsExpiry 
)
static
Here is the call graph for this function:

◆ ntlm_AcquireCredentialsHandleW()

static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW ( SEC_WCHAR pszPrincipal,
SEC_WCHAR pszPackage,
ULONG  fCredentialUse,
void *  pvLogonID,
void *  pAuthData,
SEC_GET_KEY_FN  pGetKeyFn,
void *  pvGetKeyArgument,
PCredHandle  phCredential,
PTimeStamp  ptsExpiry 
)
static
Here is the call graph for this function:

◆ ntlm_CompleteAuthToken()

static SECURITY_STATUS SEC_ENTRY ntlm_CompleteAuthToken ( PCtxtHandle  phContext,
PSecBufferDesc  pToken 
)
static
Here is the call graph for this function:

◆ ntlm_computeMicValue()

SECURITY_STATUS ntlm_computeMicValue ( NTLM_CONTEXT *  ntlm,
SecBuffer *  micvalue 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_computeProofValue()

SECURITY_STATUS ntlm_computeProofValue ( NTLM_CONTEXT *  ntlm,
SecBuffer *  ntproof 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_ContextFree()

static void ntlm_ContextFree ( NTLM_CONTEXT *  context)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_ContextNew()

static NTLM_CONTEXT* ntlm_ContextNew ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_DecryptMessage()

static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage ( PCtxtHandle  phContext,
PSecBufferDesc  pMessage,
ULONG  MessageSeqNo,
PULONG  pfQOP 
)
static
Here is the call graph for this function:

◆ ntlm_DeleteSecurityContext()

static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext ( PCtxtHandle  phContext)
static
Here is the call graph for this function:

◆ ntlm_EncryptMessage()

static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage ( PCtxtHandle  phContext,
ULONG  fQOP,
PSecBufferDesc  pMessage,
ULONG  MessageSeqNo 
)
static
Here is the call graph for this function:

◆ ntlm_FreeCredentialsHandle()

static SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle ( PCredHandle  phCredential)
static
Here is the call graph for this function:

◆ ntlm_ImpersonateSecurityContext()

static SECURITY_STATUS SEC_ENTRY ntlm_ImpersonateSecurityContext ( PCtxtHandle  phContext)
static

◆ ntlm_InitializeSecurityContextA()

static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA ( PCredHandle  phCredential,
PCtxtHandle  phContext,
SEC_CHAR pszTargetName,
ULONG  fContextReq,
ULONG  Reserved1,
ULONG  TargetDataRep,
PSecBufferDesc  pInput,
ULONG  Reserved2,
PCtxtHandle  phNewContext,
PSecBufferDesc  pOutput,
PULONG  pfContextAttr,
PTimeStamp  ptsExpiry 
)
static

◆ ntlm_InitializeSecurityContextW()

static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW ( PCredHandle  phCredential,
PCtxtHandle  phContext,
SEC_WCHAR pszTargetName,
ULONG  fContextReq,
ULONG  Reserved1,
ULONG  TargetDataRep,
PSecBufferDesc  pInput,
ULONG  Reserved2,
PCtxtHandle  phNewContext,
PSecBufferDesc  pOutput,
PULONG  pfContextAttr,
PTimeStamp  ptsExpiry 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_MakeSignature()

static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature ( PCtxtHandle  phContext,
ULONG  fQOP,
PSecBufferDesc  pMessage,
ULONG  MessageSeqNo 
)
static

◆ ntlm_QueryContextAttributesA()

static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA ( PCtxtHandle  phContext,
ULONG  ulAttribute,
void *  pBuffer 
)
static
Here is the call graph for this function:

◆ ntlm_QueryContextAttributesW()

static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW ( PCtxtHandle  phContext,
ULONG  ulAttribute,
void *  pBuffer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_QueryCredentialsAttributesA()

static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA ( PCredHandle  phCredential,
ULONG  ulAttribute,
void *  pBuffer 
)
static
Here is the call graph for this function:

◆ ntlm_QueryCredentialsAttributesW()

static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW ( PCredHandle  phCredential,
ULONG  ulAttribute,
void *  pBuffer 
)
static
Here is the caller graph for this function:

◆ ntlm_RevertSecurityContext()

static SECURITY_STATUS SEC_ENTRY ntlm_RevertSecurityContext ( PCtxtHandle  phContext)
static

◆ ntlm_SetContextAttributesA()

static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesA ( PCtxtHandle  phContext,
ULONG  ulAttribute,
void *  pBuffer,
ULONG  cbBuffer 
)
static
Here is the call graph for this function:

◆ ntlm_SetContextAttributesW()

static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesW ( PCtxtHandle  phContext,
ULONG  ulAttribute,
void *  pBuffer,
ULONG  cbBuffer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_SetContextServicePrincipalNameW()

static int ntlm_SetContextServicePrincipalNameW ( NTLM_CONTEXT *  context,
LPWSTR  ServicePrincipalName 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_SetContextTargetName()

static int ntlm_SetContextTargetName ( NTLM_CONTEXT *  context,
char *  TargetName 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_SetContextWorkstation()

static int ntlm_SetContextWorkstation ( NTLM_CONTEXT *  context,
char *  Workstation 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ntlm_VerifySignature()

static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature ( PCtxtHandle  phContext,
PSecBufferDesc  pMessage,
ULONG  MessageSeqNo,
PULONG  pfQOP 
)
static

Variable Documentation

◆ NTLM_PACKAGE_NAME

const char* NTLM_PACKAGE_NAME = "NTLM"
static

◆ NTLM_SecPkgInfoA

const SecPkgInfoA NTLM_SecPkgInfoA
Initial value:
= {
0x00082B37,
1,
0x000A,
0x00000B48,
"NTLM",
"NTLM Security Package"
}

◆ NTLM_SecPkgInfoW

const SecPkgInfoW NTLM_SecPkgInfoW
Initial value:
= {
0x00082B37,
1,
0x000A,
0x00000B48,
}

◆ NTLM_SecPkgInfoW_Comment

WCHAR NTLM_SecPkgInfoW_Comment[]
static
Initial value:
= {
'N', 'T', 'L', 'M', ' ', 'S', 'e', 'c', 'u', 'r', 'i',
't', 'y', ' ', 'P', 'a', 'c', 'k', 'a', 'g', 'e', '\0'
}

◆ NTLM_SecPkgInfoW_Name

WCHAR NTLM_SecPkgInfoW_Name[] = { 'N', 'T', 'L', 'M', '\0' }
static

◆ NTLM_SecurityFunctionTableA

◆ NTLM_SecurityFunctionTableW

ntlm_AcquireCredentialsHandleA
static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse, void *pvLogonID, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:317
ntlm_QueryCredentialsAttributesW
static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:365
ntlm_RevertSecurityContext
static SECURITY_STATUS SEC_ENTRY ntlm_RevertSecurityContext(PCtxtHandle phContext)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:956
ntlm_DecryptMessage
static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1058
ntlm_VerifySignature
static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1163
ntlm_EncryptMessage
static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:961
ntlm_InitializeSecurityContextA
static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:618
ntlm_DeleteSecurityContext
static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContext)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:659
NTLM_SecPkgInfoW_Name
static WCHAR NTLM_SecPkgInfoW_Name[]
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1241
ntlm_FreeCredentialsHandle
static SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(PCredHandle phCredential)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:349
ntlm_AcceptSecurityContext
static SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:386
ntlm_QueryContextAttributesA
static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:808
ntlm_SetContextAttributesA
static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:949
ntlm_InitializeSecurityContextW
static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:497
ntlm_QueryContextAttributesW
static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:714
ntlm_MakeSignature
static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1157
NTLM_SecPkgInfoW_Comment
static WCHAR NTLM_SecPkgInfoW_Comment[]
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1243
ntlm_AcquireCredentialsHandleW
static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse, void *pvLogonID, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:285
ntlm_ImpersonateSecurityContext
static SECURITY_STATUS SEC_ENTRY ntlm_ImpersonateSecurityContext(PCtxtHandle phContext)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:492
ntlm_QueryCredentialsAttributesA
static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:376
ntlm_CompleteAuthToken
static SECURITY_STATUS SEC_ENTRY ntlm_CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:639
NULL
if availableBytes return NULL
Definition: TPCircularBuffer.h:109