From 0aebbf4ee2377dc6abc7059299bf6f7adea5ac74 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 26 Apr 2023 10:49:15 +0200 Subject: [PATCH] Add more entropy --- src/common/utils/cryptography.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/common/utils/cryptography.cpp b/src/common/utils/cryptography.cpp index 824cb9a7..802f8bcf 100644 --- a/src/common/utils/cryptography.cpp +++ b/src/common/utils/cryptography.cpp @@ -1,5 +1,8 @@ #include "string.hpp" #include "cryptography.hpp" + +#include + #include "nt.hpp" #include "finally.hpp" @@ -116,11 +119,17 @@ namespace utils::cryptography int i[4]; // uninitialized data auto* i_ptr = &i; - this->add_entropy(reinterpret_cast(&i), sizeof(i)); - this->add_entropy(reinterpret_cast(&i_ptr), sizeof(i_ptr)); + this->add_entropy(&i, sizeof(i)); + this->add_entropy(&i_ptr, sizeof(i_ptr)); auto t = time(nullptr); - this->add_entropy(reinterpret_cast(&t), sizeof(t)); + this->add_entropy(&t, sizeof(t)); + + std::random_device rd{}; + for (auto j = 0; j < 4; ++j) { + const auto x = rd(); + this->add_entropy(&x, sizeof(x)); + } } };