diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index 7bf0647a..4edc8e73 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -336,20 +336,13 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id, } std::string provider_session_token; + bool sign_fake_request = false; // TODO(b/169483174): remove this variable. if (usage_support_type_ == kUsageEntrySupport) { if (!license_parser_->ExtractProviderSessionToken( key_response_, &provider_session_token) || usage_table_header_ == nullptr) { provider_session_token.clear(); - // TODO(b/161023174): remove this code in v17. - std::string fake_message("empty message"); - std::string core_message; - std::string license_request_signature; - // Sign a fake message so that OEMCrypto will start the rental clock. The - // signature and generated core message are ignored. - CdmResponseType status = crypto_session_->PrepareAndSignLicenseRequest( - fake_message, &core_message, &license_request_signature); - if (status != NO_ERROR) return status; + sign_fake_request = true; // TODO(b/169483174): remove this line. } else if (!VerifyOfflineUsageEntry()) { LOGE("License usage entry is invalid, cannot restore"); return LICENSE_USAGE_ENTRY_MISSING; @@ -362,6 +355,24 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id, return sts; } } + } else { + sign_fake_request = true; // TODO(b/169483174): remove this block. + } + // TODO(b/169483174): remove this code in v17. For OEMCrypto v16, an offline + // license would not work because the rental clock in OEMCrypto is only + // started when the license request is signed. We will sign a fake license + // request if the device does not support usage tables, or if the license does + // not have a usage entry. + if (sign_fake_request) { + std::string fake_message("empty message"); + std::string core_message; + std::string license_request_signature; + // Sign a fake message so that OEMCrypto will start the rental clock. The + // signature and generated core message are ignored. + const CdmResponseType status = + crypto_session_->PrepareAndSignLicenseRequest( + fake_message, &core_message, &license_request_signature); + if (status != NO_ERROR) return status; } CdmResponseType result;