Certificate provisioning verification

bug: 8620943

This is a merge of changes made to the Widevine CDM
repository during certificate provisioning verification.

The following changes are included:

Fixes for certificate based licensing
https://widevine-internal-review.googlesource.com/#/c/5162/

Base64 encode and decode now handles non-multiple of 24-bits input
https://widevine-internal-review.googlesource.com/#/c/4981/

Fixed issues with device provisioning response handling
https://widevine-internal-review.googlesource.com/#/c/5153/

Persistent storage to support device certificates
https://widevine-internal-review.googlesource.com/#/c/5161/

Enable loading of certificates
https://widevine-internal-review.googlesource.com/#/c/5172/

Provide license server url
https://widevine-internal-review.googlesource.com/#/c/5173/

Change-Id: I0c032c1ae0055dcc1a7a77ad4b0ea0898030dc7d
This commit is contained in:
Jeff Tinker
2013-04-22 20:05:55 -07:00
parent 3a28eeeb68
commit 958bbe6d05
30 changed files with 1497 additions and 290 deletions

View File

@@ -23,6 +23,9 @@ std::string g_license_server;
std::string g_port;
wvcdm::KeyId g_wrong_key_id;
int g_use_full_path = 0; // cannot use boolean in getopt_long
static const std::string kDefaultProvisioningServerUrl =
"http://www-googleapis-test.sandbox.google.com/certificateprovisioning/v1/devicecertificates/create";
} // namespace
namespace wvcdm {
@@ -46,11 +49,14 @@ class WvCdmRequestLicenseTest : public testing::Test {
void GenerateKeyRequest(const std::string& key_system,
const std::string& init_data) {
wvcdm::CdmAppParameterMap app_parameters;
std::string server_url;
EXPECT_EQ(decryptor_.GenerateKeyRequest(session_id_,
init_data,
kLicenseTypeStreaming,
app_parameters,
&key_msg_), wvcdm::KEY_MESSAGE);
&key_msg_,
&server_url), wvcdm::KEY_MESSAGE);
EXPECT_EQ(0, server_url.size());
}
void GenerateRenewalRequest(const std::string& key_system,
@@ -58,11 +64,14 @@ class WvCdmRequestLicenseTest : public testing::Test {
// TODO application makes a license request, CDM will renew the license
// when appropriate.
wvcdm::CdmAppParameterMap app_parameters;
std::string server_url;
EXPECT_EQ(decryptor_.GenerateKeyRequest(session_id_,
init_data,
kLicenseTypeStreaming,
app_parameters,
&key_msg_), wvcdm::KEY_MESSAGE);
&key_msg_,
&server_url), wvcdm::KEY_MESSAGE);
EXPECT_NE(0, server_url.size());
}
// posts a request and extracts the drm message from the response
@@ -101,6 +110,34 @@ class WvCdmRequestLicenseTest : public testing::Test {
return drm_msg;
}
// posts a request and extracts the drm message from the response
std::string GetCertRequestResponse(const std::string& server_url,
int expected_response) {
UrlRequest url_request(server_url, g_port);
if (!url_request.is_connected()) {
return "";
}
url_request.PostCertRequest(key_msg_);
std::string response;
int resp_bytes = url_request.GetResponse(response);
LOGD("size=%u, response start: %s", response.size(),
response.substr(0, 1024).c_str());
LOGD("end: %s", response.substr(response.size() - 256).c_str());
LOGD("end %d bytes response dump", resp_bytes);
// Youtube server returns 400 for invalid message while play server returns
// 500, so just test inequity here for invalid message
int status_code = url_request.GetStatusCode(response);
if (expected_response == 200) {
EXPECT_EQ(200, status_code);
} else {
EXPECT_NE(200, status_code);
}
return response;
}
void VerifyKeyRequestResponse(const std::string& server_url,
const std::string& client_auth,
std::string& init_data,
@@ -124,6 +161,19 @@ class WvCdmRequestLicenseTest : public testing::Test {
std::string session_id_;
};
TEST_F(WvCdmRequestLicenseTest, ProvisioningTest) {
decryptor_.OpenSession(g_key_system, &session_id_);
std::string provisioning_server_url = "";
decryptor_.GetProvisioningRequest(&key_msg_, &provisioning_server_url);
EXPECT_STREQ(provisioning_server_url.data(), kDefaultProvisioningServerUrl.data());
std::string response = GetCertRequestResponse(kDefaultProvisioningServerUrl, 200);
if (!response.empty())
decryptor_.HandleProvisioningResponse(response);
decryptor_.CloseSession(session_id_);
}
TEST_F(WvCdmRequestLicenseTest, BaseMessageTest) {
decryptor_.OpenSession(g_key_system, &session_id_);
GenerateKeyRequest(g_key_system, g_key_id);