Mike McCormack : advapi32: Implement and test SystemFunction003.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 15 07:34:57 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 09fc7e046a594443ffbe82a6687f4ffe92369b42
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=09fc7e046a594443ffbe82a6687f4ffe92369b42

Author: Mike McCormack <mike at codeweavers.com>
Date:   Sun May 14 17:06:22 2006 +0900

advapi32: Implement and test SystemFunction003.

---

 dlls/advapi32/advapi32.spec        |    2 +
 dlls/advapi32/crypt_lmhash.c       |   22 ++++++++++++++
 dlls/advapi32/tests/crypt_lmhash.c |   55 ++++++++++++++++++++++++++++--------
 3 files changed, 66 insertions(+), 13 deletions(-)

diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec
index cb747b0..f9b909b 100644
--- a/dlls/advapi32/advapi32.spec
+++ b/dlls/advapi32/advapi32.spec
@@ -597,7 +597,7 @@ # @ stub StopTraceW
 @ stdcall SynchronizeWindows31FilesAndWindowsNTRegistry(long long long long)
 @ stdcall SystemFunction001(ptr ptr ptr)
 @ stdcall SystemFunction002(ptr ptr ptr)
-@ stub SystemFunction003
+@ stdcall SystemFunction003(ptr ptr)
 @ stub SystemFunction004
 @ stub SystemFunction005
 @ stdcall SystemFunction006(ptr ptr)
diff --git a/dlls/advapi32/crypt_lmhash.c b/dlls/advapi32/crypt_lmhash.c
index 85e29fb..0d00777 100644
--- a/dlls/advapi32/crypt_lmhash.c
+++ b/dlls/advapi32/crypt_lmhash.c
@@ -135,3 +135,25 @@ NTSTATUS WINAPI SystemFunction002(const 
     CRYPT_DESunhash(output, key, data);
     return STATUS_SUCCESS;
 }
+
+/******************************************************************************
+ * SystemFunction003  [ADVAPI32.@]
+ *
+ * Hashes a key using DES and a fixed datablock
+ *
+ * PARAMS
+ *   key     [I] key data    (7 bytes)
+ *   output  [O] hashed key  (8 bytes)
+ *
+ * RETURNS
+ *  Success: STATUS_SUCCESS
+ *  Failure: STATUS_UNSUCCESSFUL
+ *
+ */
+NTSTATUS WINAPI SystemFunction003(const LPBYTE key, LPBYTE output)
+{
+    if (!output)
+        return STATUS_UNSUCCESSFUL;
+    CRYPT_DEShash(output, key, CRYPT_LMhash_Magic);
+    return STATUS_SUCCESS;
+}
diff --git a/dlls/advapi32/tests/crypt_lmhash.c b/dlls/advapi32/tests/crypt_lmhash.c
index c0353d3..207a3e6 100644
--- a/dlls/advapi32/tests/crypt_lmhash.c
+++ b/dlls/advapi32/tests/crypt_lmhash.c
@@ -34,16 +34,18 @@ struct ustring {
     unsigned char *Buffer;
 };
 
-typedef VOID (WINAPI *fnSystemFunction006)( PCSTR passwd, PSTR lmhash );
-typedef NTSTATUS (WINAPI *fnSystemFunction008)(const LPBYTE, const LPBYTE, LPBYTE);
 typedef NTSTATUS (WINAPI *fnSystemFunction001)(const LPBYTE, const LPBYTE, LPBYTE);
 typedef NTSTATUS (WINAPI *fnSystemFunction002)(const LPBYTE, const LPBYTE, LPBYTE);
+typedef NTSTATUS (WINAPI *fnSystemFunction003)(const LPBYTE, LPBYTE);
+typedef VOID (WINAPI *fnSystemFunction006)( PCSTR passwd, PSTR lmhash );
+typedef NTSTATUS (WINAPI *fnSystemFunction008)(const LPBYTE, const LPBYTE, LPBYTE);
 typedef NTSTATUS (WINAPI *fnSystemFunction032)(struct ustring *, struct ustring *);
 
-fnSystemFunction006 pSystemFunction006;
-fnSystemFunction008 pSystemFunction008;
 fnSystemFunction001 pSystemFunction001;
 fnSystemFunction002 pSystemFunction002;
+fnSystemFunction003 pSystemFunction003;
+fnSystemFunction006 pSystemFunction006;
+fnSystemFunction008 pSystemFunction008;
 fnSystemFunction032 pSystemFunction032;
 
 static void test_SystemFunction006(void)
@@ -163,12 +165,49 @@ static void test_SystemFunction032(void)
     ok(!memcmp(expected, data.Buffer, data.Length), "wrong result\n");
 }
 
+static void test_SystemFunction003(void)
+{
+    unsigned char output[8], data[8];
+    unsigned char key[7] = { 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24 };
+    unsigned char exp1[8] = { 0x9d, 0x21, 0xc8, 0x86, 0x6c, 0x21, 0xcf, 0x43 };
+    char exp2[] = "KGS!@#$%";
+    int r;
+
+    r = pSystemFunction003(NULL, NULL);
+    ok(r == STATUS_UNSUCCESSFUL, "function failed\n");
+
+    r = pSystemFunction003(key, NULL);
+    ok(r == STATUS_UNSUCCESSFUL, "function failed\n");
+
+    memset(data, 0, sizeof data);
+    r = pSystemFunction003(key, data);
+    ok(r == STATUS_SUCCESS, "function failed\n");
+    ok( !memcmp(exp1, data, sizeof data), "decrypted message wrong\n");
+
+    memset(output, 0, sizeof output);
+    r = pSystemFunction002(data, key, output);
+
+    ok( !memcmp(exp2, output, sizeof output), "decrypted message wrong\n");
+}
+
 START_TEST(crypt_lmhash)
 {
     HMODULE module;
 
     if (!(module = LoadLibrary("advapi32.dll"))) return;
 
+    pSystemFunction001 = (fnSystemFunction001)GetProcAddress( module, "SystemFunction001" );
+    if (pSystemFunction001)
+        test_SystemFunction001();
+
+    pSystemFunction002 = (fnSystemFunction002)GetProcAddress( module, "SystemFunction002" );
+    if (pSystemFunction002)
+        test_SystemFunction002();
+
+    pSystemFunction003 = (fnSystemFunction003)GetProcAddress( module, "SystemFunction003" );
+    if (pSystemFunction003)
+        test_SystemFunction003();
+
     pSystemFunction006 = (fnSystemFunction006)GetProcAddress( module, "SystemFunction006" );
     if (pSystemFunction006) 
         test_SystemFunction006();
@@ -177,17 +216,9 @@ START_TEST(crypt_lmhash)
     if (pSystemFunction008)
         test_SystemFunction008();
 
-    pSystemFunction001 = (fnSystemFunction001)GetProcAddress( module, "SystemFunction001" );
-    if (pSystemFunction001)
-        test_SystemFunction001();
-
     pSystemFunction032 = (fnSystemFunction032)GetProcAddress( module, "SystemFunction032" );
     if (pSystemFunction032)
         test_SystemFunction032();
 
-    pSystemFunction002 = (fnSystemFunction002)GetProcAddress( module, "SystemFunction002" );
-    if (pSystemFunction002)
-        test_SystemFunction002();
-
     FreeLibrary( module );
 }




More information about the wine-cvs mailing list