Various work.
[libdcp.git] / src / kdm.cc
index 2005f58a49e3aa82754c426dfe20287f62db22dd..bdfa1fec458b6f83026b8a21d08dcee829fe9679 100644 (file)
@@ -32,7 +32,7 @@
 #include "exceptions.h"
 #include "signer.h"
 #include "cpl.h"
-#include "mxf_asset.h"
+#include "mxf.h"
 #include "xml/kdm_smpte.h"
 
 using std::list;
@@ -43,22 +43,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 */
@@ -124,10 +124,10 @@ KDM::KDM (
        */
        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> > assets = cpl->assets ();
+       for (list<shared_ptr<const Content> >::iterator i = assets.begin(); i != assets.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()));
                }
@@ -138,9 +138,9 @@ KDM::KDM (
 
        /* AuthenticatedPrivate */
 
-       for (list<shared_ptr<const Asset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
+       for (list<shared_ptr<const Content> >::iterator i = assets.begin(); i != assets.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 (),
@@ -383,7 +383,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;