forked from cryfs/cryfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomGeneratorThread.h
More file actions
34 lines (26 loc) · 983 Bytes
/
Copy pathRandomGeneratorThread.h
File metadata and controls
34 lines (26 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#ifndef MESSMER_CPPUTILS_RANDOM_RANDOMGENERATORTHREAD_H
#define MESSMER_CPPUTILS_RANDOM_RANDOMGENERATORTHREAD_H
#include "../thread/LoopThread.h"
#include "ThreadsafeRandomDataBuffer.h"
#include <vendor_cryptopp/osrng.h>
namespace cpputils {
//TODO Test
class RandomGeneratorThread final {
public:
RandomGeneratorThread(ThreadsafeRandomDataBuffer *buffer, size_t minSize, size_t maxSize);
void start();
private:
bool _loopIteration();
Data _generateRandomData(size_t size);
CryptoPP::AutoSeededRandomPool _randomGenerator;
ThreadsafeRandomDataBuffer *_buffer;
size_t _minSize;
size_t _maxSize;
//This has to be the last member, because it has to be destructed first - otherwise the thread could still be
//running while the RandomGeneratorThread object is invalid.
LoopThread _thread;
DISALLOW_COPY_AND_ASSIGN(RandomGeneratorThread);
};
}
#endif