OEMCrypto v14 Unit tests and reference code

Merge from Widevine repo of http://go/wvgerrit/41661

bug: 64001862 OEMCrypto V14 for Android P

test: Unit tests pass
Change-Id: I3314a881357c12ef63d7b257d83f6f0d07e4725a
This commit is contained in:
Fred Gylys-Colwell
2018-01-23 16:03:20 -08:00
parent 979ed70c7b
commit 19cb1792a4
7 changed files with 29 additions and 11 deletions

View File

@@ -138,6 +138,7 @@ std::string DeviceFeatures::RestrictFilter(const std::string& initial_filter) {
if (api_version < 11) FilterOut(&filter, "*API11*");
if (api_version < 12) FilterOut(&filter, "*API12*");
if (api_version < 13) FilterOut(&filter, "*API13*");
if (api_version < 14) FilterOut(&filter, "*API14*");
// Performance tests take a long time. Filter them out if they are not
// specifically requested.
if (filter.find("Performance") == std::string::npos) {

View File

@@ -528,7 +528,10 @@ void Session::FillRefreshMessage(size_t key_count, uint32_t control_bits,
encrypted_license().keys[i].key_id_length = license_.keys[i].key_id_length;
memcpy(encrypted_license().keys[i].key_id, license_.keys[i].key_id,
encrypted_license().keys[i].key_id_length);
if (global_features.api_version == 13) {
if (global_features.api_version == 14) {
// For version 14, we require OEMCrypto to handle kc14 for all licenses.
memcpy(license_.keys[i].control.verification, "kc14", 4);
} else if (global_features.api_version == 13) {
// For version 13, we require OEMCrypto to handle kc13 for all licenses.
memcpy(encrypted_license().keys[i].control.verification, "kc13", 4);
} else if (global_features.api_version == 12) {

View File

@@ -118,7 +118,7 @@ TEST_F(OEMCryptoClientTest, VersionNumber) {
cout << " OEMCrypto does not support usage tables." << endl;
}
ASSERT_GE(version, 8u);
ASSERT_LE(version, 13u);
ASSERT_LE(version, 14u);
}
TEST_F(OEMCryptoClientTest, ProvisioningDeclaredAPI12) {
@@ -1143,7 +1143,7 @@ TEST_P(SessionTestAlternateVerification, LoadKeys) {
// the current API + 2. We use +2 because we want to test at least 1
// future API, and the ::testing::Range is not inclusive.
INSTANTIATE_TEST_CASE_P(TestAll, SessionTestAlternateVerification,
Range(8, 13 + 2));
Range(8, 14 + 2));
TEST_F(OEMCryptoSessionTests, LoadKeysBadSignature) {
Session s;

View File

@@ -138,4 +138,12 @@ TEST_F(OEMCryptoAndroidOCTest, MinVersionNumber13) {
ASSERT_GE(version, 13u);
}
// These tests are required for Pi Android devices.
class OEMCryptoAndroidPiTest : public OEMCryptoAndroidOCTest {};
TEST_F(OEMCryptoAndroidPiTest, MinVersionNumber14) {
uint32_t version = OEMCrypto_APIVersion();
ASSERT_GE(version, 14u);
}
} // namespace wvoec