/* rsaenh.dll
 *
 * Copyright (c) TransGaming Technologies 2003
 *
 * david@transgaming.com
 */

#include <stdlib.h>
#include <time.h>

#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wine/debug.h"
#include "winerror.h"

#include "wincrypt.h"

#include "rsaenh_priv.h"

WINE_DEFAULT_DEBUG_CHANNEL(rsaenh);

BOOL WINAPI RSAENH_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	TRACE("(0x%08x, %ld, %p)\n",hinstDLL,fdwReason,lpvReserved);

	if (fdwReason == DLL_PROCESS_ATTACH)
	{
		/* FIXME: Initialisation */
	}
	else if (fdwReason == DLL_PROCESS_DETACH)
	{
		/* FIXME: Cleanup */
	}

	return TRUE;
}


/******************************************************************
 *		CPAcquireContext (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPAcquireContext(HCRYPTPROV * phProv, LPSTR pszContainer, DWORD dwFlags, PVTableProvStruc pVTable)
{
	rsaenhProviderContext *pContext = HeapAlloc(GetProcessHeap(), 0, sizeof(rsaenhProviderContext));
	*phProv = (HCRYPTPROV)pContext;
	return TRUE;
}


/******************************************************************
 *		CPCreateHash (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH * phHash)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPDecrypt (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE * pbData, DWORD * pdwDataLen)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPDeriveKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPDeriveKey(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, HCRYPTKEY * phKey)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPDestroyHash (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPDestroyHash(HCRYPTPROV hProv, HCRYPTHASH hHash)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPDestroyKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPDestroyKey(HCRYPTPROV hProv, HCRYPTKEY hKey)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPDuplicateHash (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPDuplicateHash(HCRYPTPROV hUID, HCRYPTHASH hHash, DWORD * pdwReserved, DWORD dwFlags, HCRYPTHASH * phHash)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPDuplicateKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPDuplicateKey(HCRYPTPROV hUID, HCRYPTKEY hKey, DWORD * pdwReserved, DWORD dwFlags, HCRYPTKEY * phKey)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPEncrypt (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE * pbData, DWORD * pdwDataLen, DWORD dwBufLen)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPExportKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPExportKey(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTKEY hPubKey, DWORD dwBlobType, DWORD dwFlags, BYTE * pbData, DWORD * pdwDataLen)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPGenKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY * phKey)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPGenRandom (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPGenRandom(HCRYPTPROV hProv, DWORD dwLen, BYTE * pbBuffer)
{
	/* FIXME:
	 * windows does a whole bunch of extra stuff to get nice seeds. we don't. we should. */
	int i;

	WARN("this isn't very 'secure'\n");
	srand( (unsigned)time( NULL ) );
	for (i = 0; i < dwLen; i++)
		pbBuffer[i] = (unsigned char)(rand() % 255);
	return TRUE;
}


/******************************************************************
 *		CPGetHashParam (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPGetHashParam(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwParam, BYTE * pbData, DWORD * pdwDataLen, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPGetKeyParam (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPGetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, BYTE * pbData, DWORD * pdwDataLen, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPGetProvParam (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE * pbData, DWORD * pdwDataLen, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPGetUserKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPGetUserKey(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY * phUserKey)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPHashData (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPHashData(HCRYPTPROV hProv, HCRYPTHASH hHash, BYTE * pbData, DWORD dwDataLen, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPHashSessionKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPHashSessionKey(HCRYPTPROV hProv, HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPImportKey (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPImportKey(HCRYPTPROV hProv, BYTE * pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY * phKey)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPReleaseContext (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
{
	rsaenhProviderContext *pContext = (rsaenhProviderContext *)hProv;
	HeapFree(GetProcessHeap(), 0, pContext);
	return TRUE;
}


/******************************************************************
 *		CPSetHashParam (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPSetHashParam(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwParam, BYTE * pbData, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPSetKeyParam (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, BYTE * pbData, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPSetProvParam (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPSetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE * pbData, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPSignHash (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription, DWORD dwFlags, BYTE * pbSignature, DWORD * pdwSigLen)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		CPVerifySignature (RSAENH.@)
 *
 *
 */
BOOL WINAPI RSAENH_CPVerifySignature(HCRYPTPROV hProv, HCRYPTHASH hHash, BYTE * pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
{
	FIXME(":stub\n");
	return FALSE;
}


/******************************************************************
 *		DllRegisterServer (RSAENH.@)
 *
 *
 */
HRESULT WINAPI RSAENH_DllRegisterServer(void)
{
	FIXME(":stub\n");
	return S_OK;
}


/******************************************************************
 *		DllUnregisterServer (RSAENH.@)
 *
 *
 */
HRESULT WINAPI RSAENH_DllUnregisterServer(void)
{
	FIXME(":stub\n");
	return S_OK;
}


