/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
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
*/
-#include <iomanip>
-#include <algorithm>
-#include <boost/algorithm/string.hpp>
-#include <openssl/rsa.h>
-#include <openssl/pem.h>
-#include <openssl/err.h>
-#include <libcxml/cxml.h>
-#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 <libcxml/cxml.h>
+#include <openssl/rsa.h>
+#include <openssl/pem.h>
+#include <openssl/err.h>
+#include <boost/algorithm/string.hpp>
+#include <iomanip>
+#include <algorithm>
using std::list;
using std::string;
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 */
}
KDM::KDM (
- shared_ptr<const CPL> cpl, shared_ptr<const Signer> signer, shared_ptr<const Certificate> recipient_cert,
+ boost::shared_ptr<const CPL> cpl,
+ boost::shared_ptr<const Signer> signer,
+ boost::shared_ptr<const Certificate> recipient_cert,
boost::posix_time::ptime not_valid_before, boost::posix_time::ptime not_valid_after,
string annotation_text, string issue_date
)
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 ();
*/
apu.authorized_device_info.device_list.push_back ("2jmj7l5rSw0yVb/vlWAYkK/YBwk=");
- list<shared_ptr<const Asset> > assets = cpl->assets ();
- for (list<shared_ptr<const Asset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
+ list<shared_ptr<const Content> > content = cpl->content ();
+ for (list<shared_ptr<const Content> >::iterator i = content.begin(); i != content.end(); ++i) {
/* XXX: non-MXF assets? */
- shared_ptr<const MXFAsset> mxf = boost::dynamic_pointer_cast<const MXFAsset> (*i);
+ shared_ptr<const MXF> mxf = boost::dynamic_pointer_cast<const MXF> (*i);
if (mxf) {
apu.key_id_list.push_back (xml::TypedKeyId (mxf->key_type(), "urn:uuid:" + mxf->key_id()));
}
/* AuthenticatedPrivate */
- for (list<shared_ptr<const Asset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
+ for (list<shared_ptr<const Content> >::iterator i = content.begin(); i != content.end(); ++i) {
/* XXX: non-MXF assets? */
- shared_ptr<const MXFAsset> mxf = boost::dynamic_pointer_cast<const MXFAsset> (*i);
+ shared_ptr<const MXF> mxf = boost::dynamic_pointer_cast<const MXF> (*i);
if (mxf) {
KDMKey kkey (
signer, cpl->id (), mxf->key_type (), mxf->key_id (),
}
KDMKey::KDMKey (
- shared_ptr<const Signer> 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<const Signer> 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)
}
string
-KDMKey::encrypted_base64 (shared_ptr<const Certificate> recipient_cert) const
+KDMKey::encrypted_base64 (boost::shared_ptr<const Certificate> recipient_cert) const
{
assert (_key_type.length() == 4);
assert (_not_valid_before.length() == 25);
}
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;