diff options
| -rwxr-xr-x | src/KM_prng.cpp | 11 | ||||
| -rwxr-xr-x | src/KM_util.cpp | 4 | ||||
| -rwxr-xr-x | src/KM_util.h | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/KM_prng.cpp b/src/KM_prng.cpp index f9ec0c0..f2736f1 100755 --- a/src/KM_prng.cpp +++ b/src/KM_prng.cpp @@ -34,6 +34,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <KM_aes.h> #include <KM_sha1.h> #include <KM_mutex.h> +#include <boost/random.hpp> #include <string.h> #include <assert.h> @@ -69,6 +70,8 @@ namespace{ AES_ctx m_Context; byte_t m_ctr_buf[RNG_BLOCK_SIZE]; Mutex m_Lock; + boost::random::mt19937 m_Test_Rng; + boost::random::uniform_int_distribution<> m_Test_Dist; h__RNG() { @@ -145,6 +148,14 @@ namespace{ AES_encrypt(&m_Context, tmp); memcpy(buf + gen_count, tmp, len - gen_count); } + + if (test_fix_rng) + { + for (unsigned int i = 0; i < len; i++) + { + buf[i] = m_Test_Dist(m_Test_Rng); + } + } } }; } diff --git a/src/KM_util.cpp b/src/KM_util.cpp index 4c59c78..e2f2613 100755 --- a/src/KM_util.cpp +++ b/src/KM_util.cpp @@ -40,6 +40,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <map> #include <string> + +bool Kumu::test_fix_rng = false; + + const char* Kumu::Version() { diff --git a/src/KM_util.h b/src/KM_util.h index 9dcf846..5e4d5fe 100755 --- a/src/KM_util.h +++ b/src/KM_util.h @@ -40,6 +40,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Kumu { + extern bool test_fix_rng; + // The version number declaration and explanation are in ../configure.ac const char* Version(); |
