[*] Improve time based RNG failover implementation

This commit is contained in:
Reece Wilson 2023-07-13 05:58:53 +01:00
parent 29226b8134
commit 115ee1a9ec

View File

@ -170,15 +170,16 @@ namespace Aurora::RNG
static AuUInt32 RngTimeBased(AuUInt8 *pBuf, AuUInt32 uLen)
{
AuUInt64 t1;
int l, acc, bits, a, b, c;
int acc, bits, a, b, c;
l = uLen;
acc = a = b = c = 0;
bits = 8;
void *pASLRSeed = &RngTimeBased;
while (uLen--)
for (AU_ITERATE_N(uOffsetInByteStream, uLen))
{
for (AU_ITERATE_N(uMultiplePassesForTheFunOfIt, 3))
{
while (bits--) // for each bit in byte
{
@ -200,17 +201,18 @@ namespace Aurora::RNG
acc = (acc << 1) | a; // push the first bit state
}
*pBuf = AuFnv1a32Runtime(&acc, sizeof(acc)) ^
AuFnv1a32Runtime(&c, sizeof(c)) ^
AuFnv1a32Runtime(&pASLRSeed, sizeof(pASLRSeed));
c = *pBuf++;
acc = 0;
bits = 8;
c = AuFnv1a32Runtime(&acc, sizeof(acc)) ^
(AuFnv1a32Runtime(&c, sizeof(c)) * kFnv1MagicPrime32) ^
(a ? AuFnv1a32Runtime(&pASLRSeed, sizeof(pASLRSeed)) : 0);
}
return l;
*pBuf++ = AuUInt8(c);
}
return uLen;
}
AuUInt32 RngGetBytes(AuUInt8 *pBuffer, AuUInt32 uBytes)