Kai Blin : secur32: Fix generation of the session key.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Sep 8 05:15:26 CDT 2006
Module: wine
Branch: master
Commit: 85655db106c125c6541c63945a1108da4588ba3c
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=85655db106c125c6541c63945a1108da4588ba3c
Author: Kai Blin <kai.blin at gmail.com>
Date: Thu Sep 7 16:17:06 2006 +0200
secur32: Fix generation of the session key.
---
dlls/secur32/ntlm.c | 19 ++++++++++++++++++-
dlls/secur32/secur32_priv.h | 2 +-
dlls/secur32/tests/ntlm.c | 5 ++---
dlls/secur32/util.c | 4 ++--
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/dlls/secur32/ntlm.c b/dlls/secur32/ntlm.c
index ce8da6f..a3f584f 100644
--- a/dlls/secur32/ntlm.c
+++ b/dlls/secur32/ntlm.c
@@ -648,7 +648,24 @@ static SECURITY_STATUS SEC_ENTRY ntlm_In
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);
}
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 007a14b..1ad62c5 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -137,7 +137,7 @@ SECURITY_STATUS decodeBase64(char *in_bu
/* 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);
diff --git a/dlls/secur32/tests/ntlm.c b/dlls/secur32/tests/ntlm.c
index 9128620..1b13948 100644
--- a/dlls/secur32/tests/ntlm.c
+++ b/dlls/secur32/tests/ntlm.c
@@ -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);
diff --git a/dlls/secur32/util.c b/dlls/secur32/util.c
index e762c8c..4462ae9 100644
--- a/dlls/secur32/util.c
+++ b/dlls/secur32/util.c
@@ -106,7 +106,7 @@ ULONG ComputeCrc32(const BYTE *pData, IN
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_CreateNTLMv1Sess
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);
More information about the wine-cvs
mailing list