Merge branch '1.0' of git.carlh.net:git/libdcp into 1.0
[libdcp.git] / src / encrypted_kdm.cc
1 /*
2     Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "encrypted_kdm.h"
21 #include "util.h"
22 #include "certificate_chain.h"
23 #include <libcxml/cxml.h>
24 #include <libxml++/document.h>
25 #include <libxml++/nodes/element.h>
26 #include <libxml/parser.h>
27 #include <boost/date_time/posix_time/posix_time.hpp>
28 #include <boost/foreach.hpp>
29
30 using std::list;
31 using std::vector;
32 using std::string;
33 using std::map;
34 using std::pair;
35 using boost::shared_ptr;
36 using boost::optional;
37 using namespace dcp;
38
39 namespace dcp {
40
41 /** Namespace for classes used to hold our data; they are internal to this .cc file */
42 namespace data {
43
44 class Signer
45 {
46 public:
47         Signer () {}
48
49         Signer (shared_ptr<const cxml::Node> node)
50                 : x509_issuer_name (node->string_child ("X509IssuerName"))
51                 , x509_serial_number (node->string_child ("X509SerialNumber"))
52         {
53
54         }
55
56         void as_xml (xmlpp::Element* node) const
57         {
58                 node->add_child("X509IssuerName", "ds")->add_child_text (x509_issuer_name);
59                 node->add_child("X509SerialNumber", "ds")->add_child_text (x509_serial_number);
60         }
61
62         string x509_issuer_name;
63         string x509_serial_number;
64 };
65
66 class X509Data
67 {
68 public:
69         X509Data () {}
70
71         X509Data (boost::shared_ptr<const cxml::Node> node)
72                 : x509_issuer_serial (Signer (node->node_child ("X509IssuerSerial")))
73                 , x509_certificate (node->string_child ("X509Certificate"))
74         {
75                 node->done ();
76         }
77
78         void as_xml (xmlpp::Element* node) const
79         {
80                 x509_issuer_serial.as_xml (node->add_child ("X509IssuerSerial", "ds"));
81                 node->add_child("X509Certificate", "ds")->add_child_text (x509_certificate);
82         }
83
84         Signer x509_issuer_serial;
85         std::string x509_certificate;
86 };
87
88 class Reference
89 {
90 public:
91         Reference () {}
92
93         Reference (string u)
94                 : uri (u)
95         {}
96
97         Reference (shared_ptr<const cxml::Node> node)
98                 : uri (node->string_attribute ("URI"))
99                 , digest_value (node->string_child ("DigestValue"))
100         {
101
102         }
103
104         void as_xml (xmlpp::Element* node) const
105         {
106                 node->set_attribute ("URI", uri);
107                 node->add_child("DigestMethod", "ds")->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256");
108                 node->add_child("DigestValue", "ds")->add_child_text (digest_value);
109         }
110
111         string uri;
112         string digest_value;
113 };
114
115 class SignedInfo
116 {
117 public:
118         SignedInfo ()
119                 : authenticated_public ("#ID_AuthenticatedPublic")
120                 , authenticated_private ("#ID_AuthenticatedPrivate")
121         {}
122
123         SignedInfo (shared_ptr<const cxml::Node> node)
124         {
125                 list<shared_ptr<cxml::Node> > references = node->node_children ("Reference");
126                 for (list<shared_ptr<cxml::Node> >::const_iterator i = references.begin(); i != references.end(); ++i) {
127                         if ((*i)->string_attribute ("URI") == "#ID_AuthenticatedPublic") {
128                                 authenticated_public = Reference (*i);
129                         } else if ((*i)->string_attribute ("URI") == "#ID_AuthenticatedPrivate") {
130                                 authenticated_private = Reference (*i);
131                         }
132
133                         /* XXX: do something if we don't recognise the node */
134                 }
135         }
136
137         void as_xml (xmlpp::Element* node) const
138         {
139                 node->add_child ("CanonicalizationMethod", "ds")->set_attribute (
140                         "Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"
141                         );
142
143                 node->add_child ("SignatureMethod", "ds")->set_attribute (
144                         "Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
145                         );
146
147                 authenticated_public.as_xml (node->add_child ("Reference", "ds"));
148                 authenticated_private.as_xml (node->add_child ("Reference", "ds"));
149         }
150
151 private:
152         Reference authenticated_public;
153         Reference authenticated_private;
154 };
155
156 class Signature
157 {
158 public:
159         Signature () {}
160
161         Signature (shared_ptr<const cxml::Node> node)
162                 : signed_info (node->node_child ("SignedInfo"))
163                 , signature_value (node->string_child ("SignatureValue"))
164         {
165                 list<shared_ptr<cxml::Node> > x509_data_nodes = node->node_child("KeyInfo")->node_children ("X509Data");
166                 for (list<shared_ptr<cxml::Node> >::const_iterator i = x509_data_nodes.begin(); i != x509_data_nodes.end(); ++i) {
167                         x509_data.push_back (X509Data (*i));
168                 }
169         }
170
171         void as_xml (xmlpp::Node* node) const
172         {
173                 signed_info.as_xml (node->add_child ("SignedInfo", "ds"));
174                 node->add_child("SignatureValue", "ds")->add_child_text (signature_value);
175
176                 xmlpp::Element* key_info_node = node->add_child ("KeyInfo", "ds");
177                 for (std::list<X509Data>::const_iterator i = x509_data.begin(); i != x509_data.end(); ++i) {
178                         i->as_xml (key_info_node->add_child ("X509Data", "ds"));
179                 }
180         }
181
182         SignedInfo signed_info;
183         string signature_value;
184         list<X509Data> x509_data;
185 };
186
187 class AuthenticatedPrivate
188 {
189 public:
190         AuthenticatedPrivate () {}
191
192         AuthenticatedPrivate (shared_ptr<const cxml::Node> node)
193         {
194                 list<shared_ptr<cxml::Node> > encrypted_key_nodes = node->node_children ("EncryptedKey");
195                 for (list<shared_ptr<cxml::Node> >::const_iterator i = encrypted_key_nodes.begin(); i != encrypted_key_nodes.end(); ++i) {
196                         encrypted_key.push_back ((*i)->node_child("CipherData")->string_child ("CipherValue"));
197                 }
198         }
199
200         void as_xml (xmlpp::Element* node, map<string, xmlpp::Attribute *>& references) const
201         {
202                 references["ID_AuthenticatedPrivate"] = node->set_attribute ("Id", "ID_AuthenticatedPrivate");
203
204                 for (list<string>::const_iterator i = encrypted_key.begin(); i != encrypted_key.end(); ++i) {
205                         xmlpp::Element* encrypted_key = node->add_child ("EncryptedKey", "enc");
206                         /* XXX: hack for testing with Dolby */
207                         encrypted_key->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc");
208                         xmlpp::Element* encryption_method = encrypted_key->add_child ("EncryptionMethod", "enc");
209                         encryption_method->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
210                         xmlpp::Element* digest_method = encryption_method->add_child ("DigestMethod", "ds");
211                         /* XXX: hack for testing with Dolby */
212                         digest_method->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds");
213                         digest_method->set_attribute ("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
214                         xmlpp::Element* cipher_data = encrypted_key->add_child ("CipherData", "enc");
215                         cipher_data->add_child("CipherValue", "enc")->add_child_text (*i);
216                 }
217         }
218
219         list<string> encrypted_key;
220 };
221
222 class TypedKeyId
223 {
224 public:
225         TypedKeyId () {}
226
227         TypedKeyId (shared_ptr<const cxml::Node> node)
228                 : key_type (node->string_child ("KeyType"))
229                 , key_id (remove_urn_uuid (node->string_child ("KeyId")))
230         {
231
232         }
233
234         TypedKeyId (string type, string id)
235                 : key_type (type)
236                 , key_id (id)
237         {}
238
239         void as_xml (xmlpp::Element* node) const
240         {
241                 xmlpp::Element* type = node->add_child("KeyType");
242                 type->add_child_text (key_type);
243                 node->add_child("KeyId")->add_child_text ("urn:uuid:" + key_id);
244                 /* XXX: this feels like a bit of a hack */
245                 if (key_type == "MDEK") {
246                         type->set_attribute ("scope", "http://www.dolby.com/cp850/2012/KDM#kdm-key-type");
247                 }
248         }
249
250         string key_type;
251         string key_id;
252 };
253
254 class KeyIdList
255 {
256 public:
257         KeyIdList () {}
258
259         KeyIdList (shared_ptr<const cxml::Node> node)
260         {
261                 list<shared_ptr<cxml::Node> > typed_key_id_nodes = node->node_children ("TypedKeyId");
262                 for (list<shared_ptr<cxml::Node> >::const_iterator i = typed_key_id_nodes.begin(); i != typed_key_id_nodes.end(); ++i) {
263                         typed_key_id.push_back (TypedKeyId (*i));
264                 }
265         }
266
267         void as_xml (xmlpp::Element* node) const
268         {
269                 for (list<TypedKeyId>::const_iterator i = typed_key_id.begin(); i != typed_key_id.end(); ++i) {
270                         i->as_xml (node->add_child("TypedKeyId"));
271                 }
272         }
273
274         list<TypedKeyId> typed_key_id;
275 };
276
277 class AuthorizedDeviceInfo
278 {
279 public:
280         AuthorizedDeviceInfo () {}
281
282         AuthorizedDeviceInfo (shared_ptr<const cxml::Node> node)
283                 : device_list_identifier (remove_urn_uuid (node->string_child ("DeviceListIdentifier")))
284                 , device_list_description (node->optional_string_child ("DeviceListDescription"))
285         {
286                 BOOST_FOREACH (cxml::ConstNodePtr i, node->node_child("DeviceList")->node_children("CertificateThumbprint")) {
287                         certificate_thumbprints.push_back (i->content ());
288                 }
289         }
290
291         void as_xml (xmlpp::Element* node) const
292         {
293                 node->add_child ("DeviceListIdentifier")->add_child_text ("urn:uuid:" + device_list_identifier);
294                 if (device_list_description) {
295                         node->add_child ("DeviceListDescription")->add_child_text (device_list_description.get());
296                 }
297                 xmlpp::Element* device_list = node->add_child ("DeviceList");
298                 BOOST_FOREACH (string i, certificate_thumbprints) {
299                         device_list->add_child("CertificateThumbprint")->add_child_text (i);
300                 }
301         }
302
303         /** DeviceListIdentifier without the urn:uuid: prefix */
304         string device_list_identifier;
305         boost::optional<string> device_list_description;
306         std::list<string> certificate_thumbprints;
307 };
308
309 class X509IssuerSerial
310 {
311 public:
312         X509IssuerSerial () {}
313
314         X509IssuerSerial (shared_ptr<const cxml::Node> node)
315                 : x509_issuer_name (node->string_child ("X509IssuerName"))
316                 , x509_serial_number (node->string_child ("X509SerialNumber"))
317         {
318
319         }
320
321         void as_xml (xmlpp::Element* node) const
322         {
323                 node->add_child("X509IssuerName", "ds")->add_child_text (x509_issuer_name);
324                 node->add_child("X509SerialNumber", "ds")->add_child_text (x509_serial_number);
325         }
326
327         string x509_issuer_name;
328         string x509_serial_number;
329 };
330
331 class Recipient
332 {
333 public:
334         Recipient () {}
335
336         Recipient (shared_ptr<const cxml::Node> node)
337                 : x509_issuer_serial (node->node_child ("X509IssuerSerial"))
338                 , x509_subject_name (node->string_child ("X509SubjectName"))
339         {
340
341         }
342
343         void as_xml (xmlpp::Element* node) const
344         {
345                 x509_issuer_serial.as_xml (node->add_child ("X509IssuerSerial"));
346                 node->add_child("X509SubjectName")->add_child_text (x509_subject_name);
347         }
348
349         X509IssuerSerial x509_issuer_serial;
350         string x509_subject_name;
351 };
352
353 class KDMRequiredExtensions
354 {
355 public:
356         KDMRequiredExtensions () {}
357
358         KDMRequiredExtensions (shared_ptr<const cxml::Node> node)
359                 : recipient (node->node_child ("Recipient"))
360                 , composition_playlist_id (remove_urn_uuid (node->string_child ("CompositionPlaylistId")))
361                 , content_title_text (node->string_child ("ContentTitleText"))
362                 , not_valid_before (node->string_child ("ContentKeysNotValidBefore"))
363                 , not_valid_after (node->string_child ("ContentKeysNotValidAfter"))
364                 , authorized_device_info (node->node_child ("AuthorizedDeviceInfo"))
365                 , key_id_list (node->node_child ("KeyIdList"))
366         {
367
368         }
369
370         void as_xml (xmlpp::Element* node) const
371         {
372                 node->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/430-1/2006/KDM");
373
374                 recipient.as_xml (node->add_child ("Recipient"));
375                 node->add_child("CompositionPlaylistId")->add_child_text ("urn:uuid:" + composition_playlist_id);
376                 node->add_child("ContentTitleText")->add_child_text (content_title_text);
377                 if (content_authenticator) {
378                         node->add_child("ContentAuthenticator")->add_child_text (content_authenticator.get ());
379                 }
380                 node->add_child("ContentKeysNotValidBefore")->add_child_text (not_valid_before.as_string ());
381                 node->add_child("ContentKeysNotValidAfter")->add_child_text (not_valid_after.as_string ());
382                 authorized_device_info.as_xml (node->add_child ("AuthorizedDeviceInfo"));
383                 key_id_list.as_xml (node->add_child ("KeyIdList"));
384
385                 xmlpp::Element* forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList");
386                 forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-picture-disable");
387                 forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-audio-disable");
388         }
389
390         Recipient recipient;
391         string composition_playlist_id;
392         boost::optional<string> content_authenticator;
393         string content_title_text;
394         LocalTime not_valid_before;
395         LocalTime not_valid_after;
396         AuthorizedDeviceInfo authorized_device_info;
397         KeyIdList key_id_list;
398 };
399
400 class RequiredExtensions
401 {
402 public:
403         RequiredExtensions () {}
404
405         RequiredExtensions (shared_ptr<const cxml::Node> node)
406                 : kdm_required_extensions (node->node_child ("KDMRequiredExtensions"))
407         {
408
409         }
410
411         void as_xml (xmlpp::Element* node) const
412         {
413                 kdm_required_extensions.as_xml (node->add_child ("KDMRequiredExtensions"));
414         }
415
416         KDMRequiredExtensions kdm_required_extensions;
417 };
418
419 class AuthenticatedPublic
420 {
421 public:
422         AuthenticatedPublic ()
423                 : message_id (make_uuid ())
424                   /* XXX: hack for Dolby to see if there must be a not-empty annotation text */
425                 , annotation_text ("none")
426                 , issue_date (LocalTime().as_string ())
427         {}
428
429         AuthenticatedPublic (shared_ptr<const cxml::Node> node)
430                 : message_id (remove_urn_uuid (node->string_child ("MessageId")))
431                 , annotation_text (node->optional_string_child ("AnnotationText"))
432                 , issue_date (node->string_child ("IssueDate"))
433                 , signer (node->node_child ("Signer"))
434                 , required_extensions (node->node_child ("RequiredExtensions"))
435         {
436
437         }
438
439         void as_xml (xmlpp::Element* node, map<string, xmlpp::Attribute *>& references) const
440         {
441                 references["ID_AuthenticatedPublic"] = node->set_attribute ("Id", "ID_AuthenticatedPublic");
442
443                 node->add_child("MessageId")->add_child_text ("urn:uuid:" + message_id);
444                 node->add_child("MessageType")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#kdm-key-type");
445                 if (annotation_text) {
446                         node->add_child("AnnotationText")->add_child_text (annotation_text.get ());
447                 }
448                 node->add_child("IssueDate")->add_child_text (issue_date);
449
450                 signer.as_xml (node->add_child ("Signer"));
451                 required_extensions.as_xml (node->add_child ("RequiredExtensions"));
452
453                 node->add_child ("NonCriticalExtensions");
454         }
455
456         string message_id;
457         optional<string> annotation_text;
458         string issue_date;
459         Signer signer;
460         RequiredExtensions required_extensions;
461 };
462
463 /** Class to describe our data.  We use a class hierarchy as it's a bit nicer
464  *  for XML data than a flat description.
465  */
466 class EncryptedKDMData
467 {
468 public:
469         EncryptedKDMData ()
470         {
471
472         }
473
474         EncryptedKDMData (shared_ptr<const cxml::Node> node)
475                 : authenticated_public (node->node_child ("AuthenticatedPublic"))
476                 , authenticated_private (node->node_child ("AuthenticatedPrivate"))
477                 , signature (node->node_child ("Signature"))
478         {
479
480         }
481
482         shared_ptr<xmlpp::Document> as_xml () const
483         {
484                 shared_ptr<xmlpp::Document> document (new xmlpp::Document ());
485                 xmlpp::Element* root = document->create_root_node ("DCinemaSecurityMessage", "http://www.smpte-ra.org/schemas/430-3/2006/ETM");
486                 root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds");
487                 root->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc");
488                 map<string, xmlpp::Attribute *> references;
489                 authenticated_public.as_xml (root->add_child ("AuthenticatedPublic"), references);
490                 authenticated_private.as_xml (root->add_child ("AuthenticatedPrivate"), references);
491                 signature.as_xml (root->add_child ("Signature", "ds"));
492
493                 for (map<string, xmlpp::Attribute*>::const_iterator i = references.begin(); i != references.end(); ++i) {
494                         xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ());
495                 }
496
497                 return document;
498         }
499
500         AuthenticatedPublic authenticated_public;
501         AuthenticatedPrivate authenticated_private;
502         Signature signature;
503 };
504
505 }
506 }
507
508 EncryptedKDM::EncryptedKDM (string s)
509 {
510         shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage"));
511         doc->read_string (s);
512         _data = new data::EncryptedKDMData (doc);
513 }
514
515 EncryptedKDM::EncryptedKDM (
516         shared_ptr<const CertificateChain> signer,
517         Certificate recipient,
518         vector<Certificate> trusted_devices,
519         string device_list_description,
520         string cpl_id,
521         string content_title_text,
522         optional<string> annotation_text,
523         LocalTime not_valid_before,
524         LocalTime not_valid_after,
525         Formulation formulation,
526         list<pair<string, string> > key_ids,
527         list<string> keys
528         )
529         : _data (new data::EncryptedKDMData)
530 {
531         /* Fill our XML-ish description in with the juicy bits that the caller has given */
532
533         data::AuthenticatedPublic& aup = _data->authenticated_public;
534         aup.signer.x509_issuer_name = signer->leaf().issuer ();
535         aup.signer.x509_serial_number = signer->leaf().serial ();
536         aup.annotation_text = annotation_text;
537
538         data::KDMRequiredExtensions& kre = _data->authenticated_public.required_extensions.kdm_required_extensions;
539         kre.recipient.x509_issuer_serial.x509_issuer_name = recipient.issuer ();
540         kre.recipient.x509_issuer_serial.x509_serial_number = recipient.serial ();
541         kre.recipient.x509_subject_name = recipient.subject ();
542         kre.authorized_device_info.device_list_description = device_list_description;
543         kre.composition_playlist_id = cpl_id;
544         if (formulation == DCI_ANY || formulation == DCI_SPECIFIC) {
545                 kre.content_authenticator = signer->leaf().thumbprint ();
546         }
547         kre.content_title_text = content_title_text;
548         kre.not_valid_before = not_valid_before;
549         kre.not_valid_after = not_valid_after;
550         kre.authorized_device_info.device_list_identifier = make_uuid ();
551         string n = recipient.subject_common_name ();
552         if (n.find (".") != string::npos) {
553                 n = n.substr (n.find (".") + 1);
554         }
555         kre.authorized_device_info.device_list_description = n;
556
557         if (formulation == MODIFIED_TRANSITIONAL_1 || formulation == DCI_ANY) {
558                 /* Use the "assume trust" thumbprint */
559                 kre.authorized_device_info.certificate_thumbprints.push_back ("2jmj7l5rSw0yVb/vlWAYkK/YBwk=");
560         } else if (formulation == DCI_SPECIFIC) {
561                 /* As I read the standard we should use the recipient
562                    /and/ other trusted device thumbprints here.  MJD
563                    reports that this doesn't work with his setup;
564                    a working KDM does not include the recipient's
565                    thumbprint (recipient.thumbprint()).
566                 */
567                 BOOST_FOREACH (Certificate const & i, trusted_devices) {
568                         kre.authorized_device_info.certificate_thumbprints.push_back (i.thumbprint ());
569                 }
570         }
571
572         for (list<pair<string, string> >::const_iterator i = key_ids.begin(); i != key_ids.end(); ++i) {
573                 kre.key_id_list.typed_key_id.push_back (data::TypedKeyId (i->first, i->second));
574         }
575
576         _data->authenticated_private.encrypted_key = keys;
577
578         /* Read the XML so far and sign it */
579         shared_ptr<xmlpp::Document> doc = _data->as_xml ();
580         xmlpp::Node::NodeList children = doc->get_root_node()->get_children ();
581         for (xmlpp::Node::NodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
582                 if ((*i)->get_name() == "Signature") {
583                         signer->add_signature_value (*i, "ds");
584                 }
585         }
586
587         /* Read the bits that add_signature_value did back into our variables */
588         shared_ptr<cxml::Node> signed_doc (new cxml::Node (doc->get_root_node ()));
589         _data->signature = data::Signature (signed_doc->node_child ("Signature"));
590 }
591
592 EncryptedKDM::EncryptedKDM (EncryptedKDM const & other)
593         : _data (new data::EncryptedKDMData (*other._data))
594 {
595
596 }
597
598 EncryptedKDM &
599 EncryptedKDM::operator= (EncryptedKDM const & other)
600 {
601         if (this == &other) {
602                 return *this;
603         }
604
605         delete _data;
606         _data = new data::EncryptedKDMData (*other._data);
607         return *this;
608 }
609
610 EncryptedKDM::~EncryptedKDM ()
611 {
612         delete _data;
613 }
614
615 void
616 EncryptedKDM::as_xml (boost::filesystem::path path) const
617 {
618         FILE* f = fopen_boost (path, "w");
619         string const x = as_xml ();
620         fwrite (x.c_str(), 1, x.length(), f);
621         fclose (f);
622 }
623
624 string
625 EncryptedKDM::as_xml () const
626 {
627         return _data->as_xml()->write_to_string ("UTF-8");
628 }
629
630 list<string>
631 EncryptedKDM::keys () const
632 {
633         return _data->authenticated_private.encrypted_key;
634 }
635
636 optional<string>
637 EncryptedKDM::annotation_text () const
638 {
639         return _data->authenticated_public.annotation_text;
640 }
641
642 string
643 EncryptedKDM::content_title_text () const
644 {
645         return _data->authenticated_public.required_extensions.kdm_required_extensions.content_title_text;
646 }
647
648 string
649 EncryptedKDM::cpl_id () const
650 {
651         return _data->authenticated_public.required_extensions.kdm_required_extensions.composition_playlist_id;
652 }
653
654 string
655 EncryptedKDM::issue_date () const
656 {
657         return _data->authenticated_public.issue_date;
658 }
659
660 bool
661 dcp::operator== (EncryptedKDM const & a, EncryptedKDM const & b)
662 {
663         /* Not exactly efficient... */
664         return a.as_xml() == b.as_xml();
665 }