From 6969cab5eeaa2d311ef8eb77f80bf4aed1fdd032 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 10 May 2006 18:16:58 +0900 Subject: [PATCH] advapi32: Implement and test SystemFunction001. --- dlls/advapi32/advapi32.spec | 2 +- dlls/advapi32/crypt_lmhash.c | 23 +++++++++++++++++++++++ dlls/advapi32/tests/crypt_lmhash.c | 27 ++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index abec4e7a9e2..c729d3ba46f 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -595,7 +595,7 @@ # @ stub StopTraceA # @ stub StopTraceW @ stdcall SynchronizeWindows31FilesAndWindowsNTRegistry(long long long long) -@ stub SystemFunction001 +@ stdcall SystemFunction001(ptr ptr ptr) @ stub SystemFunction002 @ stub SystemFunction003 @ stub SystemFunction004 diff --git a/dlls/advapi32/crypt_lmhash.c b/dlls/advapi32/crypt_lmhash.c index dbe07ba7cd8..01f6049e41e 100644 --- a/dlls/advapi32/crypt_lmhash.c +++ b/dlls/advapi32/crypt_lmhash.c @@ -89,3 +89,26 @@ NTSTATUS WINAPI SystemFunction008(const LPBYTE challenge, const LPBYTE hash, LPB return STATUS_SUCCESS; } + +/****************************************************************************** + * SystemFunction001 [ADVAPI32.@] + * + * Encrypts a single block of data using DES + * + * PARAMS + * data [I] data to encrypt (8 bytes) + * key [I] key data (7 bytes) + * output [O] the encrypted data (8 bytes) + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_UNSUCCESSFUL + * + */ +NTSTATUS WINAPI SystemFunction001(const LPBYTE data, const LPBYTE key, LPBYTE output) +{ + if (!data || !output) + return STATUS_UNSUCCESSFUL; + CRYPT_DEShash(output, key, data); + return STATUS_SUCCESS; +} diff --git a/dlls/advapi32/tests/crypt_lmhash.c b/dlls/advapi32/tests/crypt_lmhash.c index c389fb2284c..5c266331aa2 100644 --- a/dlls/advapi32/tests/crypt_lmhash.c +++ b/dlls/advapi32/tests/crypt_lmhash.c @@ -29,10 +29,12 @@ #include "winternl.h" typedef VOID (WINAPI *fnSystemFunction006)( PCSTR passwd, PSTR lmhash ); -typedef DWORD (WINAPI *fnSystemFunction008)(const LPBYTE, const LPBYTE, LPBYTE); +typedef NTSTATUS (WINAPI *fnSystemFunction008)(const LPBYTE, const LPBYTE, LPBYTE); +typedef NTSTATUS (WINAPI *fnSystemFunction001)(const LPBYTE, const LPBYTE, LPBYTE); fnSystemFunction006 pSystemFunction006; fnSystemFunction008 pSystemFunction008; +fnSystemFunction001 pSystemFunction001; static void test_SystemFunction006(void) { @@ -93,6 +95,25 @@ static void test_SystemFunction008(void) ok( !memcmp(output, expected, sizeof expected), "response wrong\n"); } +static void test_SystemFunction001(void) +{ + unsigned char key[8] = { 0xff, 0x37, 0x50, 0xbc, 0xc2, 0xb2, 0x24, 0 }; + unsigned char data[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; + unsigned char expected[8] = { 0xc3, 0x37, 0xcd, 0x5c, 0xbd, 0x44, 0xfc, 0x97 }; + unsigned char output[16]; + NTSTATUS r; + + r = pSystemFunction001(0,0,0); + ok( r == STATUS_UNSUCCESSFUL, "wrong error code\n"); + + memset(output, 0, sizeof output); + + r = pSystemFunction001(data,key,output); + ok( r == STATUS_SUCCESS, "wrong error code\n"); + + ok(!memcmp(output, expected, sizeof expected), "response wrong\n"); +} + START_TEST(crypt_lmhash) { HMODULE module; @@ -107,5 +128,9 @@ START_TEST(crypt_lmhash) if (pSystemFunction008) test_SystemFunction008(); + pSystemFunction001 = (fnSystemFunction001)GetProcAddress( module, "SystemFunction001" ); + if (pSystemFunction001) + test_SystemFunction001(); + FreeLibrary( module ); }