Merge changes from topic "oemcrypto-v16"

* changes:
  OEMCrypto v16.2
  OEMCrypto v16.1
This commit is contained in:
Fred Gylys-Colwell
2020-02-05 16:10:47 +00:00
committed by Android (Google) Code Review
147 changed files with 14748 additions and 11097 deletions

View File

@@ -63,9 +63,6 @@ const wvcdm::CdmIdentifier kAlternateCdmIdentifier2 = {
const std::string kEmptyServiceCertificate;
const std::string kComma = ",";
// From OEMCrypto v15.2 onwards, we require the nonce table to be size 4.
const size_t kNonceTableSize = 4;
// Protobuf generated classes
using video_widevine::LicenseIdentification;
using video_widevine::LicenseRequest_ContentIdentification;
@@ -2356,22 +2353,14 @@ TEST_F(WvCdmRequestLicenseTest, ProvisioningInterspersedRetryTest) {
// test this for API versions before that if they use OEM certificates.
std::vector<std::string> key_msgs;
// TODO(b/135288420): There can be only one request per OEMCrypto session.
// This code must change.
wvcdm::CdmResponseType first_request_error;
if (provisioning_model == wvcdm::QUERY_VALUE_KEYBOX) {
// For keyboxes we use derived keys as part of the provisioning request.
// These get updated each request, therefore any request before the latest
// fails, so we only need 2 requests.
key_msgs.resize(2);
first_request_error = wvcdm::REWRAP_DEVICE_RSA_KEY_ERROR;
} else {
// For OEM certificates, we don't use derived keys, so any request is
// valid as long as its corresponding nonce is contained in the nonce
// table. This is why we need the size to be fixed.
// We need kNonceTableSize + 1 requests here to check that the first
// of these fails and the one after that succeeds.
key_msgs.resize(kNonceTableSize + 1);
first_request_error = wvcdm::REWRAP_DEVICE_RSA_KEY_30_ERROR;
}
// For keyboxes we use derived keys as part of the provisioning request.
// These get updated each request, therefore any request before the latest
// fails, so we only need 2 requests.
key_msgs.resize(2);
first_request_error = wvcdm::REWRAP_DEVICE_RSA_KEY_ERROR;
for (size_t i = 0; i < key_msgs.size(); i++) {
EXPECT_EQ(
@@ -4941,6 +4930,32 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
// These are the only valid values for Android devices.
EXPECT_TRUE(value == wvcdm::QUERY_VALUE_KEYBOX ||
value == wvcdm::QUERY_VALUE_OEM_CERTIFICATE);
EXPECT_EQ(
wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevelDefault, wvcdm::QUERY_KEY_MAX_USAGE_TABLE_ENTRIES, &value));
ss.clear();
ss.str(value);
uint32_t max_usage_table_entries;
ss >> max_usage_table_entries;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(200u, max_usage_table_entries);
EXPECT_EQ(
wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevelDefault, wvcdm::QUERY_KEY_OEMCRYPTO_API_MINOR_VERSION, &value));
ss.clear();
ss.str(value);
uint32_t api_minor_version;
ss >> api_minor_version;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(0u, api_minor_version);
}
TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
@@ -5048,6 +5063,28 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
// These are the only valid values for Android devices.
EXPECT_TRUE(value == wvcdm::QUERY_VALUE_KEYBOX ||
value == wvcdm::QUERY_VALUE_OEM_CERTIFICATE);
EXPECT_EQ(wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevel3, wvcdm::QUERY_KEY_OEMCRYPTO_API_MINOR_VERSION, &value));
ss.clear();
ss.str(value);
uint32_t api_minor_version;
ss >> api_minor_version;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(0u, api_minor_version);
EXPECT_EQ(wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevel3, wvcdm::QUERY_KEY_MAX_USAGE_TABLE_ENTRIES, &value));
ss.clear();
ss.str(value);
uint32_t max_usage_table_entries;
ss >> max_usage_table_entries;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(200u, max_usage_table_entries);
}
TEST_F(WvCdmRequestLicenseTest, QueryOemCryptoSessionId) {