9 #include <packager/app/validate_flag.h>
10 #include <packager/utils/absl_flag_hexbytes.h>
13 enable_fixed_key_encryption,
15 "Same as --enable_raw_key_encryption. Will be deprecated.");
17 enable_fixed_key_decryption,
19 "Same as --enable_raw_key_decryption. Will be deprecated.");
21 enable_raw_key_encryption,
23 "Enable encryption with raw key (key provided in command line).");
25 enable_raw_key_decryption,
27 "Enable decryption with raw key (key provided in command line).");
31 "Key id in hex string format. Will be deprecated. Use --keys.");
35 "Key in hex string format. Will be deprecated. Use --keys.");
36 ABSL_FLAG(std::string,
39 "A list of key information in the form of label=<drm "
40 "label>:key_id=<32-digit key id in hex>:key=<32-digit key in "
45 "IV in hex string format. If not specified, a random IV will be "
46 "generated. This flag should only be used for testing.");
50 "One or more PSSH boxes in hex string format. If not specified, "
51 "will generate a v1 common PSSH box as specified in "
52 "https://goo.gl/s8RIhr.");
59 if (absl::GetFlag(FLAGS_enable_fixed_key_encryption))
60 absl::SetFlag(&FLAGS_enable_raw_key_encryption,
true);
61 if (absl::GetFlag(FLAGS_enable_fixed_key_decryption))
62 absl::SetFlag(&FLAGS_enable_raw_key_decryption,
true);
63 if (absl::GetFlag(FLAGS_enable_fixed_key_encryption) ||
64 absl::GetFlag(FLAGS_enable_fixed_key_decryption)) {
66 "--enable_fixed_key_encryption and --enable_fixed_key_decryption are "
67 "going to be deprecated. Please switch to --enable_raw_key_encryption "
68 "and --enable_raw_key_decryption as soon as possible.");
71 const bool raw_key_crypto = absl::GetFlag(FLAGS_enable_raw_key_encryption) ||
72 absl::GetFlag(FLAGS_enable_raw_key_decryption);
73 const char raw_key_crypto_label[] =
"--enable_raw_key_encryption/decryption";
76 if (absl::GetFlag(FLAGS_keys).empty()) {
77 if (!
ValidateFlag(
"key_id", absl::GetFlag(FLAGS_key_id).bytes,
78 raw_key_crypto,
false, raw_key_crypto_label)) {
81 if (!
ValidateFlag(
"key", absl::GetFlag(FLAGS_key).bytes, raw_key_crypto,
82 false, raw_key_crypto_label)) {
85 if (success && (!absl::GetFlag(FLAGS_key_id).bytes.empty() ||
86 !absl::GetFlag(FLAGS_key).bytes.empty())) {
88 "--key_id and --key are going to be deprecated. Please switch to "
89 "--keys as soon as possible.");
92 if (!absl::GetFlag(FLAGS_key_id).bytes.empty() ||
93 !absl::GetFlag(FLAGS_key).bytes.empty()) {
94 PrintError(
"--key_id or --key cannot be used together with --keys.");
99 absl::GetFlag(FLAGS_enable_raw_key_encryption),
true,
100 "--enable_raw_key_encryption")) {
103 if (!absl::GetFlag(FLAGS_iv).bytes.empty()) {
104 if (absl::GetFlag(FLAGS_iv).bytes.size() != 8 &&
105 absl::GetFlag(FLAGS_iv).bytes.size() != 16) {
107 "--iv should be either 8 bytes (16 hex digits) or 16 bytes (32 hex "
114 if (!
ValidateFlag(
"pssh", absl::GetFlag(FLAGS_pssh).bytes,
115 absl::GetFlag(FLAGS_enable_raw_key_encryption),
true,
116 "--enable_raw_key_encryption")) {
All the methods that are virtual are virtual for mocking.
void PrintWarning(const std::string &warning_message)
void PrintError(const std::string &error_message)
bool ValidateFlag(const char *flag_name, const FlagType &flag_value, bool condition, bool optional, const char *label)
bool ValidateRawKeyCryptoFlags()