2 Copyright (C) 2013-2021 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.
35 /** @file src/encrypted_kdm.h
36 * @brief EncryptedKDM class
40 #ifndef LIBDCP_ENCRYPTED_KDM_H
41 #define LIBDCP_ENCRYPTED_KDM_H
44 #include "local_time.h"
46 #include <boost/filesystem.hpp>
47 #include <boost/optional.hpp>
48 #include <boost/date_time/local_time/local_time.hpp>
60 class EncryptedKDMData;
64 class CertificateChain;
68 /** @class EncryptedKDM
69 * @brief An encrypted KDM
71 * This is a KDM whose keys are encrypted using the target projector's private key.
72 * An EncryptedKDM object can be initialised from a KDM XML file, or created from
73 * a DecryptedKDM (using DecryptedKDM::encrypt).
78 explicit EncryptedKDM (std::string);
79 EncryptedKDM (EncryptedKDM const & kdm);
80 EncryptedKDM & operator= (EncryptedKDM const &);
83 /** Write this KDM as XML to a file.
84 * @param file File to write to.
86 void as_xml (boost::filesystem::path file) const;
88 /** @return This KDM as XML */
89 std::string as_xml () const;
91 /** @return The base64-encoded and encrypted keys that this KDM delivers.
92 * Note that the returned `keys' contain more than just the asset decryption
93 * keys (also key id, CPL id etc.)
95 std::vector<std::string> keys () const;
97 std::string id () const;
98 boost::optional<std::string> annotation_text () const;
99 std::string content_title_text () const;
100 std::string issue_date () const;
101 std::string cpl_id () const;
102 LocalTime not_valid_before () const;
103 LocalTime not_valid_after () const;
104 std::string recipient_x509_subject_name () const;
105 CertificateChain signer_certificate_chain () const;
109 friend class DecryptedKDM;
111 /** Construct an EncryptedKDM from a set of details */
113 std::shared_ptr<const CertificateChain> signer,
114 Certificate recipient,
115 std::vector<std::string> trusted_devices,
117 std::string cpl_content_title_text,
118 boost::optional<std::string> annotation_text,
119 LocalTime not_valid_before,
120 LocalTime not_valid_after,
121 Formulation formulation,
122 bool disable_forensic_marking_picture,
123 boost::optional<int> disable_forensic_marking_audio,
124 std::vector<std::pair<std::string, std::string>> key_ids,
125 std::vector<std::string> keys
128 data::EncryptedKDMData* _data = nullptr;
132 extern bool operator== (EncryptedKDM const & a, EncryptedKDM const & b);