diff options
author | lloyd <[email protected]> | 2008-11-11 21:06:39 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-11 21:06:39 +0000 |
commit | 03e022126be8fac992a33983ac4430150fb55c84 (patch) | |
tree | b2389a014b7b68d01fd073d83533c49564f264ec /src/utils | |
parent | 8879a51da7c3b93e27439122cea5d5aa81ae38c3 (diff) |
Drop use of entropy estimation in Randpool for the same reason as HMAC_RNG.
As with HMAC_RNG, instead assume one bit of conditional entropy per byte
of polled material. Since they are no longer used, drop the entropy
estimation routines entirely.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/entropy.cpp | 80 | ||||
-rw-r--r-- | src/utils/entropy.h | 48 | ||||
-rw-r--r-- | src/utils/info.txt | 2 |
3 files changed, 0 insertions, 130 deletions
diff --git a/src/utils/entropy.cpp b/src/utils/entropy.cpp deleted file mode 100644 index 1562eb0d2..000000000 --- a/src/utils/entropy.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************* -* Entropy_Estimator Source File * -* (C) 2008 Jack Lloyd * -*************************************************/ - -#include <botan/entropy.h> -#include <botan/bit_ops.h> - -namespace Botan { - -/** -Update the estimate -*/ -void Entropy_Estimator::update(const byte buffer[], u32bit length, - u32bit upper_limit) - { - u32bit this_buf_estimate = 0; - - /* - This is pretty naive - */ - for(u32bit j = 0; j != length; ++j) - { - byte delta = last ^ buffer[j]; - last = buffer[j]; - - byte delta2 = delta ^ last_delta; - last_delta = delta; - - byte delta3 = delta2 ^ last_delta2; - last_delta2 = delta2; - - byte min_delta = delta; - if(min_delta > delta2) min_delta = delta2; - if(min_delta > delta3) min_delta = delta3; - - this_buf_estimate += hamming_weight(min_delta); - } - - this_buf_estimate /= 2; - - if(upper_limit) - estimate += std::min(upper_limit, this_buf_estimate); - else - estimate += this_buf_estimate; - } - -/************************************************* -* Estimate the entropy of the buffer * -*************************************************/ -u32bit entropy_estimate(const byte buffer[], u32bit length) - { - if(length <= 4) - return 0; - - u32bit estimate = 0; - byte last = 0, last_delta = 0, last_delta2 = 0; - - for(u32bit j = 0; j != length; ++j) - { - byte delta = last ^ buffer[j]; - last = buffer[j]; - - byte delta2 = delta ^ last_delta; - last_delta = delta; - - byte delta3 = delta2 ^ last_delta2; - last_delta2 = delta2; - - byte min_delta = delta; - if(min_delta > delta2) min_delta = delta2; - if(min_delta > delta3) min_delta = delta3; - - estimate += hamming_weight(min_delta); - } - - return (estimate / 2); - } - -} diff --git a/src/utils/entropy.h b/src/utils/entropy.h deleted file mode 100644 index 24d2fbdbf..000000000 --- a/src/utils/entropy.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************* -* Entropy_Estimator Header File * -* (C) 2008 Jack Lloyd * -*************************************************/ - -#ifndef BOTAN_ENTROPY_ESTIMATOR_H__ -#define BOTAN_ENTROPY_ESTIMATOR_H__ - -#include <botan/types.h> -#include <algorithm> - -namespace Botan { - -/** -Naive Entropy Estimation using first, second, and third order deltas - -@todo It would be nice to extend this to test using zlib or bzip2 if -those modules are compiled in to the library -*/ -class BOTAN_DLL Entropy_Estimator - { - public: - Entropy_Estimator() - { last = last_delta = last_delta2 = 0; estimate = 0; } - - /** - Return the current estimate - */ - u32bit value() const { return estimate; } - - /** - Set an upper bound on the estimate so far - */ - void set_upper_bound(u32bit upper_limit) - { estimate = std::min(estimate, upper_limit); } - - /** - Add more entropy data to the current estimation - */ - void update(const byte buffer[], u32bit length, u32bit upper_limit = 0); - private: - u32bit estimate; - byte last, last_delta, last_delta2; - }; - -} - -#endif diff --git a/src/utils/info.txt b/src/utils/info.txt index 99d589d8c..ffc19c852 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -22,8 +22,6 @@ data_src.cpp data_src.h datastor.cpp datastor.h -entropy.cpp -entropy.h exceptn.cpp exceptn.h loadstor.h |