Correctly handle missing entry in DeactivateUsageEntry

This is a copy of
https://widevine-internal-review.googlesource.com/#/c/11110/

The level 3 oemcrypto library version of DeactivateUsageEntry now
returns OEMCrypto_ERROR_INVALID_CONTEXT if there is no entry in the
usage table.

Current Library Version:
arm:  Level3 Library Sep  3 2014 18:13:47

b/17373630

Change-Id: Iaeb65b4ad4b2b9f3c6733a2c9c8d96e2be263d09
This commit is contained in:
Fred Gylys-Colwell
2014-09-05 14:21:07 -07:00
parent 72b47e5789
commit 457998d677
2 changed files with 15 additions and 2 deletions

View File

@@ -4478,6 +4478,7 @@ TEST_F(DISABLED_GenericDRMTest, KeyDurationVerify) {
TEST_F(OEMCryptoClientTest, SupportsUsageTable) {
if (OEMCrypto_SupportsUsageTable()) {
EXPECT_EQ(OEMCrypto_SUCCESS, OEMCrypto_UpdateUsageTable());
cout << " OEMCrypto supports usage tables." << endl;
} else {
cout << " OEMCrypto does not support usage tables." << endl;
@@ -4668,7 +4669,6 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
s1.LoadTestKeys(pst1, new_mac_keys_);
sleep(kShortSleep);
cout << "Making 49\n";
const size_t ENTRY_COUNT = 49;// API says should hold at least 50 entries.
Session sessions[ENTRY_COUNT];
for (int i=0; i<ENTRY_COUNT; i++) {
@@ -4685,7 +4685,6 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
sessions[i].GenerateReport(pst);
sessions[i].close();
}
cout << "Checking 49\n";
for (int i=0; i<ENTRY_COUNT; i++) {
Session s;
s.open();
@@ -4944,6 +4943,20 @@ TEST_P(DISABLED_UsageTableTest, DeleteEntryBadRange) {
}
}
TEST_P(DISABLED_UsageTableTest, DeactivateBadPST) {
if (OEMCrypto_SupportsUsageTable()) {
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_UpdateUsageTable());
std::string pst = "nonexistant pst";
OEMCryptoResult sts = OEMCrypto_DeactivateUsageEntry(
reinterpret_cast<const uint8_t*>(pst.c_str()), pst.length());
EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, sts);
std::string null_pst = "";
sts = OEMCrypto_DeactivateUsageEntry(
reinterpret_cast<const uint8_t*>(null_pst.c_str()), null_pst.length());
EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, sts);
}
}
TEST_P(DISABLED_UsageTableTest, GenericEncrypt) {
if (OEMCrypto_SupportsUsageTable()) {
std::string pst = "A PST";