Botan  1.11.15
src/lib/entropy/egd/es_egd.h
Go to the documentation of this file.
00001 /*
00002 * EGD EntropySource
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_ENTROPY_SRC_EGD_H__
00009 #define BOTAN_ENTROPY_SRC_EGD_H__
00010 
00011 #include <botan/entropy_src.h>
00012 #include <string>
00013 #include <vector>
00014 #include <mutex>
00015 
00016 namespace Botan {
00017 
00018 /**
00019 * EGD Entropy Source
00020 */
00021 class EGD_EntropySource : public EntropySource
00022    {
00023    public:
00024       std::string name() const { return "EGD/PRNGD"; }
00025 
00026       void poll(Entropy_Accumulator& accum);
00027 
00028       EGD_EntropySource(const std::vector<std::string>&);
00029       ~EGD_EntropySource();
00030    private:
00031       class EGD_Socket
00032          {
00033          public:
00034             EGD_Socket(const std::string& path);
00035 
00036             void close();
00037             size_t read(byte outbuf[], size_t length);
00038          private:
00039             static int open_socket(const std::string& path);
00040 
00041             std::string socket_path;
00042             int m_fd; // cached fd
00043          };
00044 
00045       std::mutex m_mutex;
00046       std::vector<EGD_Socket> sockets;
00047    };
00048 
00049 }
00050 
00051 #endif