2 Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
34 /** @file src/encrypted_kdm.h
35 * @brief EncryptedKDM class.
38 #ifndef LIBDCP_ENCRYPTED_KDM_H
39 #define LIBDCP_ENCRYPTED_KDM_H
41 #include "local_time.h"
43 #include <boost/filesystem.hpp>
44 #include <boost/optional.hpp>
45 #include <boost/date_time/local_time/local_time.hpp>
54 class EncryptedKDMData;
57 class CertificateChain;
60 /** @class EncryptedKDM
61 * @brief An encrypted KDM.
63 * This is a KDM whose keys are encrypted using the target projector's private key.
64 * An EncryptedKDM object can be initialised from a KDM XML file, or created from
65 * a DecryptedKDM (using DecryptedKDM::encrypt).
70 explicit EncryptedKDM (std::string);
71 EncryptedKDM (EncryptedKDM const & kdm);
72 EncryptedKDM & operator= (EncryptedKDM const &);
75 /** Write this KDM as XML to a file.
76 * @param file File to write to.
78 void as_xml (boost::filesystem::path file) const;
80 /** @return This KDM as XML */
81 std::string as_xml () const;
83 /** @return The base64-encoded and encrypted keys that this KDM delivers.
84 * Note that the returned `keys' contain more than just the asset decryption
85 * keys (also key id, CPL id etc.)
87 std::list<std::string> keys () const;
89 std::string id () const;
90 boost::optional<std::string> annotation_text () const;
91 std::string content_title_text () const;
92 std::string issue_date () const;
93 std::string cpl_id () const;
94 LocalTime not_valid_before () const;
95 LocalTime not_valid_after () const;
96 std::string recipient_x509_subject_name () const;
97 CertificateChain signer_certificate_chain () const;
101 friend class DecryptedKDM;
103 /** Construct an EncryptedKDM from a set of details */
105 boost::shared_ptr<const CertificateChain> signer,
106 Certificate recipient,
107 std::vector<std::string> trusted_devices,
109 std::string cpl_content_title_text,
110 boost::optional<std::string> annotation_text,
111 LocalTime not_valid_before,
112 LocalTime not_valid_after,
113 Formulation formulation,
114 bool disable_forensic_marking_picture,
115 boost::optional<int> disable_forensic_marking_audio,
116 std::list<std::pair<std::string, std::string> > key_ids,
117 std::list<std::string> keys
120 data::EncryptedKDMData* _data;
123 extern bool operator== (EncryptedKDM const & a, EncryptedKDM const & b);