aboutsummaryrefslogtreecommitdiffstats
path: root/src/entropy/proc_walk
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-11-09 15:56:50 +0000
committerlloyd <[email protected]>2013-11-09 15:56:50 +0000
commitb5d287a9cfa9416aba675dd1778838e67efceefc (patch)
treeb0011b9e821c4cc406b1ce191a3042610f2aa122 /src/entropy/proc_walk
parent99eb63b2340e77d14555491c065b55135c78c18e (diff)
Fix EGD settings. Some cleanup and renaming.
Diffstat (limited to 'src/entropy/proc_walk')
-rw-r--r--src/entropy/proc_walk/info.txt6
-rw-r--r--src/entropy/proc_walk/proc_walk.cpp (renamed from src/entropy/proc_walk/es_ftw.cpp)32
-rw-r--r--src/entropy/proc_walk/proc_walk.h (renamed from src/entropy/proc_walk/es_ftw.h)16
3 files changed, 25 insertions, 29 deletions
diff --git a/src/entropy/proc_walk/info.txt b/src/entropy/proc_walk/info.txt
index 9039f0ad9..d8c60a2a7 100644
--- a/src/entropy/proc_walk/info.txt
+++ b/src/entropy/proc_walk/info.txt
@@ -1,11 +1,11 @@
-define ENTROPY_SRC_FTW
+define ENTROPY_SRC_PROC_WALKER
<source>
-es_ftw.cpp
+proc_walk.cpp
</source>
<header:internal>
-es_ftw.h
+proc_walk.h
</header:internal>
<os>
diff --git a/src/entropy/proc_walk/es_ftw.cpp b/src/entropy/proc_walk/proc_walk.cpp
index 7d72e7752..050d9dcf7 100644
--- a/src/entropy/proc_walk/es_ftw.cpp
+++ b/src/entropy/proc_walk/proc_walk.cpp
@@ -1,11 +1,13 @@
/*
-* FTW EntropySource
+* Entropy source based on reading files in /proc on the assumption
+* that a remote attacker will have difficulty guessing some of them.
+*
* (C) 1999-2008,2012 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
-#include <botan/internal/es_ftw.h>
+#include <botan/internal/proc_walk.h>
#include <botan/secmem.h>
#include <cstring>
#include <deque>
@@ -129,39 +131,31 @@ int Directory_Walker::next_fd()
}
/**
-* FTW_EntropySource Constructor
-*/
-FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p), dir(nullptr)
- {
- }
-
-/**
-* FTW_EntropySource Destructor
+* ProcWalking_EntropySource Destructor
*/
-FTW_EntropySource::~FTW_EntropySource()
+ProcWalking_EntropySource::~ProcWalking_EntropySource()
{
- delete dir;
- dir = nullptr;
+ // for ~unique_ptr
}
-void FTW_EntropySource::poll(Entropy_Accumulator& accum)
+void ProcWalking_EntropySource::poll(Entropy_Accumulator& accum)
{
const size_t MAX_FILES_READ_PER_POLL = 2048;
- if(!dir)
- dir = new Directory_Walker(path);
+ if(!m_dir)
+ m_dir = new Directory_Walker(m_path);
secure_vector<byte>& io_buffer = accum.get_io_buffer(4096);
for(size_t i = 0; i != MAX_FILES_READ_PER_POLL; ++i)
{
- int fd = dir->next_fd();
+ int fd = m_dir->next_fd();
// If we've exhaused this walk of the directory, halt the poll
if(fd == -1)
{
- delete dir;
- dir = nullptr;
+ delete m_dir;
+ m_dir = nullptr;
break;
}
diff --git a/src/entropy/proc_walk/es_ftw.h b/src/entropy/proc_walk/proc_walk.h
index 3ba222d46..e493c7ed2 100644
--- a/src/entropy/proc_walk/es_ftw.h
+++ b/src/entropy/proc_walk/proc_walk.h
@@ -5,28 +5,30 @@
* Distributed under the terms of the Botan license
*/
-#ifndef BOTAN_ENTROPY_SRC_FTW_H__
-#define BOTAN_ENTROPY_SRC_FTW_H__
+#ifndef BOTAN_ENTROPY_SRC_PROC_WALK_H__
+#define BOTAN_ENTROPY_SRC_PROC_WALK_H__
#include <botan/entropy_src.h>
+#include <memory>
namespace Botan {
/**
* File Tree Walking Entropy Source
*/
-class FTW_EntropySource : public EntropySource
+class ProcWalking_EntropySource : public EntropySource
{
public:
std::string name() const { return "Proc Walker"; }
void poll(Entropy_Accumulator& accum);
- FTW_EntropySource(const std::string& root_dir);
- ~FTW_EntropySource();
+ ProcWalking_EntropySource(const std::string& root_dir) : m_path(root_dir) {}
+
+ ~ProcWalking_EntropySource();
private:
- std::string path;
- class File_Descriptor_Source* dir;
+ const std::string m_path;
+ class File_Descriptor_Source* m_dir;
};
}