fix(SeedFileManager): 6-byte seed file issue

there was a reggression in a series of commits that led to this issue,
mainly revolving around the switch from hex-encoded output to raw bytes.
the result was a seed file in which just the first 6 bytes were updated.
this is now fixed

refs:
c4dcab3046
revert c9398a0bf4
This commit is contained in:
surtur 2022-02-07 23:00:01 +01:00
parent 5d1d25ecb4
commit 4176de2e12
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -114,7 +114,7 @@ auto SeedFileManager::update_seed_file() -> void {
}
std::string str_buff(reinterpret_cast<const char*>(&buff[0]),
buff.SizeInBytes());
buff.SizeInBytes() * 8);
this->_p_accumulator->call_reseed(str_buff);
write_seed_file();
@ -135,17 +135,11 @@ auto SeedFileManager::write_seed_file() -> void {
static_cast<unsigned int>(config.seed_f_length))};
assert(da_buff.length() % 2 == 0);
assert(da_buff.size() == config.seed_f_length * 2); // da_buff is
// hex-encoded
assert(da_buff.size() == config.seed_f_length);
// account for hex encoding that is returned from get_random_data(), i.e.
// the total length is half of the actual number of characters
const size_t length{da_buff.length() / 2};
const size_t length{da_buff.length()}; // not hex-encoded anymore
CryptoPP::StringSource src(
da_buff.c_str(),
true /*pumpAll*/,
new CryptoPP::HexDecoder(new CryptoPP::ArraySink(&buff[0], length)));
std::memmove(&buff[0], da_buff.c_str(), length);
fmt::print(stderr, "[*] sfm: writing seed file\n");