20#include <winpr/config.h>
23#include <winpr/assert.h>
24#include <winpr/sspi.h>
25#include <winpr/print.h>
26#include <winpr/string.h>
27#include <winpr/tchar.h>
28#include <winpr/sysinfo.h>
29#include <winpr/registry.h>
30#include <winpr/endian.h>
31#include <winpr/build-config.h>
34#include "ntlm_export.h"
37#include "ntlm_message.h"
39#include "../../utils.h"
42#define TAG WINPR_TAG("sspi.NTLM")
44#define WINPR_KEY "Software\\%s\\WinPR\\NTLM"
46static char* NTLM_PACKAGE_NAME =
"NTLM";
48#define check_context(ctx) check_context_((ctx), __FILE__, __func__, __LINE__)
49static BOOL check_context_(
NTLM_CONTEXT* context,
const char* file,
const char* fkt,
size_t line)
52 wLog* log = WLog_Get(TAG);
53 const DWORD log_level = WLOG_ERROR;
57 if (WLog_IsLevelActive(log, log_level))
58 WLog_PrintTextMessage(log, log_level, line, file, fkt,
"invalid context");
63 if (!context->RecvRc4Seal)
65 if (WLog_IsLevelActive(log, log_level))
66 WLog_PrintTextMessage(log, log_level, line, file, fkt,
"invalid context->RecvRc4Seal");
69 if (!context->SendRc4Seal)
71 if (WLog_IsLevelActive(log, log_level))
72 WLog_PrintTextMessage(log, log_level, line, file, fkt,
"invalid context->SendRc4Seal");
76 if (!context->SendSigningKey)
78 if (WLog_IsLevelActive(log, log_level))
79 WLog_PrintTextMessage(log, log_level, line, file, fkt,
80 "invalid context->SendSigningKey");
83 if (!context->RecvSigningKey)
85 if (WLog_IsLevelActive(log, log_level))
86 WLog_PrintTextMessage(log, log_level, line, file, fkt,
87 "invalid context->RecvSigningKey");
90 if (!context->SendSealingKey)
92 if (WLog_IsLevelActive(log, log_level))
93 WLog_PrintTextMessage(log, log_level, line, file, fkt,
94 "invalid context->SendSealingKey");
97 if (!context->RecvSealingKey)
99 if (WLog_IsLevelActive(log, log_level))
100 WLog_PrintTextMessage(log, log_level, line, file, fkt,
101 "invalid context->RecvSealingKey");
107static char* get_name(COMPUTER_NAME_FORMAT type)
111 if (GetComputerNameExA(type,
nullptr, &nSize))
114 if (GetLastError() != ERROR_MORE_DATA)
117 char* computerName = calloc(1, nSize);
122 if (!GetComputerNameExA(type, computerName, &nSize))
131static int ntlm_SetContextWorkstation(
NTLM_CONTEXT* context,
char* Workstation)
133 char* ws = Workstation;
134 CHAR* computerName =
nullptr;
136 WINPR_ASSERT(context);
140 computerName = get_name(ComputerNameNetBIOS);
147 context->Workstation.Buffer = ConvertUtf8ToWCharAlloc(ws, &len);
151 if (!context->Workstation.Buffer || (len > UINT16_MAX /
sizeof(WCHAR)))
154 context->Workstation.Length = (USHORT)(len *
sizeof(WCHAR));
158static int ntlm_SetContextServicePrincipalNameW(
NTLM_CONTEXT* context, LPWSTR ServicePrincipalName)
160 WINPR_ASSERT(context);
162 if (!ServicePrincipalName)
164 context->ServicePrincipalName.Buffer =
nullptr;
165 context->ServicePrincipalName.Length = 0;
169 context->ServicePrincipalName.Length = (USHORT)(_wcslen(ServicePrincipalName) * 2);
170 context->ServicePrincipalName.Buffer = (PWSTR)malloc(context->ServicePrincipalName.Length + 2);
172 if (!context->ServicePrincipalName.Buffer)
175 memcpy(context->ServicePrincipalName.Buffer, ServicePrincipalName,
176 context->ServicePrincipalName.Length + 2);
180static int ntlm_SetContextTargetName(
NTLM_CONTEXT* context,
char* TargetName)
182 char* name = TargetName;
184 CHAR* computerName =
nullptr;
186 WINPR_ASSERT(context);
190 if (GetComputerNameExA(ComputerNameNetBIOS,
nullptr, &nSize) ||
191 GetLastError() != ERROR_MORE_DATA)
194 computerName = calloc(nSize,
sizeof(CHAR));
199 if (!GetComputerNameExA(ComputerNameNetBIOS, computerName, &nSize))
205 if (nSize > MAX_COMPUTERNAME_LENGTH)
206 computerName[MAX_COMPUTERNAME_LENGTH] =
'\0';
217 context->TargetName.pvBuffer = ConvertUtf8ToWCharAlloc(name, &len);
219 if (!context->TargetName.pvBuffer || (len > UINT16_MAX /
sizeof(WCHAR)))
221 free(context->TargetName.pvBuffer);
222 context->TargetName.pvBuffer =
nullptr;
230 context->TargetName.cbBuffer = (USHORT)(len *
sizeof(WCHAR));
249 context->NTLMv2 = TRUE;
250 context->UseMIC = FALSE;
251 context->SendVersionInfo = TRUE;
252 context->SendSingleHostData = FALSE;
253 context->SendWorkstationName = TRUE;
254 context->NegotiateKeyExchange = TRUE;
255 context->UseSamFileDatabase = TRUE;
258 char* key = winpr_getApplicatonDetailsRegKey(WINPR_KEY);
262 RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
265 if (status == ERROR_SUCCESS)
267 if (RegQueryValueEx(hKey, _T(
"NTLMv2"),
nullptr, &dwType, (BYTE*)&dwValue,
268 &dwSize) == ERROR_SUCCESS)
269 context->NTLMv2 = dwValue ? 1 : 0;
271 if (RegQueryValueEx(hKey, _T(
"UseMIC"),
nullptr, &dwType, (BYTE*)&dwValue,
272 &dwSize) == ERROR_SUCCESS)
273 context->UseMIC = dwValue ? 1 : 0;
275 if (RegQueryValueEx(hKey, _T(
"SendVersionInfo"),
nullptr, &dwType, (BYTE*)&dwValue,
276 &dwSize) == ERROR_SUCCESS)
277 context->SendVersionInfo = dwValue ? 1 : 0;
279 if (RegQueryValueEx(hKey, _T(
"SendSingleHostData"),
nullptr, &dwType,
280 (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS)
281 context->SendSingleHostData = dwValue ? 1 : 0;
283 if (RegQueryValueEx(hKey, _T(
"SendWorkstationName"),
nullptr, &dwType,
284 (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS)
285 context->SendWorkstationName = dwValue ? 1 : 0;
287 if (RegQueryValueEx(hKey, _T(
"WorkstationName"),
nullptr, &dwType,
nullptr,
288 &dwSize) == ERROR_SUCCESS)
290 char* workstation = (
char*)malloc(dwSize + 1);
298 const LONG rc = RegQueryValueExA(hKey,
"WorkstationName",
nullptr, &dwType,
299 (BYTE*)workstation, &dwSize);
300 if (rc != ERROR_SUCCESS)
301 WLog_WARN(TAG,
"Key ''WorkstationName' not found");
302 workstation[dwSize] =
'\0';
304 if (ntlm_SetContextWorkstation(context, workstation) < 0)
323 context->SuppressExtendedProtection = FALSE;
325 RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T(
"System\\CurrentControlSet\\Control\\LSA"), 0,
326 KEY_READ | KEY_WOW64_64KEY, &hKey);
328 if (status == ERROR_SUCCESS)
330 if (RegQueryValueEx(hKey, _T(
"SuppressExtendedProtection"),
nullptr, &dwType,
331 (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS)
332 context->SuppressExtendedProtection = dwValue ? 1 : 0;
337 context->NegotiateFlags = 0;
338 context->LmCompatibilityLevel = 3;
339 ntlm_change_state(context, NTLM_STATE_INITIAL);
340 FillMemory(context->MachineID,
sizeof(context->MachineID), 0xAA);
343 context->UseMIC = TRUE;
353 winpr_RC4_Free(context->SendRc4Seal);
354 winpr_RC4_Free(context->RecvRc4Seal);
355 sspi_SecBufferFree(&context->NegotiateMessage);
356 sspi_SecBufferFree(&context->ChallengeMessage);
357 sspi_SecBufferFree(&context->AuthenticateMessage);
358 sspi_SecBufferFree(&context->ChallengeTargetInfo);
359 sspi_SecBufferFree(&context->TargetName);
360 sspi_SecBufferFree(&context->NtChallengeResponse);
361 sspi_SecBufferFree(&context->LmChallengeResponse);
362 free(context->ServicePrincipalName.Buffer);
363 free(context->Workstation.Buffer);
366 memset(context->NtlmHash, 0,
sizeof(context->NtlmHash));
367 memset(context->NtlmV2Hash, 0,
sizeof(context->NtlmV2Hash));
368 memset(context->SessionBaseKey, 0,
sizeof(context->SessionBaseKey));
369 memset(context->KeyExchangeKey, 0,
sizeof(context->KeyExchangeKey));
370 memset(context->RandomSessionKey, 0,
sizeof(context->RandomSessionKey));
371 memset(context->ExportedSessionKey, 0,
sizeof(context->ExportedSessionKey));
372 memset(context->EncryptedRandomSessionKey, 0,
sizeof(context->EncryptedRandomSessionKey));
373 memset(context->NtProofString, 0,
sizeof(context->NtProofString));
377static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
378 WINPR_ATTR_UNUSED SEC_WCHAR* pszPrincipal, WINPR_ATTR_UNUSED SEC_WCHAR* pszPackage,
379 ULONG fCredentialUse, WINPR_ATTR_UNUSED
void* pvLogonID,
void* pAuthData,
380 SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
385 if ((fCredentialUse != SECPKG_CRED_OUTBOUND) && (fCredentialUse != SECPKG_CRED_INBOUND) &&
386 (fCredentialUse != SECPKG_CRED_BOTH))
388 return SEC_E_INVALID_PARAMETER;
394 return SEC_E_INTERNAL_ERROR;
396 credentials->fCredentialUse = fCredentialUse;
397 credentials->pGetKeyFn = pGetKeyFn;
398 credentials->pvGetKeyArgument = pvGetKeyArgument;
402 UINT32 identityFlags = sspi_GetAuthIdentityFlags(pAuthData);
404 if (sspi_CopyAuthIdentity(&(credentials->identity),
407 sspi_CredentialsFree(credentials);
408 return SEC_E_INVALID_PARAMETER;
411 if (identityFlags & SEC_WINNT_AUTH_IDENTITY_EXTENDED)
417 if (settings->samFile)
419 credentials->ntlmSettings.samFile = _strdup(settings->samFile);
420 if (!credentials->ntlmSettings.samFile)
422 sspi_CredentialsFree(credentials);
423 return SEC_E_INSUFFICIENT_MEMORY;
426 credentials->ntlmSettings.hashCallback = settings->hashCallback;
427 credentials->ntlmSettings.hashCallbackArg = settings->hashCallbackArg;
430 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)credentials);
431 sspi_SecureHandleSetUpperPointer(phCredential, (
void*)NTLM_PACKAGE_NAME);
435static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(
436 SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
437 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
440 SECURITY_STATUS status = SEC_E_INSUFFICIENT_MEMORY;
441 SEC_WCHAR* principal =
nullptr;
442 SEC_WCHAR*
package = nullptr;
446 principal = ConvertUtf8ToWCharAlloc(pszPrincipal,
nullptr);
452 package = ConvertUtf8ToWCharAlloc(pszPackage, nullptr);
458 ntlm_AcquireCredentialsHandleW(principal, package, fCredentialUse, pvLogonID, pAuthData,
459 pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
468static SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(
PCredHandle phCredential)
471 return SEC_E_INVALID_HANDLE;
477 return SEC_E_INVALID_HANDLE;
479 sspi_CredentialsFree(credentials);
483static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesW(
484 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
485 WINPR_ATTR_UNUSED
void* pBuffer)
487 if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
492 WLog_ERR(TAG,
"TODO: Implement");
493 return SEC_E_UNSUPPORTED_FUNCTION;
496static SECURITY_STATUS SEC_ENTRY ntlm_QueryCredentialsAttributesA(
PCredHandle phCredential,
497 ULONG ulAttribute,
void* pBuffer)
499 return ntlm_QueryCredentialsAttributesW(phCredential, ulAttribute, pBuffer);
505static SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
508 WINPR_ATTR_UNUSED PULONG pfContextAttr, WINPR_ATTR_UNUSED
PTimeStamp ptsTimeStamp)
510 SECURITY_STATUS status = 0;
516 if (phContext && !phContext->dwLower && !phContext->dwUpper)
517 return SEC_E_INVALID_HANDLE;
523 context = ntlm_ContextNew();
526 return SEC_E_INSUFFICIENT_MEMORY;
528 context->server = TRUE;
530 if (fContextReq & ASC_REQ_CONFIDENTIALITY)
531 context->confidentiality = TRUE;
533 credentials = (
SSPI_CREDENTIALS*)sspi_SecureHandleGetLowerPointer(phCredential);
534 context->credentials = credentials;
535 context->SamFile = credentials->ntlmSettings.samFile;
536 context->HashCallback = credentials->ntlmSettings.hashCallback;
537 context->HashCallbackArg = credentials->ntlmSettings.hashCallbackArg;
539 ntlm_SetContextTargetName(context,
nullptr);
540 sspi_SecureHandleSetLowerPointer(phNewContext, context);
541 sspi_SecureHandleSetUpperPointer(phNewContext, (
void*)NTLM_PACKAGE_NAME);
544 switch (ntlm_get_state(context))
546 case NTLM_STATE_INITIAL:
548 ntlm_change_state(context, NTLM_STATE_NEGOTIATE);
551 return SEC_E_INVALID_TOKEN;
553 if (pInput->cBuffers < 1)
554 return SEC_E_INVALID_TOKEN;
556 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
559 return SEC_E_INVALID_TOKEN;
561 if (input_buffer->cbBuffer < 1)
562 return SEC_E_INVALID_TOKEN;
564 status = ntlm_read_NegotiateMessage(context, input_buffer);
565 if (status != SEC_I_CONTINUE_NEEDED)
568 if (ntlm_get_state(context) == NTLM_STATE_CHALLENGE)
571 return SEC_E_INVALID_TOKEN;
573 if (pOutput->cBuffers < 1)
574 return SEC_E_INVALID_TOKEN;
576 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
578 if (!output_buffer->BufferType)
579 return SEC_E_INVALID_TOKEN;
581 if (output_buffer->cbBuffer < 1)
582 return SEC_E_INSUFFICIENT_MEMORY;
584 return ntlm_write_ChallengeMessage(context, output_buffer);
587 return SEC_E_OUT_OF_SEQUENCE;
590 case NTLM_STATE_AUTHENTICATE:
593 return SEC_E_INVALID_TOKEN;
595 if (pInput->cBuffers < 1)
596 return SEC_E_INVALID_TOKEN;
598 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
601 return SEC_E_INVALID_TOKEN;
603 if (input_buffer->cbBuffer < 1)
604 return SEC_E_INVALID_TOKEN;
606 status = ntlm_read_AuthenticateMessage(context, input_buffer);
610 for (ULONG i = 0; i < pOutput->cBuffers; i++)
612 pOutput->pBuffers[i].cbBuffer = 0;
613 pOutput->pBuffers[i].BufferType = SECBUFFER_TOKEN;
621 return SEC_E_OUT_OF_SEQUENCE;
625static SECURITY_STATUS SEC_ENTRY
626ntlm_ImpersonateSecurityContext(WINPR_ATTR_UNUSED
PCtxtHandle phContext)
631static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
633 WINPR_ATTR_UNUSED ULONG Reserved1, WINPR_ATTR_UNUSED ULONG TargetDataRep,
PSecBufferDesc pInput,
635 WINPR_ATTR_UNUSED PULONG pfContextAttr, WINPR_ATTR_UNUSED
PTimeStamp ptsExpiry)
637 SECURITY_STATUS status = 0;
643 if (phContext && !phContext->dwLower && !phContext->dwUpper)
644 return SEC_E_INVALID_HANDLE;
650 input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN);
655 context = ntlm_ContextNew();
658 return SEC_E_INSUFFICIENT_MEMORY;
660 if (fContextReq & ISC_REQ_CONFIDENTIALITY)
661 context->confidentiality = TRUE;
663 credentials = (
SSPI_CREDENTIALS*)sspi_SecureHandleGetLowerPointer(phCredential);
664 context->credentials = credentials;
666 if (context->Workstation.Length < 1)
668 if (ntlm_SetContextWorkstation(context,
nullptr) < 0)
670 ntlm_ContextFree(context);
671 return SEC_E_INTERNAL_ERROR;
675 if (ntlm_SetContextServicePrincipalNameW(context, pszTargetName) < 0)
677 ntlm_ContextFree(context);
678 return SEC_E_INTERNAL_ERROR;
681 sspi_SecureHandleSetLowerPointer(phNewContext, context);
682 sspi_SecureHandleSetUpperPointer(phNewContext, NTLM_SSP_NAME);
685 if ((!input_buffer) || (ntlm_get_state(context) == NTLM_STATE_AUTHENTICATE))
688 return SEC_E_INVALID_TOKEN;
690 if (pOutput->cBuffers < 1)
691 return SEC_E_INVALID_TOKEN;
693 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
696 return SEC_E_INVALID_TOKEN;
698 if (output_buffer->cbBuffer < 1)
699 return SEC_E_INVALID_TOKEN;
701 if (ntlm_get_state(context) == NTLM_STATE_INITIAL)
702 ntlm_change_state(context, NTLM_STATE_NEGOTIATE);
704 if (ntlm_get_state(context) == NTLM_STATE_NEGOTIATE)
705 return ntlm_write_NegotiateMessage(context, output_buffer);
707 return SEC_E_OUT_OF_SEQUENCE;
712 return SEC_E_INVALID_TOKEN;
714 if (input_buffer->cbBuffer < 1)
715 return SEC_E_INVALID_TOKEN;
717 PSecBuffer channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS);
719 if (channel_bindings)
721 context->Bindings.BindingsLength = channel_bindings->cbBuffer;
725 if (ntlm_get_state(context) == NTLM_STATE_CHALLENGE)
727 status = ntlm_read_ChallengeMessage(context, input_buffer);
729 if (status != SEC_I_CONTINUE_NEEDED)
733 return SEC_E_INVALID_TOKEN;
735 if (pOutput->cBuffers < 1)
736 return SEC_E_INVALID_TOKEN;
738 output_buffer = sspi_FindSecBuffer(pOutput, SECBUFFER_TOKEN);
741 return SEC_E_INVALID_TOKEN;
743 if (output_buffer->cbBuffer < 1)
744 return SEC_E_INSUFFICIENT_MEMORY;
746 if (ntlm_get_state(context) == NTLM_STATE_AUTHENTICATE)
747 return ntlm_write_AuthenticateMessage(context, output_buffer);
750 return SEC_E_OUT_OF_SEQUENCE;
753 return SEC_E_OUT_OF_SEQUENCE;
759static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(
761 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
764 SECURITY_STATUS status = 0;
765 SEC_WCHAR* pszTargetNameW =
nullptr;
769 pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName,
nullptr);
771 return SEC_E_INTERNAL_ERROR;
774 status = ntlm_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq,
775 Reserved1, TargetDataRep, pInput, Reserved2,
776 phNewContext, pOutput, pfContextAttr, ptsExpiry);
777 free(pszTargetNameW);
783static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(
PCtxtHandle phContext)
786 ntlm_ContextFree(context);
792 BYTE* blob =
nullptr;
796 WINPR_ASSERT(ntproof);
798 target = &ntlm->ChallengeTargetInfo;
800 if (!sspi_SecBufferAlloc(ntproof, 36 + target->cbBuffer))
801 return SEC_E_INSUFFICIENT_MEMORY;
803 blob = (BYTE*)ntproof->pvBuffer;
804 CopyMemory(blob, ntlm->ServerChallenge, 8);
808 CopyMemory(&blob[16], ntlm->Timestamp, 8);
809 CopyMemory(&blob[24], ntlm->ClientChallenge, 8);
812 CopyMemory(&blob[36], target->pvBuffer, target->cbBuffer);
818 BYTE* blob =
nullptr;
822 WINPR_ASSERT(micvalue);
824 msgSize = ntlm->NegotiateMessage.cbBuffer + ntlm->ChallengeMessage.cbBuffer +
825 ntlm->AuthenticateMessage.cbBuffer;
827 if (!sspi_SecBufferAlloc(micvalue, msgSize))
828 return SEC_E_INSUFFICIENT_MEMORY;
830 blob = (BYTE*)micvalue->pvBuffer;
831 CopyMemory(blob, ntlm->NegotiateMessage.pvBuffer, ntlm->NegotiateMessage.cbBuffer);
832 blob += ntlm->NegotiateMessage.cbBuffer;
833 CopyMemory(blob, ntlm->ChallengeMessage.pvBuffer, ntlm->ChallengeMessage.cbBuffer);
834 blob += ntlm->ChallengeMessage.cbBuffer;
835 CopyMemory(blob, ntlm->AuthenticateMessage.pvBuffer, ntlm->AuthenticateMessage.cbBuffer);
836 blob += ntlm->MessageIntegrityCheckOffset;
837 ZeroMemory(blob, 16);
843static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(
PCtxtHandle phContext,
844 ULONG ulAttribute,
void* pBuffer)
847 return SEC_E_INVALID_HANDLE;
850 return SEC_E_INSUFFICIENT_MEMORY;
853 if (!check_context(context))
854 return SEC_E_INVALID_HANDLE;
856 if (ulAttribute == SECPKG_ATTR_SIZES)
859 ContextSizes->cbMaxToken = 2010;
860 ContextSizes->cbMaxSignature = 16;
861 ContextSizes->cbBlockSize = 0;
862 ContextSizes->cbSecurityTrailer = 16;
866 else if (ulAttribute == SECPKG_ATTR_AUTH_IDENTITY)
872 WINPR_ASSERT(AuthIdentity);
873 *AuthIdentity = empty;
875 context->UseSamFileDatabase = FALSE;
876 credentials = context->credentials;
878 if (credentials->identity.UserLength > 0)
880 if (ConvertWCharNToUtf8(credentials->identity.User, credentials->identity.UserLength,
881 AuthIdentity->User, ARRAYSIZE(AuthIdentity->User)) <= 0)
882 return SEC_E_INTERNAL_ERROR;
885 if (credentials->identity.DomainLength > 0)
887 if (ConvertWCharNToUtf8(credentials->identity.Domain,
888 credentials->identity.DomainLength, AuthIdentity->Domain,
889 ARRAYSIZE(AuthIdentity->Domain)) <= 0)
890 return SEC_E_INTERNAL_ERROR;
895 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_NTPROOF_VALUE)
897 return ntlm_computeProofValue(context, (
SecBuffer*)pBuffer);
899 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_RANDKEY)
904 if (!sspi_SecBufferAlloc(randkey, 16))
905 return (SEC_E_INSUFFICIENT_MEMORY);
907 CopyMemory(randkey->pvBuffer, context->EncryptedRandomSessionKey, 16);
910 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_MIC)
915 if (!sspi_SecBufferAlloc(mic, 16))
916 return (SEC_E_INSUFFICIENT_MEMORY);
918 CopyMemory(mic->pvBuffer, message->MessageIntegrityCheck, 16);
921 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_MIC_VALUE)
923 return ntlm_computeMicValue(context, (
SecBuffer*)pBuffer);
925 else if (ulAttribute == SECPKG_ATTR_PACKAGE_INFO)
930 (
SecPkgInfoA*)sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size);
933 return SEC_E_INSUFFICIENT_MEMORY;
935 pPackageInfo->fCapabilities = NTLM_SecPkgInfoA.fCapabilities;
936 pPackageInfo->wVersion = NTLM_SecPkgInfoA.wVersion;
937 pPackageInfo->wRPCID = NTLM_SecPkgInfoA.wRPCID;
938 pPackageInfo->cbMaxToken = NTLM_SecPkgInfoA.cbMaxToken;
939 pPackageInfo->Name = _strdup(NTLM_SecPkgInfoA.Name);
940 pPackageInfo->Comment = _strdup(NTLM_SecPkgInfoA.Comment);
942 if (!pPackageInfo->Name || !pPackageInfo->Comment)
944 sspi_ContextBufferFree(pPackageInfo);
945 return SEC_E_INSUFFICIENT_MEMORY;
947 PackageInfo->PackageInfo = pPackageInfo;
951 WLog_ERR(TAG,
"TODO: Implement ulAttribute=0x%08" PRIx32, ulAttribute);
952 return SEC_E_UNSUPPORTED_FUNCTION;
955static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA(
PCtxtHandle phContext,
956 ULONG ulAttribute,
void* pBuffer)
958 return ntlm_QueryContextAttributesW(phContext, ulAttribute, pBuffer);
961static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesW(
PCtxtHandle phContext,
962 ULONG ulAttribute,
void* pBuffer,
966 return SEC_E_INVALID_HANDLE;
969 return SEC_E_INVALID_PARAMETER;
973 return SEC_E_INVALID_HANDLE;
975 if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_HASH)
980 return SEC_E_INVALID_PARAMETER;
982 if (AuthNtlmHash->Version == 1)
983 CopyMemory(context->NtlmHash, AuthNtlmHash->NtlmHash, 16);
984 else if (AuthNtlmHash->Version == 2)
985 CopyMemory(context->NtlmV2Hash, AuthNtlmHash->NtlmHash, 16);
989 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_MESSAGE)
994 return SEC_E_INVALID_PARAMETER;
996 if (AuthNtlmMessage->type == 1)
998 sspi_SecBufferFree(&context->NegotiateMessage);
1000 if (!sspi_SecBufferAlloc(&context->NegotiateMessage, AuthNtlmMessage->length))
1001 return SEC_E_INSUFFICIENT_MEMORY;
1003 CopyMemory(context->NegotiateMessage.pvBuffer, AuthNtlmMessage->buffer,
1004 AuthNtlmMessage->length);
1006 else if (AuthNtlmMessage->type == 2)
1008 sspi_SecBufferFree(&context->ChallengeMessage);
1010 if (!sspi_SecBufferAlloc(&context->ChallengeMessage, AuthNtlmMessage->length))
1011 return SEC_E_INSUFFICIENT_MEMORY;
1013 CopyMemory(context->ChallengeMessage.pvBuffer, AuthNtlmMessage->buffer,
1014 AuthNtlmMessage->length);
1016 else if (AuthNtlmMessage->type == 3)
1018 sspi_SecBufferFree(&context->AuthenticateMessage);
1020 if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, AuthNtlmMessage->length))
1021 return SEC_E_INSUFFICIENT_MEMORY;
1023 CopyMemory(context->AuthenticateMessage.pvBuffer, AuthNtlmMessage->buffer,
1024 AuthNtlmMessage->length);
1029 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_TIMESTAMP)
1035 return SEC_E_INVALID_PARAMETER;
1037 if (AuthNtlmTimestamp->ChallengeOrResponse)
1038 CopyMemory(context->ChallengeTimestamp, AuthNtlmTimestamp->Timestamp, 8);
1040 CopyMemory(context->Timestamp, AuthNtlmTimestamp->Timestamp, 8);
1044 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_CLIENT_CHALLENGE)
1050 return SEC_E_INVALID_PARAMETER;
1052 CopyMemory(context->ClientChallenge, AuthNtlmClientChallenge->ClientChallenge, 8);
1055 else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_SERVER_CHALLENGE)
1061 return SEC_E_INVALID_PARAMETER;
1063 CopyMemory(context->ServerChallenge, AuthNtlmServerChallenge->ServerChallenge, 8);
1067 WLog_ERR(TAG,
"TODO: Implement ulAttribute=%08" PRIx32, ulAttribute);
1068 return SEC_E_UNSUPPORTED_FUNCTION;
1071static SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesA(
PCtxtHandle phContext,
1072 ULONG ulAttribute,
void* pBuffer,
1075 return ntlm_SetContextAttributesW(phContext, ulAttribute, pBuffer, cbBuffer);
1078static SECURITY_STATUS SEC_ENTRY ntlm_SetCredentialsAttributesW(
1079 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
1080 WINPR_ATTR_UNUSED
void* pBuffer, WINPR_ATTR_UNUSED ULONG cbBuffer)
1082 return SEC_E_UNSUPPORTED_FUNCTION;
1085static SECURITY_STATUS SEC_ENTRY ntlm_SetCredentialsAttributesA(
1086 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
1087 WINPR_ATTR_UNUSED
void* pBuffer, WINPR_ATTR_UNUSED ULONG cbBuffer)
1089 return SEC_E_UNSUPPORTED_FUNCTION;
1092static SECURITY_STATUS SEC_ENTRY ntlm_RevertSecurityContext(WINPR_ATTR_UNUSED
PCtxtHandle phContext)
1097static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(
PCtxtHandle phContext,
1098 WINPR_ATTR_UNUSED ULONG fQOP,
1101 const UINT32 SeqNo = MessageSeqNo;
1103 BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
1104 BYTE checksum[8] = WINPR_C_ARRAY_INIT;
1109 if (!check_context(context))
1110 return SEC_E_INVALID_HANDLE;
1112 for (ULONG index = 0; index < pMessage->cBuffers; index++)
1114 SecBuffer* cur = &pMessage->pBuffers[index];
1116 if (cur->BufferType & SECBUFFER_DATA)
1118 else if (cur->BufferType & SECBUFFER_TOKEN)
1119 signature_buffer = cur;
1123 return SEC_E_INVALID_TOKEN;
1125 if (!signature_buffer)
1126 return SEC_E_INVALID_TOKEN;
1129 ULONG length = data_buffer->cbBuffer;
1130 void* data = malloc(length);
1133 return SEC_E_INSUFFICIENT_MEMORY;
1135 CopyMemory(data, data_buffer->pvBuffer, length);
1137 WINPR_HMAC_CTX* hmac = winpr_HMAC_New();
1139 BOOL success = FALSE;
1143 if (!winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->SendSigningKey, WINPR_MD5_DIGEST_LENGTH))
1146 winpr_Data_Write_UINT32(&value, SeqNo);
1148 if (!winpr_HMAC_Update(hmac, (
void*)&value, 4))
1150 if (!winpr_HMAC_Update(hmac, data, length))
1152 if (!winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH))
1159 winpr_HMAC_Free(hmac);
1163 return SEC_E_INSUFFICIENT_MEMORY;
1167 if ((data_buffer->BufferType & SECBUFFER_READONLY) == 0)
1169 if (context->confidentiality)
1171 if (!winpr_RC4_Update(context->SendRc4Seal, length, (BYTE*)data,
1172 (BYTE*)data_buffer->pvBuffer))
1175 return SEC_E_INSUFFICIENT_MEMORY;
1179 CopyMemory(data_buffer->pvBuffer, data, length);
1182#ifdef WITH_DEBUG_NTLM
1183 WLog_DBG(TAG,
"Data Buffer (length = %" PRIu32
")", length);
1184 winpr_HexDump(TAG, WLOG_DEBUG, data, length);
1185 WLog_DBG(TAG,
"Encrypted Data Buffer (length = %" PRIu32
")", data_buffer->cbBuffer);
1186 winpr_HexDump(TAG, WLOG_DEBUG, data_buffer->pvBuffer, data_buffer->cbBuffer);
1190 if (!winpr_RC4_Update(context->SendRc4Seal, 8, digest, checksum))
1191 return SEC_E_INSUFFICIENT_MEMORY;
1192 if ((signature_buffer->BufferType & SECBUFFER_READONLY) == 0)
1194 BYTE* signature = signature_buffer->pvBuffer;
1196 winpr_Data_Write_UINT32(signature, version);
1197 CopyMemory(&signature[4], (
void*)checksum, 8);
1198 winpr_Data_Write_UINT32(&signature[12], SeqNo);
1200 context->SendSeqNum++;
1201#ifdef WITH_DEBUG_NTLM
1202 WLog_DBG(TAG,
"Signature (length = %" PRIu32
")", signature_buffer->cbBuffer);
1203 winpr_HexDump(TAG, WLOG_DEBUG, signature_buffer->pvBuffer, signature_buffer->cbBuffer);
1210 WINPR_ATTR_UNUSED PULONG pfQOP)
1212 const UINT32 SeqNo = (UINT32)MessageSeqNo;
1214 BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
1215 BYTE checksum[8] = WINPR_C_ARRAY_INIT;
1217 BYTE expected_signature[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
1221 if (!check_context(context))
1222 return SEC_E_INVALID_HANDLE;
1224 for (ULONG index = 0; index < pMessage->cBuffers; index++)
1226 if (pMessage->pBuffers[index].BufferType == SECBUFFER_DATA)
1227 data_buffer = &pMessage->pBuffers[index];
1228 else if (pMessage->pBuffers[index].BufferType == SECBUFFER_TOKEN)
1229 signature_buffer = &pMessage->pBuffers[index];
1233 return SEC_E_INVALID_TOKEN;
1235 if (!signature_buffer)
1236 return SEC_E_INVALID_TOKEN;
1239 const ULONG length = data_buffer->cbBuffer;
1240 void* data = malloc(length);
1243 return SEC_E_INSUFFICIENT_MEMORY;
1245 CopyMemory(data, data_buffer->pvBuffer, length);
1249 if (context->confidentiality)
1251 if (!winpr_RC4_Update(context->RecvRc4Seal, length, (BYTE*)data,
1252 (BYTE*)data_buffer->pvBuffer))
1255 return SEC_E_INSUFFICIENT_MEMORY;
1259 CopyMemory(data_buffer->pvBuffer, data, length);
1262 WINPR_HMAC_CTX* hmac = winpr_HMAC_New();
1264 BOOL success = FALSE;
1269 if (!winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->RecvSigningKey, WINPR_MD5_DIGEST_LENGTH))
1272 winpr_Data_Write_UINT32(&value, SeqNo);
1274 if (!winpr_HMAC_Update(hmac, (
void*)&value, 4))
1276 if (!winpr_HMAC_Update(hmac, data_buffer->pvBuffer, data_buffer->cbBuffer))
1278 if (!winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH))
1284 winpr_HMAC_Free(hmac);
1288 return SEC_E_INSUFFICIENT_MEMORY;
1291#ifdef WITH_DEBUG_NTLM
1292 WLog_DBG(TAG,
"Encrypted Data Buffer (length = %" PRIu32
")", length);
1293 winpr_HexDump(TAG, WLOG_DEBUG, data, length);
1294 WLog_DBG(TAG,
"Data Buffer (length = %" PRIu32
")", data_buffer->cbBuffer);
1295 winpr_HexDump(TAG, WLOG_DEBUG, data_buffer->pvBuffer, data_buffer->cbBuffer);
1299 if (!winpr_RC4_Update(context->RecvRc4Seal, 8, digest, checksum))
1300 return SEC_E_MESSAGE_ALTERED;
1303 winpr_Data_Write_UINT32(expected_signature, version);
1304 CopyMemory(&expected_signature[4], (
void*)checksum, 8);
1305 winpr_Data_Write_UINT32(&expected_signature[12], SeqNo);
1306 context->RecvSeqNum++;
1308 if (memcmp(signature_buffer->pvBuffer, expected_signature, 16) != 0)
1311 WLog_ERR(TAG,
"signature verification failed, something nasty is going on!");
1312#ifdef WITH_DEBUG_NTLM
1313 WLog_ERR(TAG,
"Expected Signature:");
1314 winpr_HexDump(TAG, WLOG_ERROR, expected_signature, 16);
1315 WLog_ERR(TAG,
"Actual Signature:");
1316 winpr_HexDump(TAG, WLOG_ERROR, (BYTE*)signature_buffer->pvBuffer, 16);
1318 return SEC_E_MESSAGE_ALTERED;
1324static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(
PCtxtHandle phContext,
1325 WINPR_ATTR_UNUSED ULONG fQOP,
1328 SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
1332 BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
1333 BYTE checksum[8] = WINPR_C_ARRAY_INIT;
1335 NTLM_CONTEXT* context = sspi_SecureHandleGetLowerPointer(phContext);
1336 if (!check_context(context))
1337 return SEC_E_INVALID_HANDLE;
1339 for (ULONG i = 0; i < pMessage->cBuffers; i++)
1341 if (pMessage->pBuffers[i].BufferType == SECBUFFER_DATA)
1342 data_buffer = &pMessage->pBuffers[i];
1343 else if (pMessage->pBuffers[i].BufferType == SECBUFFER_TOKEN)
1344 sig_buffer = &pMessage->pBuffers[i];
1347 if (!data_buffer || !sig_buffer)
1348 return SEC_E_INVALID_TOKEN;
1350 WINPR_HMAC_CTX* hmac = winpr_HMAC_New();
1352 if (!winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->SendSigningKey, WINPR_MD5_DIGEST_LENGTH))
1355 winpr_Data_Write_UINT32(&seq_no, MessageSeqNo);
1356 if (!winpr_HMAC_Update(hmac, (BYTE*)&seq_no, 4))
1358 if (!winpr_HMAC_Update(hmac, data_buffer->pvBuffer, data_buffer->cbBuffer))
1360 if (!winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH))
1363 if (!winpr_RC4_Update(context->SendRc4Seal, 8, digest, checksum))
1366 BYTE* signature = sig_buffer->pvBuffer;
1367 winpr_Data_Write_UINT32(signature, 1L);
1368 CopyMemory(&signature[4], checksum, 8);
1369 winpr_Data_Write_UINT32(&signature[12], seq_no);
1370 sig_buffer->cbBuffer = 16;
1375 winpr_HMAC_Free(hmac);
1379static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(
PCtxtHandle phContext,
1381 WINPR_ATTR_UNUSED PULONG pfQOP)
1383 SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
1387 BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
1388 BYTE checksum[8] = WINPR_C_ARRAY_INIT;
1389 BYTE signature[16] = WINPR_C_ARRAY_INIT;
1391 NTLM_CONTEXT* context = sspi_SecureHandleGetLowerPointer(phContext);
1392 if (!check_context(context))
1393 return SEC_E_INVALID_HANDLE;
1395 for (ULONG i = 0; i < pMessage->cBuffers; i++)
1397 if (pMessage->pBuffers[i].BufferType == SECBUFFER_DATA)
1398 data_buffer = &pMessage->pBuffers[i];
1399 else if (pMessage->pBuffers[i].BufferType == SECBUFFER_TOKEN)
1400 sig_buffer = &pMessage->pBuffers[i];
1403 if (!data_buffer || !sig_buffer)
1404 return SEC_E_INVALID_TOKEN;
1406 WINPR_HMAC_CTX* hmac = winpr_HMAC_New();
1408 if (!winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->RecvSigningKey, WINPR_MD5_DIGEST_LENGTH))
1411 winpr_Data_Write_UINT32(&seq_no, MessageSeqNo);
1412 if (!winpr_HMAC_Update(hmac, (BYTE*)&seq_no, 4))
1414 if (!winpr_HMAC_Update(hmac, data_buffer->pvBuffer, data_buffer->cbBuffer))
1416 if (!winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH))
1419 if (!winpr_RC4_Update(context->RecvRc4Seal, 8, digest, checksum))
1422 winpr_Data_Write_UINT32(signature, 1L);
1423 CopyMemory(&signature[4], checksum, 8);
1424 winpr_Data_Write_UINT32(&signature[12], seq_no);
1427 if (memcmp(sig_buffer->pvBuffer, signature, 16) != 0)
1428 status = SEC_E_MESSAGE_ALTERED;
1431 winpr_HMAC_Free(hmac);
1438 ntlm_QueryCredentialsAttributesA,
1439 ntlm_AcquireCredentialsHandleA,
1440 ntlm_FreeCredentialsHandle,
1442 ntlm_InitializeSecurityContextA,
1443 ntlm_AcceptSecurityContext,
1445 ntlm_DeleteSecurityContext,
1447 ntlm_QueryContextAttributesA,
1448 ntlm_ImpersonateSecurityContext,
1449 ntlm_RevertSecurityContext,
1451 ntlm_VerifySignature,
1461 ntlm_EncryptMessage,
1462 ntlm_DecryptMessage,
1463 ntlm_SetContextAttributesA,
1464 ntlm_SetCredentialsAttributesA,
1470 ntlm_QueryCredentialsAttributesW,
1471 ntlm_AcquireCredentialsHandleW,
1472 ntlm_FreeCredentialsHandle,
1474 ntlm_InitializeSecurityContextW,
1475 ntlm_AcceptSecurityContext,
1477 ntlm_DeleteSecurityContext,
1479 ntlm_QueryContextAttributesW,
1480 ntlm_ImpersonateSecurityContext,
1481 ntlm_RevertSecurityContext,
1483 ntlm_VerifySignature,
1493 ntlm_EncryptMessage,
1494 ntlm_DecryptMessage,
1495 ntlm_SetContextAttributesW,
1496 ntlm_SetCredentialsAttributesW,
1505 "NTLM Security Package"
1508static WCHAR NTLM_SecPkgInfoW_NameBuffer[32] = WINPR_C_ARRAY_INIT;
1509static WCHAR NTLM_SecPkgInfoW_CommentBuffer[32] = WINPR_C_ARRAY_INIT;
1516 NTLM_SecPkgInfoW_NameBuffer,
1517 NTLM_SecPkgInfoW_CommentBuffer
1520char* ntlm_negotiate_flags_string(
char* buffer,
size_t size, UINT32 flags)
1522 if (!buffer || (size == 0))
1525 (void)_snprintf(buffer, size,
"[0x%08" PRIx32
"] ", flags);
1527 for (
int x = 0; x < 31; x++)
1529 const UINT32 mask = 1u << x;
1530 size_t len = strnlen(buffer, size);
1533 const char* str = ntlm_get_negotiate_string(mask);
1534 const size_t flen = strlen(str);
1536 if ((len > 0) && (buffer[len - 1] !=
' '))
1540 winpr_str_append(
"|", buffer, size,
nullptr);
1544 if (size - len < flen)
1546 winpr_str_append(str, buffer, size,
nullptr);
1553const char* ntlm_message_type_string(UINT32 messageType)
1555 switch (messageType)
1557 case MESSAGE_TYPE_NEGOTIATE:
1558 return "MESSAGE_TYPE_NEGOTIATE";
1559 case MESSAGE_TYPE_CHALLENGE:
1560 return "MESSAGE_TYPE_CHALLENGE";
1561 case MESSAGE_TYPE_AUTHENTICATE:
1562 return "MESSAGE_TYPE_AUTHENTICATE";
1564 return "MESSAGE_TYPE_UNKNOWN";
1568const char* ntlm_state_string(NTLM_STATE state)
1572 case NTLM_STATE_INITIAL:
1573 return "NTLM_STATE_INITIAL";
1574 case NTLM_STATE_NEGOTIATE:
1575 return "NTLM_STATE_NEGOTIATE";
1576 case NTLM_STATE_CHALLENGE:
1577 return "NTLM_STATE_CHALLENGE";
1578 case NTLM_STATE_AUTHENTICATE:
1579 return "NTLM_STATE_AUTHENTICATE";
1580 case NTLM_STATE_FINAL:
1581 return "NTLM_STATE_FINAL";
1583 return "NTLM_STATE_UNKNOWN";
1586void ntlm_change_state(
NTLM_CONTEXT* ntlm, NTLM_STATE state)
1589 WLog_DBG(TAG,
"change state from %s to %s", ntlm_state_string(ntlm->state),
1590 ntlm_state_string(state));
1591 ntlm->state = state;
1600BOOL ntlm_reset_cipher_state(
PSecHandle phContext)
1602 NTLM_CONTEXT* context = sspi_SecureHandleGetLowerPointer(phContext);
1606 check_context(context);
1607 winpr_RC4_Free(context->SendRc4Seal);
1608 winpr_RC4_Free(context->RecvRc4Seal);
1609 context->SendRc4Seal = winpr_RC4_New(context->RecvSealingKey, 16);
1610 context->RecvRc4Seal = winpr_RC4_New(context->SendSealingKey, 16);
1612 if (!context->SendRc4Seal)
1614 WLog_ERR(TAG,
"Failed to allocate context->SendRc4Seal");
1617 if (!context->RecvRc4Seal)
1619 WLog_ERR(TAG,
"Failed to allocate context->RecvRc4Seal");
1629 InitializeConstWCharFromUtf8(NTLM_SecPkgInfoA.Name, NTLM_SecPkgInfoW_NameBuffer,
1630 ARRAYSIZE(NTLM_SecPkgInfoW_NameBuffer));
1631 InitializeConstWCharFromUtf8(NTLM_SecPkgInfoA.Comment, NTLM_SecPkgInfoW_CommentBuffer,
1632 ARRAYSIZE(NTLM_SecPkgInfoW_CommentBuffer));