Add rollback-prevention time methods to ref

Merge from master branch of Widevine repo of http://go/wvgerrit/66077
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64562

Bug: b/78357351

b/62058202 addressed issues with the Level 3 OEMCrypto in guarding
against rollback. This change does something similar for the ref, so
that OEMCrypto vendors have rollback-prevention code they can refer to.

Test: linux/ce cdm unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: I76128c5def2615ecbdbe94e3af1fec4a025be8c1
This commit is contained in:
Srujan Gaddam
2018-11-12 14:19:56 -08:00
committed by Fred Gylys-Colwell
parent b7e4b56934
commit 0ee5214b92
7 changed files with 135 additions and 14 deletions

View File

@@ -71,7 +71,8 @@ OEMCryptoResult UsageTableEntry::SetPST(const uint8_t* pst, size_t pst_length) {
data_.pst_length = pst_length;
if (!pst || !pst_length) return OEMCrypto_ERROR_INVALID_CONTEXT;
memcpy(data_.pst, pst, pst_length);
data_.time_of_license_received = time(NULL);
data_.time_of_license_received =
usage_table_->ce_->RollbackCorrectedOfflineTime();
return OEMCrypto_SUCCESS;
}
@@ -105,7 +106,8 @@ bool UsageTableEntry::CheckForUse() {
recent_decrypt_ = true;
if (data_.status == kUnused) {
data_.status = kActive;
data_.time_of_first_decrypt = time(NULL);
data_.time_of_first_decrypt =
usage_table_->ce_->RollbackCorrectedOfflineTime();
data_.generation_number++;
usage_table_->IncrementGeneration();
}
@@ -149,7 +151,7 @@ OEMCryptoResult UsageTableEntry::ReportUsage(const std::vector<uint8_t>& pst,
return OEMCrypto_ERROR_INVALID_CONTEXT;
}
wvcdm::Unpacked_PST_Report pst_report(buffer);
int64_t now = time(NULL);
int64_t now = usage_table_->ce_->RollbackCorrectedOfflineTime();
pst_report.set_seconds_since_license_received(now -
data_.time_of_license_received);
pst_report.set_seconds_since_first_decrypt(now - data_.time_of_first_decrypt);
@@ -170,7 +172,8 @@ OEMCryptoResult UsageTableEntry::ReportUsage(const std::vector<uint8_t>& pst,
void UsageTableEntry::UpdateAndIncrement() {
if (recent_decrypt_) {
data_.time_of_last_decrypt = time(NULL);
data_.time_of_last_decrypt =
usage_table_->ce_->RollbackCorrectedOfflineTime();
recent_decrypt_ = false;
}
data_.generation_number++;
@@ -757,7 +760,7 @@ OEMCryptoResult UsageTable::CreateOldUsageEntry(
std::vector<uint8_t> pstv(pst, pst + pst_length);
OldUsageTableEntry* old_entry = old_table_->CreateEntry(pstv);
int64_t now = time(NULL);
int64_t now = ce_->RollbackCorrectedOfflineTime();
old_entry->time_of_license_received_ = now - time_since_license_received;
old_entry->time_of_first_decrypt_ = now - time_since_first_decrypt;
old_entry->time_of_last_decrypt_ = now - time_since_last_decrypt;