Mike McCormack : advapi32: Implement and test SystemFunction(012-023).
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 22 05:19:26 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 6fad2cbaffa07094e7d65f68b7c584dc57a50d57
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=6fad2cbaffa07094e7d65f68b7c584dc57a50d57
Author: Mike McCormack <mike at codeweavers.com>
Date: Sun May 21 17:28:11 2006 +0900
advapi32: Implement and test SystemFunction(012-023).
---
dlls/advapi32/advapi32.spec | 24 ++++-----
dlls/advapi32/crypt_lmhash.c | 58 ++++++++++++++++++++++
dlls/advapi32/tests/crypt_lmhash.c | 97 ++++++++++++++++++++++++++++++++++++
3 files changed, 167 insertions(+), 12 deletions(-)
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec
index becd80e..c11e57e 100644
--- a/dlls/advapi32/advapi32.spec
+++ b/dlls/advapi32/advapi32.spec
@@ -606,18 +606,18 @@ # @ stub StopTraceW
@ stdcall SystemFunction009(ptr ptr ptr)
@ stdcall SystemFunction010(ptr ptr ptr)
@ stub SystemFunction011
-@ stub SystemFunction012
-@ stub SystemFunction013
-@ stub SystemFunction014
-@ stub SystemFunction015
-@ stub SystemFunction016
-@ stub SystemFunction017
-@ stub SystemFunction018
-@ stub SystemFunction019
-@ stub SystemFunction020
-@ stub SystemFunction021
-@ stub SystemFunction022
-@ stub SystemFunction023
+@ stdcall SystemFunction012(ptr ptr ptr)
+@ stdcall SystemFunction013(ptr ptr ptr)
+@ stdcall SystemFunction014(ptr ptr ptr) SystemFunction012
+@ stdcall SystemFunction015(ptr ptr ptr) SystemFunction013
+@ stdcall SystemFunction016(ptr ptr ptr) SystemFunction012
+@ stdcall SystemFunction017(ptr ptr ptr) SystemFunction013
+@ stdcall SystemFunction018(ptr ptr ptr) SystemFunction012
+@ stdcall SystemFunction019(ptr ptr ptr) SystemFunction013
+@ stdcall SystemFunction020(ptr ptr ptr) SystemFunction012
+@ stdcall SystemFunction021(ptr ptr ptr) SystemFunction013
+@ stdcall SystemFunction022(ptr ptr ptr) SystemFunction012
+@ stdcall SystemFunction023(ptr ptr ptr) SystemFunction013
@ stub SystemFunction024
@ stub SystemFunction025
@ stub SystemFunction026
diff --git a/dlls/advapi32/crypt_lmhash.c b/dlls/advapi32/crypt_lmhash.c
index 8200abc..fb01b5b 100644
--- a/dlls/advapi32/crypt_lmhash.c
+++ b/dlls/advapi32/crypt_lmhash.c
@@ -290,3 +290,61 @@ NTSTATUS WINAPI SystemFunction005(const
return STATUS_SUCCESS;
}
+
+/******************************************************************************
+ * SystemFunction012 [ADVAPI32.@]
+ * SystemFunction014 [ADVAPI32.@]
+ * SystemFunction016 [ADVAPI32.@]
+ * SystemFunction018 [ADVAPI32.@]
+ * SystemFunction020 [ADVAPI32.@]
+ * SystemFunction022 [ADVAPI32.@]
+ *
+ * Encrypts two DES blocks with two keys
+ *
+ * PARAMS
+ * data [I] data to encrypt (16 bytes)
+ * key [I] key data (two lots of 7 bytes)
+ * output [O] buffer to receive encrypted data (16 bytes)
+ *
+ * RETURNS
+ * Success: STATUS_SUCCESS
+ * Failure: STATUS_UNSUCCESSFUL if the input or output buffer is NULL
+ */
+NTSTATUS WINAPI SystemFunction012(const LPBYTE in, const LPBYTE key, LPBYTE out)
+{
+ if (!in || !out)
+ return STATUS_UNSUCCESSFUL;
+
+ CRYPT_DEShash(out, key, in);
+ CRYPT_DEShash(out+8, key+7, in+8);
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+ * SystemFunction013 [ADVAPI32.@]
+ * SystemFunction015 [ADVAPI32.@]
+ * SystemFunction017 [ADVAPI32.@]
+ * SystemFunction019 [ADVAPI32.@]
+ * SystemFunction021 [ADVAPI32.@]
+ * SystemFunction023 [ADVAPI32.@]
+ *
+ * Decrypts two DES blocks with two keys
+ *
+ * PARAMS
+ * data [I] data to decrypt (16 bytes)
+ * key [I] key data (two lots of 7 bytes)
+ * output [O] buffer to receive decrypted data (16 bytes)
+ *
+ * RETURNS
+ * Success: STATUS_SUCCESS
+ * Failure: STATUS_UNSUCCESSFUL if the input or output buffer is NULL
+ */
+NTSTATUS WINAPI SystemFunction013(const LPBYTE in, const LPBYTE key, LPBYTE out)
+{
+ if (!in || !out)
+ return STATUS_UNSUCCESSFUL;
+
+ CRYPT_DESunhash(out, key, in);
+ CRYPT_DESunhash(out+8, key+7, in+8);
+ return STATUS_SUCCESS;
+}
diff --git a/dlls/advapi32/tests/crypt_lmhash.c b/dlls/advapi32/tests/crypt_lmhash.c
index 46f6ea4..c0b4b96 100644
--- a/dlls/advapi32/tests/crypt_lmhash.c
+++ b/dlls/advapi32/tests/crypt_lmhash.c
@@ -42,6 +42,7 @@ typedef NTSTATUS (WINAPI *fnSystemFuncti
typedef VOID (WINAPI *fnSystemFunction006)( PCSTR passwd, PSTR lmhash );
typedef NTSTATUS (WINAPI *fnSystemFunction008)(const LPBYTE, const LPBYTE, LPBYTE);
typedef NTSTATUS (WINAPI *fnSystemFunction009)(const LPBYTE, const LPBYTE, LPBYTE);
+typedef int (WINAPI *descrypt)(unsigned char *, unsigned char *, unsigned char *);
typedef NTSTATUS (WINAPI *fnSystemFunction032)(struct ustring *, struct ustring *);
fnSystemFunction001 pSystemFunction001;
@@ -52,6 +53,23 @@ fnSystemFunction004 pSystemFunction005;
fnSystemFunction006 pSystemFunction006;
fnSystemFunction008 pSystemFunction008;
fnSystemFunction008 pSystemFunction009;
+
+/* encrypt two blocks */
+descrypt pSystemFunction012;
+descrypt pSystemFunction014;
+descrypt pSystemFunction016;
+descrypt pSystemFunction018;
+descrypt pSystemFunction020;
+descrypt pSystemFunction022;
+
+/* decrypt two blocks */
+descrypt pSystemFunction013;
+descrypt pSystemFunction015;
+descrypt pSystemFunction017;
+descrypt pSystemFunction019;
+descrypt pSystemFunction021;
+descrypt pSystemFunction023;
+
fnSystemFunction032 pSystemFunction032;
static void test_SystemFunction006(void)
@@ -355,6 +373,56 @@ static void test_SystemFunction009(void)
ok(!memcmp(output, expected, sizeof expected), "response wrong\n");
}
+static unsigned char des_key[] = {
+ 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24,
+ 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24,
+};
+static unsigned char des_plaintext[] = {
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0
+};
+static unsigned char des_ciphertext[] = {
+ 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97,
+ 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97, 0
+};
+
+/* test functions that encrypt two DES blocks */
+static void test_SystemFunction_encrypt(descrypt func, int num)
+{
+ unsigned char output[0x11];
+ int r;
+
+ if (!func)
+ return;
+
+ r = func(NULL, NULL, NULL);
+ ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
+
+ memset(output, 0, sizeof output);
+ r = func(des_plaintext, des_key, output);
+ ok( r == STATUS_SUCCESS, "wrong error code\n");
+ ok( !memcmp(des_ciphertext, output, sizeof des_ciphertext), "ciphertext wrong (%d)\n", num);
+}
+
+/* test functions that decrypt two DES blocks */
+static void test_SystemFunction_decrypt(descrypt func, int num)
+{
+ unsigned char output[0x11];
+ int r;
+
+ if (!func)
+ return;
+
+ r = func(NULL, NULL, NULL);
+ ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n");
+
+ memset(output, 0, sizeof output);
+
+ r = func(des_ciphertext, des_key, output);
+ ok( r == STATUS_SUCCESS, "wrong error code\n");
+ ok( !memcmp(des_plaintext, output, sizeof des_plaintext), "plaintext wrong (%d)\n", num);
+}
+
START_TEST(crypt_lmhash)
{
HMODULE module;
@@ -397,5 +465,34 @@ START_TEST(crypt_lmhash)
if (pSystemFunction032)
test_SystemFunction032();
+ pSystemFunction012 = (descrypt) GetProcAddress( module, "SystemFunction012");
+ pSystemFunction013 = (descrypt) GetProcAddress( module, "SystemFunction013");
+ pSystemFunction014 = (descrypt) GetProcAddress( module, "SystemFunction014");
+ pSystemFunction015 = (descrypt) GetProcAddress( module, "SystemFunction015");
+ pSystemFunction016 = (descrypt) GetProcAddress( module, "SystemFunction016");
+ pSystemFunction017 = (descrypt) GetProcAddress( module, "SystemFunction017");
+ pSystemFunction018 = (descrypt) GetProcAddress( module, "SystemFunction018");
+ pSystemFunction019 = (descrypt) GetProcAddress( module, "SystemFunction019");
+ pSystemFunction020 = (descrypt) GetProcAddress( module, "SystemFunction020");
+ pSystemFunction021 = (descrypt) GetProcAddress( module, "SystemFunction021");
+ pSystemFunction022 = (descrypt) GetProcAddress( module, "SystemFunction022");
+ pSystemFunction023 = (descrypt) GetProcAddress( module, "SystemFunction023");
+
+ /* these all encrypt two DES blocks */
+ test_SystemFunction_encrypt(pSystemFunction012, 12);
+ test_SystemFunction_encrypt(pSystemFunction014, 14);
+ test_SystemFunction_encrypt(pSystemFunction016, 16);
+ test_SystemFunction_encrypt(pSystemFunction018, 18);
+ test_SystemFunction_encrypt(pSystemFunction020, 20);
+ test_SystemFunction_encrypt(pSystemFunction022, 22);
+
+ /* these all decrypt two DES blocks */
+ test_SystemFunction_decrypt(pSystemFunction013, 13);
+ test_SystemFunction_decrypt(pSystemFunction015, 15);
+ test_SystemFunction_decrypt(pSystemFunction017, 17);
+ test_SystemFunction_decrypt(pSystemFunction019, 19);
+ test_SystemFunction_decrypt(pSystemFunction021, 21);
+ test_SystemFunction_decrypt(pSystemFunction023, 23);
+
FreeLibrary( module );
}
More information about the wine-cvs
mailing list