From f3a1a152873e881376fd0ad36c2bcc15b445e391 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 30 Apr 2023 13:16:09 +0100 Subject: [PATCH] cryptography: update auto_seed --- src/utils/cryptography.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/utils/cryptography.cpp b/src/utils/cryptography.cpp index 16da24e..78ce389 100644 --- a/src/utils/cryptography.cpp +++ b/src/utils/cryptography.cpp @@ -1,4 +1,5 @@ #include +#include #include "string.hpp" #include "cryptography.hpp" @@ -107,11 +108,18 @@ namespace utils 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)); + const auto t = std::time(nullptr); + 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)); + } } };