Commit ded2bdf1 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Cleanup random debugging code.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent ee46a524
......@@ -40,15 +40,20 @@ uint64_from_buffer (unsigned char *buffer)
+ buffer[7];
}
Random::Random (uint64_t seed, Stream stream)
static void
print (const string& label, const vector<unsigned char>& data)
{
std::vector<unsigned char> ctr = get_start_counter (seed, stream);
#if 0
printf ("CTR: ");
for (auto ch : ctr)
printf ("%s: ", label.c_str());
for (auto ch : data)
printf ("%02x ", ch);
printf ("\n");
#endif
}
Random::Random (uint64_t seed, Stream stream)
{
std::vector<unsigned char> ctr = get_start_counter (seed, stream);
// print ("CTR", ctr);
gcry_error_t gcry_ret = gcry_cipher_open (&aes_ctr_cipher, GCRY_CIPHER, GCRY_CIPHER_MODE_CTR, 0);
die_on_error ("gcry_cipher_open", gcry_ret);
......@@ -84,12 +89,7 @@ Random::get_start_counter (uint64_t seed, Stream stream)
plain_text[8] = uint8_t (stream);
#if 0
printf ("[[ ");
for (auto ch : plain_text)
printf ("%02x ", ch);
printf (" ]]\n");
#endif
// print ("SEED", plain_text);
gcry_ret = gcry_cipher_encrypt (cipher_hd, &cipher_text[0], cipher_text.size(),
&plain_text[0], plain_text.size());
......@@ -97,13 +97,6 @@ Random::get_start_counter (uint64_t seed, Stream stream)
gcry_cipher_close (cipher_hd);
#if 0
printf ("[[ ");
for (auto ch : cipher_text)
printf ("%02x ", ch);
printf (" ]]\n");
#endif
return cipher_text;
}
......@@ -117,12 +110,8 @@ Random::operator()()
gcry_error_t gcry_ret = gcry_cipher_encrypt (aes_ctr_cipher, cipher_text, block_size, zeros, block_size);
die_on_error ("gcry_cipher_encrypt", gcry_ret);
#if 0
printf ("[[ ");
for (auto ch : cipher_text)
printf ("%02x ", ch);
printf (" ]]\n");
#endif
// print ("AES OUT", {cipher_text, cipher_text + block_size});
return uint64_from_buffer (&cipher_text[0]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment