2015-10-22 17:36:03 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CPPUTILS_RANDOM_OSRANDOMGENERATOR_H
|
|
|
|
#define MESSMER_CPPUTILS_RANDOM_OSRANDOMGENERATOR_H
|
|
|
|
|
|
|
|
#include "RandomGenerator.h"
|
|
|
|
#include <cryptopp/cryptopp/osrng.h>
|
|
|
|
|
|
|
|
namespace cpputils {
|
|
|
|
class OSRandomGenerator final : public RandomGenerator {
|
|
|
|
public:
|
|
|
|
OSRandomGenerator();
|
|
|
|
|
|
|
|
protected:
|
2015-10-23 20:21:17 +02:00
|
|
|
void _get(void *target, size_t bytes) override;
|
2015-11-27 14:05:30 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(OSRandomGenerator);
|
2015-10-22 17:36:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline OSRandomGenerator::OSRandomGenerator() {}
|
|
|
|
|
2015-10-23 20:21:17 +02:00
|
|
|
inline void OSRandomGenerator::_get(void *target, size_t bytes) {
|
2015-10-22 17:36:03 +02:00
|
|
|
CryptoPP::OS_GenerateRandomBlock(true, (byte*)target, bytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|