9 #include "packager/app/widevine_encryption_flags.h"
11 #include "packager/app/validate_flag.h"
12 #include "packager/base/logging.h"
13 #include "packager/base/strings/string_util.h"
15 DEFINE_bool(enable_widevine_encryption,
17 "Enable encryption with Widevine license server/proxy. User should "
18 "provide either AES signing key (--aes_signing_key, "
19 "--aes_signing_iv) or RSA signing key (--rsa_signing_key_path).");
20 DEFINE_bool(enable_widevine_decryption,
22 "Enable decryption with Widevine license server/proxy. User should "
23 "provide either AES signing key (--aes_signing_key, "
24 "--aes_signing_iv) or RSA signing key (--rsa_signing_key_path).");
25 DEFINE_string(key_server_url,
"",
"Key server url. Required for encryption and "
27 DEFINE_string(content_id,
"",
"Content Id (hex).");
30 "The name of a stored policy, which specifies DRM content "
32 DEFINE_int32(max_sd_pixels,
34 "If the video track has more pixels per frame than max_sd_pixels, "
35 "it is considered as HD, SD otherwise. Default: 768 * 576.");
36 DEFINE_string(signer,
"",
"The name of the signer.");
37 DEFINE_string(aes_signing_key,
39 "AES signing key in hex string. --aes_signing_iv is required. "
40 "Exclusive with --rsa_signing_key_path.");
41 DEFINE_string(aes_signing_iv,
43 "AES signing iv in hex string.");
44 DEFINE_string(rsa_signing_key_path,
46 "Stores PKCS#1 RSA private key for request signing. Exclusive "
47 "with --aes_signing_key.");
48 DEFINE_int32(crypto_period_duration,
50 "Crypto period duration in seconds. If it is non-zero, key "
51 "rotation is enabled.");
53 namespace edash_packager {
58 const bool widevine_crypto =
59 FLAGS_enable_widevine_encryption || FLAGS_enable_widevine_decryption;
60 const char widevine_crypto_label[] =
61 "--enable_widevine_encryption/decryption";
68 widevine_crypto_label)) {
75 widevine_crypto_label)) {
78 if (widevine_crypto && FLAGS_signer.empty() &&
79 base::StartsWith(FLAGS_key_server_url,
"http",
80 base::CompareCase::INSENSITIVE_ASCII)) {
81 LOG(WARNING) <<
"--signer is likely required with "
82 "--enable_widevine_encryption/decryption.";
85 const char widevine_encryption_label[] =
"--enable_widevine_encryption";
90 FLAGS_enable_widevine_encryption,
92 widevine_encryption_label)) {
97 FLAGS_enable_widevine_encryption,
99 widevine_encryption_label)) {
103 if (FLAGS_max_sd_pixels <= 0) {
104 PrintError(
"--max_sd_pixels must be positive.");
108 const bool aes = !FLAGS_signer.empty() && FLAGS_rsa_signing_key_path.empty();
109 const char aes_label[] =
110 "--signer is specified and exclusive with --rsa_signing_key_path";
113 "aes_signing_key", FLAGS_aes_signing_key, aes,
true, aes_label)) {
117 "aes_signing_iv", FLAGS_aes_signing_iv, aes,
true, aes_label)) {
121 const bool rsa = !FLAGS_signer.empty() && FLAGS_aes_signing_key.empty() &&
122 FLAGS_aes_signing_iv.empty();
123 const char rsa_label[] =
124 "--signer is specified and exclusive with --aes_signing_key/iv";
127 FLAGS_rsa_signing_key_path,
134 if (!FLAGS_signer.empty() &&
135 (FLAGS_aes_signing_key.empty() || FLAGS_aes_signing_iv.empty()) &&
136 FLAGS_rsa_signing_key_path.empty()) {
138 "--aes_signing_key/iv or --rsa_signing_key_path is required with "
143 if (FLAGS_crypto_period_duration < 0) {
144 PrintError(
"--crypto_period_duration should not be negative.");
bool ValidateWidevineCryptoFlags()
bool ValidateFlag(const char *flag_name, const std::string &flag_value, bool condition, bool optional, const char *label)
void PrintError(const std::string &error_message)