diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-05-13 17:20:01 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-05-13 17:20:01 +0100 |
| commit | 6cde6bcc0b604c1a157a4ccbdce29e91f4d45a91 (patch) | |
| tree | 2fb423a179320a64589500f8f3f18d62a2141826 /src/lib | |
| parent | 2a219174c74d922d068f1ca759402bdbd1c36f3c (diff) | |
swaroop: add name to ECinema KDMs and add DKDM wrapper for ECinema.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/decrypted_ecinema_kdm.cc | 6 | ||||
| -rw-r--r-- | src/lib/decrypted_ecinema_kdm.h | 7 | ||||
| -rw-r--r-- | src/lib/dkdm_wrapper.cc | 18 | ||||
| -rw-r--r-- | src/lib/dkdm_wrapper.h | 23 | ||||
| -rw-r--r-- | src/lib/encrypted_ecinema_kdm.cc | 11 | ||||
| -rw-r--r-- | src/lib/encrypted_ecinema_kdm.h | 7 | ||||
| -rw-r--r-- | src/lib/wscript | 1 |
7 files changed, 68 insertions, 5 deletions
diff --git a/src/lib/decrypted_ecinema_kdm.cc b/src/lib/decrypted_ecinema_kdm.cc index a03004e43..14843185f 100644 --- a/src/lib/decrypted_ecinema_kdm.cc +++ b/src/lib/decrypted_ecinema_kdm.cc @@ -34,8 +34,9 @@ using std::string; using std::runtime_error; using dcp::Certificate; -DecryptedECinemaKDM::DecryptedECinemaKDM (string id, dcp::Key content_key) +DecryptedECinemaKDM::DecryptedECinemaKDM (string id, string name, dcp::Key content_key) : _id (id) + , _name (name) , _content_key (content_key) { @@ -43,6 +44,7 @@ DecryptedECinemaKDM::DecryptedECinemaKDM (string id, dcp::Key content_key) DecryptedECinemaKDM::DecryptedECinemaKDM (EncryptedECinemaKDM kdm, string private_key) : _id (kdm.id()) + , _name (kdm.name()) { /* Read the private key */ @@ -68,7 +70,7 @@ DecryptedECinemaKDM::DecryptedECinemaKDM (EncryptedECinemaKDM kdm, string privat EncryptedECinemaKDM DecryptedECinemaKDM::encrypt (Certificate recipient) { - return EncryptedECinemaKDM (_id, _content_key, recipient); + return EncryptedECinemaKDM (_id, _name, _content_key, recipient); } #endif diff --git a/src/lib/decrypted_ecinema_kdm.h b/src/lib/decrypted_ecinema_kdm.h index f61402b7b..0ddc25615 100644 --- a/src/lib/decrypted_ecinema_kdm.h +++ b/src/lib/decrypted_ecinema_kdm.h @@ -28,7 +28,7 @@ class DecryptedECinemaKDM { public: - DecryptedECinemaKDM (std::string id, dcp::Key content_key); + DecryptedECinemaKDM (std::string id, std::string name, dcp::Key content_key); DecryptedECinemaKDM (EncryptedECinemaKDM kdm, std::string private_key); EncryptedECinemaKDM encrypt (dcp::Certificate recipient); @@ -37,12 +37,17 @@ public: return _id; } + std::string name () const { + return _name; + } + dcp::Key key () const { return _content_key; } private: std::string _id; + std::string _name; /** unenecrypted content key */ dcp::Key _content_key; }; diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc index 76f9217aa..0dd37b464 100644 --- a/src/lib/dkdm_wrapper.cc +++ b/src/lib/dkdm_wrapper.cc @@ -34,6 +34,10 @@ DKDMBase::read (cxml::ConstNodePtr node) { if (node->name() == "DKDM") { return shared_ptr<DKDM> (new DKDM (dcp::EncryptedKDM (node->content ()))); +#ifdef DCPOMATIC_VARIANT_SWAROOP + } else if (node->name() == "ECinemaDKDM") { + return shared_ptr<ECinemaDKDM> (new ECinemaDKDM(EncryptedECinemaKDM(node->content()))); +#endif } else if (node->name() == "DKDMGroup") { shared_ptr<DKDMGroup> group (new DKDMGroup (node->string_attribute ("Name"))); BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children()) { @@ -60,6 +64,20 @@ DKDM::as_xml (xmlpp::Element* node) const node->add_child("DKDM")->add_child_text (_dkdm.as_xml ()); } +#ifdef DCPOMATIC_VARIANT_SWAROOP +string +ECinemaDKDM::name () const +{ + return String::compose ("%1 (%2)", _dkdm.name(), _dkdm.id()); +} + +void +ECinemaDKDM::as_xml (xmlpp::Element* node) const +{ + node->add_child("ECinemaDKDM")->add_child_text (_dkdm.as_xml()); +} +#endif + void DKDMGroup::as_xml (xmlpp::Element* node) const { diff --git a/src/lib/dkdm_wrapper.h b/src/lib/dkdm_wrapper.h index 09e9d25c4..d828ffac2 100644 --- a/src/lib/dkdm_wrapper.h +++ b/src/lib/dkdm_wrapper.h @@ -18,6 +18,9 @@ */ +#ifdef DCPOMATIC_VARIANT_SWAROOP +#include "encrypted_ecinema_kdm.h" +#endif #include <dcp/encrypted_kdm.h> #include <libcxml/cxml.h> #include <boost/enable_shared_from_this.hpp> @@ -67,6 +70,26 @@ private: dcp::EncryptedKDM _dkdm; }; +#ifdef DCPOMATIC_VARIANT_SWAROOP +class ECinemaDKDM : public DKDMBase +{ +public: + explicit ECinemaDKDM (EncryptedECinemaKDM k) + : _dkdm (k) + {} + + std::string name () const; + void as_xml (xmlpp::Element *) const; + + EncryptedECinemaKDM dkdm () const { + return _dkdm; + } + +private: + EncryptedECinemaKDM _dkdm; +}; +#endif + class DKDMGroup : public DKDMBase { public: diff --git a/src/lib/encrypted_ecinema_kdm.cc b/src/lib/encrypted_ecinema_kdm.cc index ab9e15e85..e4e19d7fb 100644 --- a/src/lib/encrypted_ecinema_kdm.cc +++ b/src/lib/encrypted_ecinema_kdm.cc @@ -21,12 +21,14 @@ #ifdef DCPOMATIC_VARIANT_SWAROOP #include "encrypted_ecinema_kdm.h" +#include "exceptions.h" #include <dcp/key.h> #include <dcp/certificate.h> #include <dcp/util.h> #include <libcxml/cxml.h> #include <libxml++/libxml++.h> #include <openssl/rsa.h> +#include <openssl/err.h> #include <iostream> using std::cout; @@ -34,12 +36,17 @@ using std::string; using boost::shared_ptr; using dcp::Certificate; -EncryptedECinemaKDM::EncryptedECinemaKDM (string id, dcp::Key content_key, Certificate recipient) +EncryptedECinemaKDM::EncryptedECinemaKDM (string id, string name, dcp::Key content_key, Certificate recipient) : _id (id) + , _name (name) { RSA* rsa = recipient.public_key (); _content_key = dcp::Data (RSA_size(rsa)); int const N = RSA_public_encrypt (content_key.length(), content_key.value(), _content_key.data().get(), rsa, RSA_PKCS1_OAEP_PADDING); + if (N == -1) { + throw KDMError ("Could not encrypt ECinema KDM", ERR_error_string(ERR_get_error(), 0)); + } + } EncryptedECinemaKDM::EncryptedECinemaKDM (string xml) @@ -47,6 +54,7 @@ EncryptedECinemaKDM::EncryptedECinemaKDM (string xml) cxml::Document doc ("ECinemaSecurityMessage"); doc.read_string (xml); _id = doc.string_child ("Id"); + _name = doc.string_child ("Name"); _content_key = dcp::Data (256); int const len = dcp::base64_decode (doc.string_child("Key"), _content_key.data().get(), _content_key.size()); _content_key.set_size (len); @@ -72,6 +80,7 @@ EncryptedECinemaKDM::as_xml () const xmlpp::Document document; xmlpp::Element* root = document.create_root_node ("ECinemaSecurityMessage"); root->add_child("Id")->add_child_text(_id); + root->add_child("Name")->add_child_text(_name); root->add_child("Key")->add_child_text(lines); return document.write_to_string ("UTF-8"); } diff --git a/src/lib/encrypted_ecinema_kdm.h b/src/lib/encrypted_ecinema_kdm.h index ece1e3161..0bcbc4117 100644 --- a/src/lib/encrypted_ecinema_kdm.h +++ b/src/lib/encrypted_ecinema_kdm.h @@ -40,6 +40,10 @@ public: return _id; } + std::string name () const { + return _name; + } + dcp::Data key () const { return _content_key; } @@ -47,9 +51,10 @@ public: private: friend class DecryptedECinemaKDM; - EncryptedECinemaKDM (std::string id, dcp::Key key, dcp::Certificate recipient); + EncryptedECinemaKDM (std::string id, std::string name, dcp::Key key, dcp::Certificate recipient); std::string _id; + std::string _name; /** encrypted content key */ dcp::Data _content_key; }; diff --git a/src/lib/wscript b/src/lib/wscript index c5a270f65..37b942400 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -77,6 +77,7 @@ sources = """ digester.cc dkdm_wrapper.cc dolby_cp750.cc + ecinema_screen_kdm.cc edid.cc emailer.cc empty.cc |
