X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fkdm.cc;h=fe7fe393381a8c977dd62e6c71012fb0283f944f;hb=f9862aff32f7ea5aa10f9362d7598480b1c9cf28;hp=80d64441bddf128d6b8771ccb8bc1e2e1b589414;hpb=cccab9e0c03bf03e51a8924c05b6e5ed74d94e99;p=libdcp.git diff --git a/src/kdm.cc b/src/kdm.cc index 80d64441..fe7fe393 100644 --- a/src/kdm.cc +++ b/src/kdm.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,23 +17,27 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include "AS_DCP.h" -#include "KM_util.h" +/** @file src/kdm.cc + * @brief KDM and KDMKey classes. + */ + #include "util.h" #include "kdm.h" #include "compose.hpp" #include "exceptions.h" #include "signer.h" #include "cpl.h" -#include "mxf_asset.h" -#include "xml/kdm_smpte.h" +#include "mxf.h" +#include "kdm_smpte_xml.h" +#include "AS_DCP.h" +#include "KM_util.h" +#include +#include +#include +#include +#include +#include +#include using std::list; using std::string; @@ -43,22 +47,22 @@ using std::setw; using std::setfill; using std::cout; using boost::shared_ptr; -using namespace libdcp; +using namespace dcp; KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key) : _xml_kdm (new xml::DCinemaSecurityMessage (kdm)) { /* Read the private key */ - FILE* private_key_file = fopen (private_key.string().c_str(), "r"); + FILE* private_key_file = fopen_boost (private_key, "r"); if (!private_key_file) { - throw FileError ("could not find RSA private key file", private_key); + throw FileError ("could not find RSA private key file", private_key, errno); } RSA* rsa = PEM_read_RSAPrivateKey (private_key_file, 0, 0, 0); fclose (private_key_file); if (!rsa) { - throw FileError ("could not read RSA private key file", private_key); + throw FileError ("could not read RSA private key file", private_key, errno); } /* Use it to decrypt the keys */ @@ -87,7 +91,9 @@ KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key) } KDM::KDM ( - shared_ptr cpl, shared_ptr signer, shared_ptr recipient_cert, + boost::shared_ptr cpl, + boost::shared_ptr signer, + boost::shared_ptr recipient_cert, boost::posix_time::ptime not_valid_before, boost::posix_time::ptime not_valid_after, string annotation_text, string issue_date ) @@ -108,7 +114,7 @@ KDM::KDM ( apu.recipient.x509_subject_name = recipient_cert->subject (); apu.composition_playlist_id = "urn:uuid:" + cpl->id (); // apu.content_authenticator = signer->certificates().leaf()->thumbprint (); - apu.content_title_text = cpl->name (); + apu.content_title_text = cpl->content_title_text (); apu.content_keys_not_valid_before = ptime_to_string (not_valid_before); apu.content_keys_not_valid_after = ptime_to_string (not_valid_after); apu.authorized_device_info.device_list_identifier = "urn:uuid:" + make_uuid (); @@ -117,12 +123,17 @@ KDM::KDM ( n = n.substr (n.find (".") + 1); } apu.authorized_device_info.device_list_description = n; - apu.authorized_device_info.device_list.push_back (recipient_cert->thumbprint ()); +// apu.authorized_device_info.device_list.push_back (recipient_cert->thumbprint ()); + + /* Sometimes digital_cinema_tools uses this magic thumbprint instead of that from an actual + recipient certificate. KDMs delivered to City Screen appear to use the same thing. + */ + apu.authorized_device_info.device_list.push_back ("2jmj7l5rSw0yVb/vlWAYkK/YBwk="); - list > assets = cpl->assets (); - for (list >::iterator i = assets.begin(); i != assets.end(); ++i) { + list > content = cpl->content (); + for (list >::iterator i = content.begin(); i != content.end(); ++i) { /* XXX: non-MXF assets? */ - shared_ptr mxf = boost::dynamic_pointer_cast (*i); + shared_ptr mxf = boost::dynamic_pointer_cast (*i); if (mxf) { apu.key_id_list.push_back (xml::TypedKeyId (mxf->key_type(), "urn:uuid:" + mxf->key_id())); } @@ -133,9 +144,9 @@ KDM::KDM ( /* AuthenticatedPrivate */ - for (list >::iterator i = assets.begin(); i != assets.end(); ++i) { + for (list >::iterator i = content.begin(); i != content.end(); ++i) { /* XXX: non-MXF assets? */ - shared_ptr mxf = boost::dynamic_pointer_cast (*i); + shared_ptr mxf = boost::dynamic_pointer_cast (*i); if (mxf) { KDMKey kkey ( signer, cpl->id (), mxf->key_type (), mxf->key_id (), @@ -197,7 +208,13 @@ KDM::as_xml () const } KDMKey::KDMKey ( - shared_ptr signer, string cpl_id, string key_type, string key_id, boost::posix_time::ptime from, boost::posix_time::ptime until, Key key + boost::shared_ptr signer, + string cpl_id, + string key_type, + string key_id, + boost::posix_time::ptime from, + boost::posix_time::ptime until, + Key key ) : _cpl_id (cpl_id) , _key_type (key_type) @@ -270,7 +287,7 @@ KDMKey::operator= (KDMKey const & other) } string -KDMKey::encrypted_base64 (shared_ptr recipient_cert) const +KDMKey::encrypted_base64 (boost::shared_ptr recipient_cert) const { assert (_key_type.length() == 4); assert (_not_valid_before.length() == 25); @@ -378,7 +395,7 @@ KDMKey::put_uuid (uint8_t ** d, string id) const } bool -libdcp::operator== (libdcp::KDMKey const & a, libdcp::KDMKey const & b) +dcp::operator== (dcp::KDMKey const & a, dcp::KDMKey const & b) { if (memcmp (a._signer_thumbprint, b._signer_thumbprint, 20) != 0) { return false;