From 4176de2e12bc2e2bfc08c4c5697136185cf8c01d Mon Sep 17 00:00:00 2001 From: surtur Date: Mon, 7 Feb 2022 23:00:01 +0100 Subject: [PATCH] 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: https://git.dotya.ml/ak-fortuna/fortuna/commit/c4dcab30463013e85ddc6934b843f9f878a111b6 revert https://git.dotya.ml/ak-fortuna/fortuna/commit/c9398a0bf41881380c6f4882de64865ddc3a1f8b --- seed_file_management.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/seed_file_management.cpp b/seed_file_management.cpp index 5f098eb..a7d812d 100644 --- a/seed_file_management.cpp +++ b/seed_file_management.cpp @@ -114,7 +114,7 @@ auto SeedFileManager::update_seed_file() -> void { } std::string str_buff(reinterpret_cast(&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(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");