Do not convert the protection scheme to network byte order
[ Merge of http://go/wvgerrit/19960 ] Protections schemes are specified using a 4CC code {"cbc1", "cbcs", "cenc", "cens"}. A host to network conversion was performed when the PSSH was created and inserted into the license request. A reverse conversion was performed when the code was extracted from the license response. These conversions are problematic if the PSSH is created externally and passed into mediaDrm. To address this, the conversions have been removed and allow protobuf to handle byte ordering. For backward compatibility we allow codes in either ordering. b/30713238 Change-Id: I25f01ecc621549fd3c13b443e4c8b89168463249
This commit is contained in:
@@ -755,6 +755,62 @@ HlsDecryptionInfo kHlsDecryptionTestVectors[] = {
|
||||
{true, 1, &kSampleAes192ByteSegmentInfo[0], kAttributeListSampleAes},
|
||||
{true, 1, &kSampleAes338ByteSegmentInfo[0], kAttributeListSampleAes},
|
||||
};
|
||||
|
||||
const std::string kHlsPsshAes128LittleEndianFourCC = wvcdm::a2bs_hex(
|
||||
"00000060" // blob size
|
||||
"70737368" // "pssh"
|
||||
"00000000" // flags
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||
"00000040" // pssh data size
|
||||
// pssh data:
|
||||
"08011210AB6531FF6E6EA15E387B019E"
|
||||
"59C2DE0A1A0D7769646576696E655F74"
|
||||
"6573742215686C735F6165735F313238"
|
||||
"5F73747265616D696E6748E3C48D8B03");
|
||||
const std::string kHlsPsshSampleAesLittleEndianFourCC = wvcdm::a2bs_hex(
|
||||
"00000063" // blob size
|
||||
"70737368" // "pssh"
|
||||
"00000000" // flags
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||
"00000043" // pssh data size
|
||||
// pssh data:
|
||||
"08011210613DB35603320EB8E7EA24BD"
|
||||
"EEA3FDB81A0D7769646576696E655F74"
|
||||
"6573742218686C735F73616D706C655F"
|
||||
"6165735F73747265616D696E6748E3C4"
|
||||
"8D9B07");
|
||||
const std::string kHlsPsshAes128FourCC = wvcdm::a2bs_hex(
|
||||
"00000060" // blob size
|
||||
"70737368" // "pssh"
|
||||
"00000000" // flags
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||
"00000040" // pssh data size
|
||||
// pssh data:
|
||||
"08011210AB6531FF6E6EA15E387B019E"
|
||||
"59C2DE0A1A0D7769646576696E655F74"
|
||||
"6573742215686C735F6165735F313238"
|
||||
"5F73747265616D696E6748B1C6899B06");
|
||||
const std::string kHlsPsshSampleAesFourCC = wvcdm::a2bs_hex(
|
||||
"00000063" // blob size
|
||||
"70737368" // "pssh"
|
||||
"00000000" // flags
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||
"00000043" // pssh data size
|
||||
// pssh data:
|
||||
"08011210613DB35603320EB8E7EA24BD"
|
||||
"EEA3FDB81A0D7769646576696E655F74"
|
||||
"6573742218686C735F73616D706C655F"
|
||||
"6165735F73747265616D696E6748F3C6"
|
||||
"899B06");
|
||||
|
||||
HlsDecryptionInfo kHlsFourCCBackwardCompatibilityTestVectors[] = {
|
||||
{false, 2, &kAes128MultiSegmentInfo[0], kHlsPsshAes128LittleEndianFourCC},
|
||||
{true, 1, &kSampleAes160ByteSegmentInfo[0],
|
||||
kHlsPsshSampleAesLittleEndianFourCC},
|
||||
{false, 2, &kAes128MultiSegmentInfo[0], kHlsPsshAes128FourCC},
|
||||
{true, 1, &kSampleAes160ByteSegmentInfo[0], kHlsPsshSampleAesFourCC},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -3313,6 +3369,60 @@ INSTANTIATE_TEST_CASE_P(Cdm, WvHlsDecryptionTest,
|
||||
::testing::Range(&kHlsDecryptionTestVectors[0],
|
||||
&kHlsDecryptionTestVectors[11]));
|
||||
|
||||
class WvHlsFourCCBackwardCompatibilityTest
|
||||
: public WvCdmRequestLicenseTest,
|
||||
public ::testing::WithParamInterface<HlsDecryptionInfo*> {};
|
||||
|
||||
TEST_P(WvHlsFourCCBackwardCompatibilityTest, HlsDecryptionTest) {
|
||||
Provision(kLevel3);
|
||||
TestWvCdmClientPropertySet client_property_set;
|
||||
client_property_set.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
|
||||
HlsDecryptionInfo* info = GetParam();
|
||||
|
||||
TestWvCdmHlsEventListener listener;
|
||||
decryptor_.OpenSession(g_key_system, &client_property_set, EMPTY_ORIGIN,
|
||||
&listener, &session_id_);
|
||||
CdmAppParameterMap app_parameters;
|
||||
GenerateKeyRequest(wvcdm::KEY_MESSAGE, ISO_BMFF_VIDEO_MIME_TYPE,
|
||||
info->attribute_list, app_parameters,
|
||||
kLicenseTypeStreaming, NULL);
|
||||
//TODO(rfrias): Remove once we switch to git-on-borg
|
||||
std::string license_server = "https://proxy.uat.widevine.com/proxy";
|
||||
VerifyKeyRequestResponse(license_server, g_client_auth, false);
|
||||
CdmKeyStatusMap key_status_map = listener.GetKeyStatusMap();
|
||||
EXPECT_EQ(1u, key_status_map.size());
|
||||
KeyId key_id = key_status_map.begin()->first;
|
||||
EXPECT_EQ(KEY_ID_SIZE, key_id.size());
|
||||
|
||||
for (size_t i = 0; i < info->number_of_segments; ++i) {
|
||||
HlsSegmentInfo* data = info->segment_info + i;
|
||||
std::vector<uint8_t> output_buffer(data->encrypted_data.size(), 0);
|
||||
std::vector<uint8_t> iv(data->iv.begin(), data->iv.end());
|
||||
CdmDecryptionParameters decryption_parameters(
|
||||
&key_id, reinterpret_cast<const uint8_t*>(data->encrypted_data.c_str()),
|
||||
data->encrypted_data.size(), &iv, 0, &output_buffer[0]);
|
||||
decryption_parameters.is_encrypted = true;
|
||||
decryption_parameters.is_secure = false;
|
||||
decryption_parameters.cipher_mode = kCipherModeCbc;
|
||||
if (info->sample_aes) {
|
||||
decryption_parameters.pattern_descriptor.encrypt_blocks = 1;
|
||||
decryption_parameters.pattern_descriptor.skip_blocks = 9;
|
||||
}
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Decrypt(session_id_, false,
|
||||
decryption_parameters));
|
||||
EXPECT_EQ(data->clear_data,
|
||||
std::string(reinterpret_cast<const char*>(&output_buffer[0]),
|
||||
output_buffer.size()));
|
||||
}
|
||||
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Cdm, WvHlsFourCCBackwardCompatibilityTest,
|
||||
::testing::Range(&kHlsFourCCBackwardCompatibilityTestVectors[0],
|
||||
&kHlsFourCCBackwardCompatibilityTestVectors[4]));
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
void show_menu(char* prog_name) {
|
||||
|
||||
Reference in New Issue
Block a user