Commit 5d4f4321 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Always enable CBCS encryption scheme

enable_cbcs_encryption_scheme flag was set on all platforms except
Fuchsia. There is no reason this feature needs to be disabled on
Fuchsia. Remove this flag.

Bug: 1021308
Change-Id: If79065f337119f9098254f21caa12bec79609b4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898640Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712815}
parent 792db607
......@@ -722,11 +722,7 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Encryption_CBCS) {
return;
}
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
TestSimplePlayback("bear-640x360-v_frag-cbcs.mp4");
#else
DVLOG(0) << "Skipping test; 'cbcs' decryption not supported.";
#endif
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
......@@ -861,9 +857,7 @@ IN_PROC_BROWSER_TEST_P(ECKEncryptedMediaTest, DecryptOnly_VideoOnly_MP4_CBCS) {
// 'cbcs' decryption is only supported on CDM 10 or later as long as
// the appropriate buildflag is enabled.
std::string expected_result =
GetCdmInterfaceVersion() >= 10 && BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
? media::kEnded
: media::kError;
GetCdmInterfaceVersion() >= 10 ? media::kEnded : media::kError;
RunEncryptedMediaTest(kDefaultEmePlayer, "bear-640x360-v_frag-cbcs.mp4",
kExternalClearKeyDecryptOnlyKeySystem, SrcType::MSE,
kNoSessionToLoad, false, PlayCount::ONCE,
......@@ -894,9 +888,7 @@ IN_PROC_BROWSER_TEST_P(ECKEncryptedMediaTest, Playback_Encryption_CBCS) {
// 'cbcs' decryption is only supported on CDM 10 or later as long as
// the appropriate buildflag is enabled.
std::string expected_result =
GetCdmInterfaceVersion() >= 10 && BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
? media::kEnded
: media::kError;
GetCdmInterfaceVersion() >= 10 ? media::kEnded : media::kError;
RunEncryptedMediaMultipleFileTest(
kExternalClearKeyKeySystem, "bear-640x360-v_frag-cbcs.mp4",
"bear-640x360-a_frag-cbcs.mp4", expected_result);
......
......@@ -383,26 +383,20 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Encryption_CENS) {
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_Encryption_CBCS) {
std::string expected_result =
BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) ? media::kEnded : media::kError;
RunMultipleFileTest("bear-640x360-v_frag-cbcs.mp4",
"bear-640x360-a_frag-cbcs.mp4", expected_result);
"bear-640x360-a_frag-cbcs.mp4", media::kEnded);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
Playback_Encryption_CBCS_Video_CENC_Audio) {
std::string expected_result =
BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) ? media::kEnded : media::kError;
RunMultipleFileTest("bear-640x360-v_frag-cbcs.mp4",
"bear-640x360-a_frag-cenc.mp4", expected_result);
"bear-640x360-a_frag-cenc.mp4", media::kEnded);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
Playback_Encryption_CENC_Video_CBCS_Audio) {
std::string expected_result =
BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) ? media::kEnded : media::kError;
RunMultipleFileTest("bear-640x360-v_frag-cenc.mp4",
"bear-640x360-a_frag-cbcs.mp4", expected_result);
"bear-640x360-a_frag-cbcs.mp4", media::kEnded);
}
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
......
......@@ -21,7 +21,6 @@ buildflag_header("media_buildflags") {
"ALTERNATE_CDM_STORAGE_ID_KEY=\"$alternate_cdm_storage_id_key\"",
"CDM_PLATFORM_SPECIFIC_PATH=\"$cdm_platform_specific_path\"",
"ENABLE_PLATFORM_AC3_EAC3_AUDIO=$enable_platform_ac3_eac3_audio",
"ENABLE_CBCS_ENCRYPTION_SCHEME=$enable_cbcs_encryption_scheme",
"ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
"ENABLE_CDM_PROXY=$enable_cdm_proxy",
"ENABLE_CDM_STORAGE_ID=$enable_cdm_storage_id",
......
......@@ -297,15 +297,10 @@ bool SchemeType::Parse(BoxReader* reader) {
TrackEncryption::TrackEncryption()
: is_encrypted(false),
default_iv_size(0)
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
,
default_iv_size(0),
default_crypt_byte_block(0),
default_skip_byte_block(0),
default_constant_iv_size(0)
#endif
{
}
default_constant_iv_size(0) {}
TrackEncryption::TrackEncryption(const TrackEncryption& other) = default;
TrackEncryption::~TrackEncryption() = default;
FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; }
......@@ -320,7 +315,6 @@ bool TrackEncryption::Parse(BoxReader* reader) {
reader->ReadVec(&default_kid, kKeyIdSize));
is_encrypted = (flag != 0);
if (is_encrypted) {
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
if (reader->version() > 0) {
default_crypt_byte_block = (possible_pattern_info >> 4) & 0x0f;
default_skip_byte_block = possible_pattern_info & 0x0f;
......@@ -334,9 +328,6 @@ bool TrackEncryption::Parse(BoxReader* reader) {
} else {
RCHECK(default_iv_size == 8 || default_iv_size == 16);
}
#else
RCHECK(default_iv_size == 8 || default_iv_size == 16);
#endif
} else {
RCHECK(default_iv_size == 0);
}
......@@ -373,22 +364,12 @@ bool ProtectionSchemeInfo::Parse(BoxReader* reader) {
bool ProtectionSchemeInfo::HasSupportedScheme() const {
FourCC four_cc = type.type;
if (four_cc == FOURCC_CENC)
return true;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
if (four_cc == FOURCC_CBCS)
return true;
#endif
return false;
return (four_cc == FOURCC_CENC || four_cc == FOURCC_CBCS);
}
bool ProtectionSchemeInfo::IsCbcsEncryptionScheme() const {
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
FourCC four_cc = type.type;
return (four_cc == FOURCC_CBCS);
#else
return false;
#endif
}
MovieHeader::MovieHeader()
......@@ -1614,15 +1595,10 @@ bool SampleToGroup::Parse(BoxReader* reader) {
CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry()
: is_encrypted(false),
iv_size(0)
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
,
iv_size(0),
crypt_byte_block(0),
skip_byte_block(0),
constant_iv_size(0)
#endif
{
}
constant_iv_size(0) {}
CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry(
const CencSampleEncryptionInfoEntry& other) = default;
CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry() = default;
......@@ -1636,7 +1612,6 @@ bool CencSampleEncryptionInfoEntry::Parse(BoxReader* reader) {
is_encrypted = (flag != 0);
if (is_encrypted) {
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
crypt_byte_block = (possible_pattern_info >> 4) & 0x0f;
skip_byte_block = possible_pattern_info & 0x0f;
if (iv_size == 0) {
......@@ -1648,9 +1623,6 @@ bool CencSampleEncryptionInfoEntry::Parse(BoxReader* reader) {
} else {
RCHECK(iv_size == 8 || iv_size == 16);
}
#else
RCHECK(iv_size == 8 || iv_size == 16);
#endif
} else {
RCHECK(iv_size == 0);
}
......
......@@ -133,12 +133,10 @@ struct MEDIA_EXPORT TrackEncryption : Box {
bool is_encrypted;
uint8_t default_iv_size;
std::vector<uint8_t> default_kid;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
uint8_t default_crypt_byte_block;
uint8_t default_skip_byte_block;
uint8_t default_constant_iv_size;
uint8_t default_constant_iv[kInitializationVectorSize];
#endif
};
struct MEDIA_EXPORT SchemeInfo : Box {
......@@ -357,12 +355,10 @@ struct MEDIA_EXPORT CencSampleEncryptionInfoEntry {
bool is_encrypted;
uint8_t iv_size;
std::vector<uint8_t> key_id;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
uint8_t crypt_byte_block;
uint8_t skip_byte_block;
uint8_t constant_iv_size;
uint8_t constant_iv[kInitializationVectorSize];
#endif
};
struct MEDIA_EXPORT SampleGroupDescription : Box { // 'sgpd'.
......
......@@ -51,29 +51,23 @@ EncryptionScheme GetEncryptionScheme(const ProtectionSchemeInfo& sinf) {
FourCC fourcc = sinf.type.type;
EncryptionScheme::CipherMode mode = EncryptionScheme::CIPHER_MODE_UNENCRYPTED;
EncryptionPattern pattern;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
bool uses_pattern_encryption = false;
#endif
switch (fourcc) {
case FOURCC_CENC:
mode = EncryptionScheme::CIPHER_MODE_AES_CTR;
break;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
case FOURCC_CBCS:
mode = EncryptionScheme::CIPHER_MODE_AES_CBC;
uses_pattern_encryption = true;
break;
#endif
default:
NOTREACHED();
break;
}
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
if (uses_pattern_encryption) {
pattern = {sinf.info.track_encryption.default_crypt_byte_block,
sinf.info.track_encryption.default_skip_byte_block};
}
#endif
return EncryptionScheme(mode, pattern);
}
} // namespace
......
......@@ -57,9 +57,7 @@ struct TrackRunInfo {
int aux_info_total_size;
EncryptionMode encryption_mode;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
EncryptionPattern encryption_pattern;
#endif // BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
std::vector<CencSampleEncryptionInfoEntry> fragment_sample_encryption_info;
......@@ -376,17 +374,12 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
if (!sinf->HasSupportedScheme()) {
tri.encryption_mode = EncryptionMode::kUnencrypted;
} else {
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
tri.encryption_mode = sinf->IsCbcsEncryptionScheme()
? EncryptionMode::kCbcs
: EncryptionMode::kCenc;
tri.encryption_pattern =
EncryptionPattern(track_encryption->default_crypt_byte_block,
track_encryption->default_skip_byte_block);
#else
DCHECK(!sinf->IsCbcsEncryptionScheme());
tri.encryption_mode = EncryptionMode::kCenc;
#endif
}
// Initialize aux_info variables only if no sample encryption entries.
......@@ -500,7 +493,6 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
SampleEncryptionEntry& entry = tri.sample_encryption_entries[k];
RCHECK(entry.Parse(sample_encryption_reader.get(), iv_size,
traf.sample_encryption.use_subsample_encryption));
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
// If we don't have a per-sample IV, get the constant IV.
bool is_encrypted = index == 0 ? track_encryption->is_encrypted
: info_entry->is_encrypted;
......@@ -534,7 +526,6 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
: info_entry->constant_iv;
memcpy(entry.initialization_vector, constant_iv, constant_iv_size);
}
#endif // BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
}
}
runs_.push_back(tri);
......@@ -620,12 +611,10 @@ bool TrackRunIterator::CacheAuxInfo(const uint8_t* buf, int buf_size) {
RCHECK_MEDIA_LOGGED(
entry.Parse(&reader, iv_size, has_subsamples), media_log_,
"SampleEncryptionEntry parse failed when caching aux info");
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
// if we don't have a per-sample IV, get the constant IV.
if (!iv_size) {
RCHECK(ApplyConstantIv(i, &entry));
}
#endif
}
pos += info_size;
}
......@@ -751,7 +740,6 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
if (run_itr_->sample_encryption_entries.empty()) {
DCHECK_EQ(0, aux_info_size());
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
// The 'cbcs' scheme allows empty aux info when a constant IV is in use
// with full sample encryption. That case will fall through to here.
SampleEncryptionEntry sample_encryption_entry;
......@@ -771,7 +759,6 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
run_itr_->encryption_pattern);
}
}
#endif
MEDIA_LOG(ERROR, media_log_) << "Sample encryption info is not available.";
return nullptr;
}
......@@ -791,7 +778,6 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
return nullptr;
}
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
if (protection_scheme_info().IsCbcsEncryptionScheme()) {
uint32_t index = GetGroupDescriptionIndex(sample_idx);
uint32_t encrypt_blocks =
......@@ -806,7 +792,6 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
key_id, iv, sample_encryption_entry.subsamples,
EncryptionPattern(encrypt_blocks, skip_blocks));
}
#endif
return DecryptConfig::CreateCencConfig(key_id, iv,
sample_encryption_entry.subsamples);
......@@ -839,7 +824,6 @@ uint8_t TrackRunIterator::GetIvSize(size_t sample_index) const {
: GetSampleEncryptionInfoEntry(*run_itr_, index)->iv_size;
}
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
bool TrackRunIterator::ApplyConstantIv(size_t sample_index,
SampleEncryptionEntry* entry) const {
DCHECK(IsSampleEncrypted(sample_index));
......@@ -856,7 +840,6 @@ bool TrackRunIterator::ApplyConstantIv(size_t sample_index,
memcpy(entry->initialization_vector, constant_iv, kInitializationVectorSize);
return true;
}
#endif
} // namespace mp4
} // namespace media
......@@ -104,9 +104,7 @@ class MEDIA_EXPORT TrackRunIterator {
bool IsSampleEncrypted(size_t sample_index) const;
uint8_t GetIvSize(size_t sample_index) const;
const std::vector<uint8_t>& GetKeyId(size_t sample_index) const;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
bool ApplyConstantIv(size_t sample_index, SampleEncryptionEntry* entry) const;
#endif
const Movie* moov_;
MediaLog* media_log_;
......
......@@ -97,7 +97,6 @@ const uint8_t kFragmentCencSampleGroupKeyId[] = {
0x74, 0x43, 0x65, 0x6e, 0x63, 0x53, 0x61, 0x6d,
};
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
// Sample encryption data for two samples, using constant IV (defined by 'tenc'
// or sample group entry).
const uint8_t kSampleEncryptionDataWithSubsamplesAndConstantIv[] = {
......@@ -137,7 +136,6 @@ const char kIv5[] = {
0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x35,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
};
#endif
} // namespace
......@@ -425,7 +423,6 @@ class TrackRunIteratorTest : public testing::Test {
}
}
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
// Update the first sample description of a Track to indicate CBCS encryption
// with a constant IV and pattern.
void AddEncryptionCbcs(Track* track) {
......@@ -487,7 +484,6 @@ class TrackRunIteratorTest : public testing::Test {
frag->auxiliary_size.sample_info_sizes.push_back(16);
frag->auxiliary_size.sample_info_sizes.push_back(16);
}
#endif
bool InitMoofWithArbitraryAuxInfo(MovieFragment* moof) {
// Add aux info header (equal sized aux info for every sample).
......@@ -1017,7 +1013,6 @@ TEST_F(TrackRunIteratorTest, KeyFrameFlagCombinations) {
EXPECT_EQ("2 K P P P K P", KeyframeAndRAPInfo(iter_.get()));
}
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
TEST_F(TrackRunIteratorTest, DecryptConfigTestWithConstantIvNoAuxInfo) {
AddEncryptionCbcs(&moov_.tracks[1]);
iter_.reset(new TrackRunIterator(&moov_, &media_log_));
......@@ -1107,7 +1102,5 @@ TEST_F(TrackRunIteratorTest, DecryptConfigTestWithSampleGroupsAndConstantIv) {
EXPECT_EQ(track_encryption_iv, iter_->GetDecryptConfig()->iv());
}
#endif
} // namespace mp4
} // namespace media
......@@ -70,11 +70,6 @@ declare_args() {
enable_mse_mpeg2ts_stream_parser =
proprietary_codecs && (is_chromecast || is_fuchsia || use_fuzzing_engine)
# Enable parsing for the 'cbcs' encryption scheme added by MPEG Common
# Encryption 3rd Edition (ISO/IEC 23001-7), published 02/15/2016.
enable_cbcs_encryption_scheme =
is_chromecast || is_mac || is_win || is_linux || is_android
# Enable HEVC/H265 demuxing. Actual decoding must be provided by the
# platform. Enabled by default for Chromecast.
enable_platform_hevc = proprietary_codecs && is_chromecast
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment