Commit in reactos/lib/advapi32/crypt on MAIN
crypt.c+155-1511.1 -> 1.2
crypt.h+3-31.1 -> 1.2
crypt_des.c+30-291.1 -> 1.2
crypt_lmhash.c+7-181.1 -> 1.2
crypt_md4.c+112-1131.1 -> 1.2
crypt_md5.c+124-1251.1 -> 1.2
crypt_sha.c+5-41.1 -> 1.2
+436-443
7 modified files
- Remove Wine-isms from advapi32 because it's a ReactOS DLL!
- Enforce a consistent coding style.
- Remove -D__REACTOS__

reactos/lib/advapi32/crypt
crypt.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt.c	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt.c	12 Dec 2004 15:16:26 -0000	1.2
@@ -24,33 +24,13 @@
  *  - Thread-safing
  *  - Signature checking
  */
-#include "wine/config.h"
-#include "wine/port.h"
 
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "wine/unicode.h"
+#include "advapi32.h"
 #include "crypt.h"
-#include "winnls.h"
-#include "wincrypt.h"
-#include "windef.h"
-#include "winerror.h"
-#include "winreg.h"
-#include "winbase.h"
-//#include "winuser.h"
-#include "wine/debug.h"
-
-typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(
-    struct _EXCEPTION_POINTERS *ExceptionInfo
-    );
 
-#include "wine/winternl.h"
-#include "wine/ntstatus.h"
+#define NDEBUG
+#include <debug.h>
 
-WINE_DEFAULT_DEBUG_CHANNEL(crypt);
 
 HWND crypt_hWindow = 0;
 
@@ -69,8 +49,12 @@
 	{
 		strcpy(keyname, KEYSTR);
 		strcpy(keyname + strlen(KEYSTR), pProvName);
-	} else
+	}
+	else
+	{
 		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+	}
+
 	return keyname;
 }
 
@@ -89,8 +73,11 @@
 		*(--ptr) = (dwType % 10) + '0';
 		*(--ptr) = ((dwType / 10) % 10) + '0';
 		*(--ptr) = (dwType / 100) + '0';
-	} else
+	}
+	else
+	{
 		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+	}
 	return keyname;
 }
 
@@ -160,7 +147,7 @@
 		return FALSE;
 	}
 
-	FIXME("(%s, %p): not verifying image\n", lpszImage, pData);
+	DPRINT1("FIXME (%s, %p): not verifying image\n", lpszImage, pData);
 
 	return TRUE;
 }
@@ -175,6 +162,7 @@
 
 #define CRYPT_GetProvFunc(name) \
 	if ( !(provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)) ) goto error
+
 #define CRYPT_GetProvFuncOpt(name) \
 	provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)
 PCRYPTPROV CRYPT_LoadProvider(PSTR pImage)
@@ -182,13 +170,16 @@
 	PCRYPTPROV provider;
 	DWORD errorcode = ERROR_NOT_ENOUGH_MEMORY;
 
-	if ( !(provider = CRYPT_Alloc(sizeof(CRYPTPROV))) ) goto error;
-	if ( !(provider->pFuncs = CRYPT_Alloc(sizeof(PROVFUNCS))) ) goto error;
-	if ( !(provider->pVTable = CRYPT_Alloc(sizeof(VTableProvStruc))) ) goto error;
-	if ( !(provider->hModule = LoadLibraryA(pImage)) )
+	if (!(provider = CRYPT_Alloc(sizeof(CRYPTPROV))))
+		goto error;
+	if (!(provider->pFuncs = CRYPT_Alloc(sizeof(PROVFUNCS))))
+		goto error;
+	if (!(provider->pVTable = CRYPT_Alloc(sizeof(VTableProvStruc))))
+		goto error;
+	if (!(provider->hModule = LoadLibraryA(pImage)))
 	{
 		errorcode = (GetLastError() == ERROR_FILE_NOT_FOUND) ? NTE_PROV_DLL_NOT_FOUND : NTE_PROVIDER_DLL_FAIL;
-		FIXME("Failed to load dll %s\n", debugstr_a(pImage));
+		DPRINT1("Failed to load dll %s\n", pImage);
 		goto error;
 	}
 	provider->refcount = 1;
@@ -222,7 +213,7 @@
 
 	/* FIXME: Not sure what the pbContextInfo field is for.
 	 *        Does it need memory allocation?
-         */
+	 */
 	provider->pVTable->Version = 3;
 	provider->pVTable->pFuncVerifyImage = (FARPROC)CRYPT_VerifyImage;
 	provider->pVTable->pFuncReturnhWnd = (FARPROC)CRYPT_ReturnhWnd;
@@ -271,7 +262,7 @@
 	DWORD keytype, type, len;
 	ULONG r;
 
-	TRACE("(%p, %s, %s, %ld, %08lx)\n", phProv, pszContainer,
+	DPRINT("(%p, %s, %s, %ld, %08lx)\n", phProv, pszContainer,
 		pszProvider, dwProvType, dwFlags);
 
 	if (dwProvType < 1 || dwProvType > MAXPROVTYPES)
@@ -291,54 +282,62 @@
 		/* No CSP name specified so try the user default CSP first
 		 * then try the machine default CSP
 		 */
-		if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, TRUE)) ) {
-			TRACE("No provider registered for crypto provider type %ld.\n", dwProvType);
+		if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, TRUE)))
+		{
+			DPRINT("No provider registered for crypto provider type %ld.\n", dwProvType);
 			SetLastError(NTE_PROV_TYPE_NOT_DEF);
 			return FALSE;
 		}
+
 		if (RegOpenKeyA(HKEY_CURRENT_USER, keyname, &key))
 		{
 			CRYPT_Free(keyname);
-			if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, FALSE)) ) {
-				TRACE("No type registered for crypto provider type %ld.\n", dwProvType);
+			if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, FALSE)))
+			{
+				DPRINT("No type registered for crypto provider type %ld.\n", dwProvType);
 				RegCloseKey(key);
 				SetLastError(NTE_PROV_TYPE_NOT_DEF);
 				goto error;
 			}
-			if (RegOpenKeyA(HKEY_LOCAL_MACHINE, keyname, &key)) {
-				TRACE("Did not find registry entry of crypto provider for %s.\n", debugstr_a(keyname));
+
+			if (RegOpenKeyA(HKEY_LOCAL_MACHINE, keyname, &key))
+			{
+				DPRINT("Did not find registry entry of crypto provider for %S.\n", keyname);
 				CRYPT_Free(keyname);
 				RegCloseKey(key);
 				SetLastError(NTE_PROV_TYPE_NOT_DEF);
 				goto error;
 			}
 		}
+
 		CRYPT_Free(keyname);
 		r = RegQueryValueExA(key, "Name", NULL, &keytype, NULL, &len);
-		ifr != ERROR_SUCCESS || !len || keytype != REG_SZ)
+		if (r != ERROR_SUCCESS || !len || keytype != REG_SZ)
 		{
-			TRACE("error %ld reading size of 'Name' from registry\n", r );
+			DPRINT("error %ld reading size of 'Name' from registry\n", r );
 			RegCloseKey(key);
 			SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
 			goto error;
 		}
-		if(!(provname = CRYPT_Alloc(len)))
+		if (!(provname = CRYPT_Alloc(len)))
 		{
 			RegCloseKey(key);
 			SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 			goto error;
 		}
 		r = RegQueryValueExA(key, "Name", NULL, NULL, provname, &len);
-		if( r != ERROR_SUCCESS )
+		if (r != ERROR_SUCCESS)
 		{
-			TRACE("error %ld reading 'Name' from registry\n", r );
+			DPRINT("error %ld reading 'Name' from registry\n", r );
 			RegCloseKey(key);
 			SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
 			goto error;
 		}
 		RegCloseKey(key);
-	} else {
-		if ( !(provname = CRYPT_Alloc(strlen(pszProvider) +1)) )
+	}
+	else
+	{
+		if (!(provname = CRYPT_Alloc(strlen(pszProvider) +1)))
 		{
 			SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 			goto error;
@@ -363,7 +362,7 @@
 	}
 	if (type != dwProvType)
 	{
-		TRACE("Crypto provider has wrong type (%ld vs expected %ld).\n", type, dwProvType);
+		DPRINT("Crypto provider has wrong type (%ld vs expected %ld).\n", type, dwProvType);
 		SetLastError(NTE_PROV_TYPE_NO_MATCH);
 		goto error;
 	}
@@ -371,7 +370,7 @@
 	r = RegQueryValueExA(key, "Image Path", NULL, &keytype, NULL, &len);
 	if ( r != ERROR_SUCCESS || keytype != REG_SZ)
 	{
-		TRACE("error %ld reading size of 'Image Path' from registry\n", r );
+		DPRINT("error %ld reading size of 'Image Path' from registry\n", r );
 		RegCloseKey(key);
 		SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
 		goto error;
@@ -383,16 +382,16 @@
 		goto error;
 	}
 	r = RegQueryValueExA(key, "Image Path", NULL, NULL, temp, &len);
-	if( r != ERROR_SUCCESS )
+	if (r != ERROR_SUCCESS)
 	{
-		TRACE("error %ld reading 'Image Path' from registry\n", r );
+		DPRINT("error %ld reading 'Image Path' from registry\n", r );
 		RegCloseKey(key);
 		SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
 		goto error;
 	}
 
 	r = RegQueryValueExA(key, "Signature", NULL, &keytype, NULL, &len);
-	if ( r == ERROR_SUCCESS && keytype == REG_BINARY )
+	if (r == ERROR_SUCCESS && keytype == REG_BINARY)
 	{
 		if (!(signature = CRYPT_Alloc(len)))
 		{
@@ -401,9 +400,9 @@
 			goto error;
 		}
 		r = RegQueryValueExA(key, "Signature", NULL, NULL, signature, &len);
-		if ( r != ERROR_SUCCESS )
+		if (r != ERROR_SUCCESS)
 		{
-			TRACE("error %ld reading 'Signature'\n", r );
+			DPRINT("error %ld reading 'Signature'\n", r );
 			CRYPT_Free(signature);
 			RegCloseKey(key);
 			SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
@@ -415,7 +414,7 @@
 		r = RegQueryValueExA(key, "SigInFile", NULL, &keytype, NULL, &len);
 		if (r != ERROR_SUCCESS)
 		{
-			TRACE("error %ld reading size of 'SigInFile'\n", r );
+			DPRINT("error %ld reading size of 'SigInFile'\n", r );
 			RegCloseKey(key);
 			SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
 			goto error;
@@ -437,7 +436,7 @@
 	}
 	RegCloseKey(key);
 	len = ExpandEnvironmentStringsA(temp, NULL, 0);
-	if ( !(imagepath = CRYPT_Alloc(len)) )
+	if (!(imagepath = CRYPT_Alloc(len)))
 	{
 		CRYPT_Free(signature);
 		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -458,7 +457,8 @@
 	}
 	pProv = CRYPT_LoadProvider(imagepath);
 	CRYPT_Free(signature);
-	if (!pProv) {
+	if (!pProv)
+	{
 		/* CRYPT_LoadProvider calls SetLastError */
 		goto error;
 	}
@@ -469,14 +469,16 @@
 		/* MSDN: When this flag is set, the value returned in phProv is undefined,
 		 *       and thus, the CryptReleaseContext function need not be called afterwards.
 		 *       Therefore, we must clean up everything now.
-                 */
+		 */
 		if (dwFlags & CRYPT_DELETEKEYSET)
 		{
 			FreeLibrary(pProv->hModule);
 			CRYPT_Free(provname);
 			CRYPT_Free(pProv->pFuncs);
 			CRYPT_Free(pProv);
-		} else {
+		}
+		else
+		{
 			*phProv = (HCRYPTPROV)pProv;
 		}
 		CRYPT_Free(temp);
@@ -515,12 +517,12 @@
 	PSTR pProvider = NULL, pContainer = NULL;
 	BOOL ret = FALSE;
 
-	TRACE("(%p, %s, %s, %ld, %08lx)\n", phProv, debugstr_w(pszContainer),
-		debugstr_w(pszProvider), dwProvType, dwFlags);
+	DPRINT("(%p, %S, %S, %ld, %08lx)\n", phProv, pszContainer,
+		pszProvider, dwProvType, dwFlags);
 
-	if ( !CRYPT_UnicodeToANSI(pszContainer, &pContainer, -1) )
+	if (!CRYPT_UnicodeToANSI(pszContainer, &pContainer, -1))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
-	if ( !CRYPT_UnicodeToANSI(pszProvider, &pProvider, -1) )
+	if (!CRYPT_UnicodeToANSI(pszProvider, &pProvider, -1))
 	{
 		CRYPT_Free(pContainer);
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -553,9 +555,9 @@
  */
 BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFlags)
 {
-	PCRYPTPROV pProv = (PCRYPTPROV)hProv;	
+	PCRYPTPROV pProv = (PCRYPTPROV)hProv;
 
-	TRACE("(0x%lx, %p, %08lx)\n", hProv, pdwReserved, dwFlags);
+	DPRINT("(0x%lx, %p, %08lx)\n", hProv, pdwReserved, dwFlags);
 
 	if (!pProv)
 	{
@@ -585,7 +587,7 @@
 	PCRYPTPROV pProv = (PCRYPTPROV)hProv;
 	BOOL ret = TRUE;
 
-	TRACE("(0x%lx, %08ld)\n", hProv, dwFlags);
+	DPRINT("(0x%lx, %08ld)\n", hProv, dwFlags);
 
 	if (!pProv)
 	{
@@ -594,7 +596,7 @@
 	}
 
 	pProv->refcount--;
-	if (pProv->refcount <= 0) 
+	if (pProv->refcount <= 0)
 	{
 		ret = pProv->pFuncs->pCPReleaseContext(pProv->hPrivate, dwFlags);
 		FreeLibrary(pProv->hModule);
@@ -630,7 +632,7 @@
 {
 	PCRYPTPROV prov = (PCRYPTPROV)hProv;
 
-	TRACE("(0x%lx, %ld, %p)\n", hProv, dwLen, pbBuffer);
+	DPRINT("(0x%lx, %ld, %p)\n", hProv, dwLen, pbBuffer);
 
 	if (!hProv)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -664,7 +666,7 @@
 	PCRYPTKEY key = (PCRYPTKEY)hKey;
 	PCRYPTHASH hash;
 
-	TRACE("(0x%lx, 0x%x, 0x%lx, %08lx, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
+	DPRINT("(0x%lx, 0x%x, 0x%lx, %08lx, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
 
 	if (!prov)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -672,17 +674,17 @@
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
 	if (dwFlags)
 		CRYPT_ReturnLastError(NTE_BAD_FLAGS);
-	if ( !(hash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
+	if (!(hash = CRYPT_Alloc(sizeof(CRYPTHASH))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	hash->pProvider = prov;
 
 	if (prov->pFuncs->pCPCreateHash(prov->hPrivate, Algid,
 			key ? key->hPrivate : 0, 0, &hash->hPrivate))
-        {
-            *phHash = (HCRYPTHASH)hash;
-            return TRUE;
-        }
+	{
+		*phHash = (HCRYPTHASH)hash;
+		return TRUE;
+	}
 
 	/* CSP error! */
 	CRYPT_Free(hash);
@@ -715,7 +717,7 @@
 	PCRYPTKEY key = (PCRYPTKEY)hKey;
 	PCRYPTHASH hash = (PCRYPTHASH)hHash;
 
-	TRACE("(0x%lx, 0x%lx, %d, %08lx, %p, %p)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
+	DPRINT("(0x%lx, 0x%lx, %d, %08lx, %p, %p)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
 
 	if (!key || !pbData || !pdwDataLen)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -748,21 +750,21 @@
 	PCRYPTHASH hash = (PCRYPTHASH)hBaseData;
 	PCRYPTKEY key;
 
-	TRACE("(0x%lx, 0x%08x, 0x%lx, 0x%08lx, %p)\n", hProv, Algid, hBaseData, dwFlags, phKey);
+	DPRINT("(0x%lx, 0x%08x, 0x%lx, 0x%08lx, %p)\n", hProv, Algid, hBaseData, dwFlags, phKey);
 
 	if (!prov || !hash)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
 	if (!phKey)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
-	if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
+	if (!(key = CRYPT_Alloc(sizeof(CRYPTKEY))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	key->pProvider = prov;
 	if (prov->pFuncs->pCPDeriveKey(prov->hPrivate, Algid, hash->hPrivate, dwFlags, &key->hPrivate))
-        {
-            *phKey = (HCRYPTKEY)key;
-            return TRUE;
-        }
+	{
+		*phKey = (HCRYPTKEY)key;
+		return TRUE;
+	}
 
 	/* CSP error! */
 	CRYPT_Free(key);
@@ -788,7 +790,7 @@
 	PCRYPTPROV prov;
 	BOOL ret;
 
-	TRACE("(0x%lx)\n", hHash);
+	DPRINT("(0x%lx)\n", hHash);
 
 	if (!hash)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -817,7 +819,7 @@
 	PCRYPTPROV prov;
 	BOOL ret;
 
-	TRACE("(0x%lx)\n", hKey);
+	DPRINT("(0x%lx)\n", hKey);
 
 	if (!key)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -849,7 +851,7 @@
 	PCRYPTPROV prov;
 	PCRYPTHASH orghash, newhash;
 
-	TRACE("(0x%lx, %p, %08ld, %p)\n", hHash, pdwReserved, dwFlags, phHash);
+	DPRINT("(0x%lx, %p, %08ld, %p)\n", hHash, pdwReserved, dwFlags, phHash);
 
 	orghash = (PCRYPTHASH)hHash;
 	if (!orghash || pdwReserved || !phHash)
@@ -859,7 +861,7 @@
 	if (!prov->pFuncs->pCPDuplicateHash)
 		CRYPT_ReturnLastError(ERROR_CALL_NOT_IMPLEMENTED);
 
-	if ( !(newhash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
+	if (!(newhash = CRYPT_Alloc(sizeof(CRYPTHASH))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	newhash->pProvider = prov;
@@ -892,7 +894,7 @@
 	PCRYPTPROV prov;
 	PCRYPTKEY orgkey, newkey;
 
-	TRACE("(0x%lx, %p, %08ld, %p)\n", hKey, pdwReserved, dwFlags, phKey);
+	DPRINT("(0x%lx, %p, %08ld, %p)\n", hKey, pdwReserved, dwFlags, phKey);
 
 	orgkey = (PCRYPTKEY)hKey;
 	if (!orgkey || pdwReserved || !phKey)
@@ -902,7 +904,7 @@
 	if (!prov->pFuncs->pCPDuplicateKey)
 		CRYPT_ReturnLastError(ERROR_CALL_NOT_IMPLEMENTED);
 
-	if ( !(newkey = CRYPT_Alloc(sizeof(CRYPTKEY))) )
+	if (!(newkey = CRYPT_Alloc(sizeof(CRYPTKEY))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	newkey->pProvider = prov;
@@ -945,7 +947,7 @@
 	PCRYPTKEY key = (PCRYPTKEY)hKey;
 	PCRYPTHASH hash = (PCRYPTHASH)hHash;
 
-	TRACE("(0x%lx, 0x%lx, %d, %08ld, %p, %p, %ld)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen);
+	DPRINT("(0x%lx, 0x%lx, %d, %08ld, %p, %p, %ld)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen);
 
 	if (!key || !pdwDataLen)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -981,24 +983,18 @@
 		DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName)
 {
 	HKEY hKey;
-	
-	static const WCHAR providerW[] = {
-                'S','o','f','t','w','a','r','e','\\',
-                'M','i','c','r','o','s','o','f','t','\\',
-                'C','r','y','p','t','o','g','r','a','p','h','y','\\',
-                'D','e','f','a','u','l','t','s','\\',
-                'P','r','o','v','i','d','e','r',0
-        };
-	
-	static const WCHAR typeW[] = {'T','y','p','e',0};
 
-	TRACE("(%ld, %p, %ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
-			pdwProvType, pszProvName, pcbProvName);
+	DPRINT("(%ld, %p, %ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
+		pdwProvType, pszProvName, pcbProvName);
 
-	if (pdwReserved || !pcbProvName) CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
-	if (dwFlags) CRYPT_ReturnLastError(NTE_BAD_FLAGS);
+	if (pdwReserved || !pcbProvName)
+		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
+	if (dwFlags)
+		CRYPT_ReturnLastError(NTE_BAD_FLAGS);
 
-	if (RegOpenKeyW(HKEY_LOCAL_MACHINE, providerW, &hKey))
+	if (RegOpenKeyW(HKEY_LOCAL_MACHINE,
+			L"Software\\Microsoft\\Cryptography\\Defaults\\Provider",
+			&hKey))
 		CRYPT_ReturnLastError(NTE_FAIL);
 
 	if (!pszProvName)
@@ -1020,7 +1016,9 @@
 		
 		if (dwIndex >= numkeys)
 			CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
-	} else {
+	}
+	else
+	{
 		DWORD size = sizeof(DWORD);
 		DWORD result;
 		HKEY subkey;
@@ -1030,7 +1028,7 @@
 			CRYPT_ReturnLastError(result);
 		if (RegOpenKeyW(hKey, pszProvName, &subkey))
 			return FALSE;
-		if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
+		if (RegQueryValueExW(subkey, L"Type", NULL, NULL, (BYTE*)pdwProvType, &size))
 			return FALSE;
 		RegCloseKey(subkey);
 	}
@@ -1050,11 +1048,11 @@
 	DWORD strlen;
 	BOOL ret; /* = FALSE; */
 
-	TRACE("(%ld, %p, %08ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
+	DPRINT("(%ld, %p, %08ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
 			pdwProvType, pszProvName, pcbProvName);
 
 	strlen = *pcbProvName * sizeof(WCHAR);
-	if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
+	if (pszProvName && !(str = CRYPT_Alloc(strlen)))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 	ret = CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen);
 	if (str)
@@ -1096,12 +1094,13 @@
 	PSTR keyname, ch;
 	DWORD result;
 
-	TRACE("(%ld, %p, %08ld, %p, %p, %p)\n", dwIndex, pdwReserved,
+	DPRINT("(%ld, %p, %08ld, %p, %p, %p)\n", dwIndex, pdwReserved,
 		dwFlags, pdwProvType, pszTypeName, pcbTypeName);
 
 	if (pdwReserved || !pdwProvType || !pcbTypeName)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
-	if (dwFlags) CRYPT_ReturnLastError(NTE_BAD_FLAGS);
+	if (dwFlags)
+		CRYPT_ReturnLastError(NTE_BAD_FLAGS);
 
 	if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\Defaults\\Provider Types", &hKey))
 		return FALSE;
@@ -1112,10 +1111,11 @@
 	keylen++;
 	if ( !(keyname = CRYPT_Alloc(keylen)) )
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
-	if ( RegEnumKeyA(hKey, dwIndex, keyname, keylen) ) {
-                CRYPT_Free(keyname);
+	if ( RegEnumKeyA(hKey, dwIndex, keyname, keylen) )
+	{
+		CRYPT_Free(keyname);
 		return FALSE;
-        }
+	}
 	RegOpenKeyA(hKey, keyname, &hSubkey);
 	ch = keyname + strlen(keyname);
 	/* Convert "Type 000" to 0, etc/ */
@@ -1145,10 +1145,10 @@
 	DWORD strlen;
 	BOOL ret;
 
-	TRACE("(%ld, %p, %08ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
+	DPRINT("(%ld, %p, %08ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
 			pdwProvType, pszTypeName, pcbTypeName);
 	strlen = *pcbTypeName / sizeof(WCHAR);
-	if ( pszTypeName && !(str = CRYPT_Alloc(strlen)) )
+	if (pszTypeName && !(str = CRYPT_Alloc(strlen)))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 	ret = CryptEnumProviderTypesA(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen);
 	if (str)
@@ -1187,7 +1187,7 @@
 	PCRYPTPROV prov;
 	PCRYPTKEY key = (PCRYPTKEY)hKey, expkey = (PCRYPTKEY)hExpKey;
 
-	TRACE("(0x%lx, 0x%lx, %ld, %08ld, %p, %p)\n", hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen);
+	DPRINT("(0x%lx, 0x%lx, %ld, %08ld, %p, %p)\n", hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen);
 
 	if (!key || !pdwDataLen)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -1217,22 +1217,22 @@
 	PCRYPTPROV prov = (PCRYPTPROV)hProv;
 	PCRYPTKEY key;
 
-	TRACE("(0x%lx, %d, %08ld, %p)\n", hProv, Algid, dwFlags, phKey);
+	DPRINT("(0x%lx, %d, %08ld, %p)\n", hProv, Algid, dwFlags, phKey);
 
 	if (!prov)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
 	if (!phKey)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
-	if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
+	if (!(key = CRYPT_Alloc(sizeof(CRYPTKEY))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	key->pProvider = prov;
 
 	if (prov->pFuncs->pCPGenKey(prov->hPrivate, Algid, dwFlags, &key->hPrivate))
-        {
-            *phKey = (HCRYPTKEY)key;
-            return TRUE;
-        }
+	{
+		*phKey = (HCRYPTKEY)key;
+		return TRUE;
+	}
 
 	/* CSP error! */
 	CRYPT_Free(key);
@@ -1272,7 +1272,7 @@
 		CRYPT_ReturnLastError(NTE_BAD_FLAGS);
 	if (dwProvType > 999)
 		CRYPT_ReturnLastError(NTE_BAD_PROV_TYPE);
-	if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)) )
+	if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 	if (RegOpenKeyA((dwFlags & CRYPT_USER_DEFAULT) ?  HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE ,keyname, &hKey))
 	{
@@ -1308,10 +1308,10 @@
 	DWORD strlen;
 	BOOL ret = FALSE;
 
-	TRACE("(%ld, %p, %08ld, %p, %p)\n", dwProvType, pdwReserved, dwFlags, pszProvName, pcbProvName);
+	DPRINT("(%ld, %p, %08ld, %p, %p)\n", dwProvType, pdwReserved, dwFlags, pszProvName, pcbProvName);
 
 	strlen = *pcbProvName / sizeof(WCHAR);
-	if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
+	if (pszProvName && !(str = CRYPT_Alloc(strlen)))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 	ret = CryptGetDefaultProviderA(dwProvType, pdwReserved, dwFlags, str, &strlen);
 	if (str)
@@ -1348,7 +1348,7 @@
 	PCRYPTPROV prov;
 	PCRYPTHASH hash = (PCRYPTHASH)hHash;
 
-	TRACE("(0x%lx, %ld, %p, %p, %08ld)\n", hHash, dwParam, pbData, pdwDataLen, dwFlags);
+	DPRINT("(0x%lx, %ld, %p, %p, %08ld)\n", hHash, dwParam, pbData, pdwDataLen, dwFlags);
 
 	if (!hash || !pdwDataLen)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -1383,7 +1383,7 @@
 	PCRYPTPROV prov;
 	PCRYPTKEY key = (PCRYPTKEY)hKey;
 
-	TRACE("(0x%lx, %ld, %p, %p, %08ld)\n", hKey, dwParam, pbData, pdwDataLen, dwFlags);
+	DPRINT("(0x%lx, %ld, %p, %p, %08ld)\n", hKey, dwParam, pbData, pdwDataLen, dwFlags);
 
 	if (!key || !pdwDataLen)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -1417,7 +1417,7 @@
 {
 	PCRYPTPROV prov = (PCRYPTPROV)hProv;
 
-	TRACE("(0x%lx, %ld, %p, %p, %08ld)\n", hProv, dwParam, pbData, pdwDataLen, dwFlags);
+	DPRINT("(0x%lx, %ld, %p, %p, %08ld)\n", hProv, dwParam, pbData, pdwDataLen, dwFlags);
 
 	return prov->pFuncs->pCPGetProvParam(prov->hPrivate, dwParam, pbData, pdwDataLen, dwFlags);
 }
@@ -1441,22 +1441,22 @@
 	PCRYPTPROV prov = (PCRYPTPROV)hProv;
 	PCRYPTKEY key;
 
-	TRACE("(0x%lx, %ld, %p)\n", hProv, dwKeySpec, phUserKey);
+	DPRINT("(0x%lx, %ld, %p)\n", hProv, dwKeySpec, phUserKey);
 
 	if (!prov)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
 	if (!phUserKey)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
-	if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
+	if (!(key = CRYPT_Alloc(sizeof(CRYPTKEY))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	key->pProvider = prov;
 
 	if (prov->pFuncs->pCPGetUserKey(prov->hPrivate, dwKeySpec, &key->hPrivate))
-        {
-            *phUserKey = (HCRYPTKEY)key;
-            return TRUE;
-        }
+	{
+		*phUserKey = (HCRYPTKEY)key;
+		return TRUE;
+	}
 
 	/* CSP Error */
 	CRYPT_Free(key);
@@ -1484,7 +1484,7 @@
 	PCRYPTHASH hash = (PCRYPTHASH)hHash;
 	PCRYPTPROV prov;
 
-	TRACE("(0x%lx, %p, %ld, %08ld)\n", hHash, pbData, dwDataLen, dwFlags);
+	DPRINT("(0x%lx, %p, %ld, %08ld)\n", hHash, pbData, dwDataLen, dwFlags);
 
 	if (!hash)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -1513,7 +1513,7 @@
 	PCRYPTKEY key = (PCRYPTKEY)hKey;
 	PCRYPTPROV prov;
 
-	TRACE("(0x%lx, 0x%lx, %08ld)\n", hHash, hKey, dwFlags);
+	DPRINT("(0x%lx, 0x%lx, %08ld)\n", hHash, hKey, dwFlags);
 
 	if (!hash || !key)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -1543,12 +1543,12 @@
 	PCRYPTPROV prov = (PCRYPTPROV)hProv;
 	PCRYPTKEY pubkey = (PCRYPTKEY)hPubKey, importkey;
 
-	TRACE("(0x%lx, %p, %ld, 0x%lx, %08ld, %p)\n", hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey);
+	DPRINT("(0x%lx, %p, %ld, 0x%lx, %08ld, %p)\n", hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey);
 
 	if (!prov || !pbData || !dwDataLen || !phKey)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
 
-	if ( !(importkey = CRYPT_Alloc(sizeof(CRYPTKEY))) )
+	if (!(importkey = CRYPT_Alloc(sizeof(CRYPTKEY))))
 		CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
 
 	importkey->pProvider = prov;
@@ -1594,9 +1594,11 @@
 	PCRYPTHASH hash = (PCRYPTHASH)hHash;
 	PCRYPTPROV prov;
 
-	TRACE("(0x%lx, %ld, %08ld, %p, %p)\n", hHash, dwKeySpec, dwFlags, pbSignature, pdwSigLen);
+	DPRINT("(0x%lx, %ld, %08ld, %p, %p)\n", hHash, dwKeySpec, dwFlags, pbSignature, pdwSigLen);
 	if (sDescription)
-		WARN("The sDescription parameter is not supported (and no longer used).  Ignoring.\n");
+	{
+		DPRINT("The sDescription parameter is not supported (and no longer used).  Ignoring.\n");
+	}
 
 	if (!hash)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -1628,7 +1630,7 @@
 	PCRYPTPROV prov;
 	PCRYPTHASH hash = (PCRYPTHASH)hHash;
 
-	TRACE("(0x%lx, %ld, %p, %08ld)\n", hHash, dwParam, pbData, dwFlags);
+	DPRINT("(0x%lx, %ld, %p, %08ld)\n", hHash, dwParam, pbData, dwFlags);
 
 	if (!hash || !pbData)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -1658,7 +1660,7 @@
 	PCRYPTPROV prov;
 	PCRYPTKEY key = (PCRYPTKEY)hKey;
 
-	TRACE("(0x%lx, %ld, %p, %08ld)\n", hKey, dwParam, pbData, dwFlags);
+	DPRINT("(0x%lx, %ld, %p, %08ld)\n", hKey, dwParam, pbData, dwFlags);
 
 	if (!key || !pbData)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -1683,7 +1685,7 @@
  */
 BOOL WINAPI CryptSetProviderA (LPCSTR pszProvName, DWORD dwProvType)
 {
-	TRACE("(%s, %ld)\n", pszProvName, dwProvType);
+	DPRINT("(%s, %ld)\n", pszProvName, dwProvType);
 	return CryptSetProviderExA(pszProvName, dwProvType, NULL, CRYPT_USER_DEFAULT);
 }
 
@@ -1694,7 +1696,7 @@
  */
 BOOL WINAPI CryptSetProviderW (LPCWSTR pszProvName, DWORD dwProvType)
 {
-	TRACE("(%s, %ld)\n", debugstr_w(pszProvName), dwProvType);
+	DPRINT("(%S, %ld)\n", pszProvName, dwProvType);
 	return CryptSetProviderExW(pszProvName, dwProvType, NULL, CRYPT_USER_DEFAULT);
 }
 
@@ -1718,7 +1720,7 @@
 	HKEY hProvKey, hTypeKey;
 	PSTR keyname;
 
-	TRACE("(%s, %ld, %p, %08ld)\n", pszProvName, dwProvType, pdwReserved, dwFlags);
+	DPRINT("(%s, %ld, %p, %08ld)\n", pszProvName, dwProvType, pdwReserved, dwFlags);
 
 	if (!pszProvName || pdwReserved)
 		CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@@ -1782,7 +1784,7 @@
 	BOOL ret = FALSE;
 	PSTR str = NULL;
 
-	TRACE("(%s, %ld, %p, %08ld)\n", debugstr_w(pszProvName), dwProvType, pdwReserved, dwFlags);
+	DPRINT("(%S, %ld, %p, %08ld)\n", pszProvName, dwProvType, pdwReserved, dwFlags);
 
 	if (CRYPT_UnicodeToANSI(pszProvName, &str, -1))
 	{
@@ -1811,14 +1813,14 @@
 {
 	PCRYPTPROV prov = (PCRYPTPROV)hProv;
 
-	TRACE("(0x%lx, %ld, %p, %08ld)\n", hProv, dwParam, pbData, dwFlags);
+	DPRINT("(0x%lx, %ld, %p, %08ld)\n", hProv, dwParam, pbData, dwFlags);
 
 	if (!prov)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
 	if (dwFlags & PP_USE_HARDWARE_RNG)
 	{
-		FIXME("PP_USE_HARDWARE_RNG: What do I do with this?\n");
-		FIXME("\tLetting the CSP decide.\n");
+		DPRINT1("PP_USE_HARDWARE_RNG: What do I do with this?\n");
+		DPRINT1("\tLetting the CSP decide.\n");
 	}
 	if (dwFlags & PP_CLIENT_HWND)
 	{
@@ -1868,10 +1870,12 @@
 	PCRYPTKEY key = (PCRYPTKEY)hPubKey;
 	PCRYPTPROV prov;
 
-	TRACE("(0x%lx, %p, %ld, 0x%lx, %08ld)\n", hHash, pbSignature,
+	DPRINT("(0x%lx, %p, %ld, 0x%lx, %08ld)\n", hHash, pbSignature,
 			dwSigLen, hPubKey, dwFlags);
 	if (sDescription)
-		WARN("The sDescription parameter is not supported (and no longer used).  Ignoring.\n");
+	{
+		DPRINT("The sDescription parameter is not supported (and no longer used).  Ignoring.\n");
+	}
 
 	if (!hash || !key)
 		CRYPT_ReturnLastError(ERROR_INVALID_HANDLE);
@@ -1901,7 +1905,7 @@
  */
 NTSTATUS WINAPI SystemFunction040(PVOID memory, ULONG length, ULONG flags)  /* RtlEncryptMemory */
 {
-	FIXME("(%p, %lx, %lx): stub [RtlEncryptMemory]\n", memory, length, flags);
+	DPRINT1("(%p, %lx, %lx): stub [RtlEncryptMemory]\n", memory, length, flags);
 	return STATUS_SUCCESS;
 }
 
@@ -1917,6 +1921,6 @@
  */
 NTSTATUS WINAPI SystemFunction041(PVOID memory, ULONG length, ULONG flags)  /* RtlDecryptMemory */
 {
-	FIXME("(%p, %lx, %lx): stub [RtlDecryptMemory]\n", memory, length, flags);
+	DPRINT1("(%p, %lx, %lx): stub [RtlDecryptMemory]\n", memory, length, flags);
 	return STATUS_SUCCESS;
 }

reactos/lib/advapi32/crypt
crypt.h 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt.h	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt.h	12 Dec 2004 15:16:26 -0000	1.2
@@ -61,20 +61,20 @@
 	UINT refcount;
 	HMODULE hModule;
 	PPROVFUNCS pFuncs;
-        HCRYPTPROV hPrivate;  /*CSP's handle - Should not be given to application under any circumstances!*/
+	HCRYPTPROV hPrivate;  /*CSP's handle - Should not be given to application under any circumstances!*/
 	PVTableProvStruc pVTable;
 } CRYPTPROV, *PCRYPTPROV;
 
 typedef struct tagCRYPTKEY
 {
 	PCRYPTPROV pProvider;
-        HCRYPTKEY hPrivate;    /*CSP's handle - Should not be given to application under any circumstances!*/
+	HCRYPTKEY hPrivate;    /*CSP's handle - Should not be given to application under any circumstances!*/
 } CRYPTKEY, *PCRYPTKEY;
 
 typedef struct tagCRYPTHASH
 {
 	PCRYPTPROV pProvider;
-        HCRYPTHASH hPrivate;    /*CSP's handle - Should not be given to application under any circumstances!*/
+	HCRYPTHASH hPrivate;    /*CSP's handle - Should not be given to application under any circumstances!*/
 } CRYPTHASH, *PCRYPTHASH;
 
 #define MAXPROVTYPES 999

reactos/lib/advapi32/crypt
crypt_des.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt_des.c	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt_des.c	12 Dec 2004 15:16:26 -0000	1.2
@@ -20,7 +20,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "windef.h"
+#include "advapi32.h"
 #include "crypt.h"
 
 static const unsigned char InitialPermuteMap[64] =
@@ -141,11 +141,11 @@
      0, 32,  8, 40, 16, 48, 24, 56
 };
 
-#define CLRBIT( STR, IDX ) ( (STR)[(IDX)/8] &= ~(0x01 << (7 - ((IDX)%8))) )
-#define SETBIT( STR, IDX ) ( (STR)[(IDX)/8] |= (0x01 << (7 - ((IDX)%8))) )
-#define GETBIT( STR, IDX ) (( ((STR)[(IDX)/8]) >> (7 - ((IDX)%8)) ) & 0x01)
+#define CLRBIT(STR, IDX) ((STR)[(IDX)/8] &= ~(0x01 << (7 - ((IDX)%8))))
+#define SETBIT(STR, IDX) ((STR)[(IDX)/8] |= (0x01 << (7 - ((IDX)%8))))
+#define GETBIT(STR, IDX) ((((STR)[(IDX)/8]) >> (7 - ((IDX)%8))) & 0x01)
 
-static void Permute( unsigned char *dst, const unsigned char *src, const unsigned char *map, const int mapsize )
+static void Permute(unsigned char *dst, const unsigned char *src, const unsigned char *map, const int mapsize)
 {
     int bitcount, i;
 
@@ -156,12 +156,12 @@
 
     for (i = 0; i < bitcount; i++)
     {
-        if (GETBIT( src, map[i] ))
-            SETBIT( dst, i );
+        if (GETBIT(src, map[i]))
+            SETBIT(dst, i);
     }
-} 
+}
 
-static void KeyShift( unsigned char *key, const int numbits )
+static void KeyShift(unsigned char *key, const int numbits)
 {
     int i;
     unsigned char keep = key[0];
@@ -177,20 +177,20 @@
             key[j] <<= 1;
         }
 
-        if (GETBIT( key, 27 ))
+        if (GETBIT(key, 27))
         {
-            CLRBIT( key, 27 );
-            SETBIT( key, 55 );
+            CLRBIT(key, 27);
+            SETBIT(key, 55);
         }
 
         if (keep & 0x80)
-            SETBIT( key, 27 );
+            SETBIT(key, 27);
 
         keep <<= 1;
     }
 }
 
-static void sbox( unsigned char *dst, const unsigned char *src )
+static void sbox(unsigned char *dst, const unsigned char *src)
 {
     int i;
 
@@ -204,7 +204,7 @@
         for (Snum = j = 0, bitnum = (i * 6); j < 6; j++, bitnum++)
         {
             Snum <<= 1;
-            Snum |= GETBIT( src, bitnum );
+            Snum |= GETBIT(src, bitnum);
         }
 
         if (0 == (i%2))
@@ -214,7 +214,7 @@
     }
 }
 
-static void xor( unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count )
+static void xor(unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count)
 {
     int i;
 
@@ -222,7 +222,7 @@
         dst[i] = a[i] ^ b[i];
 }
 
-unsigned char *CRYPT_DESkey8to7( unsigned char *dst, const unsigned char *key )
+unsigned char *CRYPT_DESkey8to7(unsigned char *dst, const unsigned char *key)
 {
     int i;
     unsigned char tmp[7];
@@ -241,7 +241,7 @@
     if ((dst == NULL) || (key == NULL))
         return NULL;
 
-    Permute( tmp, key, map8to7, 7 );
+    Permute(tmp, key, map8to7, 7);
 
     for (i = 0; i < 7; i++)
         dst[i] = tmp[i];
@@ -249,14 +249,15 @@
     return dst;
 }
 
-unsigned char *CRYPT_DEShash( unsigned char *dst, const unsigned char *key, const unsigned char *src )
+
+unsigned char *CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src)
 {
     int i;
     unsigned char K[7];
     unsigned char D[8];
 
-    Permute( K, key, KeyPermuteMap, 7 );
-    Permute( D, src, InitialPermuteMap, 8 );
+    Permute(K, key, KeyPermuteMap, 7);
+    Permute(D, src, InitialPermuteMap, 8);
 
     for (i = 0; i < 16; i++)
     {
@@ -267,15 +268,15 @@
         unsigned char  Rn[4];
         unsigned char  SubK[6];
 
-        KeyShift( K, KeyRotation[i] );
-        Permute( SubK, K, KeyCompression, 6 );
+        KeyShift(K, KeyRotation[i]);
+        Permute(SubK, K, KeyCompression, 6);
 
-        Permute( Rexp, R, DataExpansion, 6 );
-        xor( Rexp, Rexp, SubK, 6 );
+        Permute(Rexp, R, DataExpansion, 6);
+        xor(Rexp, Rexp, SubK, 6);
 
-        sbox( Rn, Rexp );
-        Permute( Rexp, Rn, PBox, 4 );
-        xor( Rn, L, Rexp, 4 );
+        sbox(Rn, Rexp);
+        Permute(Rexp, Rn, PBox, 4);
+        xor(Rn, L, Rexp, 4);
 
         for (j = 0; j < 4; j++)
         {
@@ -284,7 +285,7 @@
         }
     }
 
-    Permute( dst, D, FinalPermuteMap, 8 );
+    Permute(dst, D, FinalPermuteMap, 8);
 
     return dst;
 }

reactos/lib/advapi32/crypt
crypt_lmhash.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt_lmhash.c	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt_lmhash.c	12 Dec 2004 15:16:26 -0000	1.2
@@ -20,25 +20,14 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <stdarg.h>
-
-#include "windef.h"
-#include "winbase.h"
-#include "winreg.h"
-
-typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(
-    struct _EXCEPTION_POINTERS *ExceptionInfo
-    );
-
-#include "wine/winternl.h"
-#include "wine/ntstatus.h"
-
+#include "advapi32.h"
 #include "crypt.h"
 
+
 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 )
+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 };
@@ -48,13 +37,13 @@
     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 );
+    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 )
+NTSTATUS WINAPI SystemFunction006(LPCSTR password, LPSTR hash)
 {
-    CRYPT_LMhash( hash, password, strlen(password) );
+    CRYPT_LMhash(hash, password, strlen(password));
 
     return STATUS_SUCCESS;
 }

reactos/lib/advapi32/crypt
crypt_md4.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt_md4.c	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt_md4.c	12 Dec 2004 15:16:26 -0000	1.2
@@ -33,10 +33,9 @@
  * will fill a supplied 16-byte array with the digest.
  */
 
-#include <stdarg.h>
+#include "advapi32.h"
+#include "crypt.h"
 
-#include "windef.h"
-#include "winbase.h"
 
 typedef struct
 {
@@ -46,16 +45,106 @@
     unsigned char digest[16];
 } MD4_CTX;
 
-static void MD4Transform( unsigned int buf[4], unsigned int const in[16] );
+
+/* The three core functions */
+
+#define rotl32(x,n)  (((x) << ((unsigned int)(n))) | ((x) >> (32 - (unsigned int)(n))))
+
+#define F( x, y, z ) (((x) & (y)) | ((~x) & (z)))
+#define G( x, y, z ) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+#define H( x, y, z ) ((x) ^ (y) ^ (z))
+
+#define FF( a, b, c, d, x, s ) { \
+    (a) += F( (b), (c), (d) ) + (x); \
+    (a) = rotl32( (a), (s) ); \
+  }
+#define GG( a, b, c, d, x, s ) { \
+    (a) += G( (b), (c), (d) ) + (x) + (unsigned int)0x5a827999; \
+    (a) = rotl32( (a), (s) ); \
+  }
+#define HH( a, b, c, d, x, s ) { \
+    (a) += H( (b), (c), (d) ) + (x) + (unsigned int)0x6ed9eba1; \
+    (a) = rotl32( (a), (s) ); \
+  }
+
+/*
+ * The core of the MD4 algorithm
+ */
+static VOID MD4Transform(unsigned int buf[4], const unsigned int in[16])
+{
+    register unsigned int a, b, c, d;
+
+    a = buf[0];
+    b = buf[1];
+    c = buf[2];
+    d = buf[3];
+
+    FF( a, b, c, d, in[0], 3 );
+    FF( d, a, b, c, in[1], 7 );
+    FF( c, d, a, b, in[2], 11 );
+    FF( b, c, d, a, in[3], 19 );
+    FF( a, b, c, d, in[4], 3 );
+    FF( d, a, b, c, in[5], 7 );
+    FF( c, d, a, b, in[6], 11 );
+    FF( b, c, d, a, in[7], 19 );
+    FF( a, b, c, d, in[8], 3 );
+    FF( d, a, b, c, in[9], 7 );
+    FF( c, d, a, b, in[10], 11 );
+    FF( b, c, d, a, in[11], 19 );
+    FF( a, b, c, d, in[12], 3 );
+    FF( d, a, b, c, in[13], 7 );
+    FF( c, d, a, b, in[14], 11 );
+    FF( b, c, d, a, in[15], 19 );
+
+    GG( a, b, c, d, in[0], 3 );
+    GG( d, a, b, c, in[4], 5 );
+    GG( c, d, a, b, in[8], 9 );
+    GG( b, c, d, a, in[12], 13 );
+    GG( a, b, c, d, in[1], 3 );
+    GG( d, a, b, c, in[5], 5 );
+    GG( c, d, a, b, in[9], 9 );
+    GG( b, c, d, a, in[13], 13 );
+    GG( a, b, c, d, in[2], 3 );
+    GG( d, a, b, c, in[6], 5 );
+    GG( c, d, a, b, in[10], 9 );
+    GG( b, c, d, a, in[14], 13 );
+    GG( a, b, c, d, in[3], 3 );
+    GG( d, a, b, c, in[7], 5 );
+    GG( c, d, a, b, in[11], 9 );
+    GG( b, c, d, a, in[15], 13 );
+
+    HH( a, b, c, d, in[0], 3 );
+    HH( d, a, b, c, in[8], 9 );
+    HH( c, d, a, b, in[4], 11 );
+    HH( b, c, d, a, in[12], 15 );
+    HH( a, b, c, d, in[2], 3 );
+    HH( d, a, b, c, in[10], 9 );
+    HH( c, d, a, b, in[6], 11 );
+    HH( b, c, d, a, in[14], 15 );
+    HH( a, b, c, d, in[1], 3 );
+    HH( d, a, b, c, in[9], 9 );
+    HH( c, d, a, b, in[5], 11 );
+    HH( b, c, d, a, in[13], 15 );
+    HH( a, b, c, d, in[3], 3 );
+    HH( d, a, b, c, in[11], 9 );
+    HH( c, d, a, b, in[7], 11 );
+    HH( b, c, d, a, in[15], 15 );
+
+    buf[0] += a;
+    buf[1] += b;
+    buf[2] += c;
+    buf[3] += d;
+}
 
 /*
  * Note: this code is harmless on little-endian machines.
  */
-static void byteReverse( unsigned char *buf, unsigned longs )
+static VOID byteReverse(unsigned char *buf, unsigned longs)
 {
     unsigned int t;
 
-    do {
+    do
+    {
         t = (unsigned int)((unsigned)buf[3] << 8 | buf[2]) << 16 |
             ((unsigned)buf[1] << 8 | buf[0]);
         *(unsigned int *)buf = t;
@@ -67,7 +156,7 @@
  * Start MD4 accumulation.  Set bit count to 0 and buffer to mysterious
  * initialization constants.
  */
-VOID WINAPI MD4Init( MD4_CTX *ctx )
+VOID WINAPI MD4Init(MD4_CTX *ctx)
 {
     ctx->buf[0] = 0x67452301;
     ctx->buf[1] = 0xefcdab89;
@@ -81,7 +170,7 @@
  * Update context to reflect the concatenation of another buffer full
  * of bytes.
  */
-VOID WINAPI MD4Update( MD4_CTX *ctx, const unsigned char *buf, unsigned int len )
+VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len)
 {
     register unsigned int t;
 
@@ -102,14 +191,14 @@
 
         if (len < t)
         {
-            memcpy( p, buf, len );
+            memcpy(p, buf, len);
             return;
         }
 
-        memcpy( p, buf, t );
-        byteReverse( ctx->in, 16 );
+        memcpy(p, buf, t);
+        byteReverse(ctx->in, 16);
 
-        MD4Transform( ctx->buf, (unsigned int *)ctx->in );
+        MD4Transform(ctx->buf, (unsigned int *)ctx->in);
 
         buf += t;
         len -= t;
@@ -118,24 +207,24 @@
     /* Process data in 64-byte chunks */
     while (len >= 64)
     {
-        memcpy( ctx->in, buf, 64 );
-        byteReverse( ctx->in, 16 );
+        memcpy(ctx->in, buf, 64);
+        byteReverse(ctx->in, 16);
 
-        MD4Transform( ctx->buf, (unsigned int *)ctx->in );
+        MD4Transform(ctx->buf, (unsigned int *)ctx->in);
 
         buf += 64;
         len -= 64;
     }
 
     /* Handle any remaining bytes of data. */
-    memcpy( ctx->in, buf, len );
+    memcpy(ctx->in, buf, len);
 }
 
 /*
  * Final wrapup - pad to 64-byte boundary with the bit pattern 
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
-VOID WINAPI MD4Final( MD4_CTX *ctx )
+VOID WINAPI MD4Final(MD4_CTX *ctx)
 {
     unsigned int count;
     unsigned char *p;
@@ -156,19 +245,19 @@
     {
         /* Two lots of padding:  Pad the first block to 64 bytes */
         memset( p, 0, count );
-        byteReverse( ctx->in, 16 );
-        MD4Transform( ctx->buf, (unsigned int *)ctx->in );
+        byteReverse(ctx->in, 16);
+        MD4Transform(ctx->buf, (unsigned int *)ctx->in);
 
         /* Now fill the next block with 56 bytes */
-        memset( ctx->in, 0, 56 );
+        memset(ctx->in, 0, 56);
     }
     else
     {
         /* Pad block to 56 bytes */
-        memset( p, 0, count - 8 );
+        memset(p, 0, count - 8);
     }
 
-    byteReverse( ctx->in, 14 );
+    byteReverse(ctx->in, 14);
 
     /* Append length in bits and transform */
     ((unsigned int *)ctx->in)[14] = ctx->i[0];
@@ -176,95 +265,5 @@
 
     MD4Transform( ctx->buf, (unsigned int *)ctx->in );
     byteReverse( (unsigned char *)ctx->buf, 4 );
-    memcpy( ctx->digest, ctx->buf, 16 );
-}
-
-/* The three core functions */
-
-#define rotl32(x,n)  (((x) << ((unsigned int)(n))) | ((x) >> (32 - (unsigned int)(n))))
-
-#define F( x, y, z ) (((x) & (y)) | ((~x) & (z)))
-#define G( x, y, z ) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
-#define H( x, y, z ) ((x) ^ (y) ^ (z))
-
-#define FF( a, b, c, d, x, s ) { \
-    (a) += F( (b), (c), (d) ) + (x); \
-    (a) = rotl32( (a), (s) ); \
-  }
-#define GG( a, b, c, d, x, s ) { \
-    (a) += G( (b), (c), (d) ) + (x) + (unsigned int)0x5a827999; \
-    (a) = rotl32( (a), (s) ); \
-  }
-#define HH( a, b, c, d, x, s ) { \
-    (a) += H( (b), (c), (d) ) + (x) + (unsigned int)0x6ed9eba1; \
-    (a) = rotl32( (a), (s) ); \
-  }
-
-/*
- * The core of the MD4 algorithm
- */
-static void MD4Transform( unsigned int buf[4], const unsigned int in[16] )
-{
-    register unsigned int a, b, c, d;
-
-    a = buf[0];
-    b = buf[1];
-    c = buf[2];
-    d = buf[3];
-
-    FF( a, b, c, d, in[0], 3 );
-    FF( d, a, b, c, in[1], 7 );
-    FF( c, d, a, b, in[2], 11 );
-    FF( b, c, d, a, in[3], 19 );
-    FF( a, b, c, d, in[4], 3 );
-    FF( d, a, b, c, in[5], 7 );
-    FF( c, d, a, b, in[6], 11 );
-    FF( b, c, d, a, in[7], 19 );
-    FF( a, b, c, d, in[8], 3 );
-    FF( d, a, b, c, in[9], 7 );
-    FF( c, d, a, b, in[10], 11 );
-    FF( b, c, d, a, in[11], 19 );
-    FF( a, b, c, d, in[12], 3 );
-    FF( d, a, b, c, in[13], 7 );
-    FF( c, d, a, b, in[14], 11 );
-    FF( b, c, d, a, in[15], 19 );
-
-    GG( a, b, c, d, in[0], 3 );
-    GG( d, a, b, c, in[4], 5 );
-    GG( c, d, a, b, in[8], 9 );
-    GG( b, c, d, a, in[12], 13 );
-    GG( a, b, c, d, in[1], 3 );
-    GG( d, a, b, c, in[5], 5 );
-    GG( c, d, a, b, in[9], 9 );
-    GG( b, c, d, a, in[13], 13 );
-    GG( a, b, c, d, in[2], 3 );
-    GG( d, a, b, c, in[6], 5 );
-    GG( c, d, a, b, in[10], 9 );
-    GG( b, c, d, a, in[14], 13 );
-    GG( a, b, c, d, in[3], 3 );
-    GG( d, a, b, c, in[7], 5 );
-    GG( c, d, a, b, in[11], 9 );
-    GG( b, c, d, a, in[15], 13 );
-
-    HH( a, b, c, d, in[0], 3 );
-    HH( d, a, b, c, in[8], 9 );
-    HH( c, d, a, b, in[4], 11 );
-    HH( b, c, d, a, in[12], 15 );
-    HH( a, b, c, d, in[2], 3 );
-    HH( d, a, b, c, in[10], 9 );
-    HH( c, d, a, b, in[6], 11 );
-    HH( b, c, d, a, in[14], 15 );
-    HH( a, b, c, d, in[1], 3 );
-    HH( d, a, b, c, in[9], 9 );
-    HH( c, d, a, b, in[5], 11 );
-    HH( b, c, d, a, in[13], 15 );
-    HH( a, b, c, d, in[3], 3 );
-    HH( d, a, b, c, in[11], 9 );
-    HH( c, d, a, b, in[7], 11 );
-    HH( b, c, d, a, in[15], 15 );
-
-    buf[0] += a;
-    buf[1] += b;
-    buf[2] += c;
-    buf[3] += d;
+    memcpy(ctx->digest, ctx->buf, 16);
 }

reactos/lib/advapi32/crypt
crypt_md5.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt_md5.c	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt_md5.c	12 Dec 2004 15:16:26 -0000	1.2
@@ -33,10 +33,9 @@
  * will fill a supplied 16-byte array with the digest.
  */
 
-#include <stdarg.h>
+#include "advapi32.h"
+#include "crypt.h"
 
-#include "windef.h"
-#include "winbase.h"
 
 typedef struct
 {
@@ -46,16 +45,116 @@
     unsigned char digest[16];
 } MD5_CTX;
 
-static void MD5Transform( unsigned int buf[4], const unsigned int in[16] );
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1( x, y, z ) (x & y | ~x & z) */
+#define F1( x, y, z ) (z ^ (x & (y ^ z)))
+#define F2( x, y, z ) F1( z, x, y )
+#define F3( x, y, z ) (x ^ y ^ z)
+#define F4( x, y, z ) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP( f, w, x, y, z, data, s ) \
+        ( w += f( x, y, z ) + data,  w = w << s | w >> (32 - s),  w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data.  MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+static void MD5Transform(unsigned int buf[4], const unsigned int in[16])
+{
+    register unsigned int a, b, c, d;
+
+    a = buf[0];
+    b = buf[1];
+    c = buf[2];
+    d = buf[3];
+
+    MD5STEP( F1, a, b, c, d, in[0] + 0xd76aa478, 7 );
+    MD5STEP( F1, d, a, b, c, in[1] + 0xe8c7b756, 12 );
+    MD5STEP( F1, c, d, a, b, in[2] + 0x242070db, 17 );
+    MD5STEP( F1, b, c, d, a, in[3] + 0xc1bdceee, 22 );
+    MD5STEP( F1, a, b, c, d, in[4] + 0xf57c0faf, 7 );
+    MD5STEP( F1, d, a, b, c, in[5] + 0x4787c62a, 12 );
+    MD5STEP( F1, c, d, a, b, in[6] + 0xa8304613, 17 );
+    MD5STEP( F1, b, c, d, a, in[7] + 0xfd469501, 22 );
+    MD5STEP( F1, a, b, c, d, in[8] + 0x698098d8, 7 );
+    MD5STEP( F1, d, a, b, c, in[9] + 0x8b44f7af, 12 );
+    MD5STEP( F1, c, d, a, b, in[10] + 0xffff5bb1, 17 );
+    MD5STEP( F1, b, c, d, a, in[11] + 0x895cd7be, 22 );
+    MD5STEP( F1, a, b, c, d, in[12] + 0x6b901122, 7 );
+    MD5STEP( F1, d, a, b, c, in[13] + 0xfd987193, 12 );
+    MD5STEP( F1, c, d, a, b, in[14] + 0xa679438e, 17 );
+    MD5STEP( F1, b, c, d, a, in[15] + 0x49b40821, 22 );
+
+    MD5STEP( F2, a, b, c, d, in[1] + 0xf61e2562, 5 );
+    MD5STEP( F2, d, a, b, c, in[6] + 0xc040b340, 9 );
+    MD5STEP( F2, c, d, a, b, in[11] + 0x265e5a51, 14 );
+    MD5STEP( F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20 );
+    MD5STEP( F2, a, b, c, d, in[5] + 0xd62f105d, 5 );
+    MD5STEP( F2, d, a, b, c, in[10] + 0x02441453, 9 );
+    MD5STEP( F2, c, d, a, b, in[15] + 0xd8a1e681, 14 );
+    MD5STEP( F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20 );
+    MD5STEP( F2, a, b, c, d, in[9] + 0x21e1cde6, 5 );
+    MD5STEP( F2, d, a, b, c, in[14] + 0xc33707d6, 9 );
+    MD5STEP( F2, c, d, a, b, in[3] + 0xf4d50d87, 14 );
+    MD5STEP( F2, b, c, d, a, in[8] + 0x455a14ed, 20 );
+    MD5STEP( F2, a, b, c, d, in[13] + 0xa9e3e905, 5 );
+    MD5STEP( F2, d, a, b, c, in[2] + 0xfcefa3f8, 9 );
+    MD5STEP( F2, c, d, a, b, in[7] + 0x676f02d9, 14 );
+    MD5STEP( F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20 );
+
+    MD5STEP( F3, a, b, c, d, in[5] + 0xfffa3942, 4 );
+    MD5STEP( F3, d, a, b, c, in[8] + 0x8771f681, 11 );
+    MD5STEP( F3, c, d, a, b, in[11] + 0x6d9d6122, 16 );
+    MD5STEP( F3, b, c, d, a, in[14] + 0xfde5380c, 23 );
+    MD5STEP( F3, a, b, c, d, in[1] + 0xa4beea44, 4 );
+    MD5STEP( F3, d, a, b, c, in[4] + 0x4bdecfa9, 11 );
+    MD5STEP( F3, c, d, a, b, in[7] + 0xf6bb4b60, 16 );
+    MD5STEP( F3, b, c, d, a, in[10] + 0xbebfbc70, 23 );
+    MD5STEP( F3, a, b, c, d, in[13] + 0x289b7ec6, 4 );
+    MD5STEP( F3, d, a, b, c, in[0] + 0xeaa127fa, 11 );
+    MD5STEP( F3, c, d, a, b, in[3] + 0xd4ef3085, 16 );
+    MD5STEP( F3, b, c, d, a, in[6] + 0x04881d05, 23 );
+    MD5STEP( F3, a, b, c, d, in[9] + 0xd9d4d039, 4 );
+    MD5STEP( F3, d, a, b, c, in[12] + 0xe6db99e5, 11 );
+    MD5STEP( F3, c, d, a, b, in[15] + 0x1fa27cf8, 16 );
+    MD5STEP( F3, b, c, d, a, in[2] + 0xc4ac5665, 23 );
+
+    MD5STEP( F4, a, b, c, d, in[0] + 0xf4292244, 6 );
+    MD5STEP( F4, d, a, b, c, in[7] + 0x432aff97, 10 );
+    MD5STEP( F4, c, d, a, b, in[14] + 0xab9423a7, 15 );
+    MD5STEP( F4, b, c, d, a, in[5] + 0xfc93a039, 21 );
+    MD5STEP( F4, a, b, c, d, in[12] + 0x655b59c3, 6 );
+    MD5STEP( F4, d, a, b, c, in[3] + 0x8f0ccc92, 10 );
+    MD5STEP( F4, c, d, a, b, in[10] + 0xffeff47d, 15 );
+    MD5STEP( F4, b, c, d, a, in[1] + 0x85845dd1, 21 );
+    MD5STEP( F4, a, b, c, d, in[8] + 0x6fa87e4f, 6 );
+    MD5STEP( F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10 );
+    MD5STEP( F4, c, d, a, b, in[6] + 0xa3014314, 15 );
+    MD5STEP( F4, b, c, d, a, in[13] + 0x4e0811a1, 21 );
+    MD5STEP( F4, a, b, c, d, in[4] + 0xf7537e82, 6 );
+    MD5STEP( F4, d, a, b, c, in[11] + 0xbd3af235, 10 );
+    MD5STEP( F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15 );
+    MD5STEP( F4, b, c, d, a, in[9] + 0xeb86d391, 21 );
+
+    buf[0] += a;
+    buf[1] += b;
+    buf[2] += c;
+    buf[3] += d;
+}
 
 /*
  * Note: this code is harmless on little-endian machines.
  */
-static void byteReverse( unsigned char *buf, unsigned longs )
+static VOID byteReverse(unsigned char *buf, unsigned longs)
 {
     unsigned int t;
 
-    do {
+    do
+    {
         t = (unsigned int)((unsigned)buf[3] << 8 | buf[2]) << 16 |
             ((unsigned)buf[1] << 8 | buf[0]);
         *(unsigned int *)buf = t;
@@ -67,7 +166,7 @@
  * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
  * initialization constants.
  */
-VOID WINAPI MD5Init( MD5_CTX *ctx )
+VOID WINAPI MD5Init(MD5_CTX *ctx)
 {
     ctx->buf[0] = 0x67452301;
     ctx->buf[1] = 0xefcdab89;
@@ -81,7 +180,7 @@
  * Update context to reflect the concatenation of another buffer full
  * of bytes.
  */
-VOID WINAPI MD5Update( MD5_CTX *ctx, const unsigned char *buf, unsigned int len )
+VOID WINAPI MD5Update(MD5_CTX *ctx, const unsigned char *buf, unsigned int len)
 {
     register unsigned int t;
 
@@ -102,14 +201,14 @@
 
         if (len < t)
         {
-            memcpy( p, buf, len );
+            memcpy(p, buf, len);
             return;
         }
 
-        memcpy( p, buf, t );
-        byteReverse( ctx->in, 16 );
+        memcpy(p, buf, t);
+        byteReverse(ctx->in, 16);
 
-        MD5Transform( ctx->buf, (unsigned int *)ctx->in );
+        MD5Transform(ctx->buf, (unsigned int *)ctx->in);
 
         buf += t;
         len -= t;
@@ -118,17 +217,17 @@
     /* Process data in 64-byte chunks */
     while (len >= 64)
     {
-        memcpy( ctx->in, buf, 64 );
-        byteReverse( ctx->in, 16 );
+        memcpy(ctx->in, buf, 64);
+        byteReverse(ctx->in, 16);
 
-        MD5Transform( ctx->buf, (unsigned int *)ctx->in );
+        MD5Transform(ctx->buf, (unsigned int *)ctx->in);
 
         buf += 64;
         len -= 64;
     }
 
     /* Handle any remaining bytes of data. */
-    memcpy( ctx->in, buf, len );
+    memcpy(ctx->in, buf, len);
 }
 
 /*
@@ -155,126 +254,26 @@
     if (count < 8)
     {
         /* Two lots of padding:  Pad the first block to 64 bytes */
-        memset( p, 0, count );
-        byteReverse( ctx->in, 16 );
-        MD5Transform( ctx->buf, (unsigned int *)ctx->in );
+        memset(p, 0, count);
+        byteReverse(ctx->in, 16);
+        MD5Transform(ctx->buf, (unsigned int *)ctx->in);
 
         /* Now fill the next block with 56 bytes */
-        memset( ctx->in, 0, 56 );
+        memset(ctx->in, 0, 56);
     }
     else
     {
         /* Pad block to 56 bytes */
-        memset( p, 0, count - 8 );
+        memset(p, 0, count - 8);
     }
 
-    byteReverse( ctx->in, 14 );
+    byteReverse(ctx->in, 14);
 
     /* Append length in bits and transform */
     ((unsigned int *)ctx->in)[14] = ctx->i[0];
     ((unsigned int *)ctx->in)[15] = ctx->i[1];
 
-    MD5Transform( ctx->buf, (unsigned int *)ctx->in );
-    byteReverse( (unsigned char *)ctx->buf, 4 );
-    memcpy( ctx->digest, ctx->buf, 16 );
-}
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1( x, y, z ) (x & y | ~x & z) */
-#define F1( x, y, z ) (z ^ (x & (y ^ z)))
-#define F2( x, y, z ) F1( z, x, y )
-#define F3( x, y, z ) (x ^ y ^ z)
-#define F4( x, y, z ) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP( f, w, x, y, z, data, s ) \
-        ( w += f( x, y, z ) + data,  w = w << s | w >> (32 - s),  w += x )
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data.  MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-static void MD5Transform( unsigned int buf[4], const unsigned int in[16] )
-{
-    register unsigned int a, b, c, d;
-
-    a = buf[0];
-    b = buf[1];
-    c = buf[2];
-    d = buf[3];
-
-    MD5STEP( F1, a, b, c, d, in[0] + 0xd76aa478, 7 );
-    MD5STEP( F1, d, a, b, c, in[1] + 0xe8c7b756, 12 );
-    MD5STEP( F1, c, d, a, b, in[2] + 0x242070db, 17 );
-    MD5STEP( F1, b, c, d, a, in[3] + 0xc1bdceee, 22 );
-    MD5STEP( F1, a, b, c, d, in[4] + 0xf57c0faf, 7 );
-    MD5STEP( F1, d, a, b, c, in[5] + 0x4787c62a, 12 );
-    MD5STEP( F1, c, d, a, b, in[6] + 0xa8304613, 17 );
-    MD5STEP( F1, b, c, d, a, in[7] + 0xfd469501, 22 );
-    MD5STEP( F1, a, b, c, d, in[8] + 0x698098d8, 7 );
-    MD5STEP( F1, d, a, b, c, in[9] + 0x8b44f7af, 12 );
-    MD5STEP( F1, c, d, a, b, in[10] + 0xffff5bb1, 17 );
-    MD5STEP( F1, b, c, d, a, in[11] + 0x895cd7be, 22 );
-    MD5STEP( F1, a, b, c, d, in[12] + 0x6b901122, 7 );
-    MD5STEP( F1, d, a, b, c, in[13] + 0xfd987193, 12 );
-    MD5STEP( F1, c, d, a, b, in[14] + 0xa679438e, 17 );
-    MD5STEP( F1, b, c, d, a, in[15] + 0x49b40821, 22 );
-
-    MD5STEP( F2, a, b, c, d, in[1] + 0xf61e2562, 5 );
-    MD5STEP( F2, d, a, b, c, in[6] + 0xc040b340, 9 );
-    MD5STEP( F2, c, d, a, b, in[11] + 0x265e5a51, 14 );
-    MD5STEP( F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20 );
-    MD5STEP( F2, a, b, c, d, in[5] + 0xd62f105d, 5 );
-    MD5STEP( F2, d, a, b, c, in[10] + 0x02441453, 9 );
-    MD5STEP( F2, c, d, a, b, in[15] + 0xd8a1e681, 14 );
-    MD5STEP( F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20 );
-    MD5STEP( F2, a, b, c, d, in[9] + 0x21e1cde6, 5 );
-    MD5STEP( F2, d, a, b, c, in[14] + 0xc33707d6, 9 );
-    MD5STEP( F2, c, d, a, b, in[3] + 0xf4d50d87, 14 );
-    MD5STEP( F2, b, c, d, a, in[8] + 0x455a14ed, 20 );
-    MD5STEP( F2, a, b, c, d, in[13] + 0xa9e3e905, 5 );
-    MD5STEP( F2, d, a, b, c, in[2] + 0xfcefa3f8, 9 );
-    MD5STEP( F2, c, d, a, b, in[7] + 0x676f02d9, 14 );
-    MD5STEP( F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20 );
-
-    MD5STEP( F3, a, b, c, d, in[5] + 0xfffa3942, 4 );
-    MD5STEP( F3, d, a, b, c, in[8] + 0x8771f681, 11 );
-    MD5STEP( F3, c, d, a, b, in[11] + 0x6d9d6122, 16 );
-    MD5STEP( F3, b, c, d, a, in[14] + 0xfde5380c, 23 );
-    MD5STEP( F3, a, b, c, d, in[1] + 0xa4beea44, 4 );
-    MD5STEP( F3, d, a, b, c, in[4] + 0x4bdecfa9, 11 );
-    MD5STEP( F3, c, d, a, b, in[7] + 0xf6bb4b60, 16 );
-    MD5STEP( F3, b, c, d, a, in[10] + 0xbebfbc70, 23 );
-    MD5STEP( F3, a, b, c, d, in[13] + 0x289b7ec6, 4 );
-    MD5STEP( F3, d, a, b, c, in[0] + 0xeaa127fa, 11 );
-    MD5STEP( F3, c, d, a, b, in[3] + 0xd4ef3085, 16 );
-    MD5STEP( F3, b, c, d, a, in[6] + 0x04881d05, 23 );
-    MD5STEP( F3, a, b, c, d, in[9] + 0xd9d4d039, 4 );
-    MD5STEP( F3, d, a, b, c, in[12] + 0xe6db99e5, 11 );
-    MD5STEP( F3, c, d, a, b, in[15] + 0x1fa27cf8, 16 );
-    MD5STEP( F3, b, c, d, a, in[2] + 0xc4ac5665, 23 );
-
-    MD5STEP( F4, a, b, c, d, in[0] + 0xf4292244, 6 );
-    MD5STEP( F4, d, a, b, c, in[7] + 0x432aff97, 10 );
-    MD5STEP( F4, c, d, a, b, in[14] + 0xab9423a7, 15 );
-    MD5STEP( F4, b, c, d, a, in[5] + 0xfc93a039, 21 );
-    MD5STEP( F4, a, b, c, d, in[12] + 0x655b59c3, 6 );
-    MD5STEP( F4, d, a, b, c, in[3] + 0x8f0ccc92, 10 );
-    MD5STEP( F4, c, d, a, b, in[10] + 0xffeff47d, 15 );
-    MD5STEP( F4, b, c, d, a, in[1] + 0x85845dd1, 21 );
-    MD5STEP( F4, a, b, c, d, in[8] + 0x6fa87e4f, 6 );
-    MD5STEP( F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10 );
-    MD5STEP( F4, c, d, a, b, in[6] + 0xa3014314, 15 );
-    MD5STEP( F4, b, c, d, a, in[13] + 0x4e0811a1, 21 );
-    MD5STEP( F4, a, b, c, d, in[4] + 0xf7537e82, 6 );
-    MD5STEP( F4, d, a, b, c, in[11] + 0xbd3af235, 10 );
-    MD5STEP( F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15 );
-    MD5STEP( F4, b, c, d, a, in[9] + 0xeb86d391, 21 );
-
-    buf[0] += a;
-    buf[1] += b;
-    buf[2] += c;
-    buf[3] += d;
+    MD5Transform(ctx->buf, (unsigned int *)ctx->in);
+    byteReverse((unsigned char *)ctx->buf, 4);
+    memcpy(ctx->digest, ctx->buf, 16);
 }

reactos/lib/advapi32/crypt
crypt_sha.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- crypt_sha.c	11 Dec 2004 00:21:33 -0000	1.1
+++ crypt_sha.c	12 Dec 2004 15:16:26 -0000	1.2
@@ -17,9 +17,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <stdarg.h>
-#include "windef.h"
-#include "winbase.h"
+#include "advapi32.h"
+#include "crypt.h"
+
 
 /* SHA Context Structure Declaration */
 
@@ -50,7 +50,8 @@
 #define R4(v,w,x,y,z,i) z+=f4(w,x,y)+blk1(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
 
 /* Hash a single 512-bit block. This is the core of the algorithm. */
-void SHA1Transform(ULONG State[5], CHAR Buffer[64])
+static VOID
+SHA1Transform(ULONG State[5], CHAR Buffer[64])
 {
    ULONG a, b, c, d, e;
    ULONG *Block;
CVSspam 0.2.8