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"
38#include "../../utils.h"
40#define TAG WINPR_TAG("negotiate")
42#define NEGO_REG_KEY "Software\\%s\\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)
322 WINPR_ASSERT(kerberos);
326#if !defined(WITH_KRB5_NO_NTLM_FALLBACK)
331#if defined(WITH_KRB5)
339 if (negotiate_get_config_from_auth_package_list(pAuthData, kerberos, ntlm, u2u))
345 char* key = winpr_getApplicatonDetailsRegKey(NEGO_REG_KEY);
349 RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
351 if (rc == ERROR_SUCCESS)
355 if (negotiate_get_dword(hKey, PACKAGE_NAME_KERBEROS, &dwValue))
356 *kerberos = (dwValue != 0) ? TRUE : FALSE;
358 if (negotiate_get_dword(hKey, PACKAGE_NAME_KERBEROS_U2U, &dwValue))
359 *u2u = (dwValue != 0) ? TRUE : FALSE;
361#if !defined(WITH_KRB5_NO_NTLM_FALLBACK)
362 if (negotiate_get_dword(hKey, PACKAGE_NAME_NTLM, &dwValue))
363 *ntlm = (dwValue != 0) ? TRUE : FALSE;
374static BOOL negotiate_write_neg_token(
PSecBuffer output_buffer, NegToken* token)
376 WINPR_ASSERT(output_buffer);
380 WinPrAsn1Encoder* enc = NULL;
387 enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
395 if (!WinPrAsn1EncAppContainer(enc, 0))
399 if (!WinPrAsn1EncOID(enc, &spnego_OID))
404 if (!WinPrAsn1EncContextualSeqContainer(enc, token->init ? 0 : 1))
407 WLog_DBG(TAG, token->init ?
"Writing negTokenInit..." :
"Writing negTokenResp...");
412 if (!WinPrAsn1EncContextualRawContent(enc, 0, &mechTypes))
414 WLog_DBG(TAG,
"\tmechTypes [0] (%" PRIu32
" bytes)", token->mechTypes.cbBuffer);
417 else if (token->negState != NOSTATE)
419 if (!WinPrAsn1EncContextualEnumerated(enc, 0, token->negState))
421 WLog_DBG(TAG,
"\tnegState [0] (%d)", token->negState);
425 if (token->supportedMech.len)
427 if (!WinPrAsn1EncContextualOID(enc, 1, &token->supportedMech))
429 WLog_DBG(TAG,
"\tsupportedMech [1] (%s)", negotiate_mech_name(&token->supportedMech));
433 if (token->mechToken.cbBuffer)
435 if (WinPrAsn1EncContextualOctetString(enc, 2, &mechToken) == 0)
437 WLog_DBG(TAG,
"\tmechToken [2] (%" PRIu32
" bytes)", token->mechToken.cbBuffer);
441 if (token->mic.cbBuffer)
443 if (WinPrAsn1EncContextualOctetString(enc, 3, &mechListMic) == 0)
445 WLog_DBG(TAG,
"\tmechListMIC [3] (%" PRIu32
" bytes)", token->mic.cbBuffer);
449 if (!WinPrAsn1EncEndContainer(enc))
455 if (!WinPrAsn1EncEndContainer(enc))
459 if (!WinPrAsn1EncStreamSize(enc, &len) || len > output_buffer->cbBuffer)
462 if (len > UINT32_MAX)
465 Stream_StaticInit(&s, output_buffer->pvBuffer, len);
467 if (WinPrAsn1EncToStream(enc, &s))
469 output_buffer->cbBuffer = (UINT32)len;
474 WinPrAsn1Encoder_Free(&enc);
478static BOOL negotiate_read_neg_token(
PSecBuffer input, NegToken* token)
483 WinPrAsn1_tagId contextual = 0;
484 WinPrAsn1_tag tag = 0;
492 WinPrAsn1Decoder_InitMem(&dec, WINPR_ASN1_DER, input->pvBuffer, input->cbBuffer);
494 if (!WinPrAsn1DecPeekTag(&dec, &tag))
500 if (!WinPrAsn1DecReadApp(&dec, &tag, &dec2) || tag != 0)
505 if (!WinPrAsn1DecReadOID(&dec, &oid, FALSE))
508 if (!sspi_gss_oid_compare(&spnego_OID, &oid))
512 if (!WinPrAsn1DecReadContextualSequence(&dec, 0, &err, &dec2))
518 else if (!WinPrAsn1DecReadContextualSequence(&dec, 1, &err, &dec2))
522 WLog_DBG(TAG, token->init ?
"Reading negTokenInit..." :
"Reading negTokenResp...");
527 if (!WinPrAsn1DecReadContextualTag(&dec, &contextual, &dec2))
536 wStream s = WinPrAsn1DecGetStream(&dec2);
537 token->mechTypes.BufferType = SECBUFFER_TOKEN;
538 const size_t mlen = Stream_Length(&s);
539 if (mlen > UINT32_MAX)
541 token->mechTypes.cbBuffer = (UINT32)mlen;
542 token->mechTypes.pvBuffer = Stream_Buffer(&s);
543 WLog_DBG(TAG,
"\tmechTypes [0] (%" PRIu32
" bytes)", token->mechTypes.cbBuffer);
548 WinPrAsn1_ENUMERATED rd = 0;
549 if (!WinPrAsn1DecReadEnumerated(&dec2, &rd))
554 case ACCEPT_COMPLETED:
555 case ACCEPT_INCOMPLETE:
560 WLog_ERR(TAG,
"Invalid negState enumeration value %d", rd);
564 token->negState = WINPR_ASSERTING_INT_CAST(
enum NegState, rd);
565 WLog_DBG(TAG,
"\tnegState [0] (%d)", rd);
572 if (!WinPrAsn1DecPeekTagAndLen(&dec2, &tag, &len) || (tag != ER_TAG_BIT_STRING))
574 WLog_DBG(TAG,
"\treqFlags [1] (%" PRIuz
" bytes)", len);
579 if (!WinPrAsn1DecReadOID(&dec2, &token->supportedMech, FALSE))
581 WLog_DBG(TAG,
"\tsupportedMech [1] (%s)",
582 negotiate_mech_name(&token->supportedMech));
587 if (!WinPrAsn1DecReadOctetString(&dec2, &octet_string, FALSE))
589 if (octet_string.len > UINT32_MAX)
591 token->mechToken.cbBuffer = (UINT32)octet_string.len;
592 token->mechToken.pvBuffer = octet_string.data;
593 token->mechToken.BufferType = SECBUFFER_TOKEN;
594 WLog_DBG(TAG,
"\tmechToken [2] (%" PRIuz
" bytes)", octet_string.len);
598 if (!WinPrAsn1DecReadOctetString(&dec2, &octet_string, FALSE))
600 if (octet_string.len > UINT32_MAX)
602 token->mic.cbBuffer = (UINT32)octet_string.len;
603 token->mic.pvBuffer = octet_string.data;
604 token->mic.BufferType = SECBUFFER_TOKEN;
605 WLog_DBG(TAG,
"\tmechListMIC [3] (%" PRIuz
" bytes)", octet_string.len);
608 WLog_ERR(TAG,
"unknown contextual item %d", contextual);
611 }
while (WinPrAsn1DecPeekTag(&dec, &tag));
616static SECURITY_STATUS negotiate_mic_exchange(
NEGOTIATE_CONTEXT* context, NegToken* input_token,
617 NegToken* output_token,
PSecBuffer output_buffer)
620 SecBufferDesc mic_buffer_desc = { SECBUFFER_VERSION, 2, mic_buffers };
621 SECURITY_STATUS status = 0;
623 WINPR_ASSERT(context);
624 WINPR_ASSERT(input_token);
625 WINPR_ASSERT(output_token);
626 WINPR_ASSERT(context->mech);
627 WINPR_ASSERT(context->mech->pkg);
632 mic_buffers[0] = context->mechTypes;
635 if (input_token->mic.cbBuffer > 0)
637 mic_buffers[1] = input_token->mic;
639 status = table->VerifySignature(&context->sub_context, &mic_buffer_desc, 0, 0);
640 if (status != SEC_E_OK)
643 output_token->negState = ACCEPT_COMPLETED;
647 if (input_token->negState != ACCEPT_COMPLETED)
650 output_token->mic.BufferType = SECBUFFER_TOKEN;
653 output_token->mic.cbBuffer = output_buffer->cbBuffer - output_token->mechToken.cbBuffer;
654 output_token->mic.pvBuffer =
655 (BYTE*)output_buffer->pvBuffer + output_token->mechToken.cbBuffer;
657 mic_buffers[1] = output_token->mic;
659 status = table->MakeSignature(&context->sub_context, 0, &mic_buffer_desc, 0);
660 if (status != SEC_E_OK)
663 output_token->mic = mic_buffers[1];
667 const TCHAR* name = sspi_SecureHandleGetUpperPointer(&context->sub_context);
669 return SEC_E_INTERNAL_ERROR;
671 if (_tcsncmp(name, NTLM_SSP_NAME, ARRAYSIZE(NTLM_SSP_NAME)) == 0)
673 if (!ntlm_reset_cipher_state(&context->sub_context))
674 return SEC_E_INTERNAL_ERROR;
680static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
682 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
687 MechCred* creds = NULL;
690 NegToken input_token = empty_neg_token;
691 NegToken output_token = empty_neg_token;
696 SecBufferDesc mech_input = { SECBUFFER_VERSION, 2, mech_input_buffers };
697 SecBufferDesc mech_output = { SECBUFFER_VERSION, 1, &output_token.mechToken };
698 SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
699 SECURITY_STATUS sub_status = SEC_E_INTERNAL_ERROR;
700 WinPrAsn1Encoder* enc = NULL;
702 const Mech* mech = NULL;
704 if (!phCredential || !SecIsValidHandle(phCredential))
705 return SEC_E_NO_CREDENTIALS;
707 creds = sspi_SecureHandleGetLowerPointer(phCredential);
710 if (phContext && !phContext->dwLower && !phContext->dwUpper)
711 return SEC_E_INVALID_HANDLE;
713 context = sspi_SecureHandleGetLowerPointer(phContext);
717 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
718 bindings_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS);
721 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
725 enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
727 return SEC_E_INSUFFICIENT_MEMORY;
729 if (!WinPrAsn1EncSeqContainer(enc))
732 for (
size_t i = 0; i < MECH_COUNT; i++)
734 MechCred* cred = &creds[i];
735 const SecPkg* pkg = MechTable[i].pkg;
737 WINPR_ASSERT(pkg->table_w);
741 WLog_DBG(TAG,
"Unavailable mechanism: %s", negotiate_mech_name(cred->mech->oid));
746 if (!init_context.mech)
752 CopyMemory(&output_token.mechToken, output_buffer,
sizeof(
SecBuffer));
755 mech_input_buffers[0] = *bindings_buffer;
757 WINPR_ASSERT(pkg->table_w->InitializeSecurityContextW);
758 sub_status = pkg->table_w->InitializeSecurityContextW(
759 &cred->cred, NULL, pszTargetName, fContextReq | cred->mech->flags, Reserved1,
760 TargetDataRep, &mech_input, Reserved2, &init_context.sub_context, &mech_output,
761 pfContextAttr, ptsExpiry);
764 if (IsSecurityStatusError(sub_status))
766 if (SecIsValidHandle(&init_context.sub_context))
768 WINPR_ASSERT(pkg->table_w->DeleteSecurityContext);
769 pkg->table_w->DeleteSecurityContext(&init_context.sub_context);
775 init_context.mech = cred->mech;
778 if (!WinPrAsn1EncOID(enc, cred->mech->oid))
780 WLog_DBG(TAG,
"Available mechanism: %s", negotiate_mech_name(cred->mech->oid));
784 if (!init_context.mech)
788 if (init_context.mech->oid == &ntlm_OID)
790 init_context.spnego = FALSE;
791 output_buffer->cbBuffer = output_token.mechToken.cbBuffer;
792 WLog_DBG(TAG,
"Using direct NTLM");
796 init_context.spnego = TRUE;
797 init_context.mechTypes.BufferType = SECBUFFER_DATA;
798 const size_t cb = WinPrAsn1EncEndContainer(enc);
799 WINPR_ASSERT(cb <= UINT32_MAX);
800 init_context.mechTypes.cbBuffer = (UINT32)cb;
804 context = negotiate_ContextNew(&init_context);
807 init_context.mech->pkg->table->DeleteSecurityContext(&init_context.sub_context);
808 WinPrAsn1Encoder_Free(&enc);
809 return SEC_E_INSUFFICIENT_MEMORY;
812 sspi_SecureHandleSetUpperPointer(phNewContext, NEGO_SSP_NAME);
813 sspi_SecureHandleSetLowerPointer(phNewContext, context);
815 if (!context->spnego)
822 Stream_StaticInit(&s, context->mechTypes.pvBuffer, context->mechTypes.cbBuffer);
823 if (!WinPrAsn1EncToStream(enc, &s))
826 output_token.mechTypes.cbBuffer = context->mechTypes.cbBuffer;
827 output_token.mechTypes.pvBuffer = context->mechTypes.pvBuffer;
828 output_token.init = TRUE;
830 if (sub_status == SEC_E_OK)
831 context->state = NEGOTIATE_STATE_FINAL_OPTIMISTIC;
836 return SEC_E_INVALID_TOKEN;
838 sub_context = &context->sub_context;
839 sub_cred = negotiate_FindCredential(creds, context->mech);
841 if (!context->spnego)
843 return context->mech->pkg->table_w->InitializeSecurityContextW(
844 sub_cred, sub_context, pszTargetName, fContextReq | context->mech->flags, Reserved1,
845 TargetDataRep, pInput, Reserved2, sub_context, pOutput, pfContextAttr, ptsExpiry);
848 if (!negotiate_read_neg_token(input_buffer, &input_token))
849 return SEC_E_INVALID_TOKEN;
852 if (context->state < NEGOTIATE_STATE_NEGORESP && input_token.supportedMech.len &&
853 !sspi_gss_oid_compare(&input_token.supportedMech, context->mech->oid))
855 mech = negotiate_GetMechByOID(&input_token.supportedMech);
857 return SEC_E_INVALID_TOKEN;
860 sub_cred = negotiate_FindCredential(creds, mech);
862 return SEC_E_INVALID_TOKEN;
865 context->mech->pkg->table_w->DeleteSecurityContext(&context->sub_context);
868 context->mech = mech;
873 if (context->state < NEGOTIATE_STATE_NEGORESP)
875 switch (input_token.negState)
878 return SEC_E_INVALID_TOKEN;
880 return SEC_E_LOGON_DENIED;
885 case ACCEPT_INCOMPLETE:
886 context->state = NEGOTIATE_STATE_NEGORESP;
888 case ACCEPT_COMPLETED:
889 if (context->state == NEGOTIATE_STATE_INITIAL)
890 context->state = NEGOTIATE_STATE_NEGORESP;
892 context->state = NEGOTIATE_STATE_FINAL;
898 WLog_DBG(TAG,
"Negotiated mechanism: %s", negotiate_mech_name(context->mech->oid));
901 if (context->state == NEGOTIATE_STATE_NEGORESP)
906 CopyMemory(&output_token.mechToken, output_buffer,
sizeof(
SecBuffer));
908 mech_input_buffers[0] = input_token.mechToken;
910 mech_input_buffers[1] = *bindings_buffer;
912 status = context->mech->pkg->table_w->InitializeSecurityContextW(
913 sub_cred, sub_context, pszTargetName, fContextReq | context->mech->flags, Reserved1,
914 TargetDataRep, input_token.mechToken.cbBuffer ? &mech_input : NULL, Reserved2,
915 &context->sub_context, &mech_output, pfContextAttr, ptsExpiry);
917 if (IsSecurityStatusError(status))
921 if (status == SEC_E_OK)
923 if (output_token.mechToken.cbBuffer > 0)
924 context->state = NEGOTIATE_STATE_MIC;
926 context->state = NEGOTIATE_STATE_FINAL;
930 if (context->state == NEGOTIATE_STATE_FINAL && input_token.mic.cbBuffer == 0)
932 if (context->mic || input_token.negState != ACCEPT_COMPLETED)
933 return SEC_E_INVALID_TOKEN;
936 output_buffer->cbBuffer = 0;
940 if ((context->state == NEGOTIATE_STATE_MIC && context->mic) ||
941 context->state == NEGOTIATE_STATE_FINAL)
943 status = negotiate_mic_exchange(context, &input_token, &output_token, output_buffer);
944 if (status != SEC_E_OK)
949 if (input_token.negState == ACCEPT_COMPLETED)
952 output_buffer->cbBuffer = 0;
956 if (output_token.negState == ACCEPT_COMPLETED)
959 status = SEC_I_CONTINUE_NEEDED;
961 if (!negotiate_write_neg_token(output_buffer, &output_token))
962 status = SEC_E_INTERNAL_ERROR;
965 WinPrAsn1Encoder_Free(&enc);
969static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextA(
971 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
974 SECURITY_STATUS status = 0;
975 SEC_WCHAR* pszTargetNameW = NULL;
979 pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, NULL);
981 return SEC_E_INTERNAL_ERROR;
984 status = negotiate_InitializeSecurityContextW(
985 phCredential, phContext, pszTargetNameW, fContextReq, Reserved1, TargetDataRep, pInput,
986 Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
987 free(pszTargetNameW);
995 WinPrAsn1_tagId tag = 0;
996 const char ssp[] =
"NTLMSSP";
1001 if (input_buffer->cbBuffer >= 8 && strncmp(input_buffer->pvBuffer, ssp,
sizeof(ssp)) == 0)
1004 return negotiate_GetMechByOID(&ntlm_OID);
1008 WinPrAsn1Decoder_InitMem(&decoder, WINPR_ASN1_DER, input_buffer->pvBuffer,
1009 input_buffer->cbBuffer);
1011 if (!WinPrAsn1DecReadApp(&decoder, &tag, &appDecoder) || tag != 0)
1014 if (!WinPrAsn1DecReadOID(&appDecoder, oid, FALSE))
1017 if (sspi_gss_oid_compare(oid, &spnego_OID))
1023 return negotiate_GetMechByOID(oid);
1026static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
1033 MechCred* creds = NULL;
1035 NegToken input_token = empty_neg_token;
1036 NegToken output_token = empty_neg_token;
1039 SecBufferDesc mech_input = { SECBUFFER_VERSION, 1, &input_token.mechToken };
1040 SecBufferDesc mech_output = { SECBUFFER_VERSION, 1, &output_token.mechToken };
1041 SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
1044 WinPrAsn1_tagId tag = 0;
1046 const Mech* first_mech = NULL;
1048 if (!phCredential || !SecIsValidHandle(phCredential))
1049 return SEC_E_NO_CREDENTIALS;
1051 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1054 return SEC_E_INVALID_TOKEN;
1057 if (phContext && !phContext->dwLower && !phContext->dwUpper)
1058 return SEC_E_INVALID_HANDLE;
1060 context = sspi_SecureHandleGetLowerPointer(phContext);
1062 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
1064 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
1068 init_context.mech = guessMech(input_buffer, &init_context.spnego, &oid);
1069 if (!init_context.mech && !init_context.spnego)
1070 return SEC_E_INVALID_TOKEN;
1072 WLog_DBG(TAG,
"Mechanism: %s", negotiate_mech_name(&oid));
1074 if (init_context.spnego)
1077 if (!negotiate_read_neg_token(input_buffer, &input_token))
1078 return SEC_E_INVALID_TOKEN;
1081 if (!input_token.init || input_token.mechTypes.cbBuffer == 0)
1082 return SEC_E_INVALID_TOKEN;
1084 init_context.mechTypes.BufferType = SECBUFFER_DATA;
1085 init_context.mechTypes.cbBuffer = input_token.mechTypes.cbBuffer;
1088 WinPrAsn1Decoder_InitMem(&dec, WINPR_ASN1_DER, input_token.mechTypes.pvBuffer,
1089 input_token.mechTypes.cbBuffer);
1091 if (!WinPrAsn1DecReadSequence(&dec, &dec2))
1092 return SEC_E_INVALID_TOKEN;
1096 if (input_token.mechToken.cbBuffer)
1098 if (!WinPrAsn1DecReadOID(&dec, &oid, FALSE))
1099 return SEC_E_INVALID_TOKEN;
1101 init_context.mech = negotiate_GetMechByOID(&oid);
1103 if (init_context.mech)
1106 output_token.mechToken = *output_buffer;
1107 WLog_DBG(TAG,
"Requested mechanism: %s",
1108 negotiate_mech_name(init_context.mech->oid));
1113 if (init_context.mech)
1115 sub_cred = negotiate_FindCredential(creds, init_context.mech);
1117 status = init_context.mech->pkg->table->AcceptSecurityContext(
1118 sub_cred, NULL, init_context.spnego ? &mech_input : pInput, fContextReq,
1119 TargetDataRep, &init_context.sub_context,
1120 init_context.spnego ? &mech_output : pOutput, pfContextAttr, ptsTimeStamp);
1123 if (IsSecurityStatusError(status))
1125 if (!init_context.spnego)
1128 init_context.mic = TRUE;
1129 first_mech = init_context.mech;
1130 init_context.mech = NULL;
1131 output_token.mechToken.cbBuffer = 0;
1134 while (!init_context.mech && WinPrAsn1DecPeekTag(&dec, &tag))
1137 if (!WinPrAsn1DecReadOID(&dec, &oid, FALSE))
1138 return SEC_E_INVALID_TOKEN;
1140 init_context.mech = negotiate_GetMechByOID(&oid);
1141 WLog_DBG(TAG,
"Requested mechanism: %s", negotiate_mech_name(&oid));
1144 if (init_context.mech == first_mech)
1145 init_context.mech = NULL;
1147 if (init_context.mech && !negotiate_FindCredential(creds, init_context.mech))
1148 init_context.mech = NULL;
1151 if (!init_context.mech)
1152 return SEC_E_INTERNAL_ERROR;
1154 context = negotiate_ContextNew(&init_context);
1157 if (!IsSecurityStatusError(status))
1158 init_context.mech->pkg->table->DeleteSecurityContext(&init_context.sub_context);
1159 return SEC_E_INSUFFICIENT_MEMORY;
1162 sspi_SecureHandleSetUpperPointer(phNewContext, NEGO_SSP_NAME);
1163 sspi_SecureHandleSetLowerPointer(phNewContext, context);
1165 if (!init_context.spnego)
1168 CopyMemory(init_context.mechTypes.pvBuffer, input_token.mechTypes.pvBuffer,
1169 input_token.mechTypes.cbBuffer);
1171 if (!context->mech->preferred)
1173 output_token.negState = REQUEST_MIC;
1174 context->mic = TRUE;
1178 output_token.negState = ACCEPT_INCOMPLETE;
1181 if (status == SEC_E_OK)
1182 context->state = NEGOTIATE_STATE_FINAL;
1184 context->state = NEGOTIATE_STATE_NEGORESP;
1186 output_token.supportedMech = oid;
1187 WLog_DBG(TAG,
"Accepted mechanism: %s", negotiate_mech_name(&output_token.supportedMech));
1191 sub_cred = negotiate_FindCredential(creds, context->mech);
1193 return SEC_E_NO_CREDENTIALS;
1195 if (!context->spnego)
1197 return context->mech->pkg->table->AcceptSecurityContext(
1198 sub_cred, &context->sub_context, pInput, fContextReq, TargetDataRep,
1199 &context->sub_context, pOutput, pfContextAttr, ptsTimeStamp);
1202 if (!negotiate_read_neg_token(input_buffer, &input_token))
1203 return SEC_E_INVALID_TOKEN;
1206 if (input_token.mechToken.cbBuffer > 0)
1208 if (context->state != NEGOTIATE_STATE_NEGORESP)
1209 return SEC_E_INVALID_TOKEN;
1213 CopyMemory(&output_token.mechToken, output_buffer,
sizeof(
SecBuffer));
1215 status = context->mech->pkg->table->AcceptSecurityContext(
1216 sub_cred, &context->sub_context, &mech_input, fContextReq | context->mech->flags,
1217 TargetDataRep, &context->sub_context, &mech_output, pfContextAttr, ptsTimeStamp);
1219 if (IsSecurityStatusError(status))
1222 if (status == SEC_E_OK)
1223 context->state = NEGOTIATE_STATE_FINAL;
1225 else if (context->state == NEGOTIATE_STATE_NEGORESP)
1226 return SEC_E_INVALID_TOKEN;
1229 if (context->state == NEGOTIATE_STATE_FINAL)
1232 if (context->mic && output_token.mechToken.cbBuffer == 0 && input_token.mic.cbBuffer == 0)
1233 return SEC_E_INVALID_TOKEN;
1235 if (context->mic || input_token.mic.cbBuffer > 0)
1237 status = negotiate_mic_exchange(context, &input_token, &output_token, output_buffer);
1238 if (status != SEC_E_OK)
1242 output_token.negState = ACCEPT_COMPLETED;
1245 if (input_token.negState == ACCEPT_COMPLETED)
1248 output_buffer->cbBuffer = 0;
1252 if (output_token.negState == ACCEPT_COMPLETED)
1255 status = SEC_I_CONTINUE_NEEDED;
1257 if (!negotiate_write_neg_token(output_buffer, &output_token))
1258 return SEC_E_INTERNAL_ERROR;
1263static SECURITY_STATUS SEC_ENTRY negotiate_CompleteAuthToken(
PCtxtHandle phContext,
1267 SECURITY_STATUS status = SEC_E_OK;
1271 return SEC_E_INVALID_HANDLE;
1273 WINPR_ASSERT(context->mech);
1274 WINPR_ASSERT(context->mech->pkg);
1275 WINPR_ASSERT(context->mech->pkg->table);
1276 if (context->mech->pkg->table->CompleteAuthToken)
1277 status = context->mech->pkg->table->CompleteAuthToken(&context->sub_context, pToken);
1282static SECURITY_STATUS SEC_ENTRY negotiate_DeleteSecurityContext(
PCtxtHandle phContext)
1285 SECURITY_STATUS status = SEC_E_OK;
1287 const SecPkg* pkg = NULL;
1290 return SEC_E_INVALID_HANDLE;
1292 WINPR_ASSERT(context->mech);
1293 WINPR_ASSERT(context->mech->pkg);
1294 WINPR_ASSERT(context->mech->pkg->table);
1295 pkg = context->mech->pkg;
1297 if (pkg->table->DeleteSecurityContext)
1298 status = pkg->table->DeleteSecurityContext(&context->sub_context);
1300 negotiate_ContextFree(context);
1304static SECURITY_STATUS SEC_ENTRY
1305negotiate_ImpersonateSecurityContext(WINPR_ATTR_UNUSED
PCtxtHandle phContext)
1310static SECURITY_STATUS SEC_ENTRY
1311negotiate_RevertSecurityContext(WINPR_ATTR_UNUSED
PCtxtHandle phContext)
1316static SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributesW(
PCtxtHandle phContext,
1317 ULONG ulAttribute,
void* pBuffer)
1322 return SEC_E_INVALID_HANDLE;
1324 WINPR_ASSERT(context->mech);
1325 WINPR_ASSERT(context->mech->pkg);
1326 WINPR_ASSERT(context->mech->pkg->table_w);
1327 if (context->mech->pkg->table_w->QueryContextAttributesW)
1328 return context->mech->pkg->table_w->QueryContextAttributesW(&context->sub_context,
1329 ulAttribute, pBuffer);
1331 return SEC_E_UNSUPPORTED_FUNCTION;
1334static SECURITY_STATUS SEC_ENTRY negotiate_QueryContextAttributesA(
PCtxtHandle phContext,
1335 ULONG ulAttribute,
void* pBuffer)
1340 return SEC_E_INVALID_HANDLE;
1342 WINPR_ASSERT(context->mech);
1343 WINPR_ASSERT(context->mech->pkg);
1344 WINPR_ASSERT(context->mech->pkg->table);
1345 if (context->mech->pkg->table->QueryContextAttributesA)
1346 return context->mech->pkg->table->QueryContextAttributesA(&context->sub_context,
1347 ulAttribute, pBuffer);
1349 return SEC_E_UNSUPPORTED_FUNCTION;
1352static SECURITY_STATUS SEC_ENTRY negotiate_SetContextAttributesW(
PCtxtHandle phContext,
1353 ULONG ulAttribute,
void* pBuffer,
1359 return SEC_E_INVALID_HANDLE;
1361 WINPR_ASSERT(context->mech);
1362 WINPR_ASSERT(context->mech->pkg);
1363 WINPR_ASSERT(context->mech->pkg->table_w);
1364 if (context->mech->pkg->table_w->SetContextAttributesW)
1365 return context->mech->pkg->table_w->SetContextAttributesW(&context->sub_context,
1366 ulAttribute, pBuffer, cbBuffer);
1368 return SEC_E_UNSUPPORTED_FUNCTION;
1371static SECURITY_STATUS SEC_ENTRY negotiate_SetContextAttributesA(
PCtxtHandle phContext,
1372 ULONG ulAttribute,
void* pBuffer,
1378 return SEC_E_INVALID_HANDLE;
1380 WINPR_ASSERT(context->mech);
1381 WINPR_ASSERT(context->mech->pkg);
1382 WINPR_ASSERT(context->mech->pkg->table);
1383 if (context->mech->pkg->table->SetContextAttributesA)
1384 return context->mech->pkg->table->SetContextAttributesA(&context->sub_context, ulAttribute,
1387 return SEC_E_UNSUPPORTED_FUNCTION;
1390static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesW(
PCredHandle phCredential,
1392 void* pBuffer, ULONG cbBuffer)
1394 MechCred* creds = NULL;
1395 BOOL success = FALSE;
1396 SECURITY_STATUS secStatus = 0;
1398 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1401 return SEC_E_INVALID_HANDLE;
1403 for (
size_t i = 0; i < MECH_COUNT; i++)
1405 MechCred* cred = &creds[i];
1407 WINPR_ASSERT(cred->mech);
1408 WINPR_ASSERT(cred->mech->pkg);
1409 WINPR_ASSERT(cred->mech->pkg->table);
1410 WINPR_ASSERT(cred->mech->pkg->table_w->SetCredentialsAttributesW);
1411 secStatus = cred->mech->pkg->table_w->SetCredentialsAttributesW(&cred->cred, ulAttribute,
1414 if (secStatus == SEC_E_OK)
1421 return (success ? SEC_E_OK : SEC_E_UNSUPPORTED_FUNCTION);
1424static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesA(
PCredHandle phCredential,
1426 void* pBuffer, ULONG cbBuffer)
1428 MechCred* creds = NULL;
1429 BOOL success = FALSE;
1430 SECURITY_STATUS secStatus = 0;
1432 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1435 return SEC_E_INVALID_HANDLE;
1437 for (
size_t i = 0; i < MECH_COUNT; i++)
1439 MechCred* cred = &creds[i];
1444 WINPR_ASSERT(cred->mech);
1445 WINPR_ASSERT(cred->mech->pkg);
1446 WINPR_ASSERT(cred->mech->pkg->table);
1447 WINPR_ASSERT(cred->mech->pkg->table->SetCredentialsAttributesA);
1448 secStatus = cred->mech->pkg->table->SetCredentialsAttributesA(&cred->cred, ulAttribute,
1451 if (secStatus == SEC_E_OK)
1458 return (success ? SEC_E_OK : SEC_E_UNSUPPORTED_FUNCTION);
1461static SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleW(
1462 SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
1463 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
1466 BOOL kerberos = FALSE;
1470 if (!negotiate_get_config(pAuthData, &kerberos, &ntlm, &u2u))
1471 return SEC_E_INTERNAL_ERROR;
1473 MechCred* creds = calloc(MECH_COUNT,
sizeof(MechCred));
1476 return SEC_E_INTERNAL_ERROR;
1478 for (
size_t i = 0; i < MECH_COUNT; i++)
1480 MechCred* cred = &creds[i];
1481 const SecPkg* pkg = MechTable[i].pkg;
1482 cred->mech = &MechTable[i];
1484 if (!kerberos && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_OID))
1486 if (!u2u && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_u2u_OID))
1488 if (!ntlm && _tcsncmp(SecPkgTable[i].name, NTLM_SSP_NAME, ARRAYSIZE(NTLM_SSP_NAME)) == 0)
1491 WINPR_ASSERT(pkg->table_w);
1492 WINPR_ASSERT(pkg->table_w->AcquireCredentialsHandleW);
1493 if (pkg->table_w->AcquireCredentialsHandleW(
1494 pszPrincipal, pszPackage, fCredentialUse, pvLogonID, pAuthData, pGetKeyFn,
1495 pvGetKeyArgument, &cred->cred, ptsExpiry) != SEC_E_OK)
1501 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)creds);
1502 sspi_SecureHandleSetUpperPointer(phCredential, (
void*)NEGO_SSP_NAME);
1506static SECURITY_STATUS SEC_ENTRY negotiate_AcquireCredentialsHandleA(
1507 SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
1508 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
1511 BOOL kerberos = FALSE;
1515 if (!negotiate_get_config(pAuthData, &kerberos, &ntlm, &u2u))
1516 return SEC_E_INTERNAL_ERROR;
1518 MechCred* creds = calloc(MECH_COUNT,
sizeof(MechCred));
1521 return SEC_E_INTERNAL_ERROR;
1523 for (
size_t i = 0; i < MECH_COUNT; i++)
1525 const SecPkg* pkg = MechTable[i].pkg;
1526 MechCred* cred = &creds[i];
1528 cred->mech = &MechTable[i];
1530 if (!kerberos && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_OID))
1532 if (!u2u && sspi_gss_oid_compare(MechTable[i].oid, &kerberos_u2u_OID))
1534 if (!ntlm && _tcsncmp(SecPkgTable[i].name, NTLM_SSP_NAME, ARRAYSIZE(NTLM_SSP_NAME)) == 0)
1537 WINPR_ASSERT(pkg->table);
1538 WINPR_ASSERT(pkg->table->AcquireCredentialsHandleA);
1539 if (pkg->table->AcquireCredentialsHandleA(pszPrincipal, pszPackage, fCredentialUse,
1540 pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument,
1541 &cred->cred, ptsExpiry) != SEC_E_OK)
1547 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)creds);
1548 sspi_SecureHandleSetUpperPointer(phCredential, (
void*)NEGO_SSP_NAME);
1552static SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesW(
1553 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
1554 WINPR_ATTR_UNUSED
void* pBuffer)
1556 WLog_ERR(TAG,
"TODO: Implement");
1557 return SEC_E_UNSUPPORTED_FUNCTION;
1560static SECURITY_STATUS SEC_ENTRY negotiate_QueryCredentialsAttributesA(
1561 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
1562 WINPR_ATTR_UNUSED
void* pBuffer)
1564 WLog_ERR(TAG,
"TODO: Implement");
1565 return SEC_E_UNSUPPORTED_FUNCTION;
1568static SECURITY_STATUS SEC_ENTRY negotiate_FreeCredentialsHandle(
PCredHandle phCredential)
1570 MechCred* creds = NULL;
1572 creds = sspi_SecureHandleGetLowerPointer(phCredential);
1574 return SEC_E_INVALID_HANDLE;
1576 for (
size_t i = 0; i < MECH_COUNT; i++)
1578 MechCred* cred = &creds[i];
1580 WINPR_ASSERT(cred->mech);
1581 WINPR_ASSERT(cred->mech->pkg);
1582 WINPR_ASSERT(cred->mech->pkg->table);
1583 WINPR_ASSERT(cred->mech->pkg->table->FreeCredentialsHandle);
1584 cred->mech->pkg->table->FreeCredentialsHandle(&cred->cred);
1591static SECURITY_STATUS SEC_ENTRY negotiate_EncryptMessage(
PCtxtHandle phContext, ULONG fQOP,
1598 return SEC_E_INVALID_HANDLE;
1603 WINPR_ASSERT(context->mech);
1604 WINPR_ASSERT(context->mech->pkg);
1605 WINPR_ASSERT(context->mech->pkg->table);
1606 if (context->mech->pkg->table->EncryptMessage)
1607 return context->mech->pkg->table->EncryptMessage(&context->sub_context, fQOP, pMessage,
1610 return SEC_E_UNSUPPORTED_FUNCTION;
1613static SECURITY_STATUS SEC_ENTRY negotiate_DecryptMessage(
PCtxtHandle phContext,
1615 ULONG MessageSeqNo, ULONG* pfQOP)
1620 return SEC_E_INVALID_HANDLE;
1625 WINPR_ASSERT(context->mech);
1626 WINPR_ASSERT(context->mech->pkg);
1627 WINPR_ASSERT(context->mech->pkg->table);
1628 if (context->mech->pkg->table->DecryptMessage)
1629 return context->mech->pkg->table->DecryptMessage(&context->sub_context, pMessage,
1630 MessageSeqNo, pfQOP);
1632 return SEC_E_UNSUPPORTED_FUNCTION;
1635static SECURITY_STATUS SEC_ENTRY negotiate_MakeSignature(
PCtxtHandle phContext, ULONG fQOP,
1642 return SEC_E_INVALID_HANDLE;
1647 WINPR_ASSERT(context->mech);
1648 WINPR_ASSERT(context->mech->pkg);
1649 WINPR_ASSERT(context->mech->pkg->table);
1650 if (context->mech->pkg->table->MakeSignature)
1651 return context->mech->pkg->table->MakeSignature(&context->sub_context, fQOP, pMessage,
1654 return SEC_E_UNSUPPORTED_FUNCTION;
1657static SECURITY_STATUS SEC_ENTRY negotiate_VerifySignature(
PCtxtHandle phContext,
1659 ULONG MessageSeqNo, ULONG* pfQOP)
1664 return SEC_E_INVALID_HANDLE;
1669 WINPR_ASSERT(context->mech);
1670 WINPR_ASSERT(context->mech->pkg);
1671 WINPR_ASSERT(context->mech->pkg->table);
1672 if (context->mech->pkg->table->VerifySignature)
1673 return context->mech->pkg->table->VerifySignature(&context->sub_context, pMessage,
1674 MessageSeqNo, pfQOP);
1676 return SEC_E_UNSUPPORTED_FUNCTION;
1682 negotiate_QueryCredentialsAttributesA,
1683 negotiate_AcquireCredentialsHandleA,
1684 negotiate_FreeCredentialsHandle,
1686 negotiate_InitializeSecurityContextA,
1687 negotiate_AcceptSecurityContext,
1688 negotiate_CompleteAuthToken,
1689 negotiate_DeleteSecurityContext,
1691 negotiate_QueryContextAttributesA,
1692 negotiate_ImpersonateSecurityContext,
1693 negotiate_RevertSecurityContext,
1694 negotiate_MakeSignature,
1695 negotiate_VerifySignature,
1705 negotiate_EncryptMessage,
1706 negotiate_DecryptMessage,
1707 negotiate_SetContextAttributesA,
1708 negotiate_SetCredentialsAttributesA,
1714 negotiate_QueryCredentialsAttributesW,
1715 negotiate_AcquireCredentialsHandleW,
1716 negotiate_FreeCredentialsHandle,
1718 negotiate_InitializeSecurityContextW,
1719 negotiate_AcceptSecurityContext,
1720 negotiate_CompleteAuthToken,
1721 negotiate_DeleteSecurityContext,
1723 negotiate_QueryContextAttributesW,
1724 negotiate_ImpersonateSecurityContext,
1725 negotiate_RevertSecurityContext,
1726 negotiate_MakeSignature,
1727 negotiate_VerifySignature,
1737 negotiate_EncryptMessage,
1738 negotiate_DecryptMessage,
1739 negotiate_SetContextAttributesW,
1740 negotiate_SetCredentialsAttributesW,
1743BOOL NEGOTIATE_init(
void)
1745 InitializeConstWCharFromUtf8(NEGOTIATE_SecPkgInfoA.Name, NEGOTIATE_SecPkgInfoW_NameBuffer,
1746 ARRAYSIZE(NEGOTIATE_SecPkgInfoW_NameBuffer));
1747 InitializeConstWCharFromUtf8(NEGOTIATE_SecPkgInfoA.Comment, NEGOTIATE_SecPkgInfoW_CommentBuffer,
1748 ARRAYSIZE(NEGOTIATE_SecPkgInfoW_CommentBuffer));