blob: e0fb9c2d5586ddf573f9d09ec0f79b6991ffc85c (
plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* EGD EntropySource
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_ENTROPY_SRC_EGD_H__
#define BOTAN_ENTROPY_SRC_EGD_H__
#include <botan/entropy_src.h>
#include <string>
#include <vector>
#include <botan/mutex.h>
namespace Botan {
/**
* EGD Entropy Source
*/
class EGD_EntropySource final : public Entropy_Source
{
public:
std::string name() const override { return "egd"; }
size_t poll(RandomNumberGenerator& rng) override;
EGD_EntropySource(const std::vector<std::string>&);
~EGD_EntropySource();
private:
class EGD_Socket
{
public:
EGD_Socket(const std::string& path);
void close();
size_t read(byte outbuf[], size_t length);
private:
static int open_socket(const std::string& path);
std::string m_socket_path;
int m_fd; // cached fd
};
mutex_type m_mutex;
std::vector<EGD_Socket> m_sockets;
secure_vector<uint8_t> m_io_buf;
};
}
#endif
|