g: simplify generate_random_data() hexdecode block
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-13 02:15:23 +01:00
parent 4d0785b002
commit 2c3d5b4528
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -175,11 +175,14 @@ auto Generator::generate_random_data(uint n) -> std::string {
std::string nu_G_k{generate_blocks(2)};
// fmt::print("nu_G_k: {}\n", nu_G_k); // debugging
std::string dst;
// FIXME: +1 for the actual null-termination, not exactly sure if needed
dst.resize(G.k_length + 1);
CryptoPP::StringSource str_s(
nu_G_k, true,
new CryptoPP::HexDecoder(new CryptoPP::StringSink(dst)));
CryptoPP::HexDecoder decoder;
decoder.Put(reinterpret_cast<CryptoPP::byte*>(nu_G_k.data()),
nu_G_k.size());
decoder.MessageEnd();
dst.resize(G.k_length);
decoder.Get(reinterpret_cast<CryptoPP::byte*>(&dst[0]), dst.size());
nu_G_k.clear();