Commit 85655db1 authored by Kai Blin's avatar Kai Blin Committed by Alexandre Julliard

secur32: Fix generation of the session key.

parent 822e6af6
......@@ -648,7 +648,24 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
/*Generate the dummy session key = MD4(MD4(password))*/
if(helper->password)
SECUR32_CreateNTLMv1SessionKey(helper->password, helper->session_key);
{
SEC_WCHAR *unicode_password;
int passwd_lenW;
TRACE("Converting password to unicode.\n");
passwd_lenW = MultiByteToWideChar(CP_ACP, 0,
(LPCSTR)helper->password, helper->pwlen,
NULL, 0);
unicode_password = HeapAlloc(GetProcessHeap(), 0,
passwd_lenW * sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)helper->password,
helper->pwlen, unicode_password, passwd_lenW);
SECUR32_CreateNTLMv1SessionKey((PBYTE)unicode_password,
lstrlenW(unicode_password) * sizeof(SEC_WCHAR), helper->session_key);
HeapFree(GetProcessHeap(), 0, unicode_password);
}
else
memset(helper->session_key, 0, 16);
}
......
......@@ -137,7 +137,7 @@ SECURITY_STATUS decodeBase64(char *in_buf, int in_len, BYTE *out_buf,
/* Functions from util.c */
ULONG ComputeCrc32(const BYTE *pData, INT iLen);
SECURITY_STATUS SECUR32_CreateNTLMv1SessionKey(const char* password, PBYTE session_key);
SECURITY_STATUS SECUR32_CreateNTLMv1SessionKey(PBYTE password, int len, PBYTE session_key);
arc4_info *SECUR32_arc4Alloc(void);
void SECUR32_arc4Init(arc4_info *a4i, const BYTE *key, unsigned int keyLen);
void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length);
......
......@@ -807,12 +807,11 @@ static void testSignSeal()
sec_status = pEncryptMessage(client.ctxt, 0, crypt, 0);
ok(sec_status == SEC_E_OK, "EncryptMessage returned %s, not SEC_E_OK.\n",
getSecError(sec_status));
todo_wine{
ok(!memcmp(crypt->pBuffers[0].pvBuffer, crypt_trailer_client,
crypt->pBuffers[0].cbBuffer), "Crypt trailer not as expected.\n");
ok(!memcmp(crypt->pBuffers[1].pvBuffer, crypt_message_client,
crypt->pBuffers[1].cbBuffer), "Crypt message not as expected.\n");
}
data[0].cbBuffer = sizeof(crypt_trailer_server);
data[1].cbBuffer = sizeof(crypt_message_server);
......@@ -823,10 +822,10 @@ static void testSignSeal()
todo_wine {
ok(sec_status == SEC_E_OK, "DecryptMessage returned %s, not SEC_E_OK.\n",
getSecError(sec_status));
}
ok(!memcmp(crypt->pBuffers[1].pvBuffer, message_binary,
crypt->pBuffers[1].cbBuffer),
"Failed to decrypt message correctly.\n");
}
end:
cleanupBuffers(&client);
......
......@@ -106,7 +106,7 @@ ULONG ComputeCrc32(const BYTE *pData, INT iLen)
return ~crc;
}
SECURITY_STATUS SECUR32_CreateNTLMv1SessionKey(const char* password, PBYTE session_key)
SECURITY_STATUS SECUR32_CreateNTLMv1SessionKey(PBYTE password, int len, PBYTE session_key)
{
MD4_CTX ctx;
BYTE ntlm_hash[16];
......@@ -114,7 +114,7 @@ SECURITY_STATUS SECUR32_CreateNTLMv1SessionKey(const char* password, PBYTE sessi
TRACE("(%p, %p)\n", password, session_key);
MD4Init(&ctx);
MD4Update(&ctx, (const unsigned char*) password, lstrlenA(password));
MD4Update(&ctx, (const unsigned char*) password, len);
MD4Final(&ctx);
memcpy(ntlm_hash, ctx.digest, 0x10);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment