summaryrefslogtreecommitdiff
path: root/src/dcp.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-07 00:39:15 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-07 00:39:15 +0100
commit932b942a51bef4e2dd2de9f83aa5b68ad07f60f9 (patch)
tree40f81e0b4b2e04f46bab243e9c94ff24b8bcb2ef /src/dcp.cc
parent4313456938d34d93239194e914b82e7a5ae14c1c (diff)
Working decryption via KDM.
Diffstat (limited to 'src/dcp.cc')
-rw-r--r--src/dcp.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/dcp.cc b/src/dcp.cc
index c2118ed0..684e249d 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -46,6 +46,7 @@
#include "reel.h"
#include "cpl.h"
#include "encryption.h"
+#include "kdm.h"
using std::string;
using std::list;
@@ -65,7 +66,7 @@ DCP::DCP (string directory)
void
DCP::write_xml (XMLMetadata const & metadata, shared_ptr<Encryption> crypt) const
{
- for (list<shared_ptr<const CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
+ for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
(*i)->write_xml (metadata, crypt);
}
@@ -106,7 +107,7 @@ DCP::write_pkl (string pkl_uuid, XMLMetadata const & metadata, shared_ptr<Encryp
(*i)->write_to_pkl (asset_list);
}
- for (list<shared_ptr<const CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
+ for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
(*i)->write_to_pkl (asset_list);
}
@@ -158,7 +159,7 @@ DCP::write_assetmap (string pkl_uuid, int pkl_length, XMLMetadata const & metada
chunk->add_child("Offset")->add_child_text ("0");
chunk->add_child("Length")->add_child_text (lexical_cast<string> (pkl_length));
- for (list<shared_ptr<const CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
+ for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
(*i)->write_to_assetmap (asset_list);
}
@@ -261,8 +262,8 @@ DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (NoteT
return false;
}
- list<shared_ptr<const CPL> >::const_iterator a = _cpls.begin ();
- list<shared_ptr<const CPL> >::const_iterator b = other._cpls.begin ();
+ list<shared_ptr<CPL> >::const_iterator a = _cpls.begin ();
+ list<shared_ptr<CPL> >::const_iterator b = other._cpls.begin ();
while (a != _cpls.end ()) {
if (!(*a)->equals (*b->get(), opt, note)) {
@@ -293,7 +294,7 @@ list<shared_ptr<const Asset> >
DCP::assets () const
{
list<shared_ptr<const Asset> > a;
- for (list<shared_ptr<const CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
+ for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
list<shared_ptr<const Asset> > t = (*i)->assets ();
a.merge (t);
}
@@ -306,7 +307,7 @@ DCP::assets () const
bool
DCP::encrypted () const
{
- for (list<shared_ptr<const CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
+ for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
if ((*i)->encrypted ()) {
return true;
}
@@ -314,3 +315,17 @@ DCP::encrypted () const
return false;
}
+
+void
+DCP::add_kdm (KDM const & kdm)
+{
+ list<KDMCipher> ciphers = kdm.ciphers ();
+
+ for (list<shared_ptr<CPL> >::iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
+ for (list<KDMCipher>::iterator j = ciphers.begin(); j != ciphers.end(); ++j) {
+ if (j->cpl_id() == (*i)->id()) {
+ (*i)->add_kdm (kdm);
+ }
+ }
+ }
+}