Use only the first 16 bytes of the asset key.
Bug: 18003864 Change-Id: I65b08c4766a4c2ab08b09660b1540630387ab36c
This commit is contained in:
parent
8336801ffc
commit
0be4815edc
|
@ -61,6 +61,7 @@ namespace {
|
|||
const uint32_t kEcmFlagsSizeBytes =
|
||||
kEcmCCIFlagsSizeBytes + kEcmDCPFlagsSizeBytes;
|
||||
const uint32_t kEcmPaddingSizeBytes = 12;
|
||||
const uint32_t kAssetKeySizeBytes = 16;
|
||||
|
||||
enum Type {
|
||||
Type_void = 0,
|
||||
|
@ -963,9 +964,21 @@ bool WvmMediaParser::ProcessEcm() {
|
|||
if (!GetAssetKey(asset_id, &encryption_key)) {
|
||||
return false;
|
||||
}
|
||||
if (encryption_key.key.size() < kAssetKeySizeBytes) {
|
||||
LOG(ERROR) << "Asset Key size of " << encryption_key.key.size()
|
||||
<< " for AssetID = " << asset_id
|
||||
<< " is less than minimum asset key size.";
|
||||
return false;
|
||||
}
|
||||
// Legacy WVM content may have asset keys > 16 bytes.
|
||||
// Use only the first 16 bytes of the asset key to get
|
||||
// the content key.
|
||||
std::vector<uint8_t> asset_key(
|
||||
encryption_key.key.begin(),
|
||||
encryption_key.key.begin() + kAssetKeySizeBytes);
|
||||
std::vector<uint8_t> iv(kInitializationVectorSizeBytes);
|
||||
AesCbcCtsDecryptor asset_decryptor;
|
||||
if (!asset_decryptor.InitializeWithIv(encryption_key.key, iv)) {
|
||||
if (!asset_decryptor.InitializeWithIv(asset_key, iv)) {
|
||||
LOG(ERROR) << "Failed to initialize asset_decryptor.";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,11 @@ const int kExpectedVideoFrameCount = 6665;
|
|||
const int kExpectedAudioFrameCount = 11964;
|
||||
const uint8_t kExpectedAssetKey[] =
|
||||
"\x06\x81\x7f\x48\x6b\xf2\x7f\x3e\xc7\x39\xa8\x3f\x12\x0a\xd2\xfc";
|
||||
const uint8_t k64ByteAssetKey[] =
|
||||
"\x06\x81\x7f\x48\x6b\xf2\x7f\x3e\xc7\x39\xa8\x3f\x12\x0a\xd2\xfc"
|
||||
"\x06\x81\x7f\x48\x6b\xf2\x7f\x3e\xc7\x39\xa8\x3f\x12\x0a\xd2\xfc"
|
||||
"\x06\x81\x7f\x48\x6b\xf2\x7f\x3e\xc7\x39\xa8\x3f\x12\x0a\xd2\xfc"
|
||||
"\x06\x81\x7f\x48\x6b\xf2\x7f\x3e\xc7\x39\xa8\x3f\x12\x0a\xd2\xfc";
|
||||
const size_t kInitDataSize = 0x4000;
|
||||
} // namespace
|
||||
|
||||
|
@ -65,6 +70,7 @@ class WvmMediaParserTest : public testing::Test {
|
|||
current_track_id_(-1) {
|
||||
parser_.reset(new WvmMediaParser());
|
||||
key_source_.reset(new MockKeySource());
|
||||
encryption_key_.key.resize(16);
|
||||
encryption_key_.key.assign(kExpectedAssetKey, kExpectedAssetKey + 16);
|
||||
}
|
||||
|
||||
|
@ -169,6 +175,19 @@ TEST_F(WvmMediaParserTest, ParseWvm) {
|
|||
EXPECT_EQ(kExpectedAudioFrameCount, audio_frame_count_);
|
||||
}
|
||||
|
||||
TEST_F(WvmMediaParserTest, ParseWvmWith64ByteAssetKey) {
|
||||
EXPECT_CALL(*key_source_, FetchKeys(_)).WillOnce(Return(Status::OK));
|
||||
// WVM uses only the first 16 bytes of the asset key.
|
||||
encryption_key_.key.resize(64);
|
||||
encryption_key_.key.assign(k64ByteAssetKey, k64ByteAssetKey + 64);
|
||||
EXPECT_CALL(*key_source_, GetKey(_, _))
|
||||
.WillOnce(DoAll(SetArgPointee<1>(encryption_key_), Return(Status::OK)));
|
||||
Parse(kWvmFile);
|
||||
EXPECT_EQ(kExpectedStreams, stream_map_.size());
|
||||
EXPECT_EQ(kExpectedVideoFrameCount, video_frame_count_);
|
||||
EXPECT_EQ(kExpectedAudioFrameCount, audio_frame_count_);
|
||||
}
|
||||
|
||||
} // namespace wvm
|
||||
} // namespace media
|
||||
} // namespace edash_packager
|
||||
|
|
Loading…
Reference in New Issue