aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/entropy.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-11 21:06:39 +0000
committerlloyd <[email protected]>2008-11-11 21:06:39 +0000
commit03e022126be8fac992a33983ac4430150fb55c84 (patch)
treeb2389a014b7b68d01fd073d83533c49564f264ec /src/utils/entropy.cpp
parent8879a51da7c3b93e27439122cea5d5aa81ae38c3 (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/entropy.cpp')
-rw-r--r--src/utils/entropy.cpp80
1 files changed, 0 insertions, 80 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);
- }
-
-}