libwinpr-sspi: data type cleanup
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 22 May 2012 00:39:45 +0000 (20:39 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 22 May 2012 00:39:45 +0000 (20:39 -0400)
include/winpr/sspi.h
include/winpr/wtypes.h
libfreerdp-core/rpc.c
libfreerdp-core/rpc.h
winpr/sspi/Kerberos/kerberos.c
winpr/sspi/NTLM/ntlm.c
winpr/sspi/Negotiate/negotiate.c
winpr/sspi/credssp.c
winpr/sspi/sspi.c

index 5be7642..60b9124 100644 (file)
 #ifndef FREERDP_SSPI_H
 #define FREERDP_SSPI_H
 
+#include "config.h"
+
+//#define NATIVE_SSPI
+
 #include <wchar.h>
 #include <winpr/windows.h>
 
-#include <freerdp/api.h>
+#include <winpr/winpr.h>
 #include <freerdp/types.h>
 
 #ifdef _WIN32
@@ -34,7 +38,7 @@
 #ifdef NATIVE_SSPI
 #define SECURITY_WIN32
 #include <sspi.h>
-#pragma comment(lib, "secur32.lib")
+#include <security.h>
 #else
 #define FREERDP_SSPI
 #define SEC_ENTRY __stdcall
@@ -100,6 +104,8 @@ typedef SecPkgInfoW* PSecPkgInfoW;
 #define PSecPkgInfo PSecPkgInfoA
 #endif
 
+#define NTLMSP_NAME    _T("NTLM")
+
 #endif
 
 #define SECPKG_ID_NONE                         0xFFFF
@@ -647,7 +653,7 @@ typedef CtxtHandle* PCtxtHandle;
 
 struct _SecBuffer
 {
-       uint32 cbBuffer;
+       ULONG cbBuffer;
        uint32 BufferType;
        void* pvBuffer;
 };
@@ -676,8 +682,8 @@ typedef SECURITY_STATUS (SEC_ENTRY * ENUMERATE_SECURITY_PACKAGES_FN_W)(uint32* p
 #define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_A
 #endif
 
-typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_A)(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
-typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
+typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_A)(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer);
+typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer);
 
 #ifdef UNICODE
 #define QueryCredentialsAttributes QueryCredentialsAttributesW
@@ -688,10 +694,10 @@ typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(PCredHan
 #endif
 
 typedef SECURITY_STATUS (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_A)(LPSTR pszPrincipal, LPSTR pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
 typedef SECURITY_STATUS (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_W)(LPWSTR pszPrincipal, LPWSTR pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
 
 #ifdef UNICODE
@@ -705,13 +711,13 @@ typedef SECURITY_STATUS (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_W)(LPWSTR psz
 typedef SECURITY_STATUS (SEC_ENTRY * FREE_CREDENTIALS_HANDLE_FN)(PCredHandle phCredential);
 
 typedef SECURITY_STATUS (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_A)(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsExpiry);
+               SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry);
 typedef SECURITY_STATUS (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_W)(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsExpiry);
+               SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry);
 
 #ifdef UNICODE
 #define InitializeSecurityContext InitializeSecurityContextW
@@ -722,8 +728,8 @@ typedef SECURITY_STATUS (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_W)(PCredHand
 #endif
 
 typedef SECURITY_STATUS (SEC_ENTRY * ACCEPT_SECURITY_CONTEXT_FN)(PCredHandle phCredential, PCtxtHandle phContext,
-               PSecBufferDesc pInput, uint32 fContextReq, uint32 TargetDataRep, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsTimeStamp);
+               PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp);
 
 typedef SECURITY_STATUS (SEC_ENTRY * COMPLETE_AUTH_TOKEN_FN)(PCtxtHandle phContext, PSecBufferDesc pToken);
 
@@ -731,8 +737,8 @@ typedef SECURITY_STATUS (SEC_ENTRY * DELETE_SECURITY_CONTEXT_FN)(PCtxtHandle phC
 
 typedef SECURITY_STATUS (SEC_ENTRY * APPLY_CONTROL_TOKEN_FN)(PCtxtHandle phContext, PSecBufferDesc pInput);
 
-typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer);
-typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer);
+typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer);
+typedef SECURITY_STATUS (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer);
 
 #ifdef UNICODE
 #define QueryContextAttributes QueryContextAttributesW
@@ -746,9 +752,9 @@ typedef SECURITY_STATUS (SEC_ENTRY * IMPERSONATE_SECURITY_CONTEXT_FN)(PCtxtHandl
 
 typedef SECURITY_STATUS (SEC_ENTRY * REVERT_SECURITY_CONTEXT_FN)(PCtxtHandle phContext);
 
-typedef SECURITY_STATUS (SEC_ENTRY * MAKE_SIGNATURE_FN)(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
+typedef SECURITY_STATUS (SEC_ENTRY * MAKE_SIGNATURE_FN)(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo);
 
-typedef SECURITY_STATUS (SEC_ENTRY * VERIFY_SIGNATURE_FN)(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
+typedef SECURITY_STATUS (SEC_ENTRY * VERIFY_SIGNATURE_FN)(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
 
 typedef SECURITY_STATUS (SEC_ENTRY * FREE_CONTEXT_BUFFER_FN)(void* pvContextBuffer);
 
@@ -791,12 +797,12 @@ typedef SECURITY_STATUS (SEC_ENTRY * ADD_CREDENTIALS_FN_W)(PCredHandle hCredenti
 
 typedef SECURITY_STATUS (SEC_ENTRY * QUERY_SECURITY_CONTEXT_TOKEN_FN)(PCtxtHandle phContext, void* phToken);
 
-typedef SECURITY_STATUS (SEC_ENTRY * ENCRYPT_MESSAGE_FN)(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
+typedef SECURITY_STATUS (SEC_ENTRY * ENCRYPT_MESSAGE_FN)(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo);
 
-typedef SECURITY_STATUS (SEC_ENTRY * DECRYPT_MESSAGE_FN)(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
+typedef SECURITY_STATUS (SEC_ENTRY * DECRYPT_MESSAGE_FN)(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
 
-typedef SECURITY_STATUS (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer);
-typedef SECURITY_STATUS (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer);
+typedef SECURITY_STATUS (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer, ULONG cbBuffer);
+typedef SECURITY_STATUS (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer, ULONG cbBuffer);
 
 #ifdef UNICODE
 #define SetContextAttributes SetContextAttributesW
@@ -891,72 +897,72 @@ typedef SecurityFunctionTableW* PSecurityFunctionTableW;
 
 /* Package Management */
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(uint32* pcPackages, PSecPkgInfoA* ppPackageInfo);
-FREERDP_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(uint32* pcPackages, PSecPkgInfoW* ppPackageInfo);
-FREERDP_API SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceA(void);
-FREERDP_API SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceW(void);
-FREERDP_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo);
-FREERDP_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo);
+WINPR_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(uint32* pcPackages, PSecPkgInfoA* ppPackageInfo);
+WINPR_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(uint32* pcPackages, PSecPkgInfoW* ppPackageInfo);
+WINPR_API SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceA(void);
+WINPR_API SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceW(void);
+WINPR_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo);
+WINPR_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo);
 
 /* Credential Management */
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+WINPR_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
-FREERDP_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+WINPR_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext, uint32 fFlags, PSecBuffer pPackedContext, void* pToken);
-FREERDP_API SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(PCredHandle phCredential);
+WINPR_API SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext, uint32 fFlags, PSecBuffer pPackedContext, void* pToken);
+WINPR_API SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(PCredHandle phCredential);
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
-FREERDP_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
+WINPR_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
+WINPR_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR* pszPackage, PSecBuffer pPackedContext, void* pToken, PCtxtHandle phContext);
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
-FREERDP_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer);
+WINPR_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer);
+WINPR_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer);
 
 /* Context Management */
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
-               PSecBufferDesc pInput, uint32 fContextReq, uint32 TargetDataRep, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, TimeStamp* ptsTimeStamp);
-
-FREERDP_API SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput);
-FREERDP_API SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken);
-FREERDP_API SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext);
-FREERDP_API SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void* pvContextBuffer);
-FREERDP_API SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext);
-
-FREERDP_API SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry);
-FREERDP_API SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry);
-
-FREERDP_API SECURITY_STATUS SEC_ENTRY QueryContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer);
-FREERDP_API SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext, void* phToken);
-FREERDP_API SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer);
-FREERDP_API SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext);
+WINPR_API SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
+               PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp);
+
+WINPR_API SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput);
+WINPR_API SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken);
+WINPR_API SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext);
+WINPR_API SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void* pvContextBuffer);
+WINPR_API SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext);
+
+WINPR_API SECURITY_STATUS SEC_ENTRY 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);
+WINPR_API SECURITY_STATUS SEC_ENTRY 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);
+
+WINPR_API SECURITY_STATUS SEC_ENTRY QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer);
+WINPR_API SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext, void* phToken);
+WINPR_API SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer, ULONG cbBuffer);
+WINPR_API SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext);
 
 /* Message Support */
 
-FREERDP_API SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
-FREERDP_API SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
-FREERDP_API SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo);
-FREERDP_API SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP);
+WINPR_API SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
+WINPR_API SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo);
+WINPR_API SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo);
+WINPR_API SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
 
 #endif
 
 /* Custom API */
 
-FREERDP_API void sspi_GlobalInit();
-FREERDP_API void sspi_GlobalFinish();
+WINPR_API void sspi_GlobalInit();
+WINPR_API void sspi_GlobalFinish();
 
-FREERDP_API void sspi_SecBufferAlloc(PSecBuffer SecBuffer, size_t size);
-FREERDP_API void sspi_SecBufferFree(PSecBuffer SecBuffer);
+WINPR_API void sspi_SecBufferAlloc(PSecBuffer SecBuffer, size_t size);
+WINPR_API void sspi_SecBufferFree(PSecBuffer SecBuffer);
 
 #endif /* FREERDP_SSPI_H */
index 3df5897..af905f8 100644 (file)
@@ -116,6 +116,12 @@ typedef struct _GUID
        BYTE Data4[8];
 } GUID, UUID, *PGUID;
 
+typedef struct _LUID
+{
+       DWORD LowPart;
+       LONG  HighPart;
+} LUID, *PLUID;
+
 #ifdef UNICODE
 #define _T(x)  L ## x
 #else
index f36b74d..aacc89c 100644 (file)
@@ -29,8 +29,6 @@
 
 #include "rpc.h"
 
-#define NTLM_PACKAGE_NAME      _T("NTLM")
-
 boolean ntlm_client_init(rdpNtlm* ntlm, boolean confidentiality, char* user, char* domain, char* password)
 {
        size_t size;
@@ -40,7 +38,24 @@ boolean ntlm_client_init(rdpNtlm* ntlm, boolean confidentiality, char* user, cha
 
        ntlm->confidentiality = confidentiality;
 
+#ifdef NATIVE_SSPI
+       {
+               HMODULE hSSPI;
+               INIT_SECURITY_INTERFACE InitSecurityInterface;
+               PSecurityFunctionTable pSecurityInterface = NULL;
+
+               hSSPI = LoadLibrary(_T("secur32.dll"));
+
+#ifdef UNICODE
+               InitSecurityInterface = (INIT_SECURITY_INTERFACE) GetProcAddress(hSSPI, "InitSecurityInterfaceW");
+#else
+               InitSecurityInterface = (INIT_SECURITY_INTERFACE) GetProcAddress(hSSPI, "InitSecurityInterfaceA");
+#endif
+               ntlm->table = (*InitSecurityInterface)();
+       }
+#else
        ntlm->table = InitSecurityInterface();
+#endif
 
        ntlm->identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
 
@@ -61,7 +76,7 @@ boolean ntlm_client_init(rdpNtlm* ntlm, boolean confidentiality, char* user, cha
        ntlm->identity.Password = (uint16*) freerdp_uniconv_out(ntlm->uniconv, (char*) password, &size);
        ntlm->identity.PasswordLength = (uint32) size;
 
-       status = QuerySecurityPackageInfo(NTLM_PACKAGE_NAME, &ntlm->pPackageInfo);
+       status = ntlm->table->QuerySecurityPackageInfo(NTLMSP_NAME, &ntlm->pPackageInfo);
 
        if (status != SEC_E_OK)
        {
@@ -71,7 +86,7 @@ boolean ntlm_client_init(rdpNtlm* ntlm, boolean confidentiality, char* user, cha
 
        ntlm->cbMaxToken = ntlm->pPackageInfo->cbMaxToken;
 
-       status = ntlm->table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME,
+       status = ntlm->table->AcquireCredentialsHandle(NULL, NTLMSP_NAME,
                        SECPKG_CRED_OUTBOUND, NULL, &ntlm->identity, NULL, NULL, &ntlm->credentials, &ntlm->expiration);
 
        if (status != SEC_E_OK)
@@ -145,8 +160,8 @@ boolean ntlm_authenticate(rdpNtlm* ntlm)
 
 void ntlm_client_uninit(rdpNtlm* ntlm)
 {
-       FreeCredentialsHandle(&ntlm->credentials);
-       FreeContextBuffer(ntlm->pPackageInfo);
+       ntlm->table->FreeCredentialsHandle(&ntlm->credentials);
+       ntlm->table->FreeContextBuffer(ntlm->pPackageInfo);
 }
 
 rdpNtlm* ntlm_new()
index ff9f2db..518473e 100644 (file)
@@ -533,7 +533,7 @@ struct rdp_ntlm
        UNICONV* uniconv;
        CtxtHandle context;
        uint32 cbMaxToken;
-       uint32 fContextReq;
+       ULONG fContextReq;
        uint32 pfContextAttr;
        TimeStamp expiration;
        PSecBuffer pBuffer;
index 7f0aaf1..9a3294a 100644 (file)
@@ -308,15 +308,15 @@ void kerberos_ContextFree(KRB_CONTEXT* krb_ctx)
 }
 
 SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
-               void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry)
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
+               void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        return SEC_E_OK;
 }
 
 SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
-               void* pvGetKeyArgument, PCredHandle phCredential, TimeStamp* ptsExpiry)
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
+               void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        CREDENTIALS* credentials;
        SEC_WINNT_AUTH_IDENTITY* identity;
@@ -354,12 +354,12 @@ SECURITY_STATUS SEC_ENTRY kerberos_FreeCredentialsHandle(PCredHandle phCredentia
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
        {
@@ -426,17 +426,17 @@ void krb_SetContextIdentity(KRB_CONTEXT* context, SEC_WINNT_AUTH_IDENTITY* ident
 }
 
 SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        return SEC_E_OK;
 }
 
 SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        KRB_CONTEXT* krb_ctx;
        //SECURITY_STATUS status;
@@ -490,7 +490,7 @@ PCtxtHandle krbctx_client_init(rdpSettings* settings, SEC_WINNT_AUTH_IDENTITY* i
        KDCENTRY* kdclist;
        KDCENTRY* entry;
        KRB_CONTEXT* krb_ctx;
-       uint32 fContextReq;
+       ULONG fContextReq;
        uint32 pfContextAttr;
        TimeStamp expiration;
 
@@ -1174,12 +1174,12 @@ void krb_free_krb_error(KrbERROR* krb_err)
        }
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesW(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        if (!phContext)
                return SEC_E_INVALID_HANDLE;
@@ -1202,22 +1202,22 @@ SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(PCtxtHandle phContext
        return SEC_E_UNSUPPORTED_FUNCTION;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 {
        return SEC_E_OK;
 }
index 6b4b538..f6643b0 100644 (file)
@@ -139,7 +139,7 @@ void ntlm_ContextFree(NTLM_CONTEXT* context)
 }
 
 SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        CREDENTIALS* credentials;
@@ -174,7 +174,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal
 }
 
 SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        CREDENTIALS* credentials;
@@ -225,7 +225,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(PCredHandle phCredential)
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
        {
@@ -243,7 +243,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW(PCredHandle phCredent
        return SEC_E_UNSUPPORTED_FUNCTION;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
        {
@@ -265,8 +265,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(PCredHandle phCredent
  * @see http://msdn.microsoft.com/en-us/library/windows/desktop/aa374707
  */
 SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
-               PSecBufferDesc pInput, uint32 fContextReq, uint32 TargetDataRep, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsTimeStamp)
+               PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
 {
        NTLM_CONTEXT* context;
        SECURITY_STATUS status;
@@ -368,9 +368,9 @@ SECURITY_STATUS SEC_ENTRY ntlm_ImpersonateSecurityContext(PCtxtHandle phContext)
 }
 
 SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        return SEC_E_OK;
 }
@@ -379,9 +379,9 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(PCredHandle phCredenti
  * @see http://msdn.microsoft.com/en-us/library/windows/desktop/aa375512%28v=vs.85%29.aspx
  */
 SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        NTLM_CONTEXT* context;
        SECURITY_STATUS status;
@@ -492,12 +492,12 @@ SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContext)
 
 /* http://msdn.microsoft.com/en-us/library/windows/desktop/aa379337/ */
 
-SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        if (!phContext)
                return SEC_E_INVALID_HANDLE;
@@ -525,16 +525,16 @@ SECURITY_STATUS SEC_ENTRY ntlm_RevertSecurityContext(PCtxtHandle phContext)
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        int index;
        int length;
        void* data;
        HMAC_CTX hmac;
-       uint8 digest[16];
-       uint8 checksum[8];
-       uint8* signature;
-       uint32 version = 1;
+       BYTE digest[16];
+       BYTE checksum[8];
+       BYTE* signature;
+       ULONG version = 1;
        NTLM_CONTEXT* context;
        PSecBuffer data_buffer = NULL;
        PSecBuffer signature_buffer = NULL;
@@ -607,7 +607,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, uint32 fQOP
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 {
        int index;
        int length;
@@ -684,12 +684,12 @@ SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSecBufferD
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 {
        return SEC_E_OK;
 }
index 1ca08b1..4ff422a 100644 (file)
@@ -92,24 +92,21 @@ void negotiate_SetContextIdentity(NEGOTIATE_CONTEXT* context, SEC_WINNT_AUTH_IDE
 }
 
 SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        return SEC_E_OK;
 }
 
 SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        NEGOTIATE_CONTEXT* context;
-       //SECURITY_STATUS status;
        CREDENTIALS* credentials;
-       //PSecBuffer input_SecBuffer;
        PSecBuffer output_SecBuffer;
-       //KrbTGTREQ krb_tgtreq;
 
        context = sspi_SecureHandleGetLowerPointer(phContext);
 
@@ -117,14 +114,14 @@ SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextA(PCredHandle phCre
        {
                context = negotiate_ContextNew();
 
-               credentials = (CREDENTIALS*)     sspi_SecureHandleGetLowerPointer(phCredential);
+               credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
                negotiate_SetContextIdentity(context, &credentials->identity);
 
                sspi_SecureHandleSetLowerPointer(phNewContext, context);
                sspi_SecureHandleSetUpperPointer(phNewContext, (void*) NEGOTIATE_PACKAGE_NAME);
        }
 
-       if((!pInput) && (context->state == NEGOTIATE_STATE_INITIAL))
+       if ((!pInput) && (context->state == NEGOTIATE_STATE_INITIAL))
        {
                if (!pOutput)
                        return SEC_E_INVALID_TOKEN;
@@ -166,7 +163,7 @@ void negotiate_ContextFree(NEGOTIATE_CONTEXT* context)
        free(context);
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        if (!phContext)
                return SEC_E_INVALID_HANDLE;
@@ -190,14 +187,14 @@ SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributes(PCtxtHandle phContext
 }
 
 SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        return SEC_E_OK;
 }
 
 SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        CREDENTIALS* credentials;
@@ -219,12 +216,12 @@ SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleA(SEC_CHAR* pszPrinc
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
        {
@@ -259,22 +256,22 @@ SECURITY_STATUS SEC_ENTRY negotiate_FreeCredentialsHandle(PCredHandle phCredenti
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY negotiate_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY negotiate_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY negotiate_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY negotiate_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY negotiate_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
 {
        return SEC_E_OK;
 }
index 4d99afd..70ce381 100644 (file)
@@ -149,12 +149,10 @@ int credssp_ntlm_server_init(rdpCredssp* credssp)
        return 1;
 }
 
-#define NTLM_PACKAGE_NAME      _T("NTLM")
-
 int credssp_client_authenticate(rdpCredssp* credssp)
 {
        uint32 cbMaxToken;
-       uint32 fContextReq;
+       ULONG fContextReq;
        uint32 pfContextAttr;
        SECURITY_STATUS status;
        CredHandle credentials;
@@ -174,9 +172,26 @@ int credssp_client_authenticate(rdpCredssp* credssp)
        if (credssp_ntlm_client_init(credssp) == 0)
                return 0;
 
+#ifdef NATIVE_SSPI
+       {
+               HMODULE hSSPI;
+               INIT_SECURITY_INTERFACE InitSecurityInterface;
+               PSecurityFunctionTable pSecurityInterface = NULL;
+
+               hSSPI = LoadLibrary(_T("secur32.dll"));
+
+#ifdef UNICODE
+               InitSecurityInterface = (INIT_SECURITY_INTERFACE) GetProcAddress(hSSPI, "InitSecurityInterfaceW");
+#else
+               InitSecurityInterface = (INIT_SECURITY_INTERFACE) GetProcAddress(hSSPI, "InitSecurityInterfaceA");
+#endif
+               credssp->table = (*InitSecurityInterface)();
+       }
+#else
        credssp->table = InitSecurityInterface();
+#endif
 
-       status = QuerySecurityPackageInfo(NTLM_PACKAGE_NAME, &pPackageInfo);
+       status = credssp->table->QuerySecurityPackageInfo(NTLMSP_NAME, &pPackageInfo);
 
        if (status != SEC_E_OK)
        {
@@ -186,7 +201,7 @@ int credssp_client_authenticate(rdpCredssp* credssp)
 
        cbMaxToken = pPackageInfo->cbMaxToken;
 
-       status = credssp->table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME,
+       status = credssp->table->AcquireCredentialsHandle(NULL, NTLMSP_NAME,
                        SECPKG_CRED_OUTBOUND, NULL, &credssp->identity, NULL, NULL, &credentials, &expiration);
 
        if (status != SEC_E_OK)
@@ -216,7 +231,7 @@ int credssp_client_authenticate(rdpCredssp* credssp)
 
                status = credssp->table->InitializeSecurityContext(&credentials,
                                (have_context) ? &credssp->context : NULL,
-                               NULL, fContextReq, 0, SECURITY_NATIVE_DREP,
+                               NULL, fContextReq, 0, SECURITY_NETWORK_DREP,
                                (have_input_buffer) ? &input_buffer_desc : NULL,
                                0, &credssp->context, &output_buffer_desc, &pfContextAttr, &expiration);
 
@@ -246,15 +261,15 @@ int credssp_client_authenticate(rdpCredssp* credssp)
                                SecBufferDesc Message;
                                SECURITY_STATUS encrypt_status;
 
-                               Buffers[0].BufferType = SECBUFFER_DATA; /* TLS Public Key */
-                               Buffers[1].BufferType = SECBUFFER_TOKEN; /* Signature */
+                               Buffers[0].BufferType = SECBUFFER_TOKEN; /* Signature */
+                               Buffers[1].BufferType = SECBUFFER_DATA; /* TLS Public Key */
 
-                               Buffers[0].cbBuffer = credssp->PublicKey.cbBuffer;
-                               Buffers[0].pvBuffer = xmalloc(Buffers[0].cbBuffer);
-                               memcpy(Buffers[0].pvBuffer, credssp->PublicKey.pvBuffer, Buffers[0].cbBuffer);
+                               Buffers[0].cbBuffer = credssp->ContextSizes.cbMaxSignature;
+                               Buffers[0].pvBuffer = xzalloc(Buffers[0].cbBuffer);
 
-                               Buffers[1].cbBuffer = credssp->ContextSizes.cbMaxSignature;
-                               Buffers[1].pvBuffer = xzalloc(Buffers[1].cbBuffer);
+                               Buffers[1].cbBuffer = credssp->PublicKey.cbBuffer;
+                               Buffers[1].pvBuffer = xmalloc(Buffers[1].cbBuffer);
+                               memcpy(Buffers[1].pvBuffer, credssp->PublicKey.pvBuffer, Buffers[1].cbBuffer);
 
                                Message.cBuffers = 2;
                                Message.ulVersion = SECBUFFER_VERSION;
@@ -270,9 +285,18 @@ int credssp_client_authenticate(rdpCredssp* credssp)
                                        return 0;
                                }
 
+#ifdef WITH_DEBUG_CREDSSP
+                               printf("CredSSP.Signature: (%d)\n", Buffers[0].cbBuffer);
+                               freerdp_hexdump((uint8*) Buffers[0].pvBuffer, Buffers[0].cbBuffer);
+                               printf("CredSSP.PublicKey: (%d)\n", credssp->PublicKey.cbBuffer);
+                               freerdp_hexdump((uint8*) credssp->PublicKey.pvBuffer, credssp->PublicKey.cbBuffer);
+                               printf("CredSSP.PublicKey (encrypted) (%d):\n", Buffers[1].cbBuffer);
+                               freerdp_hexdump((uint8*) Buffers[1].pvBuffer, Buffers[1].cbBuffer);
+#endif
+
                                p = (uint8*) credssp->pubKeyAuth.pvBuffer;
-                               memcpy(p, Buffers[1].pvBuffer, Buffers[1].cbBuffer); /* Message Signature */
-                               memcpy(&p[Buffers[1].cbBuffer], Buffers[0].pvBuffer, Buffers[0].cbBuffer); /* Encrypted Public Key */
+                               memcpy(p, Buffers[0].pvBuffer, Buffers[0].cbBuffer); /* Message Signature */
+                               memcpy(&p[Buffers[0].cbBuffer], Buffers[1].pvBuffer, Buffers[1].cbBuffer); /* Encrypted Public Key */
                                xfree(Buffers[0].pvBuffer);
                                xfree(Buffers[1].pvBuffer);
                        }
@@ -354,8 +378,8 @@ int credssp_client_authenticate(rdpCredssp* credssp)
 
        /* Free resources */
 
-       FreeCredentialsHandle(&credentials);
-       FreeContextBuffer(pPackageInfo);
+       credssp->table->FreeCredentialsHandle(&credentials);
+       credssp->table->FreeContextBuffer(pPackageInfo);
 
        return 1;
 }
@@ -369,8 +393,8 @@ int credssp_client_authenticate(rdpCredssp* credssp)
 int credssp_server_authenticate(rdpCredssp* credssp)
 {
        uint32 cbMaxToken;
-       uint32 fContextReq;
-       uint32 pfContextAttr;
+       ULONG fContextReq;
+       ULONG pfContextAttr;
        SECURITY_STATUS status;
        CredHandle credentials;
        TimeStamp expiration;
@@ -389,9 +413,26 @@ int credssp_server_authenticate(rdpCredssp* credssp)
        if (credssp_ntlm_server_init(credssp) == 0)
                return 0;
 
+#ifdef NATIVE_SSPI
+       {
+               HMODULE hSSPI;
+               INIT_SECURITY_INTERFACE InitSecurityInterface;
+               PSecurityFunctionTable pSecurityInterface = NULL;
+
+               hSSPI = LoadLibrary(_T("secur32.dll"));
+
+#ifdef UNICODE
+               InitSecurityInterface = (INIT_SECURITY_INTERFACE) GetProcAddress(hSSPI, "InitSecurityInterfaceW");
+#else
+               InitSecurityInterface = (INIT_SECURITY_INTERFACE) GetProcAddress(hSSPI, "InitSecurityInterfaceA");
+#endif
+               credssp->table = (*InitSecurityInterface)();
+       }
+#else
        credssp->table = InitSecurityInterface();
+#endif
 
-       status = QuerySecurityPackageInfo(NTLM_PACKAGE_NAME, &pPackageInfo);
+       status = credssp->table->QuerySecurityPackageInfo(NTLMSP_NAME, &pPackageInfo);
 
        if (status != SEC_E_OK)
        {
@@ -401,7 +442,7 @@ int credssp_server_authenticate(rdpCredssp* credssp)
 
        cbMaxToken = pPackageInfo->cbMaxToken;
 
-       status = credssp->table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME,
+       status = credssp->table->AcquireCredentialsHandle(NULL, NTLMSP_NAME,
                        SECPKG_CRED_INBOUND, NULL, &credssp->identity, NULL, NULL, &credentials, &expiration);
 
        if (status != SEC_E_OK)
@@ -455,7 +496,7 @@ int credssp_server_authenticate(rdpCredssp* credssp)
 
                status = credssp->table->AcceptSecurityContext(&credentials,
                        have_context? &credssp->context: NULL,
-                       &input_buffer_desc, fContextReq, SECURITY_NATIVE_DREP, &credssp->context,
+                       &input_buffer_desc, fContextReq, SECURITY_NETWORK_DREP, &credssp->context,
                        &output_buffer_desc, &pfContextAttr, &expiration);
 
                if (input_buffer.pvBuffer != NULL)
@@ -568,7 +609,7 @@ int credssp_server_authenticate(rdpCredssp* credssp)
                }
        }
 
-       FreeContextBuffer(pPackageInfo);
+       credssp->table->FreeContextBuffer(pPackageInfo);
 
        return 1;
 }
@@ -621,7 +662,10 @@ SECURITY_STATUS credssp_verify_public_key_echo(rdpCredssp* credssp)
        status = credssp->table->DecryptMessage(&credssp->context, &Message, 0, &pfQOP);
 
        if (status != SEC_E_OK)
+       {
+               printf("DecryptMessage failure: 0x%08X\n", status);
                return status;
+       }
 
        public_key1 = (uint8*) credssp->PublicKey.pvBuffer;
        public_key2 = (uint8*) Buffers[1].pvBuffer;
index af6f8da..5ab2d4c 100644 (file)
@@ -519,7 +519,7 @@ void FreeContextBuffer_QuerySecurityPackageInfo(void* contextBuffer)
 /* Credential Management */
 
 SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        SECURITY_STATUS status;
@@ -538,7 +538,7 @@ SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC
 }
 
 SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
-               uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
+               ULONG fCredentialUse, PLUID pvLogonID, void* pAuthData, void* pGetKeyFn,
                void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        SECURITY_STATUS status;
@@ -595,7 +595,7 @@ SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR* pszPackage, PSecBuffe
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        SEC_WCHAR* Name;
        SECURITY_STATUS status;
@@ -619,7 +619,7 @@ SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential,
        return status;
 }
 
-SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
 {
        char* Name;
        SECURITY_STATUS status;
@@ -646,8 +646,8 @@ SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential,
 /* Context Management */
 
 SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
-               PSecBufferDesc pInput, uint32 fContextReq, uint32 TargetDataRep, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsTimeStamp)
+               PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
 {
        char* Name;
        SECURITY_STATUS status;
@@ -722,9 +722,9 @@ SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext)
 }
 
 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        SEC_CHAR* Name;
        SECURITY_STATUS status;
@@ -751,9 +751,9 @@ SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(PCredHandle phCredential, P
 }
 
 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
-               PSecBufferDesc pInput, uint32 Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, uint32* pfContextAttr, PTimeStamp ptsExpiry)
+               SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        SEC_CHAR* Name;
        SECURITY_STATUS status;
@@ -779,7 +779,7 @@ SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(PCredHandle phCredential, P
        return status;
 }
 
-SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        SEC_CHAR* Name;
        SECURITY_STATUS status;
@@ -803,7 +803,7 @@ SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext, uint32
        return status;
 }
 
-SECURITY_STATUS SEC_ENTRY QueryContextAttributesA(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer)
+SECURITY_STATUS SEC_ENTRY QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
 {
        SEC_CHAR* Name;
        SECURITY_STATUS status;
@@ -832,7 +832,7 @@ SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext, void*
        return SEC_E_OK;
 }
 
-SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, uint32 ulAttribute, void* pBuffer, uint32 cbBuffer)
+SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer, ULONG cbBuffer)
 {
        return SEC_E_OK;
 }
@@ -844,7 +844,7 @@ SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext)
 
 /* Message Support */
 
-SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 {
        char* Name;
        SECURITY_STATUS status;
@@ -868,7 +868,7 @@ SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, PSecBufferDesc p
        return status;
 }
 
-SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        char* Name;
        SECURITY_STATUS status;
@@ -892,7 +892,7 @@ SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, uint32 fQOP, PSe
        return status;
 }
 
-SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSecBufferDesc pMessage, uint32 MessageSeqNo)
+SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
 {
        char* Name;
        SECURITY_STATUS status;
@@ -916,7 +916,7 @@ SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, uint32 fQOP, PSec
        return status;
 }
 
-SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, uint32 MessageSeqNo, uint32* pfQOP)
+SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
 {
        char* Name;
        SECURITY_STATUS status;