Reece Wilson
8a2947ffc5
[*] Refactor bcrypt api: HashPW[Ex] -> HashPassword[Ex] [+] ByteBuffer::GetOrAllocateLinearWriteable [+] ByteBuffer::Can[Read/Write](n) [+] ByteBuffer::GetLinear[Read/Writable]able(n) [*] Split RNG.cpp into two files [+] EHashType::eSHA2_48 (_32, _64 was already in place. missed 48/384 bit) [+] AuCrypto::HMAC and IHMACContext (AuHashing) [+] EHashType::eSHA3_28 [+] EHashType::eSHA3_32 [+] EHashType::eSHA3_48 [+] EHashType::eSHA3_64 (AuCrypto) [+] EHashType::eSHA2_48_384 [+] EHashType::eSHA2_64_512 [+] EHashType::eSHA3_28_224 [+] EHashType::eSHA3_32_256 [+] EHashType::eSHA3_48_384 [+] EHashType::eSHA3_64_512 [*] (IRandomDevice) class -> struct [*] Bugfix: cast in Promise<SuccessValue_t, ErrorValue_t>::WriteIntoError [+] Missing AuHashing namespace alias [*] Time util: pad ms when fraction of a second to 3 digits
81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: IRandomDevice.hpp
|
|
Date: 2021-9-3
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::RNG
|
|
{
|
|
struct IRandomDevice
|
|
{
|
|
virtual void Read(void *in, AuUInt32 length) = 0;
|
|
|
|
virtual AuString NextString(AuUInt32 length, ERngStringCharacters type = ERngStringCharacters::eAlphaCharacters) = 0;
|
|
virtual void NextString(char *string, AuUInt32 length, ERngStringCharacters type = ERngStringCharacters::eAlphaCharacters) = 0;
|
|
virtual AuUInt8 NextByte() = 0;
|
|
virtual bool NextBoolean() = 0;
|
|
virtual AuUInt32 NextU32() = 0;
|
|
virtual AuUInt32 NextU32(AuUInt32 min, AuUInt32 max) = 0;
|
|
virtual AuUInt64 NextU64() = 0;
|
|
virtual AuInt32 NextInt(AuInt32 min, AuInt32 max) = 0;
|
|
virtual double NextDecimal() = 0;
|
|
virtual float NextNumber(float min, float max) = 0;
|
|
virtual AuUInt32 NextIndex(AuUInt32 count /* = max + 1*/) = 0;
|
|
|
|
|
|
template<typename T, int N>
|
|
inline void NextFillArray(T(&array)[N])
|
|
{
|
|
Read(array, N * sizeof(T));
|
|
}
|
|
|
|
template<typename T>
|
|
inline void NextFillArray(T *array, AuUInt32 length)
|
|
{
|
|
Read(array, length * sizeof(T));
|
|
}
|
|
|
|
template<typename T>
|
|
inline T &NextFillRange(const T &items)
|
|
{
|
|
NextFillArray(items.begin(), items.end() - items.begin());
|
|
}
|
|
|
|
template<typename T>
|
|
inline T NextFillTmpl()
|
|
{
|
|
T ret {};
|
|
Read(&ret, sizeof(T));
|
|
return ret;
|
|
}
|
|
|
|
template<typename T>
|
|
inline T &NextIterator(T &begin, T &end)
|
|
{
|
|
return begin + NextIndex(AuUInt(end - begin));
|
|
}
|
|
|
|
template<typename T>
|
|
inline T &NextArray(T *items, AuUInt32 count)
|
|
{
|
|
return items[NextIndex(count)];
|
|
}
|
|
|
|
template<typename T>
|
|
inline T &NextVector(const AuList<T> &items)
|
|
{
|
|
return NextArray(items.data(), items.size());
|
|
}
|
|
|
|
template<typename T>
|
|
inline T &NextRange(const T &items)
|
|
{
|
|
return NextIterator(items.begin(), items.end());
|
|
}
|
|
};
|
|
|
|
AUKN_SHARED_API(Random, IRandomDevice, const RandomDef &def);
|
|
} |