Below are a set of CLs being merged from the wv cdm repo to the android repo. * Fix handling of OEM Cert public key. Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/27921 ] This is a potential fix for b/36656190. Set aside public key on first call to get the public key, and use it afterwards. This gets rid of extra calls to OEMCrypto_GetOEMPublicCertificate(), which has side-effect of staging the OEM private key. This also fixes a problem where the public cert string was not being trimmed to match the size returned by OEMCrypto_GetOEMPublicCertificate(). * Complete provisioning request/response for Provisioning 3.0 Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/27780 ] Fix bug on provisioning request path where GenerateDerivedKeys() was being called when preparing to generate the signature. Add message signature verification, and call correct OEMCrypto routine to rewrap the private key (OEMCrypto_RewrapDeviceRSAKey30). * Implement Cdm::deleteAllUsageRecords() Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/27780 ] Delete all usage records for current origin. Removes usage records from file system and retains the PSTs. The deletes any usage entries matching those PSTs held by OEMCrypto. BUG: 35319024 * Remove stringencoders library from third_party. Author: Jacob Trimble <modmaker@google.com> [ Merge of http://go/wvgerrit/27585 ] We have a fork of the stringencoders library that we use for base64 encoding. This reimplements base64 encoding to remove the extra dependency and to reduce the amount of code. * Add Cdm::deleteUsageRecord() based on key_set_id. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/27605 ] Delete specified usage record from file system usage info and from OEMCrypto. BUG: 35319024 * Modifiable OEMCrypto Author: Fred Gylys-Colwell <fredgc@google.com> [ Merge of http://go/wvgerrit/24729 ] This CL adds a new variant of the OEMCrypto mock code that adjusts its behavior based on a configuration file. This is intended for testing. For example, a tester can set current_hdcp to 2 in the options.txt file, push it to the device, and verify that a license is granted for HDCP 2.0. Then the tester can edit the value of current_hdcp to 1 and push the file to the device. Playback should stop because the license is no longer valid. This variant uses a real level 1 liboemcrypto.so to push data to a secure buffer. That means we can test playback for a license that requires secure buffers on an Android device with real secure buffers. BUG: 35141278 BUG: 37353534 BUG: 71650075 Test: Not currently passing. Will be addressed in a subsequent commit in the chain. Change-Id: I58443c510919e992bb455192e70373490a00e2b6
163 lines
6.1 KiB
C++
163 lines
6.1 KiB
C++
//
|
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
|
//
|
|
#include "gtest/gtest.h"
|
|
#include "license_request.h"
|
|
#include "string_conversions.h"
|
|
#include "url_request.h"
|
|
#include "utils/Log.h"
|
|
#include "vts_module.h"
|
|
|
|
using std::array;
|
|
using std::map;
|
|
using std::string;
|
|
using std::vector;
|
|
using wvcdm::a2b_hex;
|
|
using wvcdm::b2a_hex;
|
|
using wvcdm::LicenseRequest;
|
|
using wvcdm::UrlRequest;
|
|
|
|
|
|
namespace widevine_vts {
|
|
|
|
const int kHttpOk = 200;
|
|
|
|
vector<uint8_t> WidevineVTSVendorModule_V1::getUUID() const {
|
|
uint8_t uuid[16] = {
|
|
0xED,0xEF,0x8B,0xA9,0x79,0xD6,0x4A,0xCE,
|
|
0xA3,0xC8,0x27,0xDC,0xD5,0x1D,0x21,0xED
|
|
};
|
|
return vector<uint8_t>(uuid, uuid + sizeof(uuid));
|
|
}
|
|
|
|
void LogResponseError(const string& message, int http_status_code) {
|
|
ALOGD("HTTP Status code = %d", http_status_code);
|
|
ALOGD("HTTP response(%zd): %s", message.size(), b2a_hex(message).c_str());
|
|
}
|
|
|
|
vector<uint8_t> WidevineVTSVendorModule_V1::handleProvisioningRequest(
|
|
const vector<uint8_t>& provisioning_request,
|
|
const string& server_url) {
|
|
|
|
// Use secure connection and chunk transfer coding.
|
|
UrlRequest url_request(server_url);
|
|
EXPECT_TRUE(url_request.is_connected()) << "Fail to connect to "
|
|
<< server_url;
|
|
url_request.PostCertRequestInQueryString(toString(provisioning_request));
|
|
string reply;
|
|
EXPECT_TRUE(url_request.GetResponse(&reply));
|
|
|
|
int http_status_code = url_request.GetStatusCode(reply);
|
|
if (kHttpOk != http_status_code) {
|
|
LogResponseError(reply, http_status_code);
|
|
}
|
|
EXPECT_EQ(kHttpOk, http_status_code);
|
|
vector<uint8_t> result(reply.begin(), reply.end());
|
|
return vector<uint8_t>(result);
|
|
}
|
|
|
|
vector<uint8_t> WidevineVTSVendorModule_V1::handleKeyRequest(
|
|
const vector<uint8_t>&key_request, const string& server_url) {
|
|
|
|
// Use secure connection and chunk transfer coding.
|
|
UrlRequest url_request(server_url);
|
|
EXPECT_TRUE(url_request.is_connected()) << "Fail to connect to "
|
|
<< server_url;
|
|
url_request.PostRequest(toString(key_request));
|
|
string reply;
|
|
EXPECT_TRUE(url_request.GetResponse(&reply));
|
|
|
|
int httpStatusCode = url_request.GetStatusCode(reply);
|
|
if (httpStatusCode != kHttpOk) {
|
|
LogResponseError(reply, httpStatusCode);
|
|
}
|
|
EXPECT_EQ(httpStatusCode, kHttpOk);
|
|
|
|
string drm_msg;
|
|
if (kHttpOk == httpStatusCode) {
|
|
LicenseRequest lic_request;
|
|
lic_request.GetDrmMessage(reply, drm_msg);
|
|
ALOGV("HTTP response body: (%zd bytes)", drm_msg.size());
|
|
}
|
|
vector<uint8_t> result(drm_msg.begin(), drm_msg.end());
|
|
return result;
|
|
}
|
|
|
|
vector<DrmHalVTSVendorModule_V1::ContentConfiguration>
|
|
WidevineVTSVendorModule_V1::getContentConfigurations() const {
|
|
|
|
vector<DrmHalVTSVendorModule_V1::ContentConfiguration> configurations;
|
|
{
|
|
const string serverUrl = "http://widevine-proxy.appspot.com/proxy";
|
|
const vector<uint8_t> initData = a2b_hex(
|
|
"00000042" // blob size
|
|
"70737368" // "pssh"
|
|
"00000000" // flags
|
|
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
|
"00000022" // pssh data size
|
|
"08011a0d7769646576696e655f746573" // pssh data...
|
|
"74220f73747265616d696e675f636c69"
|
|
"7031");
|
|
const vector<uint8_t> keyId = a2b_hex("371EA35E1A985D75D198A7F41020DC23");
|
|
const vector<uint8_t> keyValue = a2b_hex("371EA35E1A985D75D198A7F41020DC23");
|
|
const vector<DrmHalVTSVendorModule_V1::ContentConfiguration::Key> keys = {
|
|
{
|
|
.isSecure = false,
|
|
.keyId = keyId,
|
|
.clearContentKey = keyValue
|
|
}
|
|
};
|
|
|
|
ContentConfiguration config = {
|
|
.name = "streaming_clip1",
|
|
.serverUrl = serverUrl,
|
|
.initData = initData,
|
|
.mimeType = "cenc",
|
|
.optionalParameters = map<string, string>(),
|
|
.policy.allowOffline = false,
|
|
.keys = keys
|
|
};
|
|
configurations.push_back(config);
|
|
}
|
|
|
|
// Content Configuration #2 - Allows offline playback
|
|
{
|
|
const string serverUrl = "http://widevine-proxy.appspot.com/proxy";
|
|
const vector<uint8_t> initData = a2b_hex(
|
|
"00000040" // blob size
|
|
"70737368" // "pssh"
|
|
"00000000" // flags
|
|
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
|
"00000020" // pssh data size
|
|
"08011a0d7769646576696e655f746573" // pssh data...
|
|
"74220d6f66666c696e655f636c697033"
|
|
"7031");
|
|
const vector<uint8_t> keyId = a2b_hex("3260f39e12ccf653529990168a3583ff");
|
|
const vector<uint8_t> keyValue = a2b_hex("8040c019929b2cc116a2e8dac739eafa");
|
|
const vector<DrmHalVTSVendorModule_V1::ContentConfiguration::Key> keys = {
|
|
{
|
|
.isSecure = false,
|
|
.keyId = keyId,
|
|
.clearContentKey = keyValue
|
|
}
|
|
};
|
|
|
|
ContentConfiguration config = {
|
|
.name = "offline_clip3",
|
|
.serverUrl = serverUrl,
|
|
.initData = initData,
|
|
.mimeType = "cenc",
|
|
.optionalParameters = map<string, string>(),
|
|
.policy.allowOffline = true,
|
|
.keys = keys
|
|
};
|
|
configurations.push_back(config);
|
|
};
|
|
|
|
return configurations;
|
|
}
|
|
|
|
}; // namespace widevine_vts
|
|
|
|
|