34 virtual void GetBytes(
unsigned char* buffer,
size_t bufferSize) = 0;
48 template <
typename DataType = u
int64_t>
58 SecureRandom(
const std::shared_ptr<SecureRandomBytes>& entropySource) : m_entropy(entropySource)
59 {
static_assert(std::is_unsigned<DataType>::value,
"Type DataType must be integral"); }
71 unsigned char buffer[
sizeof(DataType)];
72 m_entropy->GetBytes(buffer,
sizeof(DataType));
77 for (
size_t i = 0; i <
sizeof(DataType); ++i)
88 operator bool()
const {
return *m_entropy; }
91 std::shared_ptr<SecureRandomBytes> m_entropy;
virtual ~SecureRandomBytes()=default
virtual void GetBytes(unsigned char *buffer, size_t bufferSize)=0
virtual void InitStaticState()
virtual std::shared_ptr< SecureRandomBytes > CreateImplementation() const =0
virtual ~SecureRandomFactory()=default
virtual void CleanupStaticState()
virtual DataType operator()()
SecureRandom(const std::shared_ptr< SecureRandomBytes > &entropySource)
virtual ~SecureRandom()=default