From 4c2c7af0cc656461c46e45d07399ba4feb3c780b Mon Sep 17 00:00:00 2001 From: James Hatheway Date: Tue, 24 Oct 2000 01:39:29 +0000 Subject: [PATCH] Added stubs for CryptGenRandom(), CryptReleaseContext(). --- dlls/advapi32/advapi32.spec | 4 +-- dlls/advapi32/crypt.c | 53 ++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 97e0fb98890..a2ef2525384 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -54,14 +54,14 @@ import ntdll.dll @ stub CryptGetKeyParam @ stub CryptGetHashParam @ stub CryptGetProvParam -@ stub CryptGenRandom +@ stdcall CryptGenRandom(long long ptr) CryptGenRandom @ stub CryptGetDefaultProviderA @ stub CryptGetDefaultProviderW @ stub CryptGetUserKey @ stub CryptHashData @ stub CryptHashSessionKey @ stub CryptImportKey -@ stub CryptReleaseContext +@ stdcall CryptReleaseContext(long long) CryptReleaseContext @ stub CryptSetHashParam @ stdcall CryptSetKeyParam(long long ptr long) CryptSetKeyParam @ stub CryptSetProvParam diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c index 00290f33f4f..7438f2ec599 100644 --- a/dlls/advapi32/crypt.c +++ b/dlls/advapi32/crypt.c @@ -1,12 +1,15 @@ /* * dlls/advapi32/crypt.c */ +#include +#include + #include "windef.h" #include "winerror.h" #include "wincrypt.h" #include "debugtools.h" -DEFAULT_DEBUG_CHANNEL(advapi) +DEFAULT_DEBUG_CHANNEL(advapi); /****************************************************************************** * CryptAcquireContextA @@ -41,3 +44,51 @@ CryptSetKeyParam( HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD dwFlags) return FALSE; } + +/****************************************************************************** + * CryptGenRandom + */ +BOOL WINAPI +CryptGenRandom (HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer) +{ + DWORD i; + + FIXME("(0x%lx, %ld, %p): stub!\n", hProv, dwLen, pbBuffer); + /* + FIXME: Currently this function is just a stub, it is missing functionality in + the following (major) ways: + (1) It makes no use of the passed in HCRYPTPROV handle. (ie. it doesn't + use a cryptographic service provider (CSP) + (2) It doesn't use the values in the passed in pbBuffer to further randomize + its internal seed. + (3) MSDN mentions that this function produces "cryptographically random" + data, which is "... far more random than the data generated by the typical + random number generator such as the one shipped with your C compiler". + We are currently using the C runtime rand() function. ^_^ + + See MSDN documentation for CryptGenRandom for more information. + */ + + if (dwLen <= 0) + return FALSE; + + srand(time(NULL)); + for (i=0; i