mirror of https://github.com/FreeRDP/FreeRDP
libwinpr-sspi: cleanup of data types in NTLM module
This commit is contained in:
parent
6bb032f24e
commit
0bd91f3cb9
|
@ -34,59 +34,6 @@
|
|||
|
||||
char* NTLM_PACKAGE_NAME = "NTLM";
|
||||
|
||||
void ntlm_SetContextIdentity(NTLM_CONTEXT* context, SEC_WINNT_AUTH_IDENTITY* identity)
|
||||
{
|
||||
context->identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||
|
||||
if (identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
|
||||
{
|
||||
context->identity.UserLength = strlen((char*) identity->User) * 2;
|
||||
context->identity.User = (UINT16*) malloc(context->identity.UserLength);
|
||||
MultiByteToWideChar(CP_ACP, 0, (char*) identity->User, strlen((char*) identity->User),
|
||||
(LPWSTR) context->identity.User, context->identity.UserLength / 2);
|
||||
|
||||
if (identity->DomainLength > 0)
|
||||
{
|
||||
context->identity.DomainLength = strlen((char*) identity->Domain) * 2;
|
||||
context->identity.Domain = (UINT16*) malloc(context->identity.DomainLength);
|
||||
MultiByteToWideChar(CP_ACP, 0, (char*) identity->Domain, strlen((char*) identity->Domain),
|
||||
(LPWSTR) context->identity.Domain, context->identity.DomainLength / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
context->identity.Domain = (UINT16*) NULL;
|
||||
context->identity.DomainLength = 0;
|
||||
}
|
||||
|
||||
context->identity.PasswordLength = strlen((char*) identity->Password) * 2;
|
||||
context->identity.Password = (UINT16*) malloc(context->identity.PasswordLength);
|
||||
MultiByteToWideChar(CP_ACP, 0, (char*) identity->Password, strlen((char*) identity->Password),
|
||||
(LPWSTR) context->identity.Password, context->identity.PasswordLength / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
context->identity.User = (UINT16*) malloc(identity->UserLength);
|
||||
memcpy(context->identity.User, identity->User, identity->UserLength);
|
||||
context->identity.UserLength = identity->UserLength;
|
||||
|
||||
if (identity->DomainLength > 0)
|
||||
{
|
||||
context->identity.Domain = (UINT16*) malloc(identity->DomainLength);
|
||||
memcpy(context->identity.Domain, identity->Domain, identity->DomainLength);
|
||||
context->identity.DomainLength = identity->DomainLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
context->identity.Domain = (UINT16*) NULL;
|
||||
context->identity.DomainLength = 0;
|
||||
}
|
||||
|
||||
context->identity.Password = (UINT16*) malloc(identity->PasswordLength);
|
||||
memcpy(context->identity.Password, identity->Password, identity->PasswordLength);
|
||||
context->identity.PasswordLength = identity->PasswordLength;
|
||||
}
|
||||
}
|
||||
|
||||
void ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
|
||||
{
|
||||
context->WorkstationLength = strlen(Workstation) * 2;
|
||||
|
@ -295,7 +242,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(PCredHandle phCredential, P
|
|||
context->confidentiality = true;
|
||||
|
||||
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
||||
ntlm_SetContextIdentity(context, &credentials->identity);
|
||||
sspi_CopyAuthIdentity(&context->identity, &credentials->identity);
|
||||
|
||||
ntlm_SetContextTargetName(context, "FreeRDP");
|
||||
|
||||
|
@ -408,7 +355,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(PCredHandle phCredenti
|
|||
|
||||
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
||||
|
||||
ntlm_SetContextIdentity(context, &credentials->identity);
|
||||
sspi_CopyAuthIdentity(&context->identity, &credentials->identity);
|
||||
ntlm_SetContextWorkstation(context, "WORKSTATION");
|
||||
|
||||
sspi_SecureHandleSetLowerPointer(phNewContext, context);
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "../sspi.h"
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/print.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/hexdump.h>
|
||||
|
||||
#include "ntlm_compute.h"
|
||||
|
||||
|
@ -54,7 +54,7 @@ void ntlm_input_av_pairs(NTLM_CONTEXT* context, STREAM* s)
|
|||
{
|
||||
AV_ID AvId;
|
||||
UINT16 AvLen;
|
||||
uint8* value;
|
||||
BYTE* value;
|
||||
AV_PAIRS* av_pairs = context->av_pairs;
|
||||
|
||||
#ifdef WITH_DEBUG_NTLM
|
||||
|
@ -139,7 +139,7 @@ void ntlm_input_av_pairs(NTLM_CONTEXT* context, STREAM* s)
|
|||
else
|
||||
printf("\tAvId: %s, AvLen: %d\n", "Unknown", AvLen);
|
||||
|
||||
freerdp_hexdump(value, AvLen);
|
||||
winpr_HexDump(value, AvLen);
|
||||
#endif
|
||||
}
|
||||
while (AvId != MsvAvEOL);
|
||||
|
@ -340,22 +340,22 @@ void ntlm_populate_server_av_pairs(NTLM_CONTEXT* context)
|
|||
AV_PAIRS* av_pairs = context->av_pairs;
|
||||
|
||||
av_pairs->NbDomainName.length = strlen(test_NbDomainName) * 2;
|
||||
av_pairs->NbDomainName.value = (uint8*) malloc(av_pairs->NbDomainName.length);
|
||||
av_pairs->NbDomainName.value = (BYTE*) malloc(av_pairs->NbDomainName.length);
|
||||
MultiByteToWideChar(CP_ACP, 0, test_NbDomainName, strlen(test_NbDomainName),
|
||||
(LPWSTR) av_pairs->NbDomainName.value, av_pairs->NbDomainName.length / 2);
|
||||
|
||||
av_pairs->NbComputerName.length = strlen(test_NbDomainName) * 2;
|
||||
av_pairs->NbComputerName.value = (uint8*) malloc(av_pairs->NbComputerName.length);
|
||||
av_pairs->NbComputerName.value = (BYTE*) malloc(av_pairs->NbComputerName.length);
|
||||
MultiByteToWideChar(CP_ACP, 0, test_NbComputerName, strlen(test_NbComputerName),
|
||||
(LPWSTR) av_pairs->NbComputerName.value, av_pairs->NbComputerName.length / 2);
|
||||
|
||||
av_pairs->DnsDomainName.length = strlen(test_DnsDomainName) * 2;
|
||||
av_pairs->DnsDomainName.value = (uint8*) malloc(av_pairs->DnsDomainName.length);
|
||||
av_pairs->DnsDomainName.value = (BYTE*) malloc(av_pairs->DnsDomainName.length);
|
||||
MultiByteToWideChar(CP_ACP, 0, test_DnsDomainName, strlen(test_DnsDomainName),
|
||||
(LPWSTR) av_pairs->DnsDomainName.value, av_pairs->DnsDomainName.length / 2);
|
||||
|
||||
av_pairs->DnsComputerName.length = strlen(test_DnsComputerName) * 2;
|
||||
av_pairs->DnsComputerName.value = (uint8*) malloc(av_pairs->DnsComputerName.length);
|
||||
av_pairs->DnsComputerName.value = (BYTE*) malloc(av_pairs->DnsComputerName.length);
|
||||
MultiByteToWideChar(CP_ACP, 0, test_DnsComputerName, strlen(test_DnsComputerName),
|
||||
(LPWSTR) av_pairs->DnsComputerName.value, av_pairs->DnsComputerName.length / 2);
|
||||
|
||||
|
@ -379,37 +379,37 @@ void ntlm_print_av_pairs(NTLM_CONTEXT* context)
|
|||
if (av_pairs->NbDomainName.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvNbDomainName AvLen: %d\n", av_pairs->NbDomainName.length);
|
||||
freerdp_hexdump(av_pairs->NbDomainName.value, av_pairs->NbDomainName.length);
|
||||
winpr_HexDump(av_pairs->NbDomainName.value, av_pairs->NbDomainName.length);
|
||||
}
|
||||
|
||||
if (av_pairs->NbComputerName.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvNbComputerName AvLen: %d\n", av_pairs->NbComputerName.length);
|
||||
freerdp_hexdump(av_pairs->NbComputerName.value, av_pairs->NbComputerName.length);
|
||||
winpr_HexDump(av_pairs->NbComputerName.value, av_pairs->NbComputerName.length);
|
||||
}
|
||||
|
||||
if (av_pairs->DnsDomainName.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvDnsDomainName AvLen: %d\n", av_pairs->DnsDomainName.length);
|
||||
freerdp_hexdump(av_pairs->DnsDomainName.value, av_pairs->DnsDomainName.length);
|
||||
winpr_HexDump(av_pairs->DnsDomainName.value, av_pairs->DnsDomainName.length);
|
||||
}
|
||||
|
||||
if (av_pairs->DnsComputerName.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvDnsComputerName AvLen: %d\n", av_pairs->DnsComputerName.length);
|
||||
freerdp_hexdump(av_pairs->DnsComputerName.value, av_pairs->DnsComputerName.length);
|
||||
winpr_HexDump(av_pairs->DnsComputerName.value, av_pairs->DnsComputerName.length);
|
||||
}
|
||||
|
||||
if (av_pairs->DnsTreeName.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvDnsTreeName AvLen: %d\n", av_pairs->DnsTreeName.length);
|
||||
freerdp_hexdump(av_pairs->DnsTreeName.value, av_pairs->DnsTreeName.length);
|
||||
winpr_HexDump(av_pairs->DnsTreeName.value, av_pairs->DnsTreeName.length);
|
||||
}
|
||||
|
||||
if (av_pairs->Timestamp.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvTimestamp AvLen: %d\n", av_pairs->Timestamp.length);
|
||||
freerdp_hexdump(av_pairs->Timestamp.value, av_pairs->Timestamp.length);
|
||||
winpr_HexDump(av_pairs->Timestamp.value, av_pairs->Timestamp.length);
|
||||
}
|
||||
|
||||
if (av_pairs->Flags > 0)
|
||||
|
@ -421,19 +421,19 @@ void ntlm_print_av_pairs(NTLM_CONTEXT* context)
|
|||
if (av_pairs->Restrictions.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvRestrictions AvLen: %d\n", av_pairs->Restrictions.length);
|
||||
freerdp_hexdump(av_pairs->Restrictions.value, av_pairs->Restrictions.length);
|
||||
winpr_HexDump(av_pairs->Restrictions.value, av_pairs->Restrictions.length);
|
||||
}
|
||||
|
||||
if (av_pairs->ChannelBindings.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvChannelBindings AvLen: %d\n", av_pairs->ChannelBindings.length);
|
||||
freerdp_hexdump(av_pairs->ChannelBindings.value, av_pairs->ChannelBindings.length);
|
||||
winpr_HexDump(av_pairs->ChannelBindings.value, av_pairs->ChannelBindings.length);
|
||||
}
|
||||
|
||||
if (av_pairs->TargetName.length > 0)
|
||||
{
|
||||
printf("\tAvId: MsvAvTargetName AvLen: %d\n", av_pairs->TargetName.length);
|
||||
freerdp_hexdump(av_pairs->TargetName.value, av_pairs->TargetName.length);
|
||||
winpr_HexDump(av_pairs->TargetName.value, av_pairs->TargetName.length);
|
||||
}
|
||||
|
||||
printf("}\n");
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
#include <freerdp/crypto/crypto.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/print.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/hexdump.h>
|
||||
|
||||
#include "ntlm_compute.h"
|
||||
|
||||
static const char lm_magic[] = "KGS!@#$%";
|
||||
const char lm_magic[] = "KGS!@#$%";
|
||||
|
||||
static const char client_sign_magic[] = "session key to client-to-server signing key magic constant";
|
||||
static const char server_sign_magic[] = "session key to server-to-client signing key magic constant";
|
||||
|
@ -370,23 +370,23 @@ void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
|
|||
|
||||
#ifdef WITH_DEBUG_NTLM
|
||||
printf("Password (length = %d)\n", context->identity.PasswordLength);
|
||||
freerdp_hexdump((BYTE*) context->identity.Password, context->identity.PasswordLength);
|
||||
winpr_HexDump((BYTE*) context->identity.Password, context->identity.PasswordLength);
|
||||
printf("\n");
|
||||
|
||||
printf("Username (length = %d)\n", context->identity.UserLength);
|
||||
freerdp_hexdump((BYTE*) context->identity.User, context->identity.UserLength);
|
||||
winpr_HexDump((BYTE*) context->identity.User, context->identity.UserLength);
|
||||
printf("\n");
|
||||
|
||||
printf("Domain (length = %d)\n", context->identity.DomainLength);
|
||||
freerdp_hexdump((BYTE*) context->identity.Domain, context->identity.DomainLength);
|
||||
winpr_HexDump((BYTE*) context->identity.Domain, context->identity.DomainLength);
|
||||
printf("\n");
|
||||
|
||||
printf("Workstation (length = %d)\n", context->WorkstationLength);
|
||||
freerdp_hexdump((BYTE*) context->Workstation, context->WorkstationLength);
|
||||
winpr_HexDump((BYTE*) context->Workstation, context->WorkstationLength);
|
||||
printf("\n");
|
||||
|
||||
printf("NTOWFv2, NTLMv2 Hash\n");
|
||||
freerdp_hexdump(ntlm_v2_hash, 16);
|
||||
winpr_HexDump(ntlm_v2_hash, 16);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
|
@ -402,7 +402,7 @@ void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
|
|||
|
||||
#ifdef WITH_DEBUG_NTLM
|
||||
printf("NTLMv2 Response Temp Blob\n");
|
||||
freerdp_hexdump(ntlm_v2_temp.pvBuffer, ntlm_v2_temp.cbBuffer);
|
||||
winpr_HexDump(ntlm_v2_temp.pvBuffer, ntlm_v2_temp.cbBuffer);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,15 +28,15 @@ void ntlm_output_restriction_encoding(NTLM_CONTEXT* context);
|
|||
void ntlm_output_target_name(NTLM_CONTEXT* context);
|
||||
void ntlm_output_channel_bindings(NTLM_CONTEXT* context);
|
||||
|
||||
void ntlm_current_time(uint8* timestamp);
|
||||
void ntlm_current_time(BYTE* timestamp);
|
||||
void ntlm_generate_timestamp(NTLM_CONTEXT* context);
|
||||
|
||||
void ntlm_compute_ntlm_hash(uint16* password, uint32 length, char* hash);
|
||||
void ntlm_compute_ntlm_hash(uint16* password, UINT32 length, char* hash);
|
||||
void ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash);
|
||||
void ntlm_compute_lm_v2_response(NTLM_CONTEXT* context);
|
||||
void ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context);
|
||||
|
||||
void ntlm_rc4k(uint8* key, int length, uint8* plaintext, uint8* ciphertext);
|
||||
void ntlm_rc4k(BYTE* key, int length, BYTE* plaintext, BYTE* ciphertext);
|
||||
void ntlm_generate_client_challenge(NTLM_CONTEXT* context);
|
||||
void ntlm_generate_server_challenge(NTLM_CONTEXT* context);
|
||||
void ntlm_generate_key_exchange_key(NTLM_CONTEXT* context);
|
||||
|
@ -54,4 +54,3 @@ void ntlm_init_rc4_seal_states(NTLM_CONTEXT* context);
|
|||
void ntlm_compute_message_integrity_check(NTLM_CONTEXT* context);
|
||||
|
||||
#endif /* WINPR_AUTH_NTLM_COMPUTE_H */
|
||||
|
||||
|
|
Loading…
Reference in New Issue