+
+BOOST_AUTO_TEST_CASE (verify_unsigned_pkl_with_encrypted_content)
+{
+ path dir = "build/test/unsigned_pkl_with_encrypted_content";
+ prepare_directory (dir);
+ for (auto i: directory_iterator("test/ref/DCP/encryption_test")) {
+ copy_file (i.path(), dir / i.path().filename());
+ }
+
+ path const cpl = dir / ("cpl_" + encryption_test_cpl_id + ".xml");
+ path const pkl = dir / ("pkl_" + encryption_test_pkl_id + ".xml");
+ {
+ Editor e (pkl);
+ e.delete_lines ("<dsig:Signature", "</dsig:Signature>");
+ }
+
+ check_verify_result (
+ {dir},
+ {
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, encryption_test_pkl_id, canonical(pkl) },
+ /* It's encrypted so the J2K validity checks will fail */
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_JPEG2000_CODESTREAM, string("missing marker start byte") },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_FFOC },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_LFOC },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, encryption_test_cpl_id, canonical(cpl) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT, encryption_test_pkl_id, canonical(pkl) },
+ });
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_unsigned_pkl_with_unencrypted_content)
+{
+ path dir = "build/test/verify_unsigned_pkl_with_unencrypted_content";
+ prepare_directory (dir);
+ for (auto i: directory_iterator("test/ref/DCP/dcp_test1")) {
+ copy_file (i.path(), dir / i.path().filename());
+ }
+
+ {
+ Editor e (dir / dcp_test1_pkl);
+ e.delete_lines ("<dsig:Signature", "</dsig:Signature>");
+ }
+
+ check_verify_result ({dir}, {});
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_partially_encrypted)
+{
+ path dir ("build/test/verify_must_not_be_partially_encrypted");
+ prepare_directory (dir);
+
+ dcp::DCP d (dir);
+
+ auto signer = make_shared<dcp::CertificateChain>();
+ signer->add (dcp::Certificate(dcp::file_to_string("test/ref/crypt/ca.self-signed.pem")));
+ signer->add (dcp::Certificate(dcp::file_to_string("test/ref/crypt/intermediate.signed.pem")));
+ signer->add (dcp::Certificate(dcp::file_to_string("test/ref/crypt/leaf.signed.pem")));
+ signer->set_key (dcp::file_to_string("test/ref/crypt/leaf.key"));
+
+ auto cpl = make_shared<dcp::CPL>("A Test DCP", dcp::ContentKind::TRAILER);
+
+ dcp::Key key;
+
+ auto mp = make_shared<dcp::MonoPictureAsset>(dcp::Fraction (24, 1), dcp::Standard::SMPTE);
+ mp->set_key (key);
+
+ auto writer = mp->start_write (dir / "video.mxf", false);
+ dcp::ArrayData j2c ("test/data/flat_red.j2c");
+ for (int i = 0; i < 24; ++i) {
+ writer->write (j2c.data(), j2c.size());
+ }
+ writer->finalize ();
+
+ auto ms = simple_sound (dir, "", dcp::MXFMetadata(), "de-DE");
+
+ auto reel = make_shared<dcp::Reel>(
+ make_shared<dcp::ReelMonoPictureAsset>(mp, 0),
+ make_shared<dcp::ReelSoundAsset>(ms, 0)
+ );
+
+ reel->add (simple_markers());
+
+ cpl->add (reel);
+
+ cpl->set_content_version (
+ {"urn:uri:81fb54df-e1bf-4647-8788-ea7ba154375b_2012-07-17T04:45:18+00:00", "81fb54df-e1bf-4647-8788-ea7ba154375b_2012-07-17T04:45:18+00:00"}
+ );
+ cpl->set_annotation_text ("A Test DCP");
+ cpl->set_issuer ("OpenDCP 0.0.25");
+ cpl->set_creator ("OpenDCP 0.0.25");
+ cpl->set_issue_date ("2012-07-17T04:45:18+00:00");
+ cpl->set_main_sound_configuration ("L,C,R,Lfe,-,-");
+ cpl->set_main_sound_sample_rate (48000);
+ cpl->set_main_picture_stored_area (dcp::Size(1998, 1080));
+ cpl->set_main_picture_active_area (dcp::Size(1440, 1080));
+ cpl->set_version_number (1);
+
+ d.add (cpl);
+
+ d.write_xml (dcp::Standard::SMPTE, "OpenDCP 0.0.25", "OpenDCP 0.0.25", "2012-07-17T04:45:18+00:00", "A Test DCP", signer);
+
+ check_verify_result (
+ {dir},
+ {
+ {dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::PARTIALLY_ENCRYPTED},
+ /* It's encrypted so the J2K validity checks will fail */
+ {dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_JPEG2000_CODESTREAM, string("missing marker start byte")}
+ });
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_jpeg2000_codestream_2k)
+{
+ vector<dcp::VerificationNote> notes;
+ dcp::MonoPictureAsset picture (find_file(private_test / "data" / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV", "j2c.mxf"));
+ auto reader = picture.start_read ();
+ auto frame = reader->get_frame (0);
+ verify_j2k (frame, notes);
+ BOOST_REQUIRE_EQUAL (notes.size(), 0U);
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_jpeg2000_codestream_4k)
+{
+ vector<dcp::VerificationNote> notes;
+ dcp::MonoPictureAsset picture (find_file(private_test / "data" / "sul", "TLR"));
+ auto reader = picture.start_read ();
+ auto frame = reader->get_frame (0);
+ verify_j2k (frame, notes);
+ BOOST_REQUIRE_EQUAL (notes.size(), 0U);
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_jpeg2000_codestream_libdcp)
+{
+ boost::filesystem::path dir = "build/test/verify_jpeg2000_codestream_libdcp";
+ prepare_directory (dir);
+ auto dcp = make_simple (dir);
+ dcp->write_xml (dcp::Standard::SMPTE);
+ vector<dcp::VerificationNote> notes;
+ dcp::MonoPictureAsset picture (find_file(dir, "video"));
+ auto reader = picture.start_read ();
+ auto frame = reader->get_frame (0);
+ verify_j2k (frame, notes);
+ BOOST_REQUIRE_EQUAL (notes.size(), 0U);
+}
+