Cryptography Reference
In-Depth Information
Chain with 64-bit value from QueryPerformanceCounter()
QueryPerformanceCounter (&PCountBuff);
for (i = 0; i < sizeof (DWORD); i++)
{
j=i<<3;
Seedbytes[nextfree + i] =
(char)((PCountBuff.HighPart >> j) & (DWORD)0xff);
Seedbytes[nextfree + sizeof (DWORD) + i] =
(char)((PCountBuff.LowPart >> j) & (DWORD)0xff);
}
nextfree += 2*sizeof (DWORD);
MissingEntropy -= 2*sizeof (DWORD);
}
Chain with values from CryptGenRandom() :
if (CryptAcquireContext(&hProvider, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT))
{
if (CryptGenRandom (hProvider, MissingEntropy, &Seedbytes[nextfree]))
{
nextfree += MissingEntropy;
MissingEntropy = 0;
}
}
if (hProvider)
{
CryptReleaseContext (hProvider, 0);
}
#endif /* defined _WIN32 && _MSC_VER */
Fetch entropy from /dev/urandom if this source is available.
if ((fp = fopen("/dev/urandom", "r")) != NULL)
{
BytesRead = fread(&Seedbytes[nextfree], sizeof (UCHAR), MissingEntropy, fp);
nextfree += BytesRead;
MissingEntropy -= BytesRead;
fclose (fp);
}
Search WWH ::




Custom Search