[cpp-sp] branch main updated: Relocate RNG seeding to start method.
Codeberg
noreply at shibboleth.net
Tue Sep 8 12:59:15 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository cpp-sp.
View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/3677b9db9425b08ba68037dec8dd27898fed1da8
The following commit(s) were added to refs/heads/main by this push:
new 3677b9db Relocate RNG seeding to start method.
3677b9db is described below
commit 3677b9db9425b08ba68037dec8dd27898fed1da8
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Sep 8 08:59:00 2026 -0400
Relocate RNG seeding to start method.
---
shibsp/impl/AgentConfig.cpp | 47 +++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 23 deletions(-)
diff --git a/shibsp/impl/AgentConfig.cpp b/shibsp/impl/AgentConfig.cpp
index e4737eab..1114596a 100644
--- a/shibsp/impl/AgentConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -47,6 +47,7 @@
#include <boost/property_tree/ini_parser.hpp>
#ifdef WIN32
+#include <process.h>
#include <Windows.h>
#endif
@@ -207,31 +208,8 @@ bool AgentInternalConfig::init(const char* inst_prefix, const char* config_file,
return true;
}
-static unsigned long long my_entropy()
-{
- // Gather many potential forms of entropy and XOR them
- const uint64_t my_seed = 0xc587acf84d9d5a64;
- static uint64_t i = 0;
- static std::random_device rd;
- const auto hrclock = std::chrono::high_resolution_clock::now().time_since_epoch().count();
- const auto sclock = std::chrono::system_clock::now().time_since_epoch().count();
- auto *heap = malloc(1);
- const auto mash = my_seed + rd() + hrclock + sclock + (i++) +
- reinterpret_cast<intptr_t>(heap) + reinterpret_cast<intptr_t>(&hrclock) +
- reinterpret_cast<intptr_t>(&i) + reinterpret_cast<intptr_t>(&malloc) +
- reinterpret_cast<intptr_t>(&my_entropy);
- free(heap);
- return mash;
-}
-
bool AgentInternalConfig::_init(const char* inst_prefix, const char* config_file, bool rethrow)
{
- // Attempt to seed the PRNG.
- uint_least64_t seed_data[mt19937_64::state_size];
- generate_n(seed_data, mt19937_64::state_size, ref(my_entropy));
- seed_seq q(begin(seed_data), end(seed_data));
- m_rng.seed(q);
-
// Establish prefix and replace backward slashes in path.
if (!inst_prefix)
inst_prefix = getenv("SHIBSP_PREFIX");
@@ -367,9 +345,32 @@ void AgentInternalConfig::term()
_term();
}
+namespace {
+ static unsigned long long my_entropy()
+ {
+ // Gather many potential forms of entropy and XOR them
+ const uint64_t my_seed = 0xc587acf84d9d5a64;
+ static uint64_t i = 0;
+ static std::random_device rd;
+ const auto hrclock = std::chrono::high_resolution_clock::now().time_since_epoch().count();
+ const auto sclock = std::chrono::system_clock::now().time_since_epoch().count();
+ const auto mash = my_seed + rd() + getpid() + hrclock + sclock + (i++) +
+ reinterpret_cast<intptr_t>(&hrclock) + reinterpret_cast<intptr_t>(&i) +
+ reinterpret_cast<intptr_t>(&malloc) + reinterpret_cast<intptr_t>(&my_entropy);
+ return mash;
+ }
+}
+
bool AgentInternalConfig::start()
{
lock_guard<mutex> locker(m_lock);
+
+ // Attempt to seed the PRNG.
+ uint_least64_t seed_data[mt19937_64::state_size];
+ generate_n(seed_data, mt19937_64::state_size, ref(my_entropy));
+ seed_seq q(begin(seed_data), end(seed_data));
+ m_rng.seed(q);
+
if (m_initCount == 1) {
SessionCache* cache = getAgent().getSessionCache(false);
if (cache) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list