[*] Refactor RandomDef: bSecure, ::SetQuickRng()
[*] Default initialize net protocols to zero (tcp) [*] Warning under AuUInt8 &ByteBuffer::operator[](AuUInt idx)
This commit is contained in:
parent
473e7d30dd
commit
efc02d24f7
@ -20,7 +20,7 @@ namespace Aurora::IO::Net
|
||||
|
||||
struct NetSocketConnectMany
|
||||
{
|
||||
ETransportProtocol protocol;
|
||||
ETransportProtocol protocol {};
|
||||
AuList<IPAddress> ips;
|
||||
AuUInt16 uPort {};
|
||||
AuSPtr<ISocketDriver> pDriver;
|
||||
@ -29,7 +29,7 @@ namespace Aurora::IO::Net
|
||||
|
||||
struct NetSocketBind
|
||||
{
|
||||
ETransportProtocol protocol;
|
||||
ETransportProtocol protocol {};
|
||||
IPAddress ip;
|
||||
AuUInt16 uPort {};
|
||||
AuSPtr<ISocketDriverFactory> pFactory;
|
||||
|
@ -11,8 +11,8 @@ namespace Aurora::IO::Net
|
||||
{
|
||||
struct INetSrvWorkers
|
||||
{
|
||||
virtual AuSPtr<INetWorker> Attach (const AuSPtr<IIOProcessor> &processor) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual AuSPtr<INetWorker> GetWorkerByIndexSafe(AuUInt index) = 0;
|
||||
virtual AuSPtr<INetWorker> Attach (const AuSPtr<IIOProcessor> &pProcessor) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual AuSPtr<INetWorker> GetWorkerByIndexSafe(AuUInt uIndex) = 0;
|
||||
};
|
||||
};
|
@ -43,7 +43,7 @@ namespace Aurora::Memory
|
||||
{
|
||||
auto pBegin = this->begin();
|
||||
auto pEnd = this->end();
|
||||
SysAssert(idx < (pEnd - pBegin));
|
||||
SysAssert(idx < (AuUInt)(pEnd - pBegin));
|
||||
return *(pBegin + idx);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace Aurora::RNG
|
||||
{
|
||||
AU_COPY_MOVE_DEF(RandomDef);
|
||||
|
||||
bool secure;
|
||||
bool bSecure {};
|
||||
AuOptional<AuUInt32> seed;
|
||||
AuOptional<AuUInt64> seed64;
|
||||
AuOptional<AuArray<AuUInt8, 64>> seedMassive;
|
||||
@ -22,31 +22,37 @@ namespace Aurora::RNG
|
||||
{
|
||||
Reset();
|
||||
this->seed = seed;
|
||||
this->secure = false;
|
||||
this->bSecure = false;
|
||||
}
|
||||
|
||||
inline auline void SetSeed64(AuUInt64 seed)
|
||||
{
|
||||
Reset();
|
||||
this->seed64 = seed;
|
||||
this->secure = false;
|
||||
this->bSecure = false;
|
||||
}
|
||||
|
||||
inline auline void SetMassiveSeed(const AuArray<AuUInt8, 64> &seed)
|
||||
{
|
||||
Reset();
|
||||
this->seedMassive = seed;
|
||||
this->secure = false;
|
||||
this->bSecure = false;
|
||||
}
|
||||
|
||||
inline auline void SetCSRNG()
|
||||
{
|
||||
this->secure = true;
|
||||
Reset();
|
||||
this->bSecure = true;
|
||||
}
|
||||
|
||||
inline auline void SetQuickRng()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline auline void Reset()
|
||||
{
|
||||
this->bSecure = false;
|
||||
this->seed.reset();
|
||||
this->seed64.reset();
|
||||
this->seedMassive.reset();
|
||||
|
@ -43,7 +43,7 @@ namespace Aurora::RNG
|
||||
RngFillArray<false, AuUInt8>(maxEntropy.data(), 64);
|
||||
gWellRand = WELL_SeedRandBig64(maxEntropy);
|
||||
RandomDef fast;
|
||||
fast.secure = false;
|
||||
fast.SetQuickRng();
|
||||
gFastDevice = RandomUnique(fast);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace Aurora::RNG
|
||||
this->def_ = def;
|
||||
|
||||
// Gross...
|
||||
if (!def.secure)
|
||||
if (!def.bSecure)
|
||||
{
|
||||
if (def.seed)
|
||||
{
|
||||
@ -64,7 +64,7 @@ namespace Aurora::RNG
|
||||
|
||||
void RandomDevice::Read(void *in, AuUInt32 length)
|
||||
{
|
||||
if (this->def_.secure)
|
||||
if (this->def_.bSecure)
|
||||
{
|
||||
ReadSecureRNG(in, length);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user