Commit 76622bde authored by Stefan Westerfeld's avatar Stefan Westerfeld

Add missing gcrypt initialization.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 1d703405
......@@ -10,6 +10,23 @@ using std::vector;
using std::regex;
using std::regex_match;
static void
gcrypt_init()
{
static bool init_ok = false;
if (!init_ok)
{
if (!gcry_check_version (GCRYPT_VERSION))
{
fprintf (stderr, "audiowmark: libgcrypt version mismatch\n");
exit (1);
}
init_ok = true;
}
}
static vector<unsigned char> aes_key (16); // 128 bits
static constexpr auto GCRY_CIPHER = GCRY_CIPHER_AES128;
......@@ -55,6 +72,8 @@ print (const string& label, const vector<unsigned char>& data)
Random::Random (uint64_t seed, Stream stream)
{
gcrypt_init();
vector<unsigned char> ctr = get_start_counter (seed, stream);
// print ("CTR", ctr);
......@@ -201,6 +220,8 @@ Random::load_global_key (const string& key_file)
string
Random::gen_key()
{
gcrypt_init();
vector<unsigned char> key (16);
gcry_randomize (&key[0], 16, /* long term key material strength */ GCRY_VERY_STRONG_RANDOM);
return vec_to_hex_str (key);
......
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