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"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/format.hpp>
+
using std::list;
using std::vector;
using std::string;
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:
string x509_serial_number;
};
+
class X509Data
{
public:
std::string x509_certificate;
};
+
class Reference
{
public:
string digest_value;
};
+
class SignedInfo
{
public:
Reference authenticated_private;
};
+
class Signature
{
public:
vector<X509Data> x509_data;
};
+
class AuthenticatedPrivate
{
public:
vector<string> encrypted_key;
};
+
class TypedKeyId
{
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 */
string key_id;
};
+
class KeyIdList
{
public:
vector<TypedKeyId> typed_key_id;
};
+
class AuthorizedDeviceInfo
{
public:
std::vector<string> certificate_thumbprints;
};
+
class X509IssuerSerial
{
public:
string x509_serial_number;
};
+
class Recipient
{
public:
string x509_subject_name;
};
+
class KDMRequiredExtensions
{
public:
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:
KDMRequiredExtensions kdm_required_extensions;
};
+
class AuthenticatedPublic
{
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.
*/
Signature signature;
};
+
}
}
+
EncryptedKDM::EncryptedKDM (string s)
{
try {
}
}
-/** @param trusted_devices Trusted device thumbprints */
+
EncryptedKDM::EncryptedKDM (
shared_ptr<const CertificateChain> signer,
Certificate recipient,
* 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;
kre.recipient.x509_issuer_serial.x509_serial_number = recipient.serial ();
kre.recipient.x509_subject_name = recipient.subject ();
kre.composition_playlist_id = cpl_id;
- if (formulation == DCI_ANY || formulation == DCI_SPECIFIC) {
+ if (formulation == Formulation::DCI_ANY || formulation == Formulation::DCI_SPECIFIC) {
kre.content_authenticator = signer->leaf().thumbprint ();
}
kre.content_title_text = content_title_text;
kre.disable_forensic_marking_picture = disable_forensic_marking_picture;
kre.disable_forensic_marking_audio = disable_forensic_marking_audio;
- if (formulation != MODIFIED_TRANSITIONAL_TEST) {
+ if (formulation != Formulation::MODIFIED_TRANSITIONAL_TEST) {
kre.authorized_device_info = data::AuthorizedDeviceInfo ();
kre.authorized_device_info->device_list_identifier = make_uuid ();
auto n = recipient.subject_common_name ();
}
kre.authorized_device_info->device_list_description = n;
- if (formulation == MODIFIED_TRANSITIONAL_1 || formulation == DCI_ANY) {
+ if (formulation == Formulation::MODIFIED_TRANSITIONAL_1 || formulation == Formulation::DCI_ANY) {
/* Use the "assume trust" thumbprint */
kre.authorized_device_info->certificate_thumbprints.push_back ("2jmj7l5rSw0yVb/vlWAYkK/YBwk=");
- } else if (formulation == MULTIPLE_MODIFIED_TRANSITIONAL_1 || formulation == DCI_SPECIFIC) {
+ } else if (formulation == Formulation::MULTIPLE_MODIFIED_TRANSITIONAL_1 || formulation == Formulation::DCI_SPECIFIC) {
if (trusted_devices.empty ()) {
/* Fall back on the "assume trust" thumbprint so we
can generate "modified-transitional-1" KDMs
_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)
{
return *this;
}
+
EncryptedKDM::~EncryptedKDM ()
{
delete _data;
}
+
void
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
{
return chain;
}
+
bool
dcp::operator== (EncryptedKDM const & a, EncryptedKDM const & b)
{