diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-02-14 16:26:15 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-02-14 16:26:15 +0000 |
| commit | 297de9fa11c6cc296be22b227b33dcd13e2b0462 (patch) | |
| tree | 877d53d0fcfbf4ac1653a93c1dadb7b49be53852 /src | |
| parent | 1a1f074d64d05ba9108e9046a44b98a1976e5ef2 (diff) | |
Tidy up storage of key type in DecryptedKDMKey.
Diffstat (limited to 'src')
| -rw-r--r-- | src/decrypted_kdm.cc | 11 | ||||
| -rw-r--r-- | src/decrypted_kdm.h | 2 | ||||
| -rw-r--r-- | src/decrypted_kdm_key.h | 7 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index 8355e1c8..96d5f225 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -58,6 +58,7 @@ using std::hex; using std::pair; using std::map; using boost::shared_ptr; +using boost::optional; using namespace dcp; static void @@ -166,7 +167,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key) /* 93 is not-valid-after (a string) [25 bytes] */ p += 25; /* 118 is the key [ASDCP::KeyLen bytes] */ - add_key ("", key_id, Key (p), cpl_id); + add_key (optional<string>(), key_id, Key (p), cpl_id); break; } case 138: @@ -277,7 +278,7 @@ DecryptedKDM::DecryptedKDM ( * @param cpl_id ID of CPL that the key is for. */ void -DecryptedKDM::add_key (string type, string key_id, Key key, string cpl_id) +DecryptedKDM::add_key (optional<string> type, string key_id, Key key, string cpl_id) { _keys.push_back (DecryptedKDMKey (type, key_id, key, cpl_id)); } @@ -294,7 +295,9 @@ DecryptedKDM::encrypt (shared_ptr<const CertificateChain> signer, Certificate re list<pair<string, string> > key_ids; list<string> keys; BOOST_FOREACH (DecryptedKDMKey const & i, _keys) { - key_ids.push_back (make_pair (i.type(), i.id ())); + /* We're making SMPTE keys so we must have a type for each one */ + DCP_ASSERT (i.type()); + key_ids.push_back (make_pair (i.type().get(), i.id ())); /* XXX: SMPTE only */ uint8_t block[138]; @@ -308,7 +311,7 @@ DecryptedKDM::encrypt (shared_ptr<const CertificateChain> signer, Certificate re p += 20; put_uuid (&p, i.cpl_id ()); - put (&p, i.type ()); + put (&p, i.type().get()); put_uuid (&p, i.id ()); put (&p, _not_valid_before.as_string ()); put (&p, _not_valid_after.as_string ()); diff --git a/src/decrypted_kdm.h b/src/decrypted_kdm.h index 752ced04..585cc615 100644 --- a/src/decrypted_kdm.h +++ b/src/decrypted_kdm.h @@ -133,7 +133,7 @@ public: Formulation formulation ) const; - void add_key (std::string type, std::string key_id, Key key, std::string cpl_id); + void add_key (boost::optional<std::string> type, std::string key_id, Key key, std::string cpl_id); void add_key (DecryptedKDMKey key); /** @return This KDM's (decrypted) keys, which could be used to decrypt assets. */ diff --git a/src/decrypted_kdm_key.h b/src/decrypted_kdm_key.h index 95ffccb8..1e03ee0a 100644 --- a/src/decrypted_kdm_key.h +++ b/src/decrypted_kdm_key.h @@ -39,6 +39,7 @@ #define LIBDCP_DECRYPTED_KDM_KEY_H #include "key.h" +#include <boost/optional.hpp> namespace dcp { @@ -48,14 +49,14 @@ namespace dcp { class DecryptedKDMKey { public: - DecryptedKDMKey (std::string type, std::string id, Key key, std::string cpl_id) + DecryptedKDMKey (boost::optional<std::string> type, std::string id, Key key, std::string cpl_id) : _type (type) , _id (id) , _key (key) , _cpl_id (cpl_id) {} - std::string type () const { + boost::optional<std::string> type () const { return _type; } @@ -72,7 +73,7 @@ public: } private: - std::string _type; + boost::optional<std::string> _type; std::string _id; Key _key; std::string _cpl_id; |
