diff options
Diffstat (limited to 'src/lib/map_cli.cc')
| -rw-r--r-- | src/lib/map_cli.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/map_cli.cc b/src/lib/map_cli.cc index be3841deb..aab4fabff 100644 --- a/src/lib/map_cli.cc +++ b/src/lib/map_cli.cc @@ -64,6 +64,7 @@ help(std::function<void (string)> out) out(" -s, --soft-link using soft links instead of copying"); out(" -d, --assets-dir look in this directory for assets (can be given more than once)"); out(" -r, --rename rename all files to <uuid>.<mxf|xml>"); + out(" -k, --kdm decrypt assets using the given KDM"); out(" --config <dir> directory containing config.xml and cinemas.xml"); } @@ -77,6 +78,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) bool rename = false; vector<boost::filesystem::path> assets_dir; optional<boost::filesystem::path> config_dir; + optional<boost::filesystem::path> kdm_filename; /* This makes it possible to call getopt several times in the same executable, for tests */ optind = 0; @@ -90,11 +92,12 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) { "soft-link", no_argument, 0, 's' }, { "assets-dir", required_argument, 0, 'd' }, { "rename", no_argument, 0, 'r' }, + { "kdm", required_argument, 0, 'k' }, { "config", required_argument, 0, 'c' }, { 0, 0, 0, 0 } }; - int c = getopt_long(argc, argv, "ho:lsd:rc:", long_options, &option_index); + int c = getopt_long(argc, argv, "ho:lsd:rk:c:", long_options, &option_index); if (c == -1) { break; @@ -121,6 +124,9 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) case 'r': rename = true; break; + case 'k': + kdm = optarg; + break; case 'c': config_dir = optarg; break; @@ -165,6 +171,19 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) return String::compose("Could not create output directory %1: %2", *output_dir, ec.message()); } + optional<dcp::DecryptedKDM> kdm; + if (kdm_filename) { + auto key = Config::instance()->decryption_chain()->key(); + if (!key) { + return string{"Could not find private key to decrypt the KDM"}; + } + try { + kdm = dcp::DecryptedKDM(dcp::EncryptedKDM(dcp::file_to_string(*kdm_filename)), *key); + } catch (std::exception& e) { + return String::compose("Could not decrypt KDM %1: %2", kdm_filename, e.what()); + } + } + /* Find all the assets in the asset directories. This assumes that the asset directories are in fact * DCPs (with AssetMaps and so on). We could search for assets ourselves here but interop fonts are * a little tricky because they don't contain their own UUID within the DCP. |
