21#include <winpr/config.h>
24#include <winpr/wtypes.h>
25#include <winpr/assert.h>
26#include <winpr/sspi.h>
27#include <winpr/tchar.h>
28#include <winpr/registry.h>
29#include <winpr/build-config.h>
30#include <winpr/asn1.h>
34#include "../NTLM/ntlm.h"
35#include "../NTLM/ntlm_export.h"
36#include "../Kerberos/kerberos.h"
39#define TAG WINPR_TAG("negotiate")
41static const char NEGO_REG_KEY[] =
42 "Software\\" WINPR_VENDOR_STRING
"\\" WINPR_PRODUCT_STRING
"\\SSPI\\Negotiate";
44static const char PACKAGE_NAME_DISABLE_ALL[] =
"none";
45static const char PACKAGE_NAME_NTLM[] =
"ntlm";
46static const char PACKAGE_NAME_KERBEROS[] =
"kerberos";
47static const char PACKAGE_NAME_KERBEROS_U2U[] =
"u2u";
77 "Microsoft Package Negotiator"
80static WCHAR NEGOTIATE_SecPkgInfoW_NameBuffer[32] = { 0 };
81static WCHAR NEGOTIATE_SecPkgInfoW_CommentBuffer[32] = { 0 };
88 NEGOTIATE_SecPkgInfoW_NameBuffer,
89 NEGOTIATE_SecPkgInfoW_CommentBuffer
92static const WinPrAsn1_OID spnego_OID = { 6, (BYTE*)
"\x2b\x06\x01\x05\x05\x02" };
94 (BYTE*)
"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x03" };
95static const WinPrAsn1_OID kerberos_OID = { 9, (BYTE*)
"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
97 (BYTE*)
"\x2a\x86\x48\x82\xf7\x12\x01\x02\x02" };
98static const WinPrAsn1_OID ntlm_OID = { 10, (BYTE*)
"\x2b\x06\x01\x04\x01\x82\x37\x02\x02\x0a" };
100static const WinPrAsn1_OID negoex_OID = { 10, (BYTE*)
"\x2b\x06\x01\x04\x01\x82\x37\x02\x02\x1e" };
103static const SecPkg SecPkgTable[] = {
104 { KERBEROS_SSP_NAME, &KERBEROS_SecurityFunctionTableA, &KERBEROS_SecurityFunctionTableW },
105 { KERBEROS_SSP_NAME, &KERBEROS_SecurityFunctionTableA, &KERBEROS_SecurityFunctionTableW },
106 { NTLM_SSP_NAME, &NTLM_SecurityFunctionTableA, &NTLM_SecurityFunctionTableW }
109static const Mech MechTable[] = {
110 { &kerberos_u2u_OID, &SecPkgTable[0], ISC_REQ_INTEGRITY | ISC_REQ_USE_SESSION_KEY, TRUE },
111 { &kerberos_OID, &SecPkgTable[1], ISC_REQ_INTEGRITY, TRUE },
112 { &ntlm_OID, &SecPkgTable[2], 0, FALSE },
115static const SecPkg SecPkgTable[] = { { NTLM_SSP_NAME, &NTLM_SecurityFunctionTableA,
116 &NTLM_SecurityFunctionTableW } };
118static const Mech MechTable[] = {
119 { &ntlm_OID, &SecPkgTable[0], 0, FALSE },
123static const size_t MECH_COUNT =
sizeof(MechTable) /
sizeof(Mech);
136 enum NegState negState;
144static const NegToken empty_neg_token = { NOSTATE, FALSE, { 0, NULL },
145 { 0, 0, NULL }, { 0, 0, NULL }, { 0, 0, NULL } };
151 WINPR_ASSERT(init_context);
157 if (init_context->spnego)
159 init_context->mechTypes.pvBuffer = malloc(init_context->mechTypes.cbBuffer);
160 if (!init_context->mechTypes.pvBuffer)
167 *context = *init_context;
174 WINPR_ASSERT(context);
176 if (context->mechTypes.pvBuffer)
177 free(context->mechTypes.pvBuffer);
181static const char* negotiate_mech_name(
const WinPrAsn1_OID* oid)
183 if (sspi_gss_oid_compare(oid, &spnego_OID))
184 return "SPNEGO (1.3.6.1.5.5.2)";
185 else if (sspi_gss_oid_compare(oid, &kerberos_u2u_OID))
186 return "Kerberos user to user (1.2.840.113554.1.2.2.3)";
187 else if (sspi_gss_oid_compare(oid, &kerberos_OID))
188 return "Kerberos (1.2.840.113554.1.2.2)";
189 else if (sspi_gss_oid_compare(oid, &kerberos_wrong_OID))
190 return "Kerberos [wrong OID] (1.2.840.48018.1.2.2)";
191 else if (sspi_gss_oid_compare(oid, &ntlm_OID))
192 return "NTLM (1.3.6.1.4.1.311.2.2.10)";
193 else if (sspi_gss_oid_compare(oid, &negoex_OID))
194 return "NegoEx (1.3.6.1.4.1.311.2.2.30)";
196 return "Unknown mechanism";
199static const Mech* negotiate_GetMechByOID(
const WinPrAsn1_OID* oid)
205 if (sspi_gss_oid_compare(&testOid, &kerberos_wrong_OID))
207 testOid.len = kerberos_OID.len;
208 testOid.data = kerberos_OID.data;
211 for (
size_t i = 0; i < MECH_COUNT; i++)
213 if (sspi_gss_oid_compare(&testOid, MechTable[i].oid))
214 return &MechTable[i];
219static PSecHandle negotiate_FindCredential(MechCred* creds,
const Mech* mech)
226 for (
size_t i = 0; i < MECH_COUNT; i++)
228 MechCred* cred = &creds[i];
230 if (cred->mech == mech)
241static BOOL negotiate_get_dword(HKEY hKey,
const char* subkey, DWORD* pdwValue)
245 DWORD dwSize =
sizeof(dwValue);
246 LONG rc = RegQueryValueExA(hKey, subkey, NULL, &dwType, (BYTE*)&dwValue, &dwSize);
248 if (rc != ERROR_SUCCESS)
250 if (dwType != REG_DWORD)
257static BOOL negotiate_get_config_from_auth_package_list(
void* pAuthData, BOOL* kerberos, BOOL* ntlm,
261 char* tok_ctx = NULL;
262 char* PackageList = NULL;
267 char* tok_ptr = strtok_s(PackageList,
",", &tok_ctx);
271 const char* PackageName = tok_ptr;
272 BOOL PackageInclude = TRUE;
274 if (PackageName[0] ==
'!')
276 PackageName = &PackageName[1];
277 PackageInclude = FALSE;
280 if (_stricmp(PackageName, PACKAGE_NAME_NTLM) == 0)
282 *ntlm = PackageInclude;
284 else if (_stricmp(PackageName, PACKAGE_NAME_KERBEROS) == 0)
286 *kerberos = PackageInclude;
288 else if (_stricmp(PackageName, PACKAGE_NAME_KERBEROS_U2U) == 0)
290 *u2u = PackageInclude;
292 else if (_stricmp(PackageName, PACKAGE_NAME_DISABLE_ALL) == 0)
298 if (PackageName != PackageList)
300 WLog_WARN(TAG,
"Special keyword '%s' not first in list, aborting", PackageName);
306 WLog_WARN(TAG,
"Unknown authentication package name: %s, ignoring", PackageName);
309 tok_ptr = strtok_s(NULL,
",", &tok_ctx);
318static BOOL negotiate_get_config(
void* pAuthData, BOOL* kerberos, BOOL* ntlm, BOOL* u2u)
323 WINPR_ASSERT(kerberos);
327#if !defined(WITH_KRB5_NO_NTLM_FALLBACK)
332#if defined(WITH_KRB5)
340 if (negotiate_get_config_from_auth_package_list(pAuthData, kerberos, ntlm, u2u))
345 rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, NEGO_REG_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
346 if (rc == ERROR_SUCCESS)
350 if (negotiate_get_dword(hKey, PACKAGE_NAME_KERBEROS, &dwValue))
351 *kerberos = (dwValue != 0) ? TRUE : FALSE;
353 if (negotiate_get_dword(hKey, PACKAGE_NAME_KERBEROS_U2U, &dwValue))
354 *u2u = (dwValue != 0) ? TRUE : FALSE;
356#if !defined(WITH_KRB5_NO_NTLM_FALLBACK)
357 if (negotiate_get_dword(hKey, PACKAGE_NAME_NTLM, &dwValue))
358 *ntlm = (dwValue != 0) ? TRUE : FALSE;
367static BOOL negotiate_write_neg_token(
PSecBuffer output_buffer, NegToken* token)
369 WINPR_ASSERT(output_buffer);
373 WinPrAsn1Encoder* enc = NULL;
380 enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
388 if (!WinPrAsn1EncAppContainer(enc, 0))
392 if (!WinPrAsn1EncOID(enc, &spnego_OID))
397 if (!WinPrAsn1EncContextualSeqContainer(enc, token->init ? 0 : 1))
400 WLog_DBG(TAG, token->init ?
"Writing negTokenInit..." :
"Writing negTokenResp...");
405 if (!WinPrAsn1EncContextualRawContent(enc, 0, &mechTypes))
407 WLog_DBG(TAG,
"\tmechTypes [0] (%li bytes)", token->mechTypes.cbBuffer);
410 else if (token->negState != NOSTATE)
412 if (!WinPrAsn1EncContextualEnumerated(enc, 0, token->negState))
414 WLog_DBG(TAG,
"\tnegState [0] (%d)", token->negState);
418 if (token->supportedMech.len)
420 if (!WinPrAsn1EncContextualOID(enc, 1, &token->supportedMech))
422 WLog_DBG(TAG,
"\tsupportedMech [1] (%s)", negotiate_mech_name(&token->supportedMech));
426 if (token->mechToken.cbBuffer)
428 if (WinPrAsn1EncContextualOctetString(enc, 2, &mechToken) == 0)
430 WLog_DBG(TAG,
"\tmechToken [2] (%li bytes)", token->mechToken.cbBuffer);
434 if (token->mic.cbBuffer)
436 if (WinPrAsn1EncContextualOctetString(enc, 3, &mechListMic) == 0)
438 WLog_DBG(TAG,
"\tmechListMIC [3] (%li bytes)", token->mic.cbBuffer);
442 if (!WinPrAsn1EncEndContainer(enc))
448 if (!WinPrAsn1EncEndContainer(enc))
452 if (!WinPrAsn1EncStreamSize(enc, &len) || len > output_buffer->cbBuffer)
455 if (len > UINT32_MAX)
458 Stream_StaticInit(&s, output_buffer->pvBuffer, len);
460 if (WinPrAsn1EncToStream(enc, &s))
462 output_buffer->cbBuffer = (UINT32)len;
467 WinPrAsn1Encoder_Free(&enc);
471static BOOL negotiate_read_neg_token(
PSecBuffer input, NegToken* token)
476 WinPrAsn1_tagId contextual = 0;
477 WinPrAsn1_tag tag = 0;
485 WinPrAsn1Decoder_InitMem(&dec, WINPR_ASN1_DER, input->pvBuffer, input->cbBuffer);
487 if (!WinPrAsn1DecPeekTag(&dec, &tag))
493 if (!WinPrAsn1DecReadApp(&dec, &tag, &dec2) || tag != 0)
498 if (!WinPrAsn1DecReadOID(&dec, &oid, FALSE))
501 if (!sspi_gss_oid_compare(&spnego_OID, &oid))
505 if (!WinPrAsn1DecReadContextualSequence(&dec, 0, &err, &dec2))
511 else if (!WinPrAsn1DecReadContextualSequence(&dec, 1, &err, &dec2))
515 WLog_DBG(TAG, token->init ?
"Reading negTokenInit..." :
"Reading negTokenResp...");
520 if (!WinPrAsn1DecReadContextualTag(&dec, &contextual, &dec2))
529 wStream s = WinPrAsn1DecGetStream(&dec2);
530 token->mechTypes.BufferType = SECBUFFER_TOKEN;
531 const size_t mlen = Stream_Length(&s);
532 if (mlen > UINT32_MAX)
534 token->mechTypes.cbBuffer = (UINT32)mlen;
535 token->mechTypes.pvBuffer = Stream_Buffer(&s);
536 WLog_DBG(TAG,
"\tmechTypes [0] (%li bytes)", token->mechTypes.cbBuffer);
541 WinPrAsn1_ENUMERATED rd = 0;
542 if (!WinPrAsn1DecReadEnumerated(&dec2, &rd))
547 case ACCEPT_COMPLETED:
548 case ACCEPT_INCOMPLETE:
553 WLog_ERR(TAG,
"Invalid negState enumeration value %d", rd);
557 token->negState = WINPR_ASSERTING_INT_CAST(
enum NegState, rd);
558 WLog_DBG(TAG,
"\tnegState [0] (%d)", rd);
565 if (!WinPrAsn1DecPeekTagAndLen(&dec2, &tag, &len) || (tag != ER_TAG_BIT_STRING))
567 WLog_DBG(TAG,
"\treqFlags [1] (%li bytes)", len);
572 if (!WinPrAsn1DecReadOID(&dec2, &token->supportedMech, FALSE))
574 WLog_DBG(TAG,
"\tsupportedMech [1] (%s)",
575 negotiate_mech_name(&token->supportedMech));
580 if (!WinPrAsn1DecReadOctetString(&dec2, &octet_string, FALSE))
582 if (octet_string.len > UINT32_MAX)
584 token->mechToken.cbBuffer = (UINT32)octet_string.len;
585 token->mechToken.pvBuffer = octet_string.data;
586 token->mechToken.BufferType = SECBUFFER_TOKEN;
587 WLog_DBG(TAG,
"\tmechToken [2] (%li bytes)", octet_string.len);
591 if (!WinPrAsn1DecReadOctetString(&dec2, &octet_string, FALSE))
593 if (octet_string.len > UINT32_MAX)
595 token->mic.cbBuffer = (UINT32)octet_string.len;
596 token->mic.pvBuffer = octet_string.data;
597 token->mic.BufferType = SECBUFFER_TOKEN;
598 WLog_DBG(TAG,
"\tmechListMIC [3] (%li bytes)", octet_string.len);
601 WLog_ERR(TAG,
"unknown contextual item %d", contextual);
604 }
while (WinPrAsn1DecPeekTag(&dec, &tag));
609static SECURITY_STATUS negotiate_mic_exchange(
NEGOTIATE_CONTEXT* context, NegToken* input_token,
610 NegToken* output_token,
PSecBuffer output_buffer)
613 SecBufferDesc mic_buffer_desc = { SECBUFFER_VERSION, 2, mic_buffers };
614 SECURITY_STATUS status = 0;
616 WINPR_ASSERT(context);
617 WINPR_ASSERT(input_token);
618 WINPR_ASSERT(output_token);
619 WINPR_ASSERT(context->mech);
620 WINPR_ASSERT(context->mech->pkg);
625 mic_buffers[0] = context->mechTypes;
628 if (input_token->mic.cbBuffer > 0)
630 mic_buffers[1] = input_token->mic;
632 status = table->VerifySignature(&context->sub_context, &mic_buffer_desc, 0, 0);
633 if (status != SEC_E_OK)
636 output_token->negState = ACCEPT_COMPLETED;
640 if (input_token->negState != ACCEPT_COMPLETED)
643 output_token->mic.BufferType = SECBUFFER_TOKEN;
646 output_token->mic.cbBuffer = output_buffer->cbBuffer - output_token->mechToken.cbBuffer;
647 output_token->mic.pvBuffer =
648 (BYTE*)output_buffer->pvBuffer + output_token->mechToken.cbBuffer;
650 mic_buffers[1] = output_token->mic;
652 status = table->MakeSignature(&context->sub_context, 0, &mic_buffer_desc, 0);
653 if (status != SEC_E_OK)
656 output_token->mic = mic_buffers[1];
660 const TCHAR* name = sspi_SecureHandleGetUpperPointer(&context->sub_context);
662 return SEC_E_INTERNAL_ERROR;
664 if (_tcsncmp(name, NTLM_SSP_NAME, ARRAYSIZE(NTLM_SSP_NAME)) == 0)
666 if (!ntlm_reset_cipher_state(&context->sub_context))
667 return SEC_E_INTERNAL_ERROR;
673static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
675 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
680 MechCred* creds = NULL;
683 NegToken input_token = empty_neg_token;
684 NegToken output_token = empty_neg_token;
689 SecBufferDesc mech_input = { SECBUFFER_VERSION, 2, mech_input_buffers };
690 SecBufferDesc mech_output = { SECBUFFER_VERSION, 1, &output_token.mechToken };
691 SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
692 SECURITY_STATUS sub_status = SEC_E_INTERNAL_ERROR;
693 WinPrAsn1Encoder* enc = NULL;
695 const Mech* mech = NULL;
697 if (!phCredential || !SecIsValidHandle(phCredential))
698 return SEC_E_NO_CREDENTIALS;
700 creds = sspi_SecureHandleGetLowerPointer(phCredential);
703 if (phContext && !phContext->dwLower && !phContext->dwUpper)
704 return SEC_E_INVALID_HANDLE;
706 context = sspi_SecureHandleGetLowerPointer(phContext);
710 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
711 bindings_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS);
714 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
718 enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
720 return SEC_E_INSUFFICIENT_MEMORY;
722 if (!WinPrAsn1EncSeqContainer(enc))
725 for (
size_t i = 0; i < MECH_COUNT; i++)
727 MechCred* cred = &creds[i];
728 const SecPkg* pkg = MechTable[i].pkg;
730 WINPR_ASSERT(pkg->table_w);
734 WLog_DBG(TAG,
"Unavailable mechanism: %s", negotiate_mech_name(cred->mech->oid));
739 if (!init_context.mech)
745 CopyMemory(&output_token.mechToken, output_buffer,
sizeof(
SecBuffer));
748 mech_input_buffers[0] = *bindings_buffer;
750 WINPR_ASSERT(pkg->table_w->InitializeSecurityContextW);
751 sub_status = pkg->table_w->InitializeSecurityContextW(
752 &cred->cred, NULL, pszTargetName, fContextReq | cred->mech->flags, Reserved1,
753 TargetDataRep, &mech_input, Reserved2, &init_context.sub_context, &mech_output,
754 pfContextAttr, ptsExpiry);
757 if (IsSecurityStatusError(sub_status))
759 if (SecIsValidHandle(&init_context.sub_context))
761 WINPR_ASSERT(pkg->table_w->DeleteSecurityContext);
762 pkg->table_w->DeleteSecurityContext(&init_context.sub_context);
768 init_context.mech = cred->mech;
771 if (!WinPrAsn1EncOID(enc, cred->mech->oid))
773 WLog_DBG(TAG,
"Available mechanism: %s", negotiate_mech_name(cred->mech->oid));
777 if (!init_context.mech)
781 if (init_context.mech->oid == &ntlm_OID)
783 init_context.spnego = FALSE;
784 output_buffer->cbBuffer = output_token.mechToken.cbBuffer;
785 WLog_DBG(TAG,
"Using direct NTLM");
789 init_context.spnego = TRUE;
790 init_context.mechTypes.BufferType = SECBUFFER_DATA;
791 const size_t cb = WinPrAsn1EncEndContainer(enc);
792 WINPR_ASSERT(cb <= UINT32_MAX);
793 init_context.mechTypes.cbBuffer = (UINT32)cb;
797 context = negotiate_ContextNew(&init_context);
800 init_context.mech->pkg->table->DeleteSecurityContext(&init_context.sub_context);
801 WinPrAsn1Encoder_Free(&enc);
802 return SEC_E_INSUFFICIENT_MEMORY;
805 sspi_SecureHandleSetUpperPointer(phNewContext, NEGO_SSP_NAME);
806 sspi_SecureHandleSetLowerPointer(phNewContext, context);
808 if (!context->spnego)
815 Stream_StaticInit(&s, context->mechTypes.pvBuffer, context->mechTypes.cbBuffer);
816 if (!WinPrAsn1EncToStream(enc, &s))
819 output_token.mechTypes.cbBuffer = context->mechTypes.cbBuffer;
820 output_token.mechTypes.pvBuffer = context->mechTypes.pvBuffer;
821 output_token.init = TRUE;
823 if (sub_status == SEC_E_OK)
824 context->state = NEGOTIATE_STATE_FINAL_OPTIMISTIC;
829 return SEC_E_INVALID_TOKEN;
831 sub_context = &context->sub_context;
832 sub_cred = negotiate_FindCredential(creds, context->mech);
834 if (!context->spnego)
836 return context->mech->pkg->table_w->InitializeSecurityContextW(
837 sub_cred, sub_context, pszTargetName, fContextReq | context->mech->flags, Reserved1,
838 TargetDataRep, pInput, Reserved2, sub_context, pOutput, pfContextAttr, ptsExpiry);
841 if (!negotiate_read_neg_token(input_buffer, &input_token))
842 return SEC_E_INVALID_TOKEN;
845 if (context->state < NEGOTIATE_STATE_NEGORESP && input_token.supportedMech.len &&
846 !sspi_gss_oid_compare(&input_token.supportedMech, context->mech->oid))
848 mech = negotiate_GetMechByOID(&input_token.supportedMech);
850 return SEC_E_INVALID_TOKEN;
853 sub_cred = negotiate_FindCredential(creds, mech);
855 return SEC_E_INVALID_TOKEN;
858 context->mech->pkg->table_w->DeleteSecurityContext(&context->sub_context);
861 context->mech = mech;
866 if (context->state < NEGOTIATE_STATE_NEGORESP)
868 switch (input_token.negState)
871 return SEC_E_INVALID_TOKEN;
873 return SEC_E_LOGON_DENIED;
878 case ACCEPT_INCOMPLETE:
879 context->state = NEGOTIATE_STATE_NEGORESP;
881 case ACCEPT_COMPLETED:
882 if (context->state == NEGOTIATE_STATE_INITIAL)
883 context->state = NEGOTIATE_STATE_NEGORESP;
885 context->state = NEGOTIATE_STATE_FINAL;
891 WLog_DBG(TAG,
"Negotiated mechanism: %s", negotiate_mech_name(context->mech->oid));
894 if (context->state == NEGOTIATE_STATE_NEGORESP)
899 CopyMemory(&output_token.mechToken, output_buffer,
sizeof(
SecBuffer));
901 mech_input_buffers[0] = input_token.mechToken;
903 mech_input_buffers[1] = *bindings_buffer;
905 status = context->mech->pkg->table_w->InitializeSecurityContextW(
906 sub_cred, sub_context, pszTargetName, fContextReq | context->mech->flags, Reserved1,
907 TargetDataRep, input_token.mechToken.cbBuffer ? &mech_input : NULL, Reserved2,
908 &context->sub_context, &mech_output, pfContextAttr, ptsExpiry);
910 if (IsSecurityStatusError(status))
914 if (status == SEC_E_OK)
916 if (output_token.mechToken.cbBuffer > 0)
917 context->state = NEGOTIATE_STATE_MIC;
919 context->state = NEGOTIATE_STATE_FINAL;
923 if (context->state == NEGOTIATE_STATE_FINAL && input_token.mic.cbBuffer == 0)
925 if (context->mic || input_token.negState != ACCEPT_COMPLETED)
926 return SEC_E_INVALID_TOKEN;
929 output_buffer->cbBuffer = 0;
933 if ((context->state == NEGOTIATE_STATE_MIC && context->mic) ||
934 context->state == NEGOTIATE_STATE_FINAL)
936 status = negotiate_mic_exchange(context, &input_token, &output_token, output_buffer);
937 if (status != SEC_E_OK)
942 if (input_token.negState == ACCEPT_COMPLETED)
945 output_buffer->cbBuffer = 0;
949 if (output_token.negState == ACCEPT_COMPLETED)
952 status = SEC_I_CONTINUE_NEEDED;
954 if (!negotiate_write_neg_token(output_buffer, &output_token))
955 status = SEC_E_INTERNAL_ERROR;
958 WinPrAsn1Encoder_Free(&enc);
962static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextA(
964 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
967 SECURITY_STATUS status = 0;
968 SEC_WCHAR* pszTargetNameW = NULL;
972 pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, NULL);
974 return SEC_E_INTERNAL_ERROR;
977 status = negotiate_InitializeSecurityContextW(
978 phCredential, phContext, pszTargetNameW, fContextReq, Reserved1, TargetDataRep, pInput,
979 Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
980 free(pszTargetNameW);
988 WinPrAsn1_tagId tag = 0;
989 const char ssp[] =
"NTLMSSP";
994 if (input_buffer->cbBuffer >= 8 && strncmp(input_buffer->pvBuffer, ssp,
sizeof(ssp)) == 0)
997 return negotiate_GetMechByOID(&ntlm_OID);
1001 WinPrAsn1Decoder_InitMem(&decoder, WINPR_ASN1_DER, input_buffer->pvBuffer,
1002 input_buffer->cbBuffer);
1004 if (!WinPrAsn1DecReadApp(&decoder, &tag, &appDecoder) || tag != 0)
1007 if (!WinPrAsn1DecReadOID(&appDecoder, oid, FALSE))
1010 if (sspi_gss_oid_compare(oid, &spnego_OID))
1016 return negotiate_GetMechByOID(oid);
1019static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
1026 MechCred* creds = NULL;
1028 NegToken input_token = empty_neg_token;
1029 NegToken output_token = empty_neg_token;
1032 SecBufferDesc mech_input = { SECBUFFER_VERSION, 1, &input_token.mechToken };
1033 SecBufferDesc mech_output = { SECBUFFER_VERSION, 1, &output_token.mechToken };
1034 SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
1037 WinPrAsn1_tagId tag = 0;
1039 const Mech* first_mech = NULL;
1041 if (!phCredential || !SecIsValidHandle(phCredential))
1042 return SEC_E_NO_CREDENTIALS;
1044 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1047 return SEC_E_INVALID_TOKEN;
1050 if (phContext && !phContext->dwLower && !phContext->dwUpper)
1051 return SEC_E_INVALID_HANDLE;
1053 context = sspi_SecureHandleGetLowerPointer(phContext);
1055 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
1057 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
1061 init_context.mech = guessMech(input_buffer, &init_context.spnego, &oid);
1062 if (!init_context.mech && !init_context.spnego)
1063 return SEC_E_INVALID_TOKEN;
1065 WLog_DBG(TAG,
"Mechanism: %s", negotiate_mech_name(&oid));
1067 if (init_context.spnego)
1070 if (!negotiate_read_neg_token(input_buffer, &input_token))
1071 return SEC_E_INVALID_TOKEN;
1074 if (!input_token.init || input_token.mechTypes.cbBuffer == 0)
1075 return SEC_E_INVALID_TOKEN;
1077 init_context.mechTypes.BufferType = SECBUFFER_DATA;
1078 init_context.mechTypes.cbBuffer = input_token.mechTypes.cbBuffer;
1081 WinPrAsn1Decoder_InitMem(&dec, WINPR_ASN1_DER, input_token.mechTypes.pvBuffer,
1082 input_token.mechTypes.cbBuffer);
1084 if (!WinPrAsn1DecReadSequence(&dec, &dec2))
1085 return SEC_E_INVALID_TOKEN;
1089 if (input_token.mechToken.cbBuffer)
1091 if (!WinPrAsn1DecReadOID(&dec, &oid, FALSE))
1092 return SEC_E_INVALID_TOKEN;
1094 init_context.mech = negotiate_GetMechByOID(&oid);
1096 if (init_context.mech)
1099 output_token.mechToken = *output_buffer;
1100 WLog_DBG(TAG,
"Requested mechanism: %s",
1101 negotiate_mech_name(init_context.mech->oid));
1106 if (init_context.mech)
1108 sub_cred = negotiate_FindCredential(creds, init_context.mech);
1110 status = init_context.mech->pkg->table->AcceptSecurityContext(
1111 sub_cred, NULL, init_context.spnego ? &mech_input : pInput, fContextReq,
1112 TargetDataRep, &init_context.sub_context,
1113 init_context.spnego ? &mech_output : pOutput, pfContextAttr, ptsTimeStamp);
1116 if (IsSecurityStatusError(status))
1118 if (!init_context.spnego)
1121 init_context.mic = TRUE;
1122 first_mech = init_context.mech;
1123 init_context.mech = NULL;
1124 output_token.mechToken.cbBuffer = 0;
1127 while (!init_context.mech && WinPrAsn1DecPeekTag(&dec, &tag))
1130 if (!WinPrAsn1DecReadOID(&dec, &oid, FALSE))
1131 return SEC_E_INVALID_TOKEN;
1133 init_context.mech = negotiate_GetMechByOID(&oid);
1134 WLog_DBG(TAG,
"Requested mechanism: %s", negotiate_mech_name(&oid));
1137 if (init_context.mech == first_mech)
1138 init_context.mech = NULL;
1140 if (init_context.mech && !negotiate_FindCredential(creds, init_context.mech))
1141 init_context.mech = NULL;
1144 if (!init_context.mech)
1145 return SEC_E_INTERNAL_ERROR;
1147 context = negotiate_ContextNew(&init_context);
1150 if (!IsSecurityStatusError(status))
1151 init_context.mech->pkg->table->DeleteSecurityContext(&init_context.sub_context);
1152 return SEC_E_INSUFFICIENT_MEMORY;
1155 sspi_SecureHandleSetUpperPointer(phNewContext, NEGO_SSP_NAME);
1156 sspi_SecureHandleSetLowerPointer(phNewContext, context);
1158 if (!init_context.spnego)
1161 CopyMemory(init_context.mechTypes.pvBuffer, input_token.mechTypes.pvBuffer,
1162 input_token.mechTypes.cbBuffer);
1164 if (!context->mech->preferred)
1166 output_token.negState = REQUEST_MIC;
1167 context->mic = TRUE;
1171 output_token.negState = ACCEPT_INCOMPLETE;
1174 if (status == SEC_E_OK)
1175 context->state = NEGOTIATE_STATE_FINAL;
1177 context->state = NEGOTIATE_STATE_NEGORESP;
1179 output_token.supportedMech = oid;
1180 WLog_DBG(TAG,
"Accepted mechanism: %s", negotiate_mech_name(&output_token.supportedMech));
1184 sub_cred = negotiate_FindCredential(creds, context->mech);
1186 return SEC_E_NO_CREDENTIALS;
1188 if (!context->spnego)
1190 return context->mech->pkg->table->AcceptSecurityContext(
1191 sub_cred, &context->sub_context, pInput, fContextReq, TargetDataRep,
1192 &context->sub_context, pOutput, pfContextAttr, ptsTimeStamp);
1195 if (!negotiate_read_neg_token(input_buffer, &input_token))
1196 return SEC_E_INVALID_TOKEN;
1199 if (input_token.mechToken.cbBuffer > 0)
1201 if (context->state != NEGOTIATE_STATE_NEGORESP)
1202 return SEC_E_INVALID_TOKEN;
1206 CopyMemory(&output_token.mechToken, output_buffer,
sizeof(
SecBuffer));
1208 status = context->mech->pkg->table->AcceptSecurityContext(
1209 sub_cred, &context->sub_context, &mech_input, fContextReq | context->mech->flags,
1210 TargetDataRep, &context->sub_context, &mech_output, pfContextAttr, ptsTimeStamp);
1212 if (IsSecurityStatusError(status))
1215 if (status == SEC_E_OK)
1216 context->state = NEGOTIATE_STATE_FINAL;
1218 else if (context->state == NEGOTIATE_STATE_NEGORESP)
1219 return SEC_E_INVALID_TOKEN;
1222 if (context->state == NEGOTIATE_STATE_FINAL)
1225 if (context->mic && output_token.mechToken.cbBuffer == 0 && input_token.mic.cbBuffer == 0)
1226 return SEC_E_INVALID_TOKEN;
1228 if (context->mic || input_token.mic.cbBuffer > 0)
1230 status = negotiate_mic_exchange(context, &input_token, &output_token, output_buffer);
1231 if (status != SEC_E_OK)
1235 output_token.negState = ACCEPT_COMPLETED;
1238 if (input_token.negState == ACCEPT_COMPLETED)
1241 output_buffer->cbBuffer = 0;
1245 if (output_token.negState == ACCEPT_COMPLETED)
1248 status = SEC_I_CONTINUE_NEEDED;
1250 if (!negotiate_write_neg_token(output_buffer, &output_token))
1251 return SEC_E_INTERNAL_ERROR;
1256static SECURITY_STATUS SEC_ENTRY negotiate_CompleteAuthToken(
PCtxtHandle phContext,
1260 SECURITY_STATUS status = SEC_E_OK;
1264 return SEC_E_INVALID_HANDLE;
1266 WINPR_ASSERT(context->mech);
1267 WINPR_ASSERT(context->mech->pkg);
1268 WINPR_ASSERT(context->mech->pkg->table);
1269 if (context->mech->pkg->table->CompleteAuthToken)
1270 status = context->mech->pkg->table->CompleteAuthToken(&context->sub_context, pToken);
1275static SECURITY_STATUS SEC_ENTRY negotiate_DeleteSecurityContext(
PCtxtHandle phContext)
1278 SECURITY_STATUS status = SEC_E_OK;
1280 const SecPkg* pkg = NULL;
1283 return SEC_E_INVALID_HANDLE;
1285 WINPR_ASSERT(context->mech);
1286 WINPR_ASSERT(context->mech->pkg);
1287 WINPR_ASSERT(context->mech->pkg->table);
1288 pkg = context->mech->pkg;
1290 if (pkg->table->DeleteSecurityContext)
1291 status = pkg->table->DeleteSecurityContext(&context->sub_context);
1293 negotiate_ContextFree(context);
1297static SECURITY_STATUS SEC_ENTRY
1298negotiate_ImpersonateSecurityContext(WINPR_ATTR_UNUSED
PCtxtHandle phContext)
1303static SECURITY_STATUS SEC_ENTRY
1304negotiate_RevertSecurityContext(WINPR_ATTR_UNUSED
PCtxtHandle phContext)
1309static SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributesW(
PCtxtHandle phContext,
1310 ULONG ulAttribute,
void* pBuffer)
1315 return SEC_E_INVALID_HANDLE;
1317 WINPR_ASSERT(context->mech);
1318 WINPR_ASSERT(context->mech->pkg);
1319 WINPR_ASSERT(context->mech->pkg->table_w);
1320 if (context->mech->pkg->table_w->QueryContextAttributesW)
1321 return context->mech->pkg->table_w->QueryContextAttributesW(&context->sub_context,
1322 ulAttribute, pBuffer);
1324 return SEC_E_UNSUPPORTED_FUNCTION;
1327static SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributesA(
PCtxtHandle phContext,
1328 ULONG ulAttribute,
void* pBuffer)
1333 return SEC_E_INVALID_HANDLE;
1335 WINPR_ASSERT(context->mech);
1336 WINPR_ASSERT(context->mech->pkg);
1337 WINPR_ASSERT(context->mech->pkg->table);
1338 if (context->mech->pkg->table->QueryContextAttributesA)
1339 return context->mech->pkg->table->QueryContextAttributesA(&context->sub_context,
1340 ulAttribute, pBuffer);
1342 return SEC_E_UNSUPPORTED_FUNCTION;
1345static SECURITY_STATUS SEC_ENTRY negotiate_SetContextAttributesW(
PCtxtHandle phContext,
1346 ULONG ulAttribute,
void* pBuffer,
1352 return SEC_E_INVALID_HANDLE;
1354 WINPR_ASSERT(context->mech);
1355 WINPR_ASSERT(context->mech->pkg);
1356 WINPR_ASSERT(context->mech->pkg->table_w);
1357 if (context->mech->pkg->table_w->SetContextAttributesW)
1358 return context->mech->pkg->table_w->SetContextAttributesW(&context->sub_context,
1359 ulAttribute, pBuffer, cbBuffer);
1361 return SEC_E_UNSUPPORTED_FUNCTION;
1364static SECURITY_STATUS SEC_ENTRY negotiate_SetContextAttributesA(
PCtxtHandle phContext,
1365 ULONG ulAttribute,
void* pBuffer,
1371 return SEC_E_INVALID_HANDLE;
1373 WINPR_ASSERT(context->mech);
1374 WINPR_ASSERT(context->mech->pkg);
1375 WINPR_ASSERT(context->mech->pkg->table);
1376 if (context->mech->pkg->table->SetContextAttributesA)
1377 return context->mech->pkg->table->SetContextAttributesA(&context->sub_context, ulAttribute,
1380 return SEC_E_UNSUPPORTED_FUNCTION;
1383static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesW(
PCredHandle phCredential,
1385 void* pBuffer, ULONG cbBuffer)
1387 MechCred* creds = NULL;
1388 BOOL success = FALSE;
1389 SECURITY_STATUS secStatus = 0;
1391 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1394 return SEC_E_INVALID_HANDLE;
1396 for (
size_t i = 0; i < MECH_COUNT; i++)
1398 MechCred* cred = &creds[i];
1400 WINPR_ASSERT(cred->mech);
1401 WINPR_ASSERT(cred->mech->pkg);
1402 WINPR_ASSERT(cred->mech->pkg->table);
1403 WINPR_ASSERT(cred->mech->pkg->table_w->SetCredentialsAttributesW);
1404 secStatus = cred->mech->pkg->table_w->SetCredentialsAttributesW(&cred->cred, ulAttribute,
1407 if (secStatus == SEC_E_OK)
1414 return (success ? SEC_E_OK : SEC_E_UNSUPPORTED_FUNCTION);
1417static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesA(
PCredHandle phCredential,
1419 void* pBuffer, ULONG cbBuffer)
1421 MechCred* creds = NULL;
1422 BOOL success = FALSE;
1423 SECURITY_STATUS secStatus = 0;
1425 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1428 return SEC_E_INVALID_HANDLE;
1430 for (
size_t i = 0; i < MECH_COUNT; i++)
1432 MechCred* cred = &creds[i];
1437 WINPR_ASSERT(cred->mech);
1438 WINPR_ASSERT(cred->mech->pkg);
1439 WINPR_ASSERT(cred->mech->pkg->table);
1440 WINPR_ASSERT(cred->mech->pkg->table->SetCredentialsAttributesA);
1441 secStatus = cred->mech->pkg->table->SetCredentialsAttributesA(&cred->cred, ulAttribute,
1444 if (secStatus == SEC_E_OK)
1451 return (success ? SEC_E_OK : SEC_E_UNSUPPORTED_FUNCTION);
1454static SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleW(
1455 SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
1456 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
1459 BOOL kerberos = FALSE;
1463 if (!negotiate_get_config(pAuthData, &kerberos, &ntlm, &u2u))
1464 return SEC_E_INTERNAL_ERROR;
1466 MechCred* creds = calloc(MECH_COUNT,
sizeof(MechCred));
1469 return SEC_E_INTERNAL_ERROR;
1471 for (
size_t i = 0; i < MECH_COUNT; i++)
1473 MechCred* cred = &creds[i];
1474 const SecPkg* pkg = MechTable[i].pkg;
1475 cred->mech = &MechTable[i];
1477 if (!kerberos && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_OID))
1479 if (!u2u && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_u2u_OID))
1481 if (!ntlm && _tcsncmp(SecPkgTable[i].name, NTLM_SSP_NAME, ARRAYSIZE(NTLM_SSP_NAME)) == 0)
1484 WINPR_ASSERT(pkg->table_w);
1485 WINPR_ASSERT(pkg->table_w->AcquireCredentialsHandleW);
1486 if (pkg->table_w->AcquireCredentialsHandleW(
1487 pszPrincipal, pszPackage, fCredentialUse, pvLogonID, pAuthData, pGetKeyFn,
1488 pvGetKeyArgument, &cred->cred, ptsExpiry) != SEC_E_OK)
1494 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)creds);
1495 sspi_SecureHandleSetUpperPointer(phCredential, (
void*)NEGO_SSP_NAME);
1499static SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleA(
1500 SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
1501 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
1504 BOOL kerberos = FALSE;
1508 if (!negotiate_get_config(pAuthData, &kerberos, &ntlm, &u2u))
1509 return SEC_E_INTERNAL_ERROR;
1511 MechCred* creds = calloc(MECH_COUNT,
sizeof(MechCred));
1514 return SEC_E_INTERNAL_ERROR;
1516 for (
size_t i = 0; i < MECH_COUNT; i++)
1518 const SecPkg* pkg = MechTable[i].pkg;
1519 MechCred* cred = &creds[i];
1521 cred->mech = &MechTable[i];
1523 if (!kerberos && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_OID))
1525 if (!u2u && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_u2u_OID))
1527 if (!ntlm && _tcsncmp(SecPkgTable[i].name, NTLM_SSP_NAME, ARRAYSIZE(NTLM_SSP_NAME)) == 0)
1530 WINPR_ASSERT(pkg->table);
1531 WINPR_ASSERT(pkg->table->AcquireCredentialsHandleA);
1532 if (pkg->table->AcquireCredentialsHandleA(pszPrincipal, pszPackage, fCredentialUse,
1533 pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument,
1534 &cred->cred, ptsExpiry) != SEC_E_OK)
1540 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)creds);
1541 sspi_SecureHandleSetUpperPointer(phCredential, (
void*)NEGO_SSP_NAME);
1545static SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesW(
1546 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
1547 WINPR_ATTR_UNUSED
void* pBuffer)
1549 WLog_ERR(TAG,
"TODO: Implement");
1550 return SEC_E_UNSUPPORTED_FUNCTION;
1553static SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesA(
1554 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
1555 WINPR_ATTR_UNUSED
void* pBuffer)
1557 WLog_ERR(TAG,
"TODO: Implement");
1558 return SEC_E_UNSUPPORTED_FUNCTION;
1561static SECURITY_STATUS SEC_ENTRY negotiate_FreeCredentialsHandle(
PCredHandle phCredential)
1563 MechCred* creds = NULL;
1565 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1567 return SEC_E_INVALID_HANDLE;
1569 for (
size_t i = 0; i < MECH_COUNT; i++)
1571 MechCred* cred = &creds[i];
1573 WINPR_ASSERT(cred->mech);
1574 WINPR_ASSERT(cred->mech->pkg);
1575 WINPR_ASSERT(cred->mech->pkg->table);
1576 WINPR_ASSERT(cred->mech->pkg->table->FreeCredentialsHandle);
1577 cred->mech->pkg->table->FreeCredentialsHandle(&cred->cred);
1584static SECURITY_STATUS SEC_ENTRY negotiate_EncryptMessage(
PCtxtHandle phContext, ULONG fQOP,
1591 return SEC_E_INVALID_HANDLE;
1596 WINPR_ASSERT(context->mech);
1597 WINPR_ASSERT(context->mech->pkg);
1598 WINPR_ASSERT(context->mech->pkg->table);
1599 if (context->mech->pkg->table->EncryptMessage)
1600 return context->mech->pkg->table->EncryptMessage(&context->sub_context, fQOP, pMessage,
1603 return SEC_E_UNSUPPORTED_FUNCTION;
1606static SECURITY_STATUS SEC_ENTRY negotiate_DecryptMessage(
PCtxtHandle phContext,
1608 ULONG MessageSeqNo, ULONG* pfQOP)
1613 return SEC_E_INVALID_HANDLE;
1618 WINPR_ASSERT(context->mech);
1619 WINPR_ASSERT(context->mech->pkg);
1620 WINPR_ASSERT(context->mech->pkg->table);
1621 if (context->mech->pkg->table->DecryptMessage)
1622 return context->mech->pkg->table->DecryptMessage(&context->sub_context, pMessage,
1623 MessageSeqNo, pfQOP);
1625 return SEC_E_UNSUPPORTED_FUNCTION;
1628static SECURITY_STATUS SEC_ENTRY negotiate_MakeSignature(
PCtxtHandle phContext, ULONG fQOP,
1635 return SEC_E_INVALID_HANDLE;
1640 WINPR_ASSERT(context->mech);
1641 WINPR_ASSERT(context->mech->pkg);
1642 WINPR_ASSERT(context->mech->pkg->table);
1643 if (context->mech->pkg->table->MakeSignature)
1644 return context->mech->pkg->table->MakeSignature(&context->sub_context, fQOP, pMessage,
1647 return SEC_E_UNSUPPORTED_FUNCTION;
1650static SECURITY_STATUS SEC_ENTRY negotiate_VerifySignature(
PCtxtHandle phContext,
1652 ULONG MessageSeqNo, ULONG* pfQOP)
1657 return SEC_E_INVALID_HANDLE;
1662 WINPR_ASSERT(context->mech);
1663 WINPR_ASSERT(context->mech->pkg);
1664 WINPR_ASSERT(context->mech->pkg->table);
1665 if (context->mech->pkg->table->VerifySignature)
1666 return context->mech->pkg->table->VerifySignature(&context->sub_context, pMessage,
1667 MessageSeqNo, pfQOP);
1669 return SEC_E_UNSUPPORTED_FUNCTION;
1675 negotiate_QueryCredentialsAttributesA,
1676 negotiate_AcquireCredentialsHandleA,
1677 negotiate_FreeCredentialsHandle,
1679 negotiate_InitializeSecurityContextA,
1680 negotiate_AcceptSecurityContext,
1681 negotiate_CompleteAuthToken,
1682 negotiate_DeleteSecurityContext,
1684 negotiate_QueryContextAttributesA,
1685 negotiate_ImpersonateSecurityContext,
1686 negotiate_RevertSecurityContext,
1687 negotiate_MakeSignature,
1688 negotiate_VerifySignature,
1698 negotiate_EncryptMessage,
1699 negotiate_DecryptMessage,
1700 negotiate_SetContextAttributesA,
1701 negotiate_SetCredentialsAttributesA,
1707 negotiate_QueryCredentialsAttributesW,
1708 negotiate_AcquireCredentialsHandleW,
1709 negotiate_FreeCredentialsHandle,
1711 negotiate_InitializeSecurityContextW,
1712 negotiate_AcceptSecurityContext,
1713 negotiate_CompleteAuthToken,
1714 negotiate_DeleteSecurityContext,
1716 negotiate_QueryContextAttributesW,
1717 negotiate_ImpersonateSecurityContext,
1718 negotiate_RevertSecurityContext,
1719 negotiate_MakeSignature,
1720 negotiate_VerifySignature,
1730 negotiate_EncryptMessage,
1731 negotiate_DecryptMessage,
1732 negotiate_SetContextAttributesW,
1733 negotiate_SetCredentialsAttributesW,
1736BOOL NEGOTIATE_init(
void)
1738 InitializeConstWCharFromUtf8(NEGOTIATE_SecPkgInfoA.Name, NEGOTIATE_SecPkgInfoW_NameBuffer,
1739 ARRAYSIZE(NEGOTIATE_SecPkgInfoW_NameBuffer));
1740 InitializeConstWCharFromUtf8(NEGOTIATE_SecPkgInfoA.Comment, NEGOTIATE_SecPkgInfoW_CommentBuffer,
1741 ARRAYSIZE(NEGOTIATE_SecPkgInfoW_CommentBuffer));