openjpeg-cdist bump again.
[libdcp.git] / src / decrypted_kdm.cc
index 556cd9d54316e9f86d35f4490b54d441aeec2a39..02515fe879a3079488e91c8096e79dc7d86f8f2a 100644 (file)
@@ -20,6 +20,7 @@
 #include "decrypted_kdm.h"
 #include "decrypted_kdm_key.h"
 #include "encrypted_kdm.h"
+#include "reel_mxf_asset.h"
 #include "util.h"
 #include "exceptions.h"
 #include "cpl.h"
@@ -184,6 +185,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
 
 DecryptedKDM::DecryptedKDM (
        boost::shared_ptr<const CPL> cpl,
+       Key key,
        LocalTime not_valid_before,
        LocalTime not_valid_after,
        string annotation_text,
@@ -197,21 +199,21 @@ DecryptedKDM::DecryptedKDM (
        , _issue_date (issue_date)
 {
        /* Create DecryptedKDMKey objects for each MXF asset */
-       list<shared_ptr<const Content> > content = cpl->content ();
-       for (list<shared_ptr<const Content> >::iterator i = content.begin(); i != content.end(); ++i) {
+       list<shared_ptr<const ReelAsset> > assets = cpl->reel_assets ();
+       for (list<shared_ptr<const ReelAsset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
                /* XXX: do non-MXF assets need keys? */
-               shared_ptr<const MXF> mxf = boost::dynamic_pointer_cast<const MXF> (*i);
+               shared_ptr<const ReelMXFAsset> mxf = boost::dynamic_pointer_cast<const ReelMXFAsset> (*i);
                if (mxf) {
                        if (mxf->key_id().empty ()) {
-                               throw NotEncryptedError (mxf->file().string ());
+                               throw NotEncryptedError (mxf->id());
                        }
-                       _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id(), mxf->key().get (), cpl->id ()));
+                       _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id(), key, cpl->id ()));
                }
        }
 }
 
 EncryptedKDM
-DecryptedKDM::encrypt (shared_ptr<const Signer> signer, shared_ptr<const Certificate> recipient, Formulation formulation) const
+DecryptedKDM::encrypt (shared_ptr<const Signer> signer, Certificate recipient, Formulation formulation) const
 {
        list<pair<string, string> > key_ids;
        list<string> keys;
@@ -227,7 +229,7 @@ DecryptedKDM::encrypt (shared_ptr<const Signer> signer, shared_ptr<const Certifi
                uint8_t structure_id[] = { 0xf1, 0xdc, 0x12, 0x44, 0x60, 0x16, 0x9a, 0x0e, 0x85, 0xbc, 0x30, 0x06, 0x42, 0xf8, 0x66, 0xab };
                put (&p, structure_id, 16);
 
-               base64_decode (signer->certificates().leaf()->thumbprint (), p, 20);
+               base64_decode (signer->certificates().leaf().thumbprint (), p, 20);
                p += 20;
                
                put_uuid (&p, i->cpl_id ());
@@ -238,7 +240,7 @@ DecryptedKDM::encrypt (shared_ptr<const Signer> signer, shared_ptr<const Certifi
                put (&p, i->key().value(), ASDCP::KeyLen);
                
                /* Encrypt using the projector's public key */
-               RSA* rsa = recipient->public_key ();
+               RSA* rsa = recipient.public_key ();
                unsigned char encrypted[RSA_size(rsa)];
                int const encrypted_len = RSA_public_encrypt (p - block, block, encrypted, rsa, RSA_PKCS1_OAEP_PADDING);
                if (encrypted_len == -1) {
@@ -260,7 +262,7 @@ DecryptedKDM::encrypt (shared_ptr<const Signer> signer, shared_ptr<const Certifi
                keys.push_back (lines.str ());
        }
 
-       string device_list_description = recipient->common_name ();
+       string device_list_description = recipient.common_name ();
        if (device_list_description.find (".") != string::npos) {
                device_list_description = device_list_description.substr (device_list_description.find (".") + 1);
        }