2 Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #ifndef LIBDCP_DECRYPTED_KDM_H
21 #define LIBDCP_DECRYPTED_KDM_H
23 /** @file src/decrypted_kdm.h
24 * @brief DecryptedKDM class.
28 #include "local_time.h"
29 #include "decrypted_kdm_key.h"
31 #include "certificate.h"
32 #include <boost/filesystem.hpp>
36 class DecryptedKDMKey;
38 class CertificateChain;
41 /** @class DecryptedKDM
42 * @brief A decrypted KDM.
44 * This is a KDM that has either been decrypted by a target private key, or one which
45 * has been created (by some other means) ready for encryption later.
47 * A DecryptedKDM object can be created either from an EncryptedKDM and private key file,
48 * or from the details of the assets that the KDM should protect.
53 /** @param kdm Encrypted KDM.
54 * @param private_key Private key as a PEM-format string.
56 DecryptedKDM (EncryptedKDM const & kdm, std::string private_key);
58 /** Construct a DecryptedKDM.
59 * @param cpl CPL that the keys are for.
60 * @param key Key that was used to encrypt the assets.
61 * @param not_valid_before Start time for the KDM.
62 * @param not_valid_after End time for the KDM.
65 boost::shared_ptr<const CPL> cpl,
67 LocalTime not_valid_before,
68 LocalTime not_valid_after,
69 std::string annotation_text,
70 std::string content_title_text,
71 std::string issue_date
74 /** Encrypt this KDM's keys and sign the whole KDM.
75 * @param signer Chain to sign with.
76 * @param recipient Certificate of the projector/server which should receive this KDM's keys.
77 * @param formulation Formulation to use for the encrypted KDM.
78 * @return Encrypted KDM.
80 EncryptedKDM encrypt (boost::shared_ptr<const CertificateChain> signer, Certificate recipient, Formulation formulation) const;
82 /** @return This KDM's (decrypted) keys, which could be used to decrypt assets. */
83 std::list<DecryptedKDMKey> keys () const {
88 LocalTime _not_valid_before;
89 LocalTime _not_valid_after;
90 std::string _annotation_text;
91 std::string _content_title_text;
92 std::string _issue_date;
93 std::list<DecryptedKDMKey> _keys;