diff options
author | lloyd <[email protected]> | 2008-11-06 19:22:24 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-06 19:22:24 +0000 |
commit | bf7f64fae0d14cc175732d7dc69f71f47edc7c41 (patch) | |
tree | 8842acf8197f733782fbbf3ebbbf3fb858151769 /src/utils/util.cpp | |
parent | d50e41609c95945c714c445f6b400e02fe659b90 (diff) |
Move Entropy_Estimator to utils/entropy.h (from anon namespace in HMAC_RNG
implementation), remove freestanding estimate_entropy function, change
Randpool to use entropy estimator.
Diffstat (limited to 'src/utils/util.cpp')
-rw-r--r-- | src/utils/util.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/utils/util.cpp b/src/utils/util.cpp index af1c62ebd..f8b98fcb8 100644 --- a/src/utils/util.cpp +++ b/src/utils/util.cpp @@ -64,36 +64,4 @@ u32bit dl_work_factor(u32bit bits) #endif } -/************************************************* -* 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); - } - } |