From 84e27c660da159af5d0ce0e358f85e4a3649edcd Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Thu, 6 Jul 2023 17:01:49 -0700 Subject: [PATCH] Initialize renewal request time The `time_of_renewal_request` field in the clock_values struct was not being initialized. With this CL, we use a value of 0 to indicate a renewal has not been requested yet. We also modify the check in `ODK_ParseRenewal` to use a value of 0 for the `time_of_renewal_request` to skip the check for a stale renewal. This is done because now that a "renew on license load" license starts the playback clock immediately, we need a different way to decide if a renewal from a previous session can be loaded. PiperOrigin-RevId: 546129556 Merged from https://widevine-internal-review.googlesource.com/177998 Change-Id: I17282cf918d0cdb4d9b5108a41914ecd7d87cc8f --- libwvdrmengine/oemcrypto/odk/include/odk_structs.h | 2 +- libwvdrmengine/oemcrypto/odk/src/odk.c | 7 ++++--- libwvdrmengine/oemcrypto/odk/src/odk_timer.c | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/oemcrypto/odk/include/odk_structs.h b/libwvdrmengine/oemcrypto/odk/include/odk_structs.h index 6efce32f..fd29e0c4 100644 --- a/libwvdrmengine/oemcrypto/odk/include/odk_structs.h +++ b/libwvdrmengine/oemcrypto/odk/include/odk_structs.h @@ -19,7 +19,7 @@ extern "C" { #define ODK_MINOR_VERSION 2 /* ODK Version string. Date changed automatically on each release. */ -#define ODK_RELEASE_DATE "ODK v18.2 2023-07-06" +#define ODK_RELEASE_DATE "ODK v18.2 2023-07-07" /* The lowest version number for an ODK message. */ #define ODK_FIRST_VERSION 16 diff --git a/libwvdrmengine/oemcrypto/odk/src/odk.c b/libwvdrmengine/oemcrypto/odk/src/odk.c index 3e51a90c..3ade4a76 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk.c +++ b/libwvdrmengine/oemcrypto/odk/src/odk.c @@ -471,13 +471,14 @@ OEMCryptoResult ODK_ParseRenewal(const uint8_t* message, size_t message_length, */ /* If a renewal request is lost in transit, we should throw it out and create * a new one. We use the timestamp to make sure we have the latest request. - * We only do this if playback has already started. This allows us to reload - * an offline license and also reload a renewal before starting playback. + * We only do this if a renewal has been requested for this session. This + * allows us to reload an offline license and also reload a renewal from a + * previous session before starting playback. * TODO: b/290249855 - This is reversed. It should be "!=" instead of "<". * We will not fix this in the current release, because it is already in * production code. Instead, this will be fixed in v19. */ - if (clock_values->timer_status != ODK_CLOCK_TIMER_STATUS_LICENSE_LOADED && + if (clock_values->time_of_renewal_request > 0 && clock_values->time_of_renewal_request < renewal_response.request.playback_time) { return ODK_STALE_RENEWAL; diff --git a/libwvdrmengine/oemcrypto/odk/src/odk_timer.c b/libwvdrmengine/oemcrypto/odk/src/odk_timer.c index 23646d78..69945321 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk_timer.c +++ b/libwvdrmengine/oemcrypto/odk/src/odk_timer.c @@ -295,6 +295,7 @@ OEMCryptoResult ODK_InitializeClockValues(ODK_ClockValues* clock_values, clock_values->time_of_license_request_signed = system_time_seconds; clock_values->time_of_first_decrypt = 0; clock_values->time_of_last_decrypt = 0; + clock_values->time_of_renewal_request = 0; clock_values->time_when_timer_expires = 0; clock_values->timer_status = ODK_CLOCK_TIMER_STATUS_LICENSE_NOT_LOADED; clock_values->status = kUnused;