Merges to android Pi release (part 4)

These are a set of CLs merged from the wv cdm repo to the android repo.

* Correct RELEASE_ALL_USAGE_INFO_ERRORs

  Author: Rahul Frias <rfrias@google.com>

  [ Merge of http://go/wvgerrit/28742 ]

  RELEASE_ALL_USAGE_INFO_ERROR_4 and 5 were introduced and made use of in
  http://go/wvgerrit/24022 (branch: oc-dev). The error code definitions
  were merged over in http://go/wvgerrit/24602.

  When http://go/wvgerrit/24622 from cdm_partners_3.2 was merged to master
  (http://go/wvgerrit/27723) there was conflict in error codes. The error
  codes were adjusted to RELEASE_ALL_USAGE_INFO_ERROR_3 and 4
  and were made use of.

  To avoid renaming the errors between oc-dev and master, new errors
  RELEASE_ALL_USAGE_INFO_ERROR_6 and 7 have been added to handle the
  scenarios noted in the merge from cdm_partner_3.2. The other
  errors have been reverted back to RELEASE_ALL_USAGE_INFO_ERROR_4 and 5.
  They will be used when http://go/wvgerrit/24602 is merged.

* Address compilation issues

  Author: Rahul Frias <rfrias@google.com>

  [ Merge of http://go/wvgerrit/28740 ]

  These changes enable compilation of most of the cdm code on android
  expect for OEMCrypto unit tests (b/62739406) on wv master.

* Add property for binary/base64 provisioning msgs.

  Author: Gene Morgan <gmorgan@google.com>

  [ Merge of http://go/wvgerrit/28074 ]

  Property is "provisioning_messages_are_binary". Its default setting is
  false in the CE CDM, but it can be overridden by integrators.

  Added section to integration guide that discusses Provisioning Server
  message formats and the new property.

  Link: https://docs.google.com/document/d/1cBVbhgrajLpDe2W3_vzLzUqzpdDt73chvm4_sZlZlS8/edit#heading=h.hgxw53ddw7jo

BUG: 71650075
Test: Not currently passing. Will be addressed in a subsequent
      commit in the chain.

Change-Id: I9168193819974d1ff65d9a94dbd762e45ecc43ca
This commit is contained in:
Rahul Frias
2018-01-09 17:10:23 -08:00
parent 11068accd2
commit 169d0b6cb6
46 changed files with 1260 additions and 741 deletions

View File

@@ -45,7 +45,11 @@ KeyId g_wrong_key_id;
const std::string kCencMimeType = "video/mp4";
const std::string kWebmMimeType = "video/webm";
static void CommonSetup(ServerConfigurationId which) {
static void CommonSetup(ServerConfigurationId which,
bool bin_prov = false) {
Properties::set_provisioning_messages_are_binary(bin_prov);
Properties::Init();
// NOTE: Select configuration
ConfigTestEnv config(which);
@@ -116,6 +120,10 @@ class WvCdmEnginePreProvTest : public testing::Test {
virtual void SetUp() {
CdmResponseType status =
cdm_engine_.OpenSession(g_key_system, NULL, NULL, &session_id_);
if (status == NEED_PROVISIONING) {
Provision();
status = cdm_engine_.OpenSession(g_key_system, NULL, NULL, &session_id_);
}
ASSERT_EQ(status, NO_ERROR);
session_opened_ = true;
}
@@ -130,8 +138,8 @@ class WvCdmEnginePreProvTest : public testing::Test {
protected:
// Trade request for response via the license server.
bool LicenseServerRequestResponse(const std::string& request,
std::string* response) {
virtual bool LicenseServerRequestResponse(const std::string& request,
std::string* response) {
LOGV("LicenseServerRequestResponse: server url: %s",
g_license_server.c_str());
UrlRequest url_request(g_license_server + g_client_auth);
@@ -183,20 +191,8 @@ class WvCdmEnginePreProvTest : public testing::Test {
LOGV("WvCdmEnginePreProvTest::Provision: http_message: \n%s\n",
http_message.c_str());
// extract provisioning response from received message
// Extracts signed response from JSON string, result is serialized protobuf.
const std::string kMessageStart = "\"signedResponse\": \"";
const std::string kMessageEnd = "\"";
std::string protobuf_response;
EXPECT_TRUE (ExtractSignedMessage(http_message, kMessageStart, kMessageEnd,
&protobuf_response)) <<
"Failed to extract signed serialized response from JSON response";
LOGV("WvCdmEnginePreProvTest::Provision: extracted response "
"message: \n%s\n", protobuf_response.c_str());
ASSERT_EQ(NO_ERROR,
cdm_engine_.HandleProvisioningResponse(protobuf_response,
cdm_engine_.HandleProvisioningResponse(http_message,
&cert, &wrapped_key));
ASSERT_EQ(NO_ERROR,
@@ -258,6 +254,81 @@ class WvCdmEnginePreProvTestStagingProv30 : public WvCdmEnginePreProvTest {
}
};
class WvCdmEnginePreProvTestStagingProv30Binary : public WvCdmEnginePreProvTest {
public:
WvCdmEnginePreProvTestStagingProv30Binary() {}
virtual ~WvCdmEnginePreProvTestStagingProv30Binary() {}
static void SetUpTestCase() {
// NOTE: Select server configuration
// Override default setting of provisioning_messages_are_binary property
CommonSetup(kContentProtectionUatPlusProv30, true);
}
protected:
virtual void Provision() {
LOGV("WvCdmEnginePreProvTestProv30Binary::Provision: url=%s",
g_provisioning_server.c_str());
CdmProvisioningRequest binary_prov_request;
std::string provisioning_server_url;
CdmCertificateType cert_type = kCertificateWidevine;
std::string cert_authority;
std::string cert, wrapped_key;
ASSERT_EQ(NO_ERROR, cdm_engine_.SetServiceCertificate(
g_provisioning_service_certificate));
ASSERT_EQ(NO_ERROR, cdm_engine_.GetProvisioningRequest(
cert_type, cert_authority, &binary_prov_request,
&provisioning_server_url));
// prov_request is binary - base64 encode it
std::string prov_request(Base64SafeEncodeNoPad(
std::vector<uint8_t>(binary_prov_request.begin(),
binary_prov_request.end())));
LOGV("WvCdmEnginePreProvTest::Provision: req=%s", prov_request.c_str());
// Ignore URL provided by CdmEngine. Use ours, as configured
// for test vs. production server.
provisioning_server_url.assign(g_provisioning_server);
UrlRequest url_request(provisioning_server_url);
EXPECT_TRUE(url_request.is_connected());
url_request.PostCertRequestInQueryString(prov_request);
std::string http_message;
bool ok = url_request.GetResponse(&http_message);
EXPECT_TRUE(ok);
LOGV("WvCdmEnginePreProvTest::Provision: http_message: \n%s\n",
http_message.c_str());
// extract provisioning response from received message
// Extracts signed response from JSON string, result is serialized protobuf.
const std::string kMessageStart = "\"signedResponse\": \"";
const std::string kMessageEnd = "\"";
std::string protobuf_response;
EXPECT_TRUE (ExtractSignedMessage(http_message, kMessageStart, kMessageEnd,
&protobuf_response)) <<
"Failed to extract signed serialized response from JSON response";
LOGV("WvCdmEnginePreProvTest::Provision: extracted response "
"message: \n%s\n", protobuf_response.c_str());
// base64 decode response to yield binary protobuf
std::vector<uint8_t> response_vec(Base64SafeDecode(
std::string(protobuf_response.begin(), protobuf_response.end())));
std::string binary_protobuf_response(response_vec.begin(),
response_vec.end());
ASSERT_EQ(NO_ERROR,
cdm_engine_.HandleProvisioningResponse(binary_protobuf_response,
&cert, &wrapped_key));
ASSERT_EQ(NO_ERROR,
cdm_engine_.SetServiceCertificate(g_license_service_certificate));
}
};
class WvCdmEnginePreProvTestUatProv30 : public WvCdmEnginePreProvTest {
public:
WvCdmEnginePreProvTestUatProv30() {}
@@ -266,7 +337,7 @@ class WvCdmEnginePreProvTestUatProv30 : public WvCdmEnginePreProvTest {
static void SetUpTestCase() {
// NOTE: Select server configuration
CommonSetup(kContentProtectionUatPlusProv30);
CommonSetup(kContentProtectionStagingPlusProv30);
}
};
@@ -524,6 +595,10 @@ TEST_F(WvCdmEnginePreProvTestStagingProv30, ProvisioningTest) {
Provision();
}
TEST_F(WvCdmEnginePreProvTestStagingProv30Binary, ProvisioningTest) {
Provision();
}
// Test that provisioning works, even if device is already provisioned.
TEST_F(WvCdmEngineTest, DISABLED_ProvisioningTest) {

View File

@@ -111,7 +111,7 @@ TEST_F(ServiceCertificateTest, InitSuccess) {
CreateServiceCertificate();
service_certificate_->Init(kTestSessionId1);
EXPECT_FALSE(service_certificate_->HasCertificate());
EXPECT_FALSE(service_certificate_->has_certificate());
}
TEST_F(ServiceCertificateTest, InitPrivacyModeRequired) {
@@ -124,7 +124,7 @@ TEST_F(ServiceCertificateTest, InitPrivacyModeRequired) {
CreateServiceCertificate();
service_certificate_->Init(kTestSessionId1);
EXPECT_FALSE(service_certificate_->HasCertificate());
EXPECT_FALSE(service_certificate_->has_certificate());
}
TEST_F(ServiceCertificateTest, InitServiceCertificatePresent) {
@@ -142,7 +142,7 @@ TEST_F(ServiceCertificateTest, InitServiceCertificatePresent) {
&service_certificate));
EXPECT_EQ(NO_ERROR,
service_certificate_->Init(service_certificate));
EXPECT_TRUE(service_certificate_->HasCertificate());
EXPECT_TRUE(service_certificate_->has_certificate());
}
TEST_F(ServiceCertificateTest, SetServiceCertificate) {
@@ -155,7 +155,7 @@ TEST_F(ServiceCertificateTest, SetServiceCertificate) {
CreateServiceCertificate();
EXPECT_EQ(NO_ERROR, service_certificate_->Init(kTestSignedCertificate));
EXPECT_TRUE(service_certificate_->HasCertificate());
EXPECT_TRUE(service_certificate_->has_certificate());
}
}

View File

@@ -249,12 +249,18 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case RELEASE_ALL_USAGE_INFO_ERROR_2:
*os << "RELEASE_ALL_USAGE_INFO_ERROR_2";
break;
case RELEASE_ALL_USAGE_INFO_ERROR_3:
*os << "RELEASE_ALL_USAGE_INFO_ERROR_3";
break;
case RELEASE_ALL_USAGE_INFO_ERROR_4:
*os << "RELEASE_ALL_USAGE_INFO_ERROR_4";
break;
case RELEASE_ALL_USAGE_INFO_ERROR_5:
*os << "RELEASE_ALL_USAGE_INFO_ERROR_5";
break;
case RELEASE_ALL_USAGE_INFO_ERROR_6:
*os << "RELEASE_ALL_USAGE_INFO_ERROR_6";
break;
case RELEASE_ALL_USAGE_INFO_ERROR_7:
*os << "RELEASE_ALL_USAGE_INFO_ERROR_7";
break;
case RELEASE_KEY_ERROR: *os << "RELEASE_KEY_ERROR";
break;
case RELEASE_KEY_REQUEST_ERROR: *os << "RELEASE_KEY_REQUEST_ERROR";
@@ -530,13 +536,14 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
break;
case USAGE_INVALID_PARAMETERS_1: *os << "USAGE_INVALID_PARAMETERS_1";
break;
case USAGE_RETRIEVE_LICENSE_FAILED: *os << "USAGE_RETRIEVE_LICENSE_FAILED";
case USAGE_GET_ENTRY_RETRIEVE_LICENSE_FAILED:
*os << "USAGE_GET_ENTRY_RETRIEVE_LICENSE_FAILED";
break;
case USAGE_RETRIEVE_USAGE_INFO_FAILED:
*os << "USAGE_RETRIEVE_USAGE_INFO_FAILED";
case USAGE_GET_ENTRY_RETRIEVE_USAGE_INFO_FAILED:
*os << "USAGE_GET_ENTRY_RETRIEVE_USAGE_INFO_FAILED";
break;
case USAGE_RETRIEVE_INVALID_STORAGE_TYPE:
*os << "USAGE_RETRIEVE_INVALID_STORAGE_TYPE";
case USAGE_GET_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE:
*os << "USAGE_GET_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE";
break;
case USAGE_ENTRY_NUMBER_MISMATCH: *os << "USAGE_ENTRY_NUMBER_MISMATCH";
break;
@@ -592,6 +599,15 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
break;
case PARSE_RESPONSE_ERROR_4: *os << "PARSE_RESPONSE_ERROR_4";
break;
case USAGE_STORE_ENTRY_RETRIEVE_LICENSE_FAILED:
*os << "USAGE_STORE_ENTRY_RETRIEVE_LICENSE_FAILED";
break;
case USAGE_STORE_ENTRY_RETRIEVE_USAGE_INFO_FAILED:
*os << "USAGE_STORE_ENTRY_RETRIEVE_USAGE_INFO_FAILED";
break;
case USAGE_STORE_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE:
*os << "USAGE_STORE_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE";
break;
default:
*os << "Unknown CdmResponseType";
break;