diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-24 04:15:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-24 04:15:26 +0100 |
| commit | ceaf7bc52712cb60708ed5eb5c62c5e463dd8e89 (patch) | |
| tree | c55e4b85ee30138ce83263045d77d01631378b2e /src/encrypted_kdm.cc | |
| parent | 6c37cc1979b2a01205a888c4c98f3334685ee8dd (diff) | |
Tidying.
Diffstat (limited to 'src/encrypted_kdm.cc')
| -rw-r--r-- | src/encrypted_kdm.cc | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index d7326e89..dec2efcd 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -31,6 +31,12 @@ files in the program, then also delete it here. */ + +/** @file src/encrypted_kdm.cc + * @brief EncryptedKDM class + */ + + #include "encrypted_kdm.h" #include "util.h" #include "certificate_chain.h" @@ -44,6 +50,7 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/format.hpp> + using std::list; using std::vector; using std::string; @@ -55,11 +62,14 @@ using boost::optional; using boost::starts_with; using namespace dcp; + namespace dcp { + /** Namespace for classes used to hold our data; they are internal to this .cc file */ namespace data { + class Signer { public: @@ -82,6 +92,7 @@ public: string x509_serial_number; }; + class X509Data { public: @@ -104,6 +115,7 @@ public: std::string x509_certificate; }; + class Reference { public: @@ -131,6 +143,7 @@ public: string digest_value; }; + class SignedInfo { public: @@ -171,6 +184,7 @@ private: Reference authenticated_private; }; + class Signature { public: @@ -201,6 +215,7 @@ public: vector<X509Data> x509_data; }; + class AuthenticatedPrivate { public: @@ -235,6 +250,7 @@ public: vector<string> encrypted_key; }; + class TypedKeyId { public: @@ -254,7 +270,7 @@ public: void as_xml (xmlpp::Element* node) const { - xmlpp::Element* type = node->add_child("KeyType"); + auto type = node->add_child("KeyType"); type->add_child_text (key_type); node->add_child("KeyId")->add_child_text ("urn:uuid:" + key_id); /* XXX: this feels like a bit of a hack */ @@ -269,6 +285,7 @@ public: string key_id; }; + class KeyIdList { public: @@ -291,6 +308,7 @@ public: vector<TypedKeyId> typed_key_id; }; + class AuthorizedDeviceInfo { public: @@ -323,6 +341,7 @@ public: std::vector<string> certificate_thumbprints; }; + class X509IssuerSerial { public: @@ -345,6 +364,7 @@ public: string x509_serial_number; }; + class Recipient { public: @@ -367,6 +387,7 @@ public: string x509_subject_name; }; + class KDMRequiredExtensions { public: @@ -450,9 +471,11 @@ private: static const string audio_disable; }; + const string KDMRequiredExtensions::picture_disable = "http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-picture-disable"; const string KDMRequiredExtensions::audio_disable = "http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-audio-disable"; + class RequiredExtensions { public: @@ -472,6 +495,7 @@ public: KDMRequiredExtensions kdm_required_extensions; }; + class AuthenticatedPublic { public: @@ -516,6 +540,7 @@ public: RequiredExtensions required_extensions; }; + /** Class to describe our data. We use a class hierarchy as it's a bit nicer * for XML data than a flat description. */ @@ -559,9 +584,11 @@ public: Signature signature; }; + } } + EncryptedKDM::EncryptedKDM (string s) { try { @@ -573,7 +600,7 @@ EncryptedKDM::EncryptedKDM (string s) } } -/** @param trusted_devices Trusted device thumbprints */ + EncryptedKDM::EncryptedKDM ( shared_ptr<const CertificateChain> signer, Certificate recipient, @@ -602,7 +629,7 @@ EncryptedKDM::EncryptedKDM ( * DCI_SPECIFIC as specified Yes */ - data::AuthenticatedPublic& aup = _data->authenticated_public; + auto& aup = _data->authenticated_public; aup.signer.x509_issuer_name = signer->leaf().issuer (); aup.signer.x509_serial_number = signer->leaf().serial (); aup.annotation_text = annotation_text; @@ -675,12 +702,14 @@ EncryptedKDM::EncryptedKDM ( _data->signature = data::Signature (signed_doc->node_child ("Signature")); } + EncryptedKDM::EncryptedKDM (EncryptedKDM const & other) : _data (new data::EncryptedKDMData (*other._data)) { } + EncryptedKDM & EncryptedKDM::operator= (EncryptedKDM const & other) { @@ -693,11 +722,13 @@ EncryptedKDM::operator= (EncryptedKDM const & other) return *this; } + EncryptedKDM::~EncryptedKDM () { delete _data; } + void EncryptedKDM::as_xml (boost::filesystem::path path) const { @@ -713,66 +744,77 @@ EncryptedKDM::as_xml (boost::filesystem::path path) const } } + string EncryptedKDM::as_xml () const { return _data->as_xml()->write_to_string ("UTF-8"); } + vector<string> EncryptedKDM::keys () const { return _data->authenticated_private.encrypted_key; } + string EncryptedKDM::id () const { return _data->authenticated_public.message_id; } + optional<string> EncryptedKDM::annotation_text () const { return _data->authenticated_public.annotation_text; } + string EncryptedKDM::content_title_text () const { return _data->authenticated_public.required_extensions.kdm_required_extensions.content_title_text; } + string EncryptedKDM::cpl_id () const { return _data->authenticated_public.required_extensions.kdm_required_extensions.composition_playlist_id; } + string EncryptedKDM::issue_date () const { return _data->authenticated_public.issue_date; } + LocalTime EncryptedKDM::not_valid_before () const { return _data->authenticated_public.required_extensions.kdm_required_extensions.not_valid_before; } + LocalTime EncryptedKDM::not_valid_after () const { return _data->authenticated_public.required_extensions.kdm_required_extensions.not_valid_after; } + string EncryptedKDM::recipient_x509_subject_name () const { return _data->authenticated_public.required_extensions.kdm_required_extensions.recipient.x509_subject_name; } + CertificateChain EncryptedKDM::signer_certificate_chain () const { @@ -784,6 +826,7 @@ EncryptedKDM::signer_certificate_chain () const return chain; } + bool dcp::operator== (EncryptedKDM const & a, EncryptedKDM const & b) { |
