Commit d22ec9d5 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Add name member to Key.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 959d98d0
......@@ -21,6 +21,7 @@
#include <regex>
#include <assert.h>
#include <cinttypes>
using std::string;
using std::vector;
......@@ -203,6 +204,7 @@ void
Key::set_test_key (uint64_t key)
{
uint64_to_buffer (key, m_aes_key.data());
m_name = string_printf ("test-key-%" PRId64, key);
}
void
......@@ -214,6 +216,11 @@ Key::load_key (const string& key_file)
error ("audiowmark: error opening key file: '%s'\n", key_file.c_str());
exit (1);
}
m_name = key_file;
// basename
size_t sep = m_name.find_last_of ("\\/");
if (sep != string::npos)
m_name = m_name.substr (sep + 1);
const regex blank_re (R"(\s*(#.*)?[\r\n]+)");
const regex key_re (R"(\s*key\s+([0-9a-f]+)\s*(#.*)?[\r\n]+)");
......@@ -269,3 +276,9 @@ Key::aes_key() const
assert (m_aes_key.size() == SIZE);
return m_aes_key.data();
}
const string&
Key::name() const
{
return m_name;
}
......@@ -28,6 +28,7 @@
class Key
{
std::vector<unsigned char> m_aes_key;
std::string m_name;
public:
static constexpr size_t SIZE = 16; /* 128 bits */
......@@ -37,6 +38,7 @@ public:
void set_test_key (uint64_t key);
void load_key (const std::string& filename);
const unsigned char *aes_key() const;
const std::string& name() const;
};
class Random
......
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