libwinpr-sspi: start using Heap functions
This commit is contained in:
parent
4b72bcd3d7
commit
d57e879d7c
@ -30,5 +30,6 @@
|
||||
#endif
|
||||
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/memory.h>
|
||||
|
||||
#endif /* WINPR_CRT_H */
|
||||
|
@ -24,19 +24,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#define CopyMemory RtlCopyMemory
|
||||
#define MoveMemory RtlMoveMemory
|
||||
#define FillMemory RtlFillMemory
|
||||
#define ZeroMemory RtlZeroMemory
|
||||
#define CopyMemory RtlCopyMemory
|
||||
#define MoveMemory RtlMoveMemory
|
||||
#define FillMemory RtlFillMemory
|
||||
#define ZeroMemory RtlZeroMemory
|
||||
|
||||
#define RtlCopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
|
||||
#define RtlMoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
|
||||
#define RtlFillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
|
||||
#define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length))
|
||||
|
||||
#define HEAP_GENERATE_EXCEPTIONS 0x00000004
|
||||
#define HEAP_NO_SERIALIZE 0x00000001
|
||||
#define HEAP_ZERO_MEMORY 0x00000008
|
||||
#define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
|
||||
|
||||
WINPR_API HANDLE GetProcessHeap(void);
|
||||
WINPR_API LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);
|
||||
WINPR_API LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes);
|
||||
WINPR_API BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_CRT_MEMORY_H */
|
||||
|
@ -24,6 +24,36 @@
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
HANDLE GetProcessHeap(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
|
||||
{
|
||||
LPVOID lpMem = NULL;
|
||||
|
||||
if (dwFlags & HEAP_ZERO_MEMORY)
|
||||
lpMem = calloc(1, dwBytes);
|
||||
else
|
||||
lpMem = malloc(dwBytes);
|
||||
|
||||
return lpMem;
|
||||
}
|
||||
|
||||
LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes)
|
||||
{
|
||||
LPVOID lpNewMem;
|
||||
|
||||
lpNewMem = realloc(lpMem, dwBytes);
|
||||
|
||||
return lpNewMem;
|
||||
}
|
||||
|
||||
BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
|
||||
{
|
||||
free(lpMem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ const char* const AV_PAIRS_STRINGS[] =
|
||||
void ntlm_input_av_pairs(NTLM_CONTEXT* context, STREAM* s)
|
||||
{
|
||||
AV_ID AvId;
|
||||
uint16 AvLen;
|
||||
UINT16 AvLen;
|
||||
uint8* value;
|
||||
AV_PAIRS* av_pairs = context->av_pairs;
|
||||
|
||||
|
@ -52,7 +52,7 @@ void ntlm_output_restriction_encoding(NTLM_CONTEXT* context)
|
||||
STREAM* s;
|
||||
AV_PAIR* restrictions = &context->av_pairs->Restrictions;
|
||||
|
||||
uint8 machineID[32] =
|
||||
BYTE machineID[32] =
|
||||
"\x3A\x15\x8E\xA6\x75\x82\xD8\xF7\x3E\x06\xFA\x7A\xB4\xDF\xFD\x43"
|
||||
"\x84\x6C\x02\x3A\xFD\x5A\x94\xFE\xCF\x97\x0F\x3D\x19\x2C\x38\x20";
|
||||
|
||||
@ -90,12 +90,12 @@ void ntlm_output_target_name(NTLM_CONTEXT* context)
|
||||
* MsvAvTargetName should be the name of the service be accessed after authentication)
|
||||
* here used: "TERMSRV/192.168.0.123" in unicode (Dmitrij Jasnov)
|
||||
*/
|
||||
uint8 name[42] =
|
||||
BYTE name[42] =
|
||||
"\x54\x00\x45\x00\x52\x00\x4d\x00\x53\x00\x52\x00\x56\x00\x2f\x00\x31\x00\x39\x00\x32"
|
||||
"\x00\x2e\x00\x31\x00\x36\x00\x38\x00\x2e\x00\x30\x00\x2e\x00\x31\x00\x32\x00\x33\x00";
|
||||
|
||||
TargetName->length = 42;
|
||||
TargetName->value = (uint8*) malloc(TargetName->length);
|
||||
TargetName->value = (BYTE*) malloc(TargetName->length);
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, TargetName->value, TargetName->length);
|
||||
@ -115,7 +115,7 @@ void ntlm_output_channel_bindings(NTLM_CONTEXT* context)
|
||||
STREAM* s;
|
||||
AV_PAIR* ChannelBindings = &context->av_pairs->ChannelBindings;
|
||||
|
||||
ChannelBindings->value = (uint8*) malloc(48);
|
||||
ChannelBindings->value = (BYTE*) malloc(48);
|
||||
ChannelBindings->length = 16;
|
||||
|
||||
s = stream_new(0);
|
||||
@ -131,7 +131,7 @@ void ntlm_output_channel_bindings(NTLM_CONTEXT* context)
|
||||
* @param[out] timestamp 64-bit little-endian timestamp
|
||||
*/
|
||||
|
||||
void ntlm_current_time(uint8* timestamp)
|
||||
void ntlm_current_time(BYTE* timestamp)
|
||||
{
|
||||
uint64 time64;
|
||||
|
||||
@ -221,10 +221,10 @@ void ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)
|
||||
int length;
|
||||
char* db_user;
|
||||
char* db_hash;
|
||||
uint16* User;
|
||||
uint32 UserLength;
|
||||
UINT16* User;
|
||||
UINT32 UserLength;
|
||||
long int file_size;
|
||||
unsigned char db_hash_bin[16];
|
||||
BYTE db_hash_bin[16];
|
||||
|
||||
/* Fetch NTLMv2 hash from database */
|
||||
|
||||
@ -301,7 +301,7 @@ void ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)
|
||||
|
||||
/* Concatenate(Uppercase(username),domain)*/
|
||||
memcpy(p, context->identity.User, context->identity.UserLength);
|
||||
CharUpperBuffW(p, context->identity.UserLength / 2);
|
||||
CharUpperBuffW((LPWSTR) p, context->identity.UserLength / 2);
|
||||
|
||||
memcpy(&p[context->identity.UserLength], context->identity.Domain, context->identity.DomainLength);
|
||||
|
||||
@ -350,35 +350,35 @@ void ntlm_compute_lm_v2_response(NTLM_CONTEXT* context)
|
||||
|
||||
void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
|
||||
{
|
||||
uint8* blob;
|
||||
uint8 ntlm_v2_hash[16];
|
||||
uint8 nt_proof_str[16];
|
||||
BYTE* blob;
|
||||
BYTE ntlm_v2_hash[16];
|
||||
BYTE nt_proof_str[16];
|
||||
SecBuffer ntlm_v2_temp;
|
||||
SecBuffer ntlm_v2_temp_chal;
|
||||
|
||||
sspi_SecBufferAlloc(&ntlm_v2_temp, context->TargetInfo.cbBuffer + 28);
|
||||
|
||||
memset(ntlm_v2_temp.pvBuffer, '\0', ntlm_v2_temp.cbBuffer);
|
||||
blob = (uint8*) ntlm_v2_temp.pvBuffer;
|
||||
blob = (BYTE*) ntlm_v2_temp.pvBuffer;
|
||||
|
||||
/* Compute the NTLMv2 hash */
|
||||
ntlm_compute_ntlm_v2_hash(context, (char*) ntlm_v2_hash);
|
||||
|
||||
#ifdef WITH_DEBUG_NTLM
|
||||
printf("Password (length = %d)\n", context->identity.PasswordLength);
|
||||
freerdp_hexdump((uint8*) context->identity.Password, context->identity.PasswordLength);
|
||||
freerdp_hexdump((BYTE*) context->identity.Password, context->identity.PasswordLength);
|
||||
printf("\n");
|
||||
|
||||
printf("Username (length = %d)\n", context->identity.UserLength);
|
||||
freerdp_hexdump((uint8*) context->identity.User, context->identity.UserLength);
|
||||
freerdp_hexdump((BYTE*) context->identity.User, context->identity.UserLength);
|
||||
printf("\n");
|
||||
|
||||
printf("Domain (length = %d)\n", context->identity.DomainLength);
|
||||
freerdp_hexdump((uint8*) context->identity.Domain, context->identity.DomainLength);
|
||||
freerdp_hexdump((BYTE*) context->identity.Domain, context->identity.DomainLength);
|
||||
printf("\n");
|
||||
|
||||
printf("Workstation (length = %d)\n", context->WorkstationLength);
|
||||
freerdp_hexdump((uint8*) context->Workstation, context->WorkstationLength);
|
||||
freerdp_hexdump((BYTE*) context->Workstation, context->WorkstationLength);
|
||||
printf("\n");
|
||||
|
||||
printf("NTOWFv2, NTLMv2 Hash\n");
|
||||
@ -404,7 +404,7 @@ void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
|
||||
|
||||
/* Concatenate server challenge with temp */
|
||||
sspi_SecBufferAlloc(&ntlm_v2_temp_chal, ntlm_v2_temp.cbBuffer + 8);
|
||||
blob = (uint8*) ntlm_v2_temp_chal.pvBuffer;
|
||||
blob = (BYTE*) ntlm_v2_temp_chal.pvBuffer;
|
||||
memcpy(blob, context->ServerChallenge, 8);
|
||||
memcpy(&blob[8], ntlm_v2_temp.pvBuffer, ntlm_v2_temp.cbBuffer);
|
||||
|
||||
@ -413,7 +413,7 @@ void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
|
||||
|
||||
/* NtChallengeResponse, Concatenate NTProofStr with temp */
|
||||
sspi_SecBufferAlloc(&context->NtChallengeResponse, ntlm_v2_temp.cbBuffer + 16);
|
||||
blob = (uint8*) context->NtChallengeResponse.pvBuffer;
|
||||
blob = (BYTE*) context->NtChallengeResponse.pvBuffer;
|
||||
memcpy(blob, nt_proof_str, 16);
|
||||
memcpy(&blob[16], ntlm_v2_temp.pvBuffer, ntlm_v2_temp.cbBuffer);
|
||||
|
||||
@ -432,7 +432,7 @@ void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
|
||||
* @param ciphertext cipher text
|
||||
*/
|
||||
|
||||
void ntlm_rc4k(uint8* key, int length, uint8* plaintext, uint8* ciphertext)
|
||||
void ntlm_rc4k(BYTE* key, int length, BYTE* plaintext, BYTE* ciphertext)
|
||||
{
|
||||
CryptoRc4 rc4;
|
||||
|
||||
@ -529,14 +529,14 @@ void ntlm_decrypt_random_session_key(NTLM_CONTEXT* context)
|
||||
* @param signing_key Destination signing key
|
||||
*/
|
||||
|
||||
void ntlm_generate_signing_key(uint8* exported_session_key, PSecBuffer sign_magic, uint8* signing_key)
|
||||
void ntlm_generate_signing_key(BYTE* exported_session_key, PSecBuffer sign_magic, BYTE* signing_key)
|
||||
{
|
||||
int length;
|
||||
uint8* value;
|
||||
BYTE* value;
|
||||
CryptoMd5 md5;
|
||||
|
||||
length = 16 + sign_magic->cbBuffer;
|
||||
value = (uint8*) malloc(length);
|
||||
value = (BYTE*) malloc(length);
|
||||
|
||||
/* Concatenate ExportedSessionKey with sign magic */
|
||||
memcpy(value, exported_session_key, 16);
|
||||
@ -585,14 +585,14 @@ void ntlm_generate_server_signing_key(NTLM_CONTEXT* context)
|
||||
* @param sealing_key Destination sealing key
|
||||
*/
|
||||
|
||||
void ntlm_generate_sealing_key(uint8* exported_session_key, PSecBuffer seal_magic, uint8* sealing_key)
|
||||
void ntlm_generate_sealing_key(BYTE* exported_session_key, PSecBuffer seal_magic, BYTE* sealing_key)
|
||||
{
|
||||
uint8* p;
|
||||
BYTE* p;
|
||||
CryptoMd5 md5;
|
||||
SecBuffer buffer;
|
||||
|
||||
sspi_SecBufferAlloc(&buffer, 16 + seal_magic->cbBuffer);
|
||||
p = (uint8*) buffer.pvBuffer;
|
||||
p = (BYTE*) buffer.pvBuffer;
|
||||
|
||||
/* Concatenate ExportedSessionKey with seal magic */
|
||||
memcpy(p, exported_session_key, 16);
|
||||
|
@ -126,7 +126,7 @@ void ntlm_output_version(STREAM* s)
|
||||
stream_write_uint8(s, NTLMSSP_REVISION_W2K3); /* NTLMRevisionCurrent (1 byte) */
|
||||
}
|
||||
|
||||
void ntlm_print_negotiate_flags(uint32 flags)
|
||||
void ntlm_print_negotiate_flags(UINT32 flags)
|
||||
{
|
||||
int i;
|
||||
const char* str;
|
||||
@ -149,15 +149,15 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
uint8 Signature[8];
|
||||
uint32 MessageType;
|
||||
uint32 NegotiateFlags;
|
||||
uint16 DomainNameLen;
|
||||
uint16 DomainNameMaxLen;
|
||||
uint32 DomainNameBufferOffset;
|
||||
uint16 WorkstationLen;
|
||||
uint16 WorkstationMaxLen;
|
||||
uint32 WorkstationBufferOffset;
|
||||
BYTE Signature[8];
|
||||
UINT32 MessageType;
|
||||
UINT32 NegotiateFlags;
|
||||
UINT16 DomainNameLen;
|
||||
UINT16 DomainNameMaxLen;
|
||||
UINT32 DomainNameBufferOffset;
|
||||
UINT16 WorkstationLen;
|
||||
UINT16 WorkstationMaxLen;
|
||||
UINT32 WorkstationBufferOffset;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, buffer->pvBuffer, buffer->cbBuffer);
|
||||
@ -229,7 +229,7 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
uint32 NegotiateFlags = 0;
|
||||
UINT32 NegotiateFlags = 0;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, buffer->pvBuffer, buffer->cbBuffer);
|
||||
@ -320,19 +320,19 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
|
||||
SECURITY_STATUS ntlm_read_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
|
||||
{
|
||||
uint8* p;
|
||||
BYTE* p;
|
||||
STREAM* s;
|
||||
int length;
|
||||
char Signature[8];
|
||||
uint32 MessageType;
|
||||
uint8* StartOffset;
|
||||
uint8* PayloadOffset;
|
||||
uint16 TargetNameLen;
|
||||
uint16 TargetNameMaxLen;
|
||||
uint32 TargetNameBufferOffset;
|
||||
uint16 TargetInfoLen;
|
||||
uint16 TargetInfoMaxLen;
|
||||
uint32 TargetInfoBufferOffset;
|
||||
UINT32 MessageType;
|
||||
BYTE* StartOffset;
|
||||
BYTE* PayloadOffset;
|
||||
UINT16 TargetNameLen;
|
||||
UINT16 TargetNameMaxLen;
|
||||
UINT32 TargetNameBufferOffset;
|
||||
UINT16 TargetInfoLen;
|
||||
UINT16 TargetInfoMaxLen;
|
||||
UINT32 TargetInfoBufferOffset;
|
||||
|
||||
ntlm_generate_client_challenge(context);
|
||||
|
||||
@ -528,13 +528,13 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
uint32 PayloadOffset;
|
||||
uint16 TargetNameLen;
|
||||
uint8* TargetNameBuffer;
|
||||
uint32 TargetNameBufferOffset;
|
||||
uint16 TargetInfoLen;
|
||||
uint8* TargetInfoBuffer;
|
||||
uint32 TargetInfoBufferOffset;
|
||||
UINT32 PayloadOffset;
|
||||
UINT16 TargetNameLen;
|
||||
BYTE* TargetNameBuffer;
|
||||
UINT32 TargetNameBufferOffset;
|
||||
UINT16 TargetInfoLen;
|
||||
BYTE* TargetInfoBuffer;
|
||||
UINT32 TargetInfoBufferOffset;
|
||||
|
||||
/* Server Challenge */
|
||||
ntlm_generate_server_challenge(context);
|
||||
@ -553,7 +553,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
|
||||
if (context->NegotiateFlags & NTLMSSP_REQUEST_TARGET)
|
||||
{
|
||||
TargetNameLen = (uint16) context->TargetName.cbBuffer;
|
||||
TargetNameLen = (UINT16) context->TargetName.cbBuffer;
|
||||
TargetNameBuffer = context->TargetName.pvBuffer;
|
||||
}
|
||||
else
|
||||
@ -566,7 +566,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
|
||||
if (context->NegotiateFlags & NTLMSSP_NEGOTIATE_TARGET_INFO)
|
||||
{
|
||||
TargetInfoLen = (uint16) context->TargetInfo.cbBuffer;
|
||||
TargetInfoLen = (UINT16) context->TargetInfo.cbBuffer;
|
||||
TargetInfoBuffer = context->TargetInfo.pvBuffer;
|
||||
}
|
||||
else
|
||||
@ -651,33 +651,33 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
uint8 Signature[8];
|
||||
uint32 MessageType;
|
||||
uint32 NegotiateFlags;
|
||||
uint16 DomainNameLen;
|
||||
uint16 DomainNameMaxLen;
|
||||
uint8* DomainNameBuffer;
|
||||
uint32 DomainNameBufferOffset;
|
||||
uint16 UserNameLen;
|
||||
uint16 UserNameMaxLen;
|
||||
uint8* UserNameBuffer;
|
||||
uint32 UserNameBufferOffset;
|
||||
uint16 WorkstationLen;
|
||||
uint16 WorkstationMaxLen;
|
||||
uint8* WorkstationBuffer;
|
||||
uint32 WorkstationBufferOffset;
|
||||
uint16 LmChallengeResponseLen;
|
||||
uint16 LmChallengeResponseMaxLen;
|
||||
uint8* LmChallengeResponseBuffer;
|
||||
uint32 LmChallengeResponseBufferOffset;
|
||||
uint16 NtChallengeResponseLen;
|
||||
uint16 NtChallengeResponseMaxLen;
|
||||
uint8* NtChallengeResponseBuffer;
|
||||
uint32 NtChallengeResponseBufferOffset;
|
||||
uint16 EncryptedRandomSessionKeyLen;
|
||||
uint16 EncryptedRandomSessionKeyMaxLen;
|
||||
uint8* EncryptedRandomSessionKeyBuffer;
|
||||
uint32 EncryptedRandomSessionKeyBufferOffset;
|
||||
BYTE Signature[8];
|
||||
UINT32 MessageType;
|
||||
UINT32 NegotiateFlags;
|
||||
UINT16 DomainNameLen;
|
||||
UINT16 DomainNameMaxLen;
|
||||
BYTE* DomainNameBuffer;
|
||||
UINT32 DomainNameBufferOffset;
|
||||
UINT16 UserNameLen;
|
||||
UINT16 UserNameMaxLen;
|
||||
BYTE* UserNameBuffer;
|
||||
UINT32 UserNameBufferOffset;
|
||||
UINT16 WorkstationLen;
|
||||
UINT16 WorkstationMaxLen;
|
||||
BYTE* WorkstationBuffer;
|
||||
UINT32 WorkstationBufferOffset;
|
||||
UINT16 LmChallengeResponseLen;
|
||||
UINT16 LmChallengeResponseMaxLen;
|
||||
BYTE* LmChallengeResponseBuffer;
|
||||
UINT32 LmChallengeResponseBufferOffset;
|
||||
UINT16 NtChallengeResponseLen;
|
||||
UINT16 NtChallengeResponseMaxLen;
|
||||
BYTE* NtChallengeResponseBuffer;
|
||||
UINT32 NtChallengeResponseBufferOffset;
|
||||
UINT16 EncryptedRandomSessionKeyLen;
|
||||
UINT16 EncryptedRandomSessionKeyMaxLen;
|
||||
BYTE* EncryptedRandomSessionKeyBuffer;
|
||||
UINT32 EncryptedRandomSessionKeyBufferOffset;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, buffer->pvBuffer, buffer->cbBuffer);
|
||||
@ -807,7 +807,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
/* NtChallengeResponse */
|
||||
if (NtChallengeResponseLen > 0)
|
||||
{
|
||||
uint8* ClientChallengeBuffer;
|
||||
BYTE* ClientChallengeBuffer;
|
||||
|
||||
NtChallengeResponseBuffer = s->data + NtChallengeResponseBufferOffset;
|
||||
|
||||
@ -928,31 +928,31 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
uint8* MicOffset = NULL;
|
||||
uint32 NegotiateFlags = 0;
|
||||
BYTE* MicOffset = NULL;
|
||||
UINT32 NegotiateFlags = 0;
|
||||
|
||||
uint16 DomainNameLen;
|
||||
uint16 UserNameLen;
|
||||
uint16 WorkstationLen;
|
||||
uint16 LmChallengeResponseLen;
|
||||
uint16 NtChallengeResponseLen;
|
||||
uint16 EncryptedRandomSessionKeyLen;
|
||||
UINT16 DomainNameLen;
|
||||
UINT16 UserNameLen;
|
||||
UINT16 WorkstationLen;
|
||||
UINT16 LmChallengeResponseLen;
|
||||
UINT16 NtChallengeResponseLen;
|
||||
UINT16 EncryptedRandomSessionKeyLen;
|
||||
|
||||
uint32 PayloadBufferOffset;
|
||||
uint32 DomainNameBufferOffset;
|
||||
uint32 UserNameBufferOffset;
|
||||
uint32 WorkstationBufferOffset;
|
||||
uint32 LmChallengeResponseBufferOffset;
|
||||
uint32 NtChallengeResponseBufferOffset;
|
||||
uint32 EncryptedRandomSessionKeyBufferOffset;
|
||||
UINT32 PayloadBufferOffset;
|
||||
UINT32 DomainNameBufferOffset;
|
||||
UINT32 UserNameBufferOffset;
|
||||
UINT32 WorkstationBufferOffset;
|
||||
UINT32 LmChallengeResponseBufferOffset;
|
||||
UINT32 NtChallengeResponseBufferOffset;
|
||||
UINT32 EncryptedRandomSessionKeyBufferOffset;
|
||||
|
||||
uint8* UserNameBuffer;
|
||||
uint8* DomainNameBuffer;
|
||||
uint8* WorkstationBuffer;
|
||||
uint8* EncryptedRandomSessionKeyBuffer;
|
||||
BYTE* UserNameBuffer;
|
||||
BYTE* DomainNameBuffer;
|
||||
BYTE* WorkstationBuffer;
|
||||
BYTE* EncryptedRandomSessionKeyBuffer;
|
||||
|
||||
WorkstationLen = context->WorkstationLength;
|
||||
WorkstationBuffer = (uint8*) context->Workstation;
|
||||
WorkstationBuffer = (BYTE*) context->Workstation;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, buffer->pvBuffer, buffer->cbBuffer);
|
||||
@ -960,14 +960,14 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
if (context->ntlm_v2 < 1)
|
||||
WorkstationLen = 0;
|
||||
|
||||
DomainNameLen = (uint16) context->identity.DomainLength;
|
||||
DomainNameBuffer = (uint8*) context->identity.Domain;
|
||||
DomainNameLen = (UINT16) context->identity.DomainLength;
|
||||
DomainNameBuffer = (BYTE*) context->identity.Domain;
|
||||
|
||||
UserNameLen = (uint16) context->identity.UserLength;
|
||||
UserNameBuffer = (uint8*) context->identity.User;
|
||||
UserNameLen = (UINT16) context->identity.UserLength;
|
||||
UserNameBuffer = (BYTE*) context->identity.User;
|
||||
|
||||
LmChallengeResponseLen = (uint16) context->LmChallengeResponse.cbBuffer;
|
||||
NtChallengeResponseLen = (uint16) context->NtChallengeResponse.cbBuffer;
|
||||
LmChallengeResponseLen = (UINT16) context->LmChallengeResponse.cbBuffer;
|
||||
NtChallengeResponseLen = (UINT16) context->NtChallengeResponse.cbBuffer;
|
||||
|
||||
EncryptedRandomSessionKeyLen = 16;
|
||||
EncryptedRandomSessionKeyBuffer = context->EncryptedRandomSessionKey;
|
||||
|
@ -110,7 +110,7 @@ void sspi_ContextBufferAllocTableNew()
|
||||
|
||||
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
|
||||
|
||||
ContextBufferAllocTable.entries = calloc(1, size);
|
||||
ContextBufferAllocTable.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
||||
}
|
||||
|
||||
void sspi_ContextBufferAllocTableGrow()
|
||||
@ -121,14 +121,14 @@ void sspi_ContextBufferAllocTableGrow()
|
||||
|
||||
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
|
||||
|
||||
ContextBufferAllocTable.entries = realloc(ContextBufferAllocTable.entries, size);
|
||||
ContextBufferAllocTable.entries = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ContextBufferAllocTable.entries, size);
|
||||
memset((void*) &ContextBufferAllocTable.entries[ContextBufferAllocTable.cMaxEntries / 2], 0, size / 2);
|
||||
}
|
||||
|
||||
void sspi_ContextBufferAllocTableFree()
|
||||
{
|
||||
ContextBufferAllocTable.cEntries = ContextBufferAllocTable.cMaxEntries = 0;
|
||||
free(ContextBufferAllocTable.entries);
|
||||
HeapFree(GetProcessHeap(), 0, ContextBufferAllocTable.entries);
|
||||
}
|
||||
|
||||
void* sspi_ContextBufferAlloc(uint32 allocatorIndex, size_t size)
|
||||
@ -140,7 +140,7 @@ void* sspi_ContextBufferAlloc(uint32 allocatorIndex, size_t size)
|
||||
{
|
||||
if (ContextBufferAllocTable.entries[index].contextBuffer == NULL)
|
||||
{
|
||||
contextBuffer = calloc(1, size);
|
||||
contextBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
||||
ContextBufferAllocTable.cEntries++;
|
||||
|
||||
ContextBufferAllocTable.entries[index].contextBuffer = contextBuffer;
|
||||
@ -163,7 +163,7 @@ CREDENTIALS* sspi_CredentialsNew()
|
||||
{
|
||||
CREDENTIALS* credentials;
|
||||
|
||||
credentials = (CREDENTIALS*) calloc(1, sizeof(CREDENTIALS));
|
||||
credentials = (CREDENTIALS*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CREDENTIALS));
|
||||
|
||||
if (credentials != NULL)
|
||||
{
|
||||
@ -178,19 +178,19 @@ void sspi_CredentialsFree(CREDENTIALS* credentials)
|
||||
if (!credentials)
|
||||
return;
|
||||
|
||||
free(credentials);
|
||||
HeapFree(GetProcessHeap(), 0, credentials);
|
||||
}
|
||||
|
||||
void sspi_SecBufferAlloc(PSecBuffer SecBuffer, size_t size)
|
||||
{
|
||||
SecBuffer->cbBuffer = size;
|
||||
SecBuffer->pvBuffer = calloc(1, size);
|
||||
SecBuffer->pvBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
||||
}
|
||||
|
||||
void sspi_SecBufferFree(PSecBuffer SecBuffer)
|
||||
{
|
||||
SecBuffer->cbBuffer = 0;
|
||||
free(SecBuffer->pvBuffer);
|
||||
HeapFree(GetProcessHeap(), 0, SecBuffer->pvBuffer);
|
||||
SecBuffer->pvBuffer = NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user