libcryfs/random/OSRandomGenerator.h

28 lines
665 B
C
Raw Normal View History

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:
void _get(void *target, size_t bytes) override;
private:
DISALLOW_COPY_AND_ASSIGN(OSRandomGenerator);
2015-10-22 17:36:03 +02:00
};
inline OSRandomGenerator::OSRandomGenerator() {}
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