summaryrefslogtreecommitdiff
path: root/src/KM_prng.cpp
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-09-05 10:23:04 +0100
committerCarl Hetherington <cth@carlh.net>2019-12-03 17:01:32 +0100
commita7e1d778842dd4a5dc79fdbcf57eff175f50dafe (patch)
treece59fd931f11ab01ee10b35efd0f3ffa2accf7cd /src/KM_prng.cpp
parent3aaea6c449602d329aafbf27312d80078f7be44c (diff)
Quell some valgrind errors.
Diffstat (limited to 'src/KM_prng.cpp')
-rwxr-xr-xsrc/KM_prng.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/KM_prng.cpp b/src/KM_prng.cpp
index 735289d..336bfca 100755
--- a/src/KM_prng.cpp
+++ b/src/KM_prng.cpp
@@ -37,6 +37,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <openssl/aes.h>
#include <openssl/sha.h>
#include <openssl/bn.h>
+#if HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
using namespace Kumu;
@@ -91,6 +94,10 @@ public:
result = URandom.Read(rng_key, RNG_KEY_SIZE, &read_count);
}
+#if HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED (rng_key, RNG_KEY_SIZE);
+#endif
+
if ( KM_FAILURE(result) )
DefaultLogSink().Error("Error opening random device: %s\n", DEV_URANDOM);
@@ -114,6 +121,11 @@ public:
SHA1_Update(&SHA, key_fodder, RNG_KEY_SIZE);
SHA1_Final(sha_buf, &SHA);
+#if HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED (sha_buf, 20);
+ VALGRIND_MAKE_MEM_DEFINED (&m_Context, sizeof(m_Context));
+#endif
+
AutoMutex Lock(m_Lock);
AES_set_encrypt_key(sha_buf, RNG_KEY_SIZE_BITS, &m_Context);
ui32_t* m_ctr_buf_int = reinterpret_cast<ui32_t*> (m_ctr_buf + 12);
@@ -150,6 +162,11 @@ public:
buf[i] = rand_r(&m_cth_test_rng_state);
#endif
}
+
+#if HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED (buf, len);
+#endif
+
}
void reset()