Skip to content

Commit

Permalink
Bug 1308076 - Ensure Primetime PSSH boxes pass the PSSH validator. r=…
Browse files Browse the repository at this point in the history
…jwwang

Primetime PSSH boxes don't use the common encryption system ID.
So to ensure we don't break any existing Primetime players, we
must allow PSSH boxes with the Primetime system ID to pass the
PSSH validator.

MozReview-Commit-ID: 3q58FKLQXgV

--HG--
extra : rebase_source : a7a0ca3d38fb027ad6de23d8260043b3193536f4
extra : source : b94fe60732fb7d3a6630c976284eaabd28b271f3
  • Loading branch information
Chris Pearce committed Oct 11, 2016
1 parent cc1ef86 commit c0fc92f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions media/psshparser/PsshParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ const uint8_t kSystemID[] = {
0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b
};

const uint8_t kPrimetimeID[] = {
0xf2, 0x39, 0xe7, 0x69, 0xef, 0xa3, 0x48, 0x50,
0x9c, 0x16, 0xa9, 0x03, 0xc6, 0x93, 0x2e, 0xfb
};

bool
ParseCENCInitData(const uint8_t* aInitData,
uint32_t aInitDataSize,
Expand Down Expand Up @@ -158,6 +163,12 @@ ParseCENCInitData(const uint8_t* aInitData,
// Insufficient bytes to read SystemID.
return false;
}
if (!memcmp(kPrimetimeID, sid, sizeof(kSystemID))) {
// Allow legacy Primetime key system PSSH boxes, which
// don't conform to common encryption format.
return true;
}

if (memcmp(kSystemID, sid, sizeof(kSystemID))) {
// Ignore pssh boxes with wrong system ID.
reader.Seek(std::max<size_t>(reader.Offset(), end));
Expand Down
13 changes: 13 additions & 0 deletions media/psshparser/gtest/TestPsshParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ const uint8_t g2xGoogleWPTCencInitData[] = {
0x00, 0x00, 0x00, 0x00 // datasize
};

const uint8_t gPrimetimePSSH[] = {
0x00, 0x00, 0x00, 0x00, // size = 0
0x70, 0x73, 0x73, 0x68, // 'pssh'
0x01, // version = 1
0x00, 0x00, 0x00, // flags
0xf2, 0x39, 0xe7, 0x69, 0xef, 0xa3, 0x48, 0x50, // Primetime system Id
0x9c, 0x16, 0xa9, 0x03, 0xc6, 0x93, 0x2e, 0xfb
};

TEST(PsshParser, ParseCencInitData) {
std::vector<std::vector<uint8_t>> keyIds;
bool rv;
Expand Down Expand Up @@ -153,4 +162,8 @@ TEST(PsshParser, ParseCencInitData) {
EXPECT_EQ(16u, keyIds[1].size());
EXPECT_EQ(0, memcmp(&keyIds[0].front(), &g2xGoogleWPTCencInitData[32], 16));
EXPECT_EQ(0, memcmp(&keyIds[1].front(), &g2xGoogleWPTCencInitData[84], 16));

rv = ParseCENCInitData(gPrimetimePSSH, MOZ_ARRAY_LENGTH(gPrimetimePSSH), keyIds);
EXPECT_TRUE(rv);
EXPECT_EQ(0u, keyIds.size());
}

0 comments on commit c0fc92f

Please sign in to comment.