X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fdecrypted_kdm.cc;h=99cbca10ff040bd1b87eca376f490e45baaf9e2b;hb=f0a6d7b5b8d16b8b47917cd30b340917f5c62fc5;hp=9a9a16947103c7cc0c0b968c4a7ad3b12a96247b;hpb=9e523d8a4062ad52330dff6c2ba50e54184c9bb2;p=libdcp.git diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index 9a9a1694..99cbca10 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -25,7 +25,7 @@ #include "util.h" #include "exceptions.h" #include "cpl.h" -#include "signer.h" +#include "certificate_chain.h" #include "dcp_assert.h" #include "AS_DCP.h" #include "KM_util.h" @@ -36,6 +36,7 @@ #include using std::list; +using std::vector; using std::string; using std::stringstream; using std::setw; @@ -181,6 +182,26 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key) RSA_free (rsa); BIO_free (bio); + + _annotation_text = kdm.annotation_text (); + _content_title_text = kdm.content_title_text (); + _issue_date = kdm.issue_date (); +} + +DecryptedKDM::DecryptedKDM ( + LocalTime not_valid_before, + LocalTime not_valid_after, + string annotation_text, + string content_title_text, + string issue_date + ) + : _not_valid_before (not_valid_before) + , _not_valid_after (not_valid_after) + , _annotation_text (annotation_text) + , _content_title_text (content_title_text) + , _issue_date (issue_date) +{ + } DecryptedKDM::DecryptedKDM ( @@ -211,8 +232,25 @@ DecryptedKDM::DecryptedKDM ( } } +/** @param type (MDIK, MDAK etc.) + * @param key_id Key ID. + * @param key The actual symmetric key. + * @param cpl_id ID of CPL that the key is for. + */ +void +DecryptedKDM::add_key (string type, string key_id, Key key, string cpl_id) +{ + _keys.push_back (DecryptedKDMKey (type, key_id, key, cpl_id)); +} + +void +DecryptedKDM::add_key (DecryptedKDMKey key) +{ + _keys.push_back (key); +} + EncryptedKDM -DecryptedKDM::encrypt (shared_ptr signer, Certificate recipient, Formulation formulation) const +DecryptedKDM::encrypt (shared_ptr signer, Certificate recipient, vector trusted_devices, Formulation formulation) const { list > key_ids; list keys; @@ -227,7 +265,7 @@ DecryptedKDM::encrypt (shared_ptr signer, Certificate recipient, F uint8_t structure_id[] = { 0xf1, 0xdc, 0x12, 0x44, 0x60, 0x16, 0x9a, 0x0e, 0x85, 0xbc, 0x30, 0x06, 0x42, 0xf8, 0x66, 0xab }; put (&p, structure_id, 16); - base64_decode (signer->certificates().leaf().thumbprint (), p, 20); + base64_decode (signer->leaf().thumbprint (), p, 20); p += 20; put_uuid (&p, i.cpl_id ()); @@ -260,7 +298,7 @@ DecryptedKDM::encrypt (shared_ptr signer, Certificate recipient, F keys.push_back (lines.str ()); } - string device_list_description = recipient.common_name (); + string device_list_description = recipient.subject_common_name (); if (device_list_description.find (".") != string::npos) { device_list_description = device_list_description.substr (device_list_description.find (".") + 1); } @@ -268,6 +306,7 @@ DecryptedKDM::encrypt (shared_ptr signer, Certificate recipient, F return EncryptedKDM ( signer, recipient, + trusted_devices, device_list_description, _keys.front().cpl_id (), _content_title_text,