diff options
author | lloyd <[email protected]> | 2008-10-26 20:55:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-26 20:55:57 +0000 |
commit | ac4bab4e40a45a7d1b6061142ab831813bf0d6ca (patch) | |
tree | cbaad5829ae4a65689a4b5cbfa4ed4dfcbcdbcc3 /src/entropy/dev_random | |
parent | a78b39c6bd171c8851aa53debe8ebc1665104d9b (diff) |
Move EntropySource base class to new entropy_src.h (which allows the implementations
to decouple from knowing about RandomNumberGenerator).
Diffstat (limited to 'src/entropy/dev_random')
-rw-r--r-- | src/entropy/dev_random/es_dev.cpp | 14 | ||||
-rw-r--r-- | src/entropy/dev_random/es_dev.h | 8 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/entropy/dev_random/es_dev.cpp b/src/entropy/dev_random/es_dev.cpp index 310620716..426ef8443 100644 --- a/src/entropy/dev_random/es_dev.cpp +++ b/src/entropy/dev_random/es_dev.cpp @@ -89,9 +89,9 @@ int Device_Reader::open(const std::string& pathname) } -/************************************************* -* Gather entropy from a RNG device * -*************************************************/ +/** +* Gather entropy from a RNG device +*/ u32bit Device_EntropySource::slow_poll(byte output[], u32bit length) { u32bit read = 0; @@ -109,4 +109,12 @@ u32bit Device_EntropySource::slow_poll(byte output[], u32bit length) return read; } +/** +* Fast /dev/random and co poll: limit output to 64 bytes +*/ +u32bit Device_EntropySource::fast_poll(byte output[], u32bit length) + { + return slow_poll(output, std::max<u32bit>(length, 64)); + } + } diff --git a/src/entropy/dev_random/es_dev.h b/src/entropy/dev_random/es_dev.h index 91f08ad4c..024afbdb4 100644 --- a/src/entropy/dev_random/es_dev.h +++ b/src/entropy/dev_random/es_dev.h @@ -6,8 +6,9 @@ #ifndef BOTAN_ENTROPY_SRC_DEVICE_H__ #define BOTAN_ENTROPY_SRC_DEVICE_H__ -#include <botan/rng.h> +#include <botan/entropy_src.h> #include <vector> +#include <string> namespace Botan { @@ -17,8 +18,11 @@ namespace Botan { class BOTAN_DLL Device_EntropySource : public EntropySource { public: - Device_EntropySource(const std::vector<std::string>& fs) : fsnames(fs) {} + Device_EntropySource(const std::vector<std::string>& fs) : + fsnames(fs) {} + u32bit slow_poll(byte[], u32bit); + u32bit fast_poll(byte[], u32bit); private: std::vector<std::string> fsnames; }; |