generator: use de_hex()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-30 22:40:21 +01:00
parent fa9dc26f66
commit c6bf1c7f52
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -73,7 +73,7 @@ auto Generator::reseed(const std::string& s) -> void {
try {
std::string a{fortuna::Util::do_sha(da_key + s)};
std::memmove(G.k, a.c_str(), G.k_length);
std::memmove(G.k, fortuna::Util::de_hex(a).c_str(), G.k_length);
++G.ctr;
fmt::print("[i] generator: reseeded\n");
}
@ -196,15 +196,7 @@ auto Generator::generate_random_data(const unsigned int& n) -> std::string {
try {
std::string nu_G_k{generate_blocks(2)};
// fmt::print("nu_G_k: {}\n", nu_G_k); // debugging
std::string 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());
std::string dst{fortuna::Util::de_hex(nu_G_k)};
nu_G_k.clear();