From 8d6c3c9ae554430582dcb016897e87f6d04d5d78 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 19 Sep 2013 20:44:42 +0100 Subject: Various encryption-related stuff. --- src/kdm.cc | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src/kdm.cc') diff --git a/src/kdm.cc b/src/kdm.cc index 09935ca3..bbfd3832 100644 --- a/src/kdm.cc +++ b/src/kdm.cc @@ -80,7 +80,7 @@ KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key) throw MiscError (String::compose ("Could not decrypt KDM (%1)", ERR_error_string (ERR_get_error(), 0))); } - _ciphers.push_back (KDMCipher (decrypted, decrypted_len)); + _keys.push_back (KDMKey (decrypted, decrypted_len)); delete[] decrypted; } @@ -88,7 +88,7 @@ KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key) } -KDMCipher::KDMCipher (unsigned char const * raw, int len) +KDMKey::KDMKey (unsigned char const * raw, int len) { switch (len) { case 134: @@ -99,8 +99,7 @@ KDMCipher::KDMCipher (unsigned char const * raw, int len) _key_id = get_uuid (&raw, 16); _not_valid_before = get (&raw, 25); _not_valid_after = get (&raw, 25); - memcpy (_key_raw, raw, 16); - _key_string = get_hex (&raw, 16); + _key = Key (raw); break; case 138: /* SMPTE */ @@ -111,8 +110,7 @@ KDMCipher::KDMCipher (unsigned char const * raw, int len) _key_id = get_uuid (&raw, 16); _not_valid_before = get (&raw, 25); _not_valid_after = get (&raw, 25); - memcpy (_key_raw, raw, 16); - _key_string = get_hex (&raw, 16); + _key = Key (raw); break; default: assert (false); @@ -120,7 +118,7 @@ KDMCipher::KDMCipher (unsigned char const * raw, int len) } string -KDMCipher::get (unsigned char const ** p, int N) const +KDMKey::get (unsigned char const ** p, int N) const { string g; for (int i = 0; i < N; ++i) { @@ -132,7 +130,7 @@ KDMCipher::get (unsigned char const ** p, int N) const } string -KDMCipher::get_uuid (unsigned char const ** p, int N) const +KDMKey::get_uuid (unsigned char const ** p, int N) const { stringstream g; @@ -146,16 +144,3 @@ KDMCipher::get_uuid (unsigned char const ** p, int N) const return g.str (); } - -string -KDMCipher::get_hex (unsigned char const ** p, int N) const -{ - stringstream g; - - for (int i = 0; i < N; ++i) { - g << setw(2) << setfill('0') << hex << static_cast (**p); - (*p)++; - } - - return g.str (); -} -- cgit v1.2.3