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
 

Functions

static int ntlm_SetContextWorkstation (NTLM_CONTEXT *context, char *Workstation)
 
static int ntlm_SetContextServicePrincipalNameW (NTLM_CONTEXT *context, LPWSTR ServicePrincipalName)
 
static int ntlm_SetContextServicePrincipalNameA (NTLM_CONTEXT *context, char *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

#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.

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

Function Documentation

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:

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:

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:

static SECURITY_STATUS SEC_ENTRY ntlm_CompleteAuthToken ( PCtxtHandle  phContext,
PSecBufferDesc  pToken 
)
static

Here is the call graph for this function:

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:

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:

static void ntlm_ContextFree ( NTLM_CONTEXT *  context)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static NTLM_CONTEXT* ntlm_ContextNew ( void  )
static

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext ( PCtxtHandle  phContext)
static

Here is the call graph for this function:

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

Here is the call graph for this function:

static SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle ( PCredHandle  phCredential)
static

Here is the call graph for this function:

static SECURITY_STATUS SEC_ENTRY ntlm_ImpersonateSecurityContext ( PCtxtHandle  phContext)
static
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
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:

static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature ( PCtxtHandle  phContext,
ULONG  fQOP,
PSecBufferDesc  pMessage,
ULONG  MessageSeqNo 
)
static
static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA ( PCtxtHandle  phContext,
ULONG  ulAttribute,
void pBuffer 
)
static

Here is the call graph for this function:

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:

static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA ( PCredHandle  phCredential,
ULONG  ulAttribute,
void pBuffer 
)
static

Here is the call graph for this function:

static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW ( PCredHandle  phCredential,
ULONG  ulAttribute,
void pBuffer 
)
static

Here is the caller graph for this function:

static SECURITY_STATUS SEC_ENTRY ntlm_RevertSecurityContext ( PCtxtHandle  phContext)
static
static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesA ( PCtxtHandle  phContext,
ULONG  ulAttribute,
void pBuffer,
ULONG  cbBuffer 
)
static

Here is the call graph for this function:

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:

static int ntlm_SetContextServicePrincipalNameA ( NTLM_CONTEXT *  context,
char *  ServicePrincipalName 
)
static

Here is the call graph for this function:

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:

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:

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:

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

Variable Documentation

const char* NTLM_PACKAGE_NAME = "NTLM"
static
const SecPkgInfoA NTLM_SecPkgInfoA
Initial value:
=
{
0x00082B37,
1,
0x000A,
0x00000B48,
"NTLM",
"NTLM Security Package"
}
const SecPkgInfoW NTLM_SecPkgInfoW
Initial value:
=
{
0x00082B37,
1,
0x000A,
0x00000B48,
}
static WCHAR NTLM_SecPkgInfoW_Name[]
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1248
static WCHAR NTLM_SecPkgInfoW_Comment[]
Definition: winpr/libwinpr/sspi/NTLM/ntlm.c:1250
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'
}
WCHAR NTLM_SecPkgInfoW_Name[] = { 'N', 'T', 'L', 'M', '\0' }
static
const SecurityFunctionTableA NTLM_SecurityFunctionTableA
const SecurityFunctionTableW NTLM_SecurityFunctionTableW