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/encrypted_ecinema_kdm.cc | |
| parent | 2a219174c74d922d068f1ca759402bdbd1c36f3c (diff) | |
swaroop: add name to ECinema KDMs and add DKDM wrapper for ECinema.
Diffstat (limited to 'src/lib/encrypted_ecinema_kdm.cc')
| -rw-r--r-- | src/lib/encrypted_ecinema_kdm.cc | 11 |
1 files changed, 10 insertions, 1 deletions
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"); } |
