From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/advapi32/Makefile.in | 3 +-- dlls/advapi32/advapi32.spec | 2 +- dlls/cryptsp/Makefile.in | 5 ++++- .../{advapi32/crypt_arc4.c => cryptsp/arc4.c} | 22 ++++++------------- dlls/cryptsp/cryptsp.spec | 2 +- 5 files changed, 14 insertions(+), 20 deletions(-) rename dlls/{advapi32/crypt_arc4.c => cryptsp/arc4.c} (88%)
diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in index 272f9764267..269bed5d410 100644 --- a/dlls/advapi32/Makefile.in +++ b/dlls/advapi32/Makefile.in @@ -1,14 +1,13 @@ EXTRADEFS = -D_ADVAPI32_ MODULE = advapi32.dll IMPORTLIB = advapi32 -IMPORTS = kernelbase sechost msvcrt +IMPORTS = kernelbase sechost msvcrt cryptsp DELAYIMPORTS = rpcrt4 user32 userenv
SOURCES = \ advapi.c \ cred.c \ crypt.c \ - crypt_arc4.c \ crypt_des.c \ crypt_lmhash.c \ eventlog.c \ diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index dde83cc7045..41eb3e7a32c 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -808,7 +808,7 @@ @ stub SystemFunction029 @ stdcall SystemFunction030(ptr ptr) @ stdcall SystemFunction031(ptr ptr) SystemFunction030 -@ stdcall SystemFunction032(ptr ptr) +@ stdcall SystemFunction032(ptr ptr) cryptsp.SystemFunction032 @ stub SystemFunction033 @ stub SystemFunction034 @ stdcall SystemFunction035(str) diff --git a/dlls/cryptsp/Makefile.in b/dlls/cryptsp/Makefile.in index 2422119d806..4a2a7c4ef5d 100644 --- a/dlls/cryptsp/Makefile.in +++ b/dlls/cryptsp/Makefile.in @@ -1,3 +1,6 @@ MODULE = cryptsp.dll - +IMPORTLIB = cryptsp IMPORTS = advapi32 + +SOURCES = \ + arc4.c diff --git a/dlls/advapi32/crypt_arc4.c b/dlls/cryptsp/arc4.c similarity index 88% rename from dlls/advapi32/crypt_arc4.c rename to dlls/cryptsp/arc4.c index 523cda224e7..e64eb85a8cb 100644 --- a/dlls/advapi32/crypt_arc4.c +++ b/dlls/cryptsp/arc4.c @@ -27,7 +27,12 @@ #include "windef.h" #include "winternl.h"
-#include "crypt.h" +struct ustring +{ + DWORD Length; + DWORD MaximumLength; + unsigned char *Buffer; +};
typedef struct tag_arc4_info { unsigned char state[256]; @@ -79,20 +84,7 @@ static void arc4_ProcessString(arc4_info *a4i, BYTE *inoutString, unsigned int l }
/****************************************************************************** - * SystemFunction032 [ADVAPI32.@] - * - * Encrypts a string data using ARC4 - * - * PARAMS - * data [I/O] data to encrypt - * key [I] key data - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_UNSUCCESSFUL - * - * NOTES - * see http://web.it.kth.se/~rom/ntsec.html#crypto-strongavail + * SystemFunction032 (cryptsp.@) */ NTSTATUS WINAPI SystemFunction032(struct ustring *data, const struct ustring *key) { diff --git a/dlls/cryptsp/cryptsp.spec b/dlls/cryptsp/cryptsp.spec index 98626b759f3..545e5294a4d 100644 --- a/dlls/cryptsp/cryptsp.spec +++ b/dlls/cryptsp/cryptsp.spec @@ -60,6 +60,6 @@ @ stdcall -import SystemFunction027(ptr ptr ptr) @ stdcall -import SystemFunction030(ptr ptr) @ stdcall -import SystemFunction031(ptr ptr) -@ stdcall -import SystemFunction032(ptr ptr) +@ stdcall SystemFunction032(ptr ptr) @ stub SystemFunction033 @ stdcall -import SystemFunction035(str)
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/advapi32/advapi32.spec | 38 +++--- dlls/advapi32/crypt_lmhash.c | 180 ----------------------------- dlls/cryptsp/Makefile.in | 3 +- dlls/cryptsp/cryptsp.spec | 34 +++--- dlls/cryptsp/lmhash.c | 217 +++++++++++++++++++++++++++++++++++ 5 files changed, 255 insertions(+), 217 deletions(-) create mode 100644 dlls/cryptsp/lmhash.c
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 41eb3e7a32c..60855c8b526 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -782,28 +782,28 @@ @ stdcall SystemFunction003(ptr ptr) @ stdcall SystemFunction004(ptr ptr ptr) @ stdcall SystemFunction005(ptr ptr ptr) -@ stdcall SystemFunction006(ptr ptr) +@ stdcall SystemFunction006(ptr ptr) cryptsp.SystemFunction006 @ stdcall SystemFunction007(ptr ptr) -@ stdcall SystemFunction008(ptr ptr ptr) -@ stdcall SystemFunction009(ptr ptr ptr) +@ stdcall SystemFunction008(ptr ptr ptr) cryptsp.SystemFunction008 +@ stdcall SystemFunction009(ptr ptr ptr) cryptsp.SystemFunction009 @ stdcall SystemFunction010(ptr ptr ptr) @ stdcall SystemFunction011(ptr ptr ptr) SystemFunction010 -@ 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 -@ stdcall SystemFunction024(ptr ptr ptr) -@ stdcall SystemFunction025(ptr ptr ptr) -@ stdcall SystemFunction026(ptr ptr ptr) SystemFunction024 -@ stdcall SystemFunction027(ptr ptr ptr) SystemFunction025 +@ stdcall SystemFunction012(ptr ptr ptr) cryptsp.SystemFunction012 +@ stdcall SystemFunction013(ptr ptr ptr) cryptsp.SystemFunction013 +@ stdcall SystemFunction014(ptr ptr ptr) cryptsp.SystemFunction014 +@ stdcall SystemFunction015(ptr ptr ptr) cryptsp.SystemFunction015 +@ stdcall SystemFunction016(ptr ptr ptr) cryptsp.SystemFunction016 +@ stdcall -import SystemFunction017(ptr ptr ptr) SystemFunction013 +@ stdcall SystemFunction018(ptr ptr ptr) cryptsp.SystemFunction018 +@ stdcall -import SystemFunction019(ptr ptr ptr) SystemFunction013 +@ stdcall SystemFunction020(ptr ptr ptr) cryptsp.SystemFunction020 +@ stdcall SystemFunction021(ptr ptr ptr) cryptsp.SystemFunction021 +@ stdcall SystemFunction022(ptr ptr ptr) cryptsp.SystemFunction022 +@ stdcall SystemFunction023(ptr ptr ptr) cryptsp.SystemFunction023 +@ stdcall SystemFunction024(ptr ptr ptr) cryptsp.SystemFunction024 +@ stdcall SystemFunction025(ptr ptr ptr) cryptsp.SystemFunction025 +@ stdcall SystemFunction026(ptr ptr ptr) cryptsp.SystemFunction026 +@ stdcall SystemFunction027(ptr ptr ptr) cryptsp.SystemFunction027 @ stub SystemFunction028 @ stub SystemFunction029 @ stdcall SystemFunction030(ptr ptr) diff --git a/dlls/advapi32/crypt_lmhash.c b/dlls/advapi32/crypt_lmhash.c index 345c89ddb73..3f4283171b5 100644 --- a/dlls/advapi32/crypt_lmhash.c +++ b/dlls/advapi32/crypt_lmhash.c @@ -32,72 +32,6 @@ static const unsigned char CRYPT_LMhash_Magic[8] = { 'K', 'G', 'S', '!', '@', '#', '$', '%' };
-static void CRYPT_LMhash( unsigned char *dst, const unsigned char *pwd, const int len ) -{ - int i, max = 14; - unsigned char tmp_pwd[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - - max = len > max ? max : len; - - for (i = 0; i < max; i++) - tmp_pwd[i] = pwd[i]; - - CRYPT_DEShash( dst, tmp_pwd, CRYPT_LMhash_Magic ); - CRYPT_DEShash( &dst[8], &tmp_pwd[7], CRYPT_LMhash_Magic ); -} - -NTSTATUS WINAPI SystemFunction006( LPCSTR password, LPSTR hash ) -{ - CRYPT_LMhash( (unsigned char*)hash, (const unsigned char*)password, strlen(password) ); - - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction008 [ADVAPI32.@] - * - * Creates a LM response from a challenge and a password hash - * - * PARAMS - * challenge [I] Challenge from authentication server - * hash [I] NTLM hash (from SystemFunction006) - * response [O] response to send back to the server - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_UNSUCCESSFUL - * - * NOTES - * see http://davenport.sourceforge.net/ntlm.html#theLmResponse - * - */ -NTSTATUS WINAPI SystemFunction008(const BYTE *challenge, const BYTE *hash, LPBYTE response) -{ - BYTE key[7*3]; - - if (!challenge || !response) - return STATUS_UNSUCCESSFUL; - - memset(key, 0, sizeof key); - memcpy(key, hash, 0x10); - - CRYPT_DEShash(response, key, challenge); - CRYPT_DEShash(response+8, key+7, challenge); - CRYPT_DEShash(response+16, key+14, challenge); - - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction009 [ADVAPI32.@] - * - * Seems to do the same as SystemFunction008 ... - */ -NTSTATUS WINAPI SystemFunction009(const BYTE *challenge, const BYTE *hash, LPBYTE response) -{ - return SystemFunction008(challenge, hash, response); -} - /****************************************************************************** * SystemFunction001 [ADVAPI32.@] * @@ -288,117 +222,3 @@ NTSTATUS WINAPI SystemFunction005(const struct ustring *in,
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 BYTE *in, const BYTE *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 BYTE *in, const BYTE *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; -} - -/****************************************************************************** - * SystemFunction024 [ADVAPI32.@] - * - * Encrypts two DES blocks with a 32 bit key... - * - * PARAMS - * data [I] data to encrypt (16 bytes) - * key [I] key data (4 bytes) - * output [O] buffer to receive encrypted data (16 bytes) - * - * RETURNS - * Success: STATUS_SUCCESS - */ -NTSTATUS WINAPI SystemFunction024(const BYTE *in, const BYTE *key, LPBYTE out) -{ - BYTE deskey[0x10]; - - memcpy(deskey, key, 4); - memcpy(deskey+4, key, 4); - memcpy(deskey+8, key, 4); - memcpy(deskey+12, key, 4); - - CRYPT_DEShash(out, deskey, in); - CRYPT_DEShash(out+8, deskey+7, in+8); - - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction025 [ADVAPI32.@] - * - * Decrypts two DES blocks with a 32 bit key... - * - * PARAMS - * data [I] data to encrypt (16 bytes) - * key [I] key data (4 bytes) - * output [O] buffer to receive encrypted data (16 bytes) - * - * RETURNS - * Success: STATUS_SUCCESS - */ -NTSTATUS WINAPI SystemFunction025(const BYTE *in, const BYTE *key, LPBYTE out) -{ - BYTE deskey[0x10]; - - memcpy(deskey, key, 4); - memcpy(deskey+4, key, 4); - memcpy(deskey+8, key, 4); - memcpy(deskey+12, key, 4); - - CRYPT_DESunhash(out, deskey, in); - CRYPT_DESunhash(out+8, deskey+7, in+8); - - return STATUS_SUCCESS; -} diff --git a/dlls/cryptsp/Makefile.in b/dlls/cryptsp/Makefile.in index 4a2a7c4ef5d..8d466541625 100644 --- a/dlls/cryptsp/Makefile.in +++ b/dlls/cryptsp/Makefile.in @@ -3,4 +3,5 @@ IMPORTLIB = cryptsp IMPORTS = advapi32
SOURCES = \ - arc4.c + arc4.c \ + lmhash.c diff --git a/dlls/cryptsp/cryptsp.spec b/dlls/cryptsp/cryptsp.spec index 545e5294a4d..6e541c9ec82 100644 --- a/dlls/cryptsp/cryptsp.spec +++ b/dlls/cryptsp/cryptsp.spec @@ -38,26 +38,26 @@ @ stdcall -import CryptSignHashW(long long wstr long ptr ptr) @ stdcall -import CryptVerifySignatureA(long ptr long long str long) @ stdcall -import CryptVerifySignatureW(long ptr long long wstr long) -@ stdcall -import SystemFunction006(ptr ptr) +@ stdcall SystemFunction006(ptr ptr) @ stdcall -import SystemFunction007(ptr ptr) -@ stdcall -import SystemFunction008(ptr ptr ptr) -@ stdcall -import SystemFunction009(ptr ptr ptr) +@ stdcall SystemFunction008(ptr ptr ptr) +@ stdcall SystemFunction009(ptr ptr ptr) SystemFunction008 @ stdcall -import SystemFunction010(ptr ptr ptr) @ stdcall -import SystemFunction011(ptr ptr ptr) -@ stdcall -import SystemFunction012(ptr ptr ptr) -@ stdcall -import SystemFunction013(ptr ptr ptr) -@ stdcall -import SystemFunction014(ptr ptr ptr) -@ stdcall -import SystemFunction015(ptr ptr ptr) -@ stdcall -import SystemFunction016(ptr ptr ptr) -@ stdcall -import SystemFunction018(ptr ptr ptr) -@ stdcall -import SystemFunction020(ptr ptr ptr) -@ stdcall -import SystemFunction021(ptr ptr ptr) -@ stdcall -import SystemFunction022(ptr ptr ptr) -@ stdcall -import SystemFunction023(ptr ptr ptr) -@ stdcall -import SystemFunction024(ptr ptr ptr) -@ stdcall -import SystemFunction025(ptr ptr ptr) -@ stdcall -import SystemFunction026(ptr ptr ptr) -@ stdcall -import SystemFunction027(ptr ptr ptr) +@ 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 SystemFunction018(ptr ptr ptr) SystemFunction012 +@ stdcall SystemFunction020(ptr ptr ptr) SystemFunction012 +@ stdcall SystemFunction021(ptr ptr ptr) SystemFunction013 +@ stdcall SystemFunction022(ptr ptr ptr) SystemFunction012 +@ stdcall SystemFunction023(ptr ptr ptr) SystemFunction013 +@ stdcall SystemFunction024(ptr ptr ptr) +@ stdcall SystemFunction025(ptr ptr ptr) +@ stdcall SystemFunction026(ptr ptr ptr) SystemFunction024 +@ stdcall SystemFunction027(ptr ptr ptr) SystemFunction025 @ stdcall -import SystemFunction030(ptr ptr) @ stdcall -import SystemFunction031(ptr ptr) @ stdcall SystemFunction032(ptr ptr) diff --git a/dlls/cryptsp/lmhash.c b/dlls/cryptsp/lmhash.c new file mode 100644 index 00000000000..4e347a29c32 --- /dev/null +++ b/dlls/cryptsp/lmhash.c @@ -0,0 +1,217 @@ +/* + * Copyright 2004 Hans Leidekker + * + * Based on LMHash.c from libcifs + * + * Copyright (C) 2004 by Christopher R. Hertel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winternl.h" + +NTSTATUS WINAPI SystemFunction001(const BYTE *data, const BYTE *key, BYTE *output); +NTSTATUS WINAPI SystemFunction002(const BYTE *data, const BYTE *key, BYTE *output); + +static void DEShash( BYTE *output, const BYTE *key, const BYTE *data ) +{ + SystemFunction001( data, key, output ); +} + +static void DESunhash( BYTE *output, const BYTE *key, const BYTE *data ) +{ + SystemFunction002( data, key, output ); +} + +static const unsigned char LMhash_Magic[8] = {'K','G','S','!','@','#','$','%'}; + +static void LMhash( unsigned char *dst, const unsigned char *pwd, const int len ) +{ + int i, max = 14; + unsigned char tmp_pwd[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + + max = len > max ? max : len; + + for (i = 0; i < max; i++) + tmp_pwd[i] = pwd[i]; + + DEShash( dst, tmp_pwd, LMhash_Magic ); + DEShash( &dst[8], &tmp_pwd[7], LMhash_Magic ); +} + +/****************************************************************************** + * SystemFunction006 (cryptsp.@) + */ +NTSTATUS WINAPI SystemFunction006( const char *password, char *hash ) +{ + LMhash( (unsigned char *)hash, (const unsigned char *)password, strlen( password ) ); + + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction008 (cryptsp.@) + * SystemFunction009 (cryptsp.@) + * + * Creates a LM response from a challenge and a password hash + * + * PARAMS + * challenge [I] Challenge from authentication server + * hash [I] NTLM hash (from SystemFunction006) + * response [O] response to send back to the server + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_UNSUCCESSFUL + * + * NOTES + * see http://davenport.sourceforge.net/ntlm.html#theLmResponse + * + */ +NTSTATUS WINAPI SystemFunction008( const BYTE *challenge, const BYTE *hash, BYTE *response ) +{ + BYTE key[7 * 3]; + + if (!challenge || !response) + return STATUS_UNSUCCESSFUL; + + memset( key, 0, sizeof(key) ); + memcpy( key, hash, 0x10 ); + + DEShash( response, key, challenge ); + DEShash( response + 8, key + 7, challenge ); + DEShash( response + 16, key + 14, challenge ); + + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction012 (cryptsp.@) + * SystemFunction014 (cryptsp.@) + * SystemFunction016 (cryptsp.@) + * SystemFunction018 (cryptsp.@) + * SystemFunction020 (cryptsp.@) + * SystemFunction022 (cryptsp.@) + * + * 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 BYTE *in, const BYTE *key, BYTE *out ) +{ + if (!in || !out) + return STATUS_UNSUCCESSFUL; + + DEShash( out, key, in ); + DEShash( out + 8, key + 7, in + 8 ); + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction013 (cryptsp.@) + * SystemFunction015 (cryptsp.@) + * SystemFunction021 (cryptsp.@) + * SystemFunction023 (cryptsp.@) + * + * 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 BYTE *in, const BYTE *key, BYTE *out ) +{ + if (!in || !out) + return STATUS_UNSUCCESSFUL; + + DESunhash( out, key, in ); + DESunhash( out + 8, key + 7, in + 8 ); + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction024 (cryptsp.@) + * SystemFunction026 (cryptsp.@) + * + * Encrypts two DES blocks with a 32 bit key... + * + * PARAMS + * data [I] data to encrypt (16 bytes) + * key [I] key data (4 bytes) + * output [O] buffer to receive encrypted data (16 bytes) + * + * RETURNS + * Success: STATUS_SUCCESS + */ +NTSTATUS WINAPI SystemFunction024( const BYTE *in, const BYTE *key, BYTE *out ) +{ + BYTE deskey[0x10]; + + memcpy( deskey, key, 4 ); + memcpy( deskey + 4, key, 4 ); + memcpy( deskey + 8, key, 4 ); + memcpy( deskey + 12, key, 4 ); + + DEShash( out, deskey, in ); + DEShash( out + 8, deskey + 7, in + 8 ); + + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction025 (cryptsp.@) + * SystemFunction027 (cryptsp.@) + * + * Decrypts two DES blocks with a 32 bit key... + * + * PARAMS + * data [I] data to encrypt (16 bytes) + * key [I] key data (4 bytes) + * output [O] buffer to receive encrypted data (16 bytes) + * + * RETURNS + * Success: STATUS_SUCCESS + */ +NTSTATUS WINAPI SystemFunction025( const BYTE *in, const BYTE *key, BYTE *out ) +{ + BYTE deskey[0x10]; + + memcpy( deskey, key, 4 ); + memcpy( deskey + 4, key, 4 ); + memcpy( deskey + 8, key, 4 ); + memcpy( deskey + 12, key, 4 ); + + DESunhash( out, deskey, in ); + DESunhash( out + 8, deskey + 7, in + 8 ); + + return STATUS_SUCCESS; +}
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/advapi32/Makefile.in | 1 - dlls/advapi32/crypt.h | 5 - dlls/advapi32/crypt_des.c | 200 ++++++++++++++++++++++++++++++- dlls/advapi32/crypt_lmhash.c | 224 ----------------------------------- 4 files changed, 198 insertions(+), 232 deletions(-) delete mode 100644 dlls/advapi32/crypt_lmhash.c
diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in index 269bed5d410..5c766629ccc 100644 --- a/dlls/advapi32/Makefile.in +++ b/dlls/advapi32/Makefile.in @@ -9,7 +9,6 @@ SOURCES = \ cred.c \ crypt.c \ crypt_des.c \ - crypt_lmhash.c \ eventlog.c \ lsa.c \ registry.c \ diff --git a/dlls/advapi32/crypt.h b/dlls/advapi32/crypt.h index 4484b4799e5..b8fd84ee566 100644 --- a/dlls/advapi32/crypt.h +++ b/dlls/advapi32/crypt.h @@ -86,11 +86,6 @@ typedef struct tagCRYPTHASH
#define MAXPROVTYPES 999
-extern unsigned char *CRYPT_DEShash( unsigned char *dst, const unsigned char *key, - const unsigned char *src ); -extern unsigned char *CRYPT_DESunhash( unsigned char *dst, const unsigned char *key, - const unsigned char *src ); - struct ustring { DWORD Length; DWORD MaximumLength; diff --git a/dlls/advapi32/crypt_des.c b/dlls/advapi32/crypt_des.c index 2da2d77e2d8..733729d0720 100644 --- a/dlls/advapi32/crypt_des.c +++ b/dlls/advapi32/crypt_des.c @@ -21,6 +21,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" #include "crypt.h"
@@ -252,7 +254,7 @@ static void xor( unsigned char *dst, const unsigned char *a, const unsigned char dst[i] = a[i] ^ b[i]; }
-unsigned char *CRYPT_DEShash( unsigned char *dst, const unsigned char *key, const unsigned char *src ) +static unsigned char *DEShash( unsigned char *dst, const unsigned char *key, const unsigned char *src ) { int i; unsigned char K[7]; @@ -292,7 +294,7 @@ unsigned char *CRYPT_DEShash( unsigned char *dst, const unsigned char *key, cons return dst; }
-unsigned char *CRYPT_DESunhash( unsigned char *dst, const unsigned char *key, const unsigned char *src ) +static unsigned char *DESunhash( unsigned char *dst, const unsigned char *key, const unsigned char *src ) { int i; unsigned char K[7]; @@ -332,3 +334,197 @@ unsigned char *CRYPT_DESunhash( unsigned char *dst, const unsigned char *key, co
return dst; } + + +/****************************************************************************** + * 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 BYTE *data, const BYTE *key, BYTE *output ) +{ + if (!data || !output) + return STATUS_UNSUCCESSFUL; + DEShash( output, key, data ); + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction002 [ADVAPI32.@] + * + * Decrypts a single block of data using DES + * + * PARAMS + * data [I] data to decrypt (8 bytes) + * key [I] key data (7 bytes) + * output [O] the decrypted data (8 bytes) + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_UNSUCCESSFUL + * + */ +NTSTATUS WINAPI SystemFunction002( const BYTE *data, const BYTE *key, BYTE *output ) +{ + if (!data || !output) + return STATUS_UNSUCCESSFUL; + 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 BYTE *key, BYTE *output ) +{ + static const unsigned char LMhash_Magic[8] = {'K','G','S','!','@','#','$','%'}; + + if (!output) + return STATUS_UNSUCCESSFUL; + DEShash( output, key, LMhash_Magic ); + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction004 [ADVAPI32.@] + * + * Encrypts a block of data with DES in ECB mode, preserving the length + * + * PARAMS + * data [I] data to encrypt + * key [I] key data (up to 7 bytes) + * output [O] buffer to receive encrypted data + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_BUFFER_TOO_SMALL if the output buffer is too small + * Failure: STATUS_INVALID_PARAMETER_2 if the key is zero length + * + * NOTES + * Encrypt buffer size should be input size rounded up to 8 bytes + * plus an extra 8 bytes. + */ +NTSTATUS WINAPI SystemFunction004( const struct ustring *in, const struct ustring *key, + struct ustring *out ) +{ + union + { + unsigned char uc[8]; + unsigned int ui[2]; + } data; + unsigned char deskey[7]; + unsigned int crypt_len, ofs; + + if (key->Length <= 0) + return STATUS_INVALID_PARAMETER_2; + + crypt_len = ((in->Length + 7) & ~7); + if (out->MaximumLength < (crypt_len + 8)) + return STATUS_BUFFER_TOO_SMALL; + + data.ui[0] = in->Length; + data.ui[1] = 1; + + if (key->Length < sizeof(deskey)) + { + memset( deskey, 0, sizeof(deskey) ); + memcpy( deskey, key->Buffer, key->Length ); + } + else + memcpy( deskey, key->Buffer, sizeof(deskey) ); + + DEShash( out->Buffer, deskey, data.uc ); + + for (ofs = 0; ofs < (crypt_len - 8); ofs += 8) + DEShash( out->Buffer + 8 + ofs, deskey, in->Buffer + ofs ); + + memset( data.uc, 0, sizeof(data.uc) ); + memcpy( data.uc, in->Buffer + ofs, in->Length + 8 - crypt_len ); + DEShash( out->Buffer + 8 + ofs, deskey, data.uc ); + + out->Length = crypt_len + 8; + + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction005 [ADVAPI32.@] + * + * Decrypts a block of data with DES in ECB mode + * + * PARAMS + * data [I] data to decrypt + * key [I] key data (up to 7 bytes) + * output [O] buffer to receive decrypted data + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_BUFFER_TOO_SMALL if the output buffer is too small + * Failure: STATUS_INVALID_PARAMETER_2 if the key is zero length + * + */ +NTSTATUS WINAPI SystemFunction005( const struct ustring *in, const struct ustring *key, + struct ustring *out ) +{ + union + { + unsigned char uc[8]; + unsigned int ui[2]; + } data; + unsigned char deskey[7]; + unsigned int ofs, crypt_len; + + if (key->Length <= 0) + return STATUS_INVALID_PARAMETER_2; + + if (key->Length < sizeof(deskey)) + { + memset( deskey, 0, sizeof(deskey) ); + memcpy( deskey, key->Buffer, key->Length ); + } + else + memcpy( deskey, key->Buffer, sizeof(deskey) ); + + DESunhash(data.uc, deskey, in->Buffer); + + if (data.ui[1] != 1) + return STATUS_UNKNOWN_REVISION; + + crypt_len = data.ui[0]; + if (crypt_len > out->MaximumLength) + return STATUS_BUFFER_TOO_SMALL; + + for (ofs = 0; (ofs + 8) < crypt_len; ofs += 8) + DESunhash( out->Buffer+ofs, deskey, in->Buffer + ofs + 8 ); + + if (ofs < crypt_len) + { + DESunhash( data.uc, deskey, in->Buffer + ofs + 8 ); + memcpy( out->Buffer + ofs, data.uc, crypt_len - ofs ); + } + + out->Length = crypt_len; + + return STATUS_SUCCESS; +} diff --git a/dlls/advapi32/crypt_lmhash.c b/dlls/advapi32/crypt_lmhash.c deleted file mode 100644 index 3f4283171b5..00000000000 --- a/dlls/advapi32/crypt_lmhash.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2004 Hans Leidekker - * - * Based on LMHash.c from libcifs - * - * Copyright (C) 2004 by Christopher R. Hertel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <stdarg.h> - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winternl.h" - -#include "crypt.h" - -static const unsigned char CRYPT_LMhash_Magic[8] = - { 'K', 'G', 'S', '!', '@', '#', '$', '%' }; - -/****************************************************************************** - * 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 BYTE *data, const BYTE *key, LPBYTE output) -{ - if (!data || !output) - return STATUS_UNSUCCESSFUL; - CRYPT_DEShash(output, key, data); - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction002 [ADVAPI32.@] - * - * Decrypts a single block of data using DES - * - * PARAMS - * data [I] data to decrypt (8 bytes) - * key [I] key data (7 bytes) - * output [O] the decrypted data (8 bytes) - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_UNSUCCESSFUL - * - */ -NTSTATUS WINAPI SystemFunction002(const BYTE *data, const BYTE *key, LPBYTE output) -{ - if (!data || !output) - return STATUS_UNSUCCESSFUL; - 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 BYTE *key, LPBYTE output) -{ - if (!output) - return STATUS_UNSUCCESSFUL; - CRYPT_DEShash(output, key, CRYPT_LMhash_Magic); - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction004 [ADVAPI32.@] - * - * Encrypts a block of data with DES in ECB mode, preserving the length - * - * PARAMS - * data [I] data to encrypt - * key [I] key data (up to 7 bytes) - * output [O] buffer to receive encrypted data - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_BUFFER_TOO_SMALL if the output buffer is too small - * Failure: STATUS_INVALID_PARAMETER_2 if the key is zero length - * - * NOTES - * Encrypt buffer size should be input size rounded up to 8 bytes - * plus an extra 8 bytes. - */ -NTSTATUS WINAPI SystemFunction004(const struct ustring *in, - const struct ustring *key, - struct ustring *out) -{ - union { - unsigned char uc[8]; - unsigned int ui[2]; - } data; - unsigned char deskey[7]; - unsigned int crypt_len, ofs; - - if (key->Length<=0) - return STATUS_INVALID_PARAMETER_2; - - crypt_len = ((in->Length+7)&~7); - if (out->MaximumLength < (crypt_len+8)) - return STATUS_BUFFER_TOO_SMALL; - - data.ui[0] = in->Length; - data.ui[1] = 1; - - if (key->Length<sizeof deskey) - { - memset(deskey, 0, sizeof deskey); - memcpy(deskey, key->Buffer, key->Length); - } - else - memcpy(deskey, key->Buffer, sizeof deskey); - - CRYPT_DEShash(out->Buffer, deskey, data.uc); - - for(ofs=0; ofs<(crypt_len-8); ofs+=8) - CRYPT_DEShash(out->Buffer+8+ofs, deskey, in->Buffer+ofs); - - memset(data.uc, 0, sizeof data.uc); - memcpy(data.uc, in->Buffer+ofs, in->Length +8-crypt_len); - CRYPT_DEShash(out->Buffer+8+ofs, deskey, data.uc); - - out->Length = crypt_len+8; - - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction005 [ADVAPI32.@] - * - * Decrypts a block of data with DES in ECB mode - * - * PARAMS - * data [I] data to decrypt - * key [I] key data (up to 7 bytes) - * output [O] buffer to receive decrypted data - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_BUFFER_TOO_SMALL if the output buffer is too small - * Failure: STATUS_INVALID_PARAMETER_2 if the key is zero length - * - */ -NTSTATUS WINAPI SystemFunction005(const struct ustring *in, - const struct ustring *key, - struct ustring *out) -{ - union { - unsigned char uc[8]; - unsigned int ui[2]; - } data; - unsigned char deskey[7]; - unsigned int ofs, crypt_len; - - if (key->Length<=0) - return STATUS_INVALID_PARAMETER_2; - - if (key->Length<sizeof deskey) - { - memset(deskey, 0, sizeof deskey); - memcpy(deskey, key->Buffer, key->Length); - } - else - memcpy(deskey, key->Buffer, sizeof deskey); - - CRYPT_DESunhash(data.uc, deskey, in->Buffer); - - if (data.ui[1] != 1) - return STATUS_UNKNOWN_REVISION; - - crypt_len = data.ui[0]; - if (crypt_len > out->MaximumLength) - return STATUS_BUFFER_TOO_SMALL; - - for (ofs=0; (ofs+8)<crypt_len; ofs+=8) - CRYPT_DESunhash(out->Buffer+ofs, deskey, in->Buffer+ofs+8); - - if (ofs<crypt_len) - { - CRYPT_DESunhash(data.uc, deskey, in->Buffer+ofs+8); - memcpy(out->Buffer+ofs, data.uc, crypt_len-ofs); - } - - out->Length = crypt_len; - - return STATUS_SUCCESS; -}
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/advapi32/advapi32.spec | 12 ++-- dlls/advapi32/crypt.c | 97 ---------------------------- dlls/cryptsp/Makefile.in | 1 + dlls/cryptsp/crypt.c | 122 ++++++++++++++++++++++++++++++++++++ dlls/cryptsp/cryptsp.spec | 14 ++--- 5 files changed, 136 insertions(+), 110 deletions(-) create mode 100644 dlls/cryptsp/crypt.c
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 60855c8b526..7f5fbb07138 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -783,11 +783,11 @@ @ stdcall SystemFunction004(ptr ptr ptr) @ stdcall SystemFunction005(ptr ptr ptr) @ stdcall SystemFunction006(ptr ptr) cryptsp.SystemFunction006 -@ stdcall SystemFunction007(ptr ptr) +@ stdcall SystemFunction007(ptr ptr) cryptsp.SystemFunction007 @ stdcall SystemFunction008(ptr ptr ptr) cryptsp.SystemFunction008 @ stdcall SystemFunction009(ptr ptr ptr) cryptsp.SystemFunction009 -@ stdcall SystemFunction010(ptr ptr ptr) -@ stdcall SystemFunction011(ptr ptr ptr) SystemFunction010 +@ stdcall SystemFunction010(ptr ptr ptr) cryptsp.SystemFunction010 +@ stdcall SystemFunction011(ptr ptr ptr) cryptsp.SystemFunction011 @ stdcall SystemFunction012(ptr ptr ptr) cryptsp.SystemFunction012 @ stdcall SystemFunction013(ptr ptr ptr) cryptsp.SystemFunction013 @ stdcall SystemFunction014(ptr ptr ptr) cryptsp.SystemFunction014 @@ -806,12 +806,12 @@ @ stdcall SystemFunction027(ptr ptr ptr) cryptsp.SystemFunction027 @ stub SystemFunction028 @ stub SystemFunction029 -@ stdcall SystemFunction030(ptr ptr) -@ stdcall SystemFunction031(ptr ptr) SystemFunction030 +@ stdcall SystemFunction030(ptr ptr) cryptsp.SystemFunction030 +@ stdcall SystemFunction031(ptr ptr) cryptsp.SystemFunction031 @ stdcall SystemFunction032(ptr ptr) cryptsp.SystemFunction032 @ stub SystemFunction033 @ stub SystemFunction034 -@ stdcall SystemFunction035(str) +@ stdcall SystemFunction035(str) cryptsp.SystemFunction035 @ stdcall SystemFunction036(ptr long) # RtlGenRandom @ stdcall SystemFunction040(ptr long long) # RtlEncryptMemory @ stdcall SystemFunction041(ptr long long) # RtlDecryptMemory diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c index 0c94999660a..03591e041e1 100644 --- a/dlls/advapi32/crypt.c +++ b/dlls/advapi32/crypt.c @@ -42,17 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
-typedef struct tagMD4_CTX { - unsigned int buf[4]; - unsigned int i[2]; - unsigned char in[64]; - unsigned char digest[16]; -} MD4_CTX; - -void WINAPI MD4Init(MD4_CTX *ctx); -void WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len); -void WINAPI MD4Final(MD4_CTX *ctx); - static HWND crypt_hWindow;
#define CRYPT_Alloc(size) (LocalAlloc(LMEM_ZEROINIT, size)) @@ -2295,92 +2284,6 @@ DWORD WINAPI ReadEncryptedFileRaw(PFE_EXPORT_FUNC export, PVOID callback, PVOID return ERROR_CALL_NOT_IMPLEMENTED; }
-/****************************************************************************** - * SystemFunction007 [ADVAPI32.@] - * - * MD4 hash a unicode string - * - * PARAMS - * string [I] the string to hash - * output [O] the md4 hash of the string (16 bytes) - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_UNSUCCESSFUL - * - */ -NTSTATUS WINAPI SystemFunction007(const UNICODE_STRING *string, LPBYTE hash) -{ - MD4_CTX ctx; - - MD4Init( &ctx ); - MD4Update( &ctx, (const BYTE *)string->Buffer, string->Length ); - MD4Final( &ctx ); - memcpy( hash, ctx.digest, 0x10 ); - - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction010 [ADVAPI32.@] - * SystemFunction011 [ADVAPI32.@] - * - * MD4 hashes 16 bytes of data - * - * PARAMS - * unknown [] seems to have no effect on the output - * data [I] pointer to data to hash (16 bytes) - * output [O] the md4 hash of the data (16 bytes) - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: STATUS_UNSUCCESSFUL - * - */ -NTSTATUS WINAPI SystemFunction010(LPVOID unknown, const BYTE *data, LPBYTE hash) -{ - MD4_CTX ctx; - - MD4Init( &ctx ); - MD4Update( &ctx, data, 0x10 ); - MD4Final( &ctx ); - memcpy( hash, ctx.digest, 0x10 ); - - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction030 (ADVAPI32.@) - * - * Tests if two blocks of 16 bytes are equal - * - * PARAMS - * b1,b2 [I] block of 16 bytes - * - * RETURNS - * TRUE if blocks are the same - * FALSE if blocks are different - */ -BOOL WINAPI SystemFunction030(LPCVOID b1, LPCVOID b2) -{ - return !memcmp(b1, b2, 0x10); -} - -/****************************************************************************** - * SystemFunction035 (ADVAPI32.@) - * - * Described here: -http://disc.server.com/discussion.cgi?disc=148775;article=942;title=Coding%2... - * - * NOTES - * Stub, always return TRUE. - */ -BOOL WINAPI SystemFunction035(LPCSTR lpszDllFilePath) -{ - FIXME("%s: stub\n", debugstr_a(lpszDllFilePath)); - return TRUE; -} - static CRITICAL_SECTION random_cs; static CRITICAL_SECTION_DEBUG random_debug = { diff --git a/dlls/cryptsp/Makefile.in b/dlls/cryptsp/Makefile.in index 8d466541625..568acdded1f 100644 --- a/dlls/cryptsp/Makefile.in +++ b/dlls/cryptsp/Makefile.in @@ -4,4 +4,5 @@ IMPORTS = advapi32
SOURCES = \ arc4.c \ + crypt.c \ lmhash.c diff --git a/dlls/cryptsp/crypt.c b/dlls/cryptsp/crypt.c new file mode 100644 index 00000000000..03a9a89cbea --- /dev/null +++ b/dlls/cryptsp/crypt.c @@ -0,0 +1,122 @@ +/* + * Copyright 1999 Ian Schmidt + * Copyright 2001 Travis Michielsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winternl.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(crypt); + +typedef struct tagMD4_CTX +{ + unsigned int buf[4]; + unsigned int i[2]; + unsigned char in[64]; + unsigned char digest[16]; +} MD4_CTX; + +void WINAPI MD4Init(MD4_CTX *ctx); +void WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len); +void WINAPI MD4Final(MD4_CTX *ctx); + +/****************************************************************************** + * SystemFunction007 (cryptsp.@) + * + * MD4 hash a unicode string + * + * PARAMS + * string [I] the string to hash + * output [O] the md4 hash of the string (16 bytes) + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_UNSUCCESSFUL + * + */ +NTSTATUS WINAPI SystemFunction007( const UNICODE_STRING *string, BYTE *hash ) +{ + MD4_CTX ctx; + + MD4Init( &ctx ); + MD4Update( &ctx, (const BYTE *)string->Buffer, string->Length ); + MD4Final( &ctx ); + memcpy( hash, ctx.digest, 0x10 ); + + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction010 (cryptsp.@) + * SystemFunction011 (cryptsp.@) + * + * MD4 hashes 16 bytes of data + * + * PARAMS + * unknown [] seems to have no effect on the output + * data [I] pointer to data to hash (16 bytes) + * output [O] the md4 hash of the data (16 bytes) + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: STATUS_UNSUCCESSFUL + * + */ +NTSTATUS WINAPI SystemFunction010( void *unknown, const BYTE *data, BYTE *hash ) +{ + MD4_CTX ctx; + + MD4Init( &ctx ); + MD4Update( &ctx, data, 0x10 ); + MD4Final( &ctx ); + memcpy( hash, ctx.digest, 0x10 ); + + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction030 (cryptsp.@) + * SystemFunction031 (cryptsp.@) + * + * Tests if two blocks of 16 bytes are equal + * + * PARAMS + * b1,b2 [I] block of 16 bytes + * + * RETURNS + * TRUE if blocks are the same + * FALSE if blocks are different + */ +BOOL WINAPI SystemFunction030( const void *b1, const void *b2 ) +{ + return !memcmp( b1, b2, 0x10 ); +} + +/****************************************************************************** + * CheckSignatureInFile (cryptsp.@) + * SystemFunction035 (cryptsp.@) + */ +BOOL WINAPI CheckSignatureInFile( const char *file ) +{ + FIXME( "%s: stub\n", debugstr_a(file) ); + return TRUE; +} diff --git a/dlls/cryptsp/cryptsp.spec b/dlls/cryptsp/cryptsp.spec index 6e541c9ec82..a76fe1756c8 100644 --- a/dlls/cryptsp/cryptsp.spec +++ b/dlls/cryptsp/cryptsp.spec @@ -1,4 +1,4 @@ -@ stub CheckSignatureInFile +@ stdcall CheckSignatureInFile(str) @ stdcall -import CryptAcquireContextA(ptr str str long long) @ stdcall -import CryptAcquireContextW(ptr wstr wstr long long) @ stdcall -import CryptContextAddRef(long ptr long) @@ -39,11 +39,11 @@ @ stdcall -import CryptVerifySignatureA(long ptr long long str long) @ stdcall -import CryptVerifySignatureW(long ptr long long wstr long) @ stdcall SystemFunction006(ptr ptr) -@ stdcall -import SystemFunction007(ptr ptr) +@ stdcall SystemFunction007(ptr ptr) @ stdcall SystemFunction008(ptr ptr ptr) @ stdcall SystemFunction009(ptr ptr ptr) SystemFunction008 -@ stdcall -import SystemFunction010(ptr ptr ptr) -@ stdcall -import SystemFunction011(ptr ptr ptr) +@ stdcall SystemFunction010(ptr ptr ptr) +@ stdcall SystemFunction011(ptr ptr ptr) SystemFunction010 @ stdcall SystemFunction012(ptr ptr ptr) @ stdcall SystemFunction013(ptr ptr ptr) @ stdcall SystemFunction014(ptr ptr ptr) SystemFunction012 @@ -58,8 +58,8 @@ @ stdcall SystemFunction025(ptr ptr ptr) @ stdcall SystemFunction026(ptr ptr ptr) SystemFunction024 @ stdcall SystemFunction027(ptr ptr ptr) SystemFunction025 -@ stdcall -import SystemFunction030(ptr ptr) -@ stdcall -import SystemFunction031(ptr ptr) +@ stdcall SystemFunction030(ptr ptr) +@ stdcall SystemFunction031(ptr ptr) SystemFunction030 @ stdcall SystemFunction032(ptr ptr) @ stub SystemFunction033 -@ stdcall -import SystemFunction035(str) +@ stdcall SystemFunction035(str) CheckSignatureInFile
From: Elizabeth Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57962 --- configure | 2 ++ configure.ac | 1 + dlls/advapi32/Makefile.in | 1 - dlls/advapi32/advapi32.spec | 10 +++++----- dlls/cryptbase/Makefile.in | 4 ++++ dlls/cryptbase/cryptbase.spec | 11 ++++++++++ .../{advapi32/crypt_des.c => cryptbase/des.c} | 20 +++++++++++++------ 7 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 dlls/cryptbase/Makefile.in create mode 100644 dlls/cryptbase/cryptbase.spec rename dlls/{advapi32/crypt_des.c => cryptbase/des.c} (97%)
diff --git a/configure b/configure index 08e7a3f7077..ef7c99dd8e8 100755 --- a/configure +++ b/configure @@ -1025,6 +1025,7 @@ enable_coremessaging enable_credui enable_crtdll enable_crypt32 +enable_cryptbase enable_cryptdlg enable_cryptdll enable_cryptext @@ -22179,6 +22180,7 @@ wine_fn_config_makefile dlls/credui/tests enable_tests wine_fn_config_makefile dlls/crtdll enable_crtdll wine_fn_config_makefile dlls/crypt32 enable_crypt32 wine_fn_config_makefile dlls/crypt32/tests enable_tests +wine_fn_config_makefile dlls/cryptbase enable_cryptbase wine_fn_config_makefile dlls/cryptdlg enable_cryptdlg wine_fn_config_makefile dlls/cryptdll enable_cryptdll wine_fn_config_makefile dlls/cryptext enable_cryptext diff --git a/configure.ac b/configure.ac index 306cbe03146..274591f5f53 100644 --- a/configure.ac +++ b/configure.ac @@ -2473,6 +2473,7 @@ WINE_CONFIG_MAKEFILE(dlls/credui/tests) WINE_CONFIG_MAKEFILE(dlls/crtdll) WINE_CONFIG_MAKEFILE(dlls/crypt32) WINE_CONFIG_MAKEFILE(dlls/crypt32/tests) +WINE_CONFIG_MAKEFILE(dlls/cryptbase) WINE_CONFIG_MAKEFILE(dlls/cryptdlg) WINE_CONFIG_MAKEFILE(dlls/cryptdll) WINE_CONFIG_MAKEFILE(dlls/cryptext) diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in index 5c766629ccc..353ee35654b 100644 --- a/dlls/advapi32/Makefile.in +++ b/dlls/advapi32/Makefile.in @@ -8,7 +8,6 @@ SOURCES = \ advapi.c \ cred.c \ crypt.c \ - crypt_des.c \ eventlog.c \ lsa.c \ registry.c \ diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 7f5fbb07138..f45e4cb023f 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -777,11 +777,11 @@ @ stdcall StopTraceA(int64 str ptr) @ stdcall -import StopTraceW(int64 wstr ptr) @ stdcall SynchronizeWindows31FilesAndWindowsNTRegistry(long long long long) -@ stdcall SystemFunction001(ptr ptr ptr) -@ stdcall SystemFunction002(ptr ptr ptr) -@ stdcall SystemFunction003(ptr ptr) -@ stdcall SystemFunction004(ptr ptr ptr) -@ stdcall SystemFunction005(ptr ptr ptr) +@ stdcall SystemFunction001(ptr ptr ptr) cryptbase.SystemFunction001 +@ stdcall SystemFunction002(ptr ptr ptr) cryptbase.SystemFunction002 +@ stdcall SystemFunction003(ptr ptr) cryptbase.SystemFunction003 +@ stdcall SystemFunction004(ptr ptr ptr) cryptbase.SystemFunction004 +@ stdcall SystemFunction005(ptr ptr ptr) cryptbase.SystemFunction005 @ stdcall SystemFunction006(ptr ptr) cryptsp.SystemFunction006 @ stdcall SystemFunction007(ptr ptr) cryptsp.SystemFunction007 @ stdcall SystemFunction008(ptr ptr ptr) cryptsp.SystemFunction008 diff --git a/dlls/cryptbase/Makefile.in b/dlls/cryptbase/Makefile.in new file mode 100644 index 00000000000..eb651765c8a --- /dev/null +++ b/dlls/cryptbase/Makefile.in @@ -0,0 +1,4 @@ +MODULE = cryptbase.dll + +SOURCES = \ + des.c diff --git a/dlls/cryptbase/cryptbase.spec b/dlls/cryptbase/cryptbase.spec new file mode 100644 index 00000000000..3fa0102fc33 --- /dev/null +++ b/dlls/cryptbase/cryptbase.spec @@ -0,0 +1,11 @@ +@ stdcall SystemFunction001(ptr ptr ptr) +@ stdcall SystemFunction002(ptr ptr ptr) +@ stdcall SystemFunction003(ptr ptr) +@ stdcall SystemFunction004(ptr ptr ptr) +@ stdcall SystemFunction005(ptr ptr ptr) +@ stub SystemFunction028 +@ stub SystemFunction029 +@ stub SystemFunction034 +@ stub SystemFunction036 +@ stub SystemFunction040 +@ stub SystemFunction041 diff --git a/dlls/advapi32/crypt_des.c b/dlls/cryptbase/des.c similarity index 97% rename from dlls/advapi32/crypt_des.c rename to dlls/cryptbase/des.c index 733729d0720..46ff81d2185 100644 --- a/dlls/advapi32/crypt_des.c +++ b/dlls/cryptbase/des.c @@ -21,10 +21,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include <stdarg.h> #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" -#include "crypt.h" +#include "winternl.h" + +struct ustring +{ + DWORD Length; + DWORD MaximumLength; + unsigned char *Buffer; +};
static const unsigned char InitialPermuteMap[64] = { @@ -337,7 +345,7 @@ static unsigned char *DESunhash( unsigned char *dst, const unsigned char *key, c
/****************************************************************************** - * SystemFunction001 [ADVAPI32.@] + * SystemFunction001 (cryptbase.@) * * Encrypts a single block of data using DES * @@ -360,7 +368,7 @@ NTSTATUS WINAPI SystemFunction001( const BYTE *data, const BYTE *key, BYTE *outp }
/****************************************************************************** - * SystemFunction002 [ADVAPI32.@] + * SystemFunction002 (cryptbase.@) * * Decrypts a single block of data using DES * @@ -383,7 +391,7 @@ NTSTATUS WINAPI SystemFunction002( const BYTE *data, const BYTE *key, BYTE *outp }
/****************************************************************************** - * SystemFunction003 [ADVAPI32.@] + * SystemFunction003 (cryptbase.@) * * Hashes a key using DES and a fixed datablock * @@ -407,7 +415,7 @@ NTSTATUS WINAPI SystemFunction003( const BYTE *key, BYTE *output ) }
/****************************************************************************** - * SystemFunction004 [ADVAPI32.@] + * SystemFunction004 (cryptbase.@) * * Encrypts a block of data with DES in ECB mode, preserving the length * @@ -469,7 +477,7 @@ NTSTATUS WINAPI SystemFunction004( const struct ustring *in, const struct ustrin }
/****************************************************************************** - * SystemFunction005 [ADVAPI32.@] + * SystemFunction005 (cryptbase.@) * * Decrypts a block of data with DES in ECB mode *
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/advapi32/advapi32.spec | 6 +- dlls/advapi32/crypt.c | 129 ----------------------------- dlls/cryptbase/Makefile.in | 1 + dlls/cryptbase/cryptbase.spec | 6 +- dlls/cryptbase/cryptbase_main.c | 140 ++++++++++++++++++++++++++++++++ tools/make_specfiles | 4 + 6 files changed, 151 insertions(+), 135 deletions(-) create mode 100644 dlls/cryptbase/cryptbase_main.c
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index f45e4cb023f..79b64df8abb 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -812,9 +812,9 @@ @ stub SystemFunction033 @ stub SystemFunction034 @ stdcall SystemFunction035(str) cryptsp.SystemFunction035 -@ stdcall SystemFunction036(ptr long) # RtlGenRandom -@ stdcall SystemFunction040(ptr long long) # RtlEncryptMemory -@ stdcall SystemFunction041(ptr long long) # RtlDecryptMemory +@ stdcall SystemFunction036(ptr long) cryptbase.SystemFunction036 +@ stdcall SystemFunction040(ptr long long) cryptbase.SystemFunction040 +@ stdcall SystemFunction041(ptr long long) cryptbase.SystemFunction041 @ stdcall TraceEvent(int64 ptr) ntdll.EtwLogTraceEvent @ stub TraceEventInstance @ varargs TraceMessage(int64 long ptr long) ntdll.EtwTraceMessage diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c index 03591e041e1..50dc7869422 100644 --- a/dlls/advapi32/crypt.c +++ b/dlls/advapi32/crypt.c @@ -2284,135 +2284,6 @@ DWORD WINAPI ReadEncryptedFileRaw(PFE_EXPORT_FUNC export, PVOID callback, PVOID return ERROR_CALL_NOT_IMPLEMENTED; }
-static CRITICAL_SECTION random_cs; -static CRITICAL_SECTION_DEBUG random_debug = -{ - 0, 0, &random_cs, - { &random_debug.ProcessLocksList, &random_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": random_cs") } -}; -static CRITICAL_SECTION random_cs = { &random_debug, -1, 0, 0, 0, 0 }; - -#define MAX_CPUS 256 -static char random_buf[sizeof(SYSTEM_INTERRUPT_INFORMATION) * MAX_CPUS]; -static ULONG random_len; -static ULONG random_pos; - -/* FIXME: assumes interrupt information provides sufficient randomness */ -static BOOL fill_random_buffer(void) -{ - ULONG len = sizeof(SYSTEM_INTERRUPT_INFORMATION) * min( NtCurrentTeb()->Peb->NumberOfProcessors, MAX_CPUS ); - NTSTATUS status; - - if ((status = NtQuerySystemInformation( SystemInterruptInformation, random_buf, len, NULL ))) - { - WARN( "failed to get random bytes %08lx\n", status ); - return FALSE; - } - random_len = len; - random_pos = 0; - return TRUE; -} - -/****************************************************************************** - * SystemFunction036 (ADVAPI32.@) - * - * MSDN documents this function as RtlGenRandom and declares it in ntsecapi.h - * - * PARAMS - * pbBuffer [O] Pointer to memory to receive random bytes. - * dwLen [I] Number of random bytes to fetch. - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ - -BOOLEAN WINAPI SystemFunction036( void *buffer, ULONG len ) -{ - char *ptr = buffer; - - EnterCriticalSection( &random_cs ); - while (len) - { - ULONG size; - if (random_pos >= random_len && !fill_random_buffer()) - { - SetLastError( NTE_FAIL ); - LeaveCriticalSection( &random_cs ); - return FALSE; - } - size = min( len, random_len - random_pos ); - memcpy( ptr, random_buf + random_pos, size ); - random_pos += size; - ptr += size; - len -= size; - } - LeaveCriticalSection( &random_cs ); - return TRUE; -} - -/* - These functions have nearly identical prototypes to CryptProtectMemory and CryptUnprotectMemory, - in crypt32.dll. - */ - -/****************************************************************************** - * SystemFunction040 (ADVAPI32.@) - * - * MSDN documents this function as RtlEncryptMemory and declares it in ntsecapi.h. - * - * PARAMS - * memory [I/O] Pointer to memory to encrypt. - * length [I] Length of region to encrypt in bytes. - * flags [I] Control whether other processes are able to decrypt the memory. - * RTL_ENCRYPT_OPTION_SAME_PROCESS - * RTL_ENCRYPT_OPTION_CROSS_PROCESS - * RTL_ENCRYPT_OPTION_SAME_LOGON - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: NTSTATUS error code - * - * NOTES - * length must be a multiple of RTL_ENCRYPT_MEMORY_SIZE. - * If flags are specified when encrypting, the same flag value must be given - * when decrypting the memory. - */ -NTSTATUS WINAPI SystemFunction040(PVOID memory, ULONG length, ULONG flags) -{ - FIXME("(%p, %lx, %lx): stub [RtlEncryptMemory]\n", memory, length, flags); - return STATUS_SUCCESS; -} - -/****************************************************************************** - * SystemFunction041 (ADVAPI32.@) - * - * MSDN documents this function as RtlDecryptMemory and declares it in ntsecapi.h. - * - * PARAMS - * memory [I/O] Pointer to memory to decrypt. - * length [I] Length of region to decrypt in bytes. - * flags [I] Control whether other processes are able to decrypt the memory. - * RTL_ENCRYPT_OPTION_SAME_PROCESS - * RTL_ENCRYPT_OPTION_CROSS_PROCESS - * RTL_ENCRYPT_OPTION_SAME_LOGON - * - * RETURNS - * Success: STATUS_SUCCESS - * Failure: NTSTATUS error code - * - * NOTES - * length must be a multiple of RTL_ENCRYPT_MEMORY_SIZE. - * If flags are specified when encrypting, the same flag value must be given - * when decrypting the memory. - */ -NTSTATUS WINAPI SystemFunction041(PVOID memory, ULONG length, ULONG flags) -{ - FIXME("(%p, %lx, %lx): stub [RtlDecryptMemory]\n", memory, length, flags); - return STATUS_SUCCESS; -} - /****************************************************************************** * WriteEncryptedFileRaw (ADVAPI32.@) * diff --git a/dlls/cryptbase/Makefile.in b/dlls/cryptbase/Makefile.in index eb651765c8a..32742f897d4 100644 --- a/dlls/cryptbase/Makefile.in +++ b/dlls/cryptbase/Makefile.in @@ -1,4 +1,5 @@ MODULE = cryptbase.dll
SOURCES = \ + cryptbase_main.c \ des.c diff --git a/dlls/cryptbase/cryptbase.spec b/dlls/cryptbase/cryptbase.spec index 3fa0102fc33..ebd836df365 100644 --- a/dlls/cryptbase/cryptbase.spec +++ b/dlls/cryptbase/cryptbase.spec @@ -6,6 +6,6 @@ @ stub SystemFunction028 @ stub SystemFunction029 @ stub SystemFunction034 -@ stub SystemFunction036 -@ stub SystemFunction040 -@ stub SystemFunction041 +@ stdcall SystemFunction036(ptr long) +@ stdcall SystemFunction040(ptr long long) +@ stdcall SystemFunction041(ptr long long) diff --git a/dlls/cryptbase/cryptbase_main.c b/dlls/cryptbase/cryptbase_main.c new file mode 100644 index 00000000000..daa3e8ff21d --- /dev/null +++ b/dlls/cryptbase/cryptbase_main.c @@ -0,0 +1,140 @@ +/* + * Copyright 1999 Ian Schmidt + * Copyright 2001 Travis Michielsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winternl.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(crypt); + +static CRITICAL_SECTION random_cs; +static CRITICAL_SECTION_DEBUG random_debug = +{ + 0, 0, &random_cs, + { &random_debug.ProcessLocksList, &random_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": random_cs") } +}; +static CRITICAL_SECTION random_cs = { &random_debug, -1, 0, 0, 0, 0 }; + +#define MAX_CPUS 256 +static char random_buf[sizeof(SYSTEM_INTERRUPT_INFORMATION) * MAX_CPUS]; +static ULONG random_len; +static ULONG random_pos; + +/* FIXME: assumes interrupt information provides sufficient randomness */ +static BOOL fill_random_buffer(void) +{ + ULONG len = sizeof(SYSTEM_INTERRUPT_INFORMATION) * min( NtCurrentTeb()->Peb->NumberOfProcessors, MAX_CPUS ); + NTSTATUS status; + + if ((status = NtQuerySystemInformation( SystemInterruptInformation, random_buf, len, NULL ))) + { + WARN( "failed to get random bytes, status %#lx\n", status ); + return FALSE; + } + random_len = len; + random_pos = 0; + return TRUE; +} + +/****************************************************************************** + * SystemFunction036 (cryptbase.@) + */ +BOOLEAN WINAPI SystemFunction036( void *buffer, ULONG len ) +{ + char *ptr = buffer; + + EnterCriticalSection( &random_cs ); + while (len) + { + ULONG size; + if (random_pos >= random_len && !fill_random_buffer()) + { + SetLastError( NTE_FAIL ); + LeaveCriticalSection( &random_cs ); + return FALSE; + } + size = min( len, random_len - random_pos ); + memcpy( ptr, random_buf + random_pos, size ); + random_pos += size; + ptr += size; + len -= size; + } + LeaveCriticalSection( &random_cs ); + return TRUE; +} + +/****************************************************************************** + * SystemFunction040 (cryptbase.@) + * + * MSDN documents this function as RtlEncryptMemory and declares it in ntsecapi.h. + * + * PARAMS + * memory [I/O] Pointer to memory to encrypt. + * length [I] Length of region to encrypt in bytes. + * flags [I] Control whether other processes are able to decrypt the memory. + * RTL_ENCRYPT_OPTION_SAME_PROCESS + * RTL_ENCRYPT_OPTION_CROSS_PROCESS + * RTL_ENCRYPT_OPTION_SAME_LOGON + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: NTSTATUS error code + * + * NOTES + * length must be a multiple of RTL_ENCRYPT_MEMORY_SIZE. + * If flags are specified when encrypting, the same flag value must be given + * when decrypting the memory. + */ +NTSTATUS WINAPI SystemFunction040( void *memory, ULONG length, ULONG flags ) +{ + FIXME("(%p, %lu, %#lx): stub [RtlEncryptMemory]\n", memory, length, flags); + return STATUS_SUCCESS; +} + +/****************************************************************************** + * SystemFunction041 (cryptbase.@) + * + * MSDN documents this function as RtlDecryptMemory and declares it in ntsecapi.h. + * + * PARAMS + * memory [I/O] Pointer to memory to decrypt. + * length [I] Length of region to decrypt in bytes. + * flags [I] Control whether other processes are able to decrypt the memory. + * RTL_ENCRYPT_OPTION_SAME_PROCESS + * RTL_ENCRYPT_OPTION_CROSS_PROCESS + * RTL_ENCRYPT_OPTION_SAME_LOGON + * + * RETURNS + * Success: STATUS_SUCCESS + * Failure: NTSTATUS error code + * + * NOTES + * length must be a multiple of RTL_ENCRYPT_MEMORY_SIZE. + * If flags are specified when encrypting, the same flag value must be given + * when decrypting the memory. + */ +NTSTATUS WINAPI SystemFunction041( void *memory, ULONG length, ULONG flags ) +{ + FIXME( "(%p, %lu, %#lx): stub [RtlDecryptMemory]\n", memory, length, flags ); + return STATUS_SUCCESS; +} diff --git a/tools/make_specfiles b/tools/make_specfiles index 0509d41d5c1..48518213201 100755 --- a/tools/make_specfiles +++ b/tools/make_specfiles @@ -97,6 +97,10 @@ my @dll_groups = "advapi32", "sechost", ], + [ + "cryptbase", + "advapi32", + ], [ "netapi32", "srvcli",