diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-07-20 23:38:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-07-20 23:38:07 +0100 |
| commit | 26f6ead44ff6bcb259c1755f91beb0a9e3eee988 (patch) | |
| tree | 00a3afe3375208ce7cd8f2650fefd368467fc5aa | |
| parent | e52f18d28d90c9deba31a441d566db94be0571b2 (diff) | |
Allow loading of EncryptedKDMs from strings.
| -rw-r--r-- | src/encrypted_kdm.cc | 7 | ||||
| -rw-r--r-- | src/encrypted_kdm.h | 6 | ||||
| -rw-r--r-- | src/util.h | 2 | ||||
| -rw-r--r-- | test/decryption_test.cc | 6 | ||||
| -rw-r--r-- | test/kdm_test.cc | 6 | ||||
| -rw-r--r-- | test/round_trip_test.cc | 2 |
6 files changed, 15 insertions, 14 deletions
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index d7cdd8dd..93852fb6 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -484,10 +484,11 @@ public: } } -EncryptedKDM::EncryptedKDM (boost::filesystem::path file) - : _data (new data::EncryptedKDMData (shared_ptr<cxml::Node> (new cxml::Document ("DCinemaSecurityMessage", file)))) +EncryptedKDM::EncryptedKDM (string s) { - + shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage")); + doc->read_string (s); + _data = new data::EncryptedKDMData (doc); } EncryptedKDM::EncryptedKDM ( diff --git a/src/encrypted_kdm.h b/src/encrypted_kdm.h index 0d459d5a..1fcd37f4 100644 --- a/src/encrypted_kdm.h +++ b/src/encrypted_kdm.h @@ -52,11 +52,7 @@ class Certificate; class EncryptedKDM { public: - /** Read a KDM from an XML file. - * @param file XML file to read. - */ - EncryptedKDM (boost::filesystem::path file); - + EncryptedKDM (std::string); EncryptedKDM (EncryptedKDM const & kdm); EncryptedKDM & operator= (EncryptedKDM const &); ~EncryptedKDM (); @@ -88,7 +88,7 @@ extern void add_signer (xmlpp::Element* parent, CertificateChain const & certifi extern int base64_decode (std::string const & in, unsigned char* out, int out_length); extern boost::optional<boost::filesystem::path> relative_to_root (boost::filesystem::path root, boost::filesystem::path file); extern FILE * fopen_boost (boost::filesystem::path, std::string); -extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length = 4096); +extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length = 65536); extern std::string private_key_fingerprint (std::string key); template <class F, class T> diff --git a/test/decryption_test.cc b/test/decryption_test.cc index b5077a46..d9170daa 100644 --- a/test/decryption_test.cc +++ b/test/decryption_test.cc @@ -60,7 +60,9 @@ BOOST_AUTO_TEST_CASE (decryption_test) BOOST_CHECK_EQUAL (encrypted.encrypted (), true); dcp::DecryptedKDM kdm ( - dcp::EncryptedKDM ("test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml"), + dcp::EncryptedKDM ( + dcp::file_to_string ("test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml") + ), dcp::file_to_string ("test/data/private.key") ); @@ -80,7 +82,7 @@ BOOST_AUTO_TEST_CASE (decryption_test) BOOST_AUTO_TEST_CASE (failing_kdm_test) { dcp::DecryptedKDM kdm ( - dcp::EncryptedKDM ("test/data/target.pem.crt.de5d4eba-e683-41ca-bdda-aa4ad96af3f4.kdm.xml"), + dcp::EncryptedKDM (dcp::file_to_string ("test/data/target.pem.crt.de5d4eba-e683-41ca-bdda-aa4ad96af3f4.kdm.xml")), dcp::file_to_string ("test/data/private.key") ); } diff --git a/test/kdm_test.cc b/test/kdm_test.cc index 1fc76dba..c2d40b3b 100644 --- a/test/kdm_test.cc +++ b/test/kdm_test.cc @@ -30,7 +30,9 @@ using boost::shared_ptr; BOOST_AUTO_TEST_CASE (kdm_test) { dcp::DecryptedKDM kdm ( - dcp::EncryptedKDM ("test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml"), + dcp::EncryptedKDM ( + dcp::file_to_string ("test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml") + ), dcp::file_to_string ("test/data/private.key") ); @@ -51,7 +53,7 @@ BOOST_AUTO_TEST_CASE (kdm_test) BOOST_AUTO_TEST_CASE (kdm_passthrough_test) { dcp::EncryptedKDM kdm ( - "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml" + dcp::file_to_string ("test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml") ); shared_ptr<xmlpp::DomParser> parser (new xmlpp::DomParser ()); diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index b0594931..94097e75 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE (round_trip_test) kdm_A.encrypt(signer, signer->certificates().leaf(), dcp::MODIFIED_TRANSITIONAL_1).as_xml (kdm_file); /* Reload the KDM, using our private key to decrypt it */ - dcp::DecryptedKDM kdm_B (dcp::EncryptedKDM (kdm_file), signer->key ()); + dcp::DecryptedKDM kdm_B (dcp::EncryptedKDM (dcp::file_to_string (kdm_file)), signer->key ()); /* Check that the decrypted KDMKeys are the same as the ones we started with */ BOOST_CHECK_EQUAL (kdm_A.keys().size(), kdm_B.keys().size()); |
