summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-31 00:03:49 +0100
committerCarl Hetherington <cth@carlh.net>2025-11-05 00:43:19 +0100
commite8ce097ce705446c27b51199a321a9918deaa0db (patch)
tree0a52cbc9c52791d453fa4bd478609aedde98c831 /test
parentef65a179e8c907029d0d9254863d4884581f3d60 (diff)
Allow specification of which parts of the DCP to encrypt (#3099).
Diffstat (limited to 'test')
-rw-r--r--test/atmos_test.cc4
m---------test/data0
-rw-r--r--test/dcp_decoder_test.cc4
-rw-r--r--test/dcp_digest_file_test.cc6
-rw-r--r--test/encryption_test.cc106
-rw-r--r--test/import_dcp_test.cc3
-rw-r--r--test/kdm_cli_test.cc4
-rw-r--r--test/kdm_naming_test.cc6
-rw-r--r--test/player_test.cc4
-rw-r--r--test/recover_test.cc3
-rw-r--r--test/remake_id_test.cc3
-rw-r--r--test/vf_kdm_test.cc6
12 files changed, 135 insertions, 14 deletions
diff --git a/test/atmos_test.cc b/test/atmos_test.cc
index 33a427321..776cc9310 100644
--- a/test/atmos_test.cc
+++ b/test/atmos_test.cc
@@ -68,7 +68,9 @@ BOOST_AUTO_TEST_CASE(atmos_encrypted_passthrough_test)
auto content = content_factory(TestPaths::private_data() / "atmos_asset.mxf");
auto film = new_test_film("atmos_encrypted_passthrough_test", content, &cl);
- film->set_encrypted(true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
+ film->set_encrypt_text(true);
film->_key = dcp::Key("4fac12927eb122af1c2781aa91f3a4cc");
make_and_verify_dcp(film, { dcp::VerificationNote::Code::MISSING_CPL_METADATA });
diff --git a/test/data b/test/data
-Subproject 024cb24f49525e0cc172d4e91d75e0c4d81ef6e
+Subproject df51596458d402f40a5afaf943225ce7e95cdf6
diff --git a/test/dcp_decoder_test.cc b/test/dcp_decoder_test.cc
index cf9950aae..87cea6691 100644
--- a/test/dcp_decoder_test.cc
+++ b/test/dcp_decoder_test.cc
@@ -64,7 +64,9 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
auto encrypted = new_test_film("check_reuse_old_data_decrypted");
encrypted->examine_and_add_content(content_factory("test/data/flat_red.png"));
BOOST_REQUIRE (!wait_for_jobs());
- encrypted->set_encrypted (true);
+ encrypted->set_encrypt_picture(true);
+ encrypted->set_encrypt_sound(true);
+ encrypted->set_encrypt_text(true);
make_and_verify_dcp (encrypted);
dcp::DCP encrypted_dcp (encrypted->dir(encrypted->dcp_name()));
diff --git a/test/dcp_digest_file_test.cc b/test/dcp_digest_file_test.cc
index 5c12fbb33..2e717896f 100644
--- a/test/dcp_digest_file_test.cc
+++ b/test/dcp_digest_file_test.cc
@@ -67,7 +67,8 @@ BOOST_AUTO_TEST_CASE (dcp_digest_file_test2)
auto red = content_factory("test/data/flat_red.png");
auto ov = new_test_film("dcp_digest_file_test2_ov", red);
- ov->set_encrypted (true);
+ ov->set_encrypt_picture(true);
+ ov->set_encrypt_sound(true);
make_and_verify_dcp (ov);
auto ov_key_check = get_key_from_digest ("build/test/dcp_digest_file_test2_ov/" + ov->dcp_name() + ".dcpdig");
@@ -91,7 +92,8 @@ BOOST_AUTO_TEST_CASE (dcp_digest_file_test2)
ov_dcp->set_reference_video (true);
ov_dcp->set_reference_audio (true);
auto vf = new_test_film("dcp_digest_file_test2_vf", { ov_dcp });
- vf->set_encrypted (true);
+ vf->set_encrypt_picture(true);
+ vf->set_encrypt_sound(true);
make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
auto vf_key_check = get_key_from_digest ("build/test/dcp_digest_file_test2_vf/" + vf->dcp_name() + ".dcpdig");
diff --git a/test/encryption_test.cc b/test/encryption_test.cc
index 97359cd44..31e31d53c 100644
--- a/test/encryption_test.cc
+++ b/test/encryption_test.cc
@@ -27,9 +27,16 @@
#include "test.h"
#include <dcp/cpl.h>
#include <dcp/dcp.h>
+#include <dcp/j2k_transcode.h>
+#include <dcp/mono_j2k_picture_asset.h>
+#include <dcp/reel.h>
+#include <dcp/reel_picture_asset.h>
+#include <dcp/reel_sound_asset.h>
+#include <dcp/reel_text_asset.h>
#include <boost/test/unit_test.hpp>
+using std::dynamic_pointer_cast;
using std::make_shared;
@@ -38,7 +45,9 @@ BOOST_AUTO_TEST_CASE (smpte_dcp_with_subtitles_can_be_decrypted)
auto content = content_factory("test/data/15s.srt");
auto film = new_test_film("smpte_dcp_with_subtitles_can_be_decrypted", content);
film->set_interop (false);
- film->set_encrypted (true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
+ film->set_encrypt_text(true);
make_and_verify_dcp (
film,
{
@@ -67,3 +76,98 @@ BOOST_AUTO_TEST_CASE (smpte_dcp_with_subtitles_can_be_decrypted)
BOOST_CHECK (examiner.kdm_valid());
}
+
+BOOST_AUTO_TEST_CASE(encrypt_only_picture)
+{
+ auto picture = content_factory("test/data/flat_red.png")[0];
+ auto text = content_factory("test/data/15s.srt")[0];
+ auto film = new_test_film("encrypt_only_picture", { picture, text });
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(false);
+ film->set_encrypt_text(false);
+ /* clairmeta says "Encrypted is not coherent for all reels" */
+ make_and_verify_dcp(
+ film,
+ {
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA,
+ dcp::VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED,
+ dcp::VerificationNote::Code::PARTIALLY_ENCRYPTED,
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ }, true, false);
+
+ dcp::DCP dcp(film->dir(film->dcp_name()));
+ dcp.read();
+ BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U);
+ auto cpl = dcp.cpls()[0];
+ BOOST_REQUIRE(cpl->file());
+
+ auto dcp_picture = dynamic_pointer_cast<dcp::MonoJ2KPictureAsset>(cpl->reels()[0]->main_picture()->asset());
+ auto reader = dcp_picture->start_read();
+ auto frame = reader->get_frame(0);
+ BOOST_CHECK_THROW(dcp::decompress_j2k(frame->data(), frame->size(), 0), dcp::J2KDecompressionError);
+}
+
+
+BOOST_AUTO_TEST_CASE(encrypt_only_sound)
+{
+ auto picture = content_factory("test/data/flat_red.png")[0];
+ auto text = content_factory("test/data/15s.srt")[0];
+ auto film = new_test_film("encrypt_only_picture", { picture, text });
+ film->set_encrypt_picture(false);
+ film->set_encrypt_sound(true);
+ film->set_encrypt_text(false);
+ /* clairmeta says "Encrypted is not coherent for all reels" */
+ make_and_verify_dcp(
+ film,
+ {
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA,
+ dcp::VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED,
+ dcp::VerificationNote::Code::PARTIALLY_ENCRYPTED,
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ }, true, false);
+
+ dcp::DCP dcp(film->dir(film->dcp_name()));
+ dcp.read();
+ BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U);
+ auto cpl = dcp.cpls()[0];
+ BOOST_REQUIRE(cpl->file());
+
+ auto dcp_sound = dynamic_pointer_cast<dcp::SoundAsset>(cpl->reels()[0]->main_sound()->asset());
+ auto reader = dcp_sound->start_read();
+ auto frame = reader->get_frame(0);
+ int zeros = 0;
+ for (int i = 0; i < 1024; ++i) {
+ zeros += frame->data()[i] == 0;
+ }
+ BOOST_CHECK(zeros != 1024);
+}
+
+
+BOOST_AUTO_TEST_CASE(encrypt_only_text)
+{
+ auto picture = content_factory("test/data/flat_red.png")[0];
+ auto text = content_factory("test/data/15s.srt")[0];
+ auto film = new_test_film("encrypt_only_picture", { picture, text });
+ film->set_encrypt_picture(false);
+ film->set_encrypt_sound(false);
+ film->set_encrypt_text(true);
+ make_and_verify_dcp(
+ film,
+ {
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA,
+ dcp::VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED,
+ dcp::VerificationNote::Code::PARTIALLY_ENCRYPTED,
+ });
+
+ dcp::DCP dcp(film->dir(film->dcp_name()));
+ dcp.read();
+ BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U);
+ auto cpl = dcp.cpls()[0];
+ BOOST_REQUIRE(cpl->file());
+
+ auto dcp_subtitle = dynamic_pointer_cast<dcp::TextAsset>(cpl->reels()[0]->main_subtitle()->asset());
+ BOOST_CHECK_THROW(dcp_subtitle->xml_as_string(), dcp::ProgrammingError);
+}
+
diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc
index 8782e7f73..0201594c7 100644
--- a/test/import_dcp_test.cc
+++ b/test/import_dcp_test.cc
@@ -58,7 +58,8 @@ BOOST_AUTO_TEST_CASE (import_dcp_test)
auto c = make_shared<FFmpegContent>("test/data/test.mp4");
auto A = new_test_film("import_dcp_test", { c });
- A->set_encrypted (true);
+ A->set_encrypt_picture(true);
+ A->set_encrypt_sound(true);
A->set_dcp_content_type(DCPContentType::from_isdcf_name("TLR"));
make_and_verify_dcp (A);
diff --git a/test/kdm_cli_test.cc b/test/kdm_cli_test.cc
index 4292da17e..4bc3ddf46 100644
--- a/test/kdm_cli_test.cc
+++ b/test/kdm_cli_test.cc
@@ -276,7 +276,9 @@ BOOST_AUTO_TEST_CASE(kdm_cli_specify_cert)
boost::filesystem::remove(kdm_filename, ec);
auto film = new_test_film("kdm_cli_specify_cert", content_factory("test/data/flat_red.png"));
- film->set_encrypted(true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
+ film->set_encrypt_text(true);
film->set_name("KDMCLI");
film->set_use_isdcf_name(false);
make_and_verify_dcp(film);
diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc
index 2308e6ac6..efc96b2c2 100644
--- a/test/kdm_naming_test.cc
+++ b/test/kdm_naming_test.cc
@@ -89,7 +89,8 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test)
film->set_name ("my_great_film");
film->examine_and_add_content(content_factory("test/data/flat_black.png"));
BOOST_REQUIRE (!wait_for_jobs());
- film->set_encrypted (true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
make_and_verify_dcp (film);
auto cpls = film->cpls ();
BOOST_REQUIRE(cpls.size() == 1);
@@ -156,7 +157,8 @@ BOOST_AUTO_TEST_CASE(directory_kdm_naming_test)
);
film->set_name ("my_great_film");
- film->set_encrypted (true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
make_and_verify_dcp (film);
auto cpls = film->cpls ();
BOOST_REQUIRE(cpls.size() == 1);
diff --git a/test/player_test.cc b/test/player_test.cc
index ab4560ffa..684cede04 100644
--- a/test/player_test.cc
+++ b/test/player_test.cc
@@ -463,7 +463,9 @@ BOOST_AUTO_TEST_CASE (encrypted_dcp_with_no_kdm_gives_no_butler_error)
auto film = new_test_film("encrypted_dcp_with_no_kdm_gives_no_butler_error", { content });
int constexpr length = 24 * 25;
content->video->set_length(length);
- film->set_encrypted (true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
+ film->set_encrypt_text(true);
make_and_verify_dcp (
film,
{
diff --git a/test/recover_test.cc b/test/recover_test.cc
index ba06fcde9..73d54b017 100644
--- a/test/recover_test.cc
+++ b/test/recover_test.cc
@@ -142,7 +142,8 @@ BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on(
{
auto content = make_shared<FFmpegContent>("test/data/count300bd24.m2ts");
auto film = new_test_film("recover_test_2d_encrypted", { content });
- film->set_encrypted (true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
film->_key = dcp::Key("eafcb91c9f5472edf01f3a2404c57258");
film->set_video_bit_rate(VideoEncoding::JPEG2000, 100000000);
diff --git a/test/remake_id_test.cc b/test/remake_id_test.cc
index 0673a4283..579a711a8 100644
--- a/test/remake_id_test.cc
+++ b/test/remake_id_test.cc
@@ -69,7 +69,8 @@ BOOST_AUTO_TEST_CASE (remake_id_test2)
/* Make a DCP */
auto content = content_factory("test/data/flat_red.png");
auto film = new_test_film("remake_id_test2_1", content);
- film->set_encrypted (true);
+ film->set_encrypt_picture(true);
+ film->set_encrypt_sound(true);
make_and_verify_dcp (film);
/* Remove and remake it */
diff --git a/test/vf_kdm_test.cc b/test/vf_kdm_test.cc
index 3fd8bc327..a5989088b 100644
--- a/test/vf_kdm_test.cc
+++ b/test/vf_kdm_test.cc
@@ -55,7 +55,8 @@ BOOST_AUTO_TEST_CASE (vf_kdm_test)
auto A = new_test_film("vf_kdm_test_ov", { c });
A->set_interop (true);
A->set_dcp_content_type(DCPContentType::from_isdcf_name("TLR"));
- A->set_encrypted (true);
+ A->set_encrypt_picture(true);
+ A->set_encrypt_sound(true);
make_and_verify_dcp (A, {dcp::VerificationNote::Code::INVALID_STANDARD});
dcp::DCP A_dcp ("build/test/vf_kdm_test_ov/" + A->dcp_name());
@@ -79,7 +80,8 @@ BOOST_AUTO_TEST_CASE (vf_kdm_test)
B->set_interop(true);
d->set_reference_video (true);
- B->set_encrypted (true);
+ B->set_encrypt_picture(true);
+ B->set_encrypt_sound(true);
make_and_verify_dcp (B, {dcp::VerificationNote::Code::INVALID_STANDARD, dcp::VerificationNote::Code::EXTERNAL_ASSET});
dcp::DCP B_dcp ("build/test/vf_kdm_test_vf/" + B->dcp_name());