Cryptography Reference
In-Depth Information
int
GetEntropy_l (CLINT Seed_l, UCHAR *Hashres, int AddEntropy,
char *RndStr, int LenRndStr)
{
unsigned i, j, nextfree = 0;
unsigned MissingEntropy = MAX(AddEntropy, sizeof (time_t));
UCHAR *Seedbytes;
int BytesRead;
int LenSeedbytes = LenRndStr + MissingEntropy +
sizeof (time_t) + 2*sizeof (ULONG);
RMDSTAT hws;
time_t SeedTime;
FILE *fp;
#if defined _WIN32 && defined _MSC_VER
LARGE_INTEGER PCountBuff;
HCRYPTPROV hProvider = 0;
#endif /* defined _WIN32 && defined _MSC_VER? */
if ((Seedbytes = (UCHAR*)malloc(LenSeedbytes)) == NULL)
{
return E_CLINT_MAL;
}
if (RndStr != NULL && LenRndStr > 0)
{
memcpy (Seedbytes, RndStr, LenRndStr);
nextfree = LenRndStr;
}
Bring system time into the buffer Seedbytes .
SeedTime = (time_t)time(NULL);
for (i = 0; i < sizeof(time_t); i++)
{
j=i<<3;
Seedbytes[nextfree+i] = (UCHAR)((SeedTime >> j) & (time_t)0xff);
}
nextfree += sizeof (time_t);
MissingEntropy -= sizeof (time_t);
Entropy from WIN32 API (link to ADVAPI32.LIB is required.
#if defined _WIN32 && defined _MSC_VER
if (MissingEntropy)
{
Search WWH ::




Custom Search