Coverage Report

Created: 2020-08-01 06:18

/src/botan/build/include/botan/internal/proc_walk.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* File Tree Walking EntropySource
3
* (C) 1999-2008 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_ENTROPY_SRC_PROC_WALK_H_
9
#define BOTAN_ENTROPY_SRC_PROC_WALK_H_
10
11
#include <botan/entropy_src.h>
12
#include <botan/mutex.h>
13
14
namespace Botan {
15
16
class File_Descriptor_Source
17
   {
18
   public:
19
      virtual int next_fd() = 0;
20
0
      virtual ~File_Descriptor_Source() = default;
21
   };
22
23
/**
24
* File Tree Walking Entropy Source
25
*/
26
class ProcWalking_EntropySource final : public Entropy_Source
27
   {
28
   public:
29
0
      std::string name() const override { return "proc_walk"; }
30
31
      size_t poll(RandomNumberGenerator& rng) override;
32
33
      explicit ProcWalking_EntropySource(const std::string& root_dir) :
34
0
         m_path(root_dir), m_dir(nullptr) {}
35
36
   private:
37
      const std::string m_path;
38
      mutex_type m_mutex;
39
      std::unique_ptr<File_Descriptor_Source> m_dir;
40
      secure_vector<uint8_t> m_buf;
41
   };
42
43
}
44
45
#endif