diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index f7658dbc..7024a0f7 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -810,15 +810,18 @@ CdmResponseType CryptoSession::PrepareAndSignLicenseRequest( OEMCryptoResult sts; size_t signature_length = 0; size_t core_message_length = 0; + *core_message = ""; + std::string combined_message = *core_message + message; // First call is intended to determine the required size of the // output buffers. WithOecSessionLock("PrepareAndSignLicenseRequest", [&] { - M_TIME( - sts = OEMCrypto_PrepAndSignLicenseRequest( - oec_session_id_, - reinterpret_cast(const_cast(message.data())), - message.size(), &core_message_length, nullptr, &signature_length), - metrics_, oemcrypto_prep_and_sign_license_request_, sts); + M_TIME(sts = OEMCrypto_PrepAndSignLicenseRequest( + oec_session_id_, + reinterpret_cast( + const_cast(combined_message.data())), + combined_message.size(), &core_message_length, nullptr, + &signature_length), + metrics_, oemcrypto_prep_and_sign_license_request_, sts); }); if (OEMCrypto_ERROR_SHORT_BUFFER != sts) { @@ -830,7 +833,7 @@ CdmResponseType CryptoSession::PrepareAndSignLicenseRequest( core_message->resize(core_message_length); signature->resize(signature_length); - std::string combined_message = *core_message + message; + combined_message = *core_message + message; WithOecSessionLock("PrepareAndSignLicenseRequest", [&] { M_TIME(sts = OEMCrypto_PrepAndSignLicenseRequest( oec_session_id_, @@ -940,15 +943,18 @@ CdmResponseType CryptoSession::PrepareAndSignRenewalRequest( OEMCryptoResult sts; size_t signature_length = 0; size_t core_message_length = 0; + *core_message = ""; + std::string combined_message = *core_message + message; // First call is intended to determine the required size of the // output buffers. WithOecSessionLock("PrepareAndSignRenewalRequest", [&] { - M_TIME( - sts = OEMCrypto_PrepAndSignRenewalRequest( - oec_session_id_, - reinterpret_cast(const_cast(message.data())), - message.size(), &core_message_length, nullptr, &signature_length), - metrics_, oemcrypto_prep_and_sign_renewal_request_, sts); + M_TIME(sts = OEMCrypto_PrepAndSignRenewalRequest( + oec_session_id_, + reinterpret_cast( + const_cast(combined_message.data())), + combined_message.size(), &core_message_length, nullptr, + &signature_length), + metrics_, oemcrypto_prep_and_sign_renewal_request_, sts); }); if (OEMCrypto_ERROR_SHORT_BUFFER != sts) { @@ -960,7 +966,7 @@ CdmResponseType CryptoSession::PrepareAndSignRenewalRequest( core_message->resize(core_message_length); signature->resize(signature_length); - std::string combined_message = *core_message + message; + combined_message = *core_message + message; WithOecSessionLock("PrepareAndSignRenewalRequest", [&] { M_TIME(sts = OEMCrypto_PrepAndSignRenewalRequest( oec_session_id_, @@ -1059,15 +1065,18 @@ CdmResponseType CryptoSession::PrepareAndSignProvisioningRequest( OEMCryptoResult sts; size_t signature_length = 0; size_t core_message_length = 0; + *core_message = ""; + std::string combined_message = *core_message + message; // First call is intended to determine the required size of the // output buffers. WithOecSessionLock("PrepareAndSignProvisioningRequest", [&] { - M_TIME( - sts = OEMCrypto_PrepAndSignProvisioningRequest( - oec_session_id_, - reinterpret_cast(const_cast(message.data())), - message.size(), &core_message_length, nullptr, &signature_length), - metrics_, oemcrypto_prep_and_sign_provisioning_request_, sts); + M_TIME(sts = OEMCrypto_PrepAndSignProvisioningRequest( + oec_session_id_, + reinterpret_cast( + const_cast(combined_message.data())), + combined_message.size(), &core_message_length, nullptr, + &signature_length), + metrics_, oemcrypto_prep_and_sign_provisioning_request_, sts); }); if (OEMCrypto_ERROR_SHORT_BUFFER != sts) { @@ -1079,7 +1088,7 @@ CdmResponseType CryptoSession::PrepareAndSignProvisioningRequest( core_message->resize(core_message_length); signature->resize(signature_length); - std::string combined_message = *core_message + message; + combined_message = *core_message + message; WithOecSessionLock("PrepareAndSignProvisioningRequest", [&] { M_TIME(sts = OEMCrypto_PrepAndSignProvisioningRequest( oec_session_id_, diff --git a/libwvdrmengine/oemcrypto/odk/test/odk_timer_test.cpp b/libwvdrmengine/oemcrypto/odk/test/odk_timer_test.cpp index fae23bc0..c7f00ce1 100644 --- a/libwvdrmengine/oemcrypto/odk/test/odk_timer_test.cpp +++ b/libwvdrmengine/oemcrypto/odk/test/odk_timer_test.cpp @@ -827,7 +827,7 @@ class RenewalTest : public ODKTimerTest { if (cutoff > 0) ASSERT_LE(stop, cutoff); // We'll fake instantaneous renewal requests. Flight time not important. clock_values_.time_of_renewal_request = start; - OEMCryptoResult result = ODK_ComputeRenewalDuration( + const OEMCryptoResult result = ODK_ComputeRenewalDuration( &timer_limits_, &clock_values_, start, renewal_duration_seconds, timer_value_pointer); // After first playback, the license is active. @@ -899,7 +899,7 @@ class RenewalTest : public ODKTimerTest { // We'll fake instantaneous renewal requests. Flight time not important. clock_values_.time_of_renewal_request = start; uint64_t timer_value; - OEMCryptoResult result = + const OEMCryptoResult result = ODK_ComputeRenewalDuration(&timer_limits_, &clock_values_, start, renewal_duration_seconds, &timer_value); EXPECT_EQ(clock_values_.time_when_timer_expires, cutoff); @@ -1062,9 +1062,9 @@ TEST_P(ODKUseCase_LicenseWithRenewal, Case5) { next_renewal, // stop: expect play allowed. next_renewal + kGracePeriod, // cutoff: when timer expires. timer_limits_.initial_renewal_duration_seconds); - } while (next_renewal + renewal_interval_ + kGracePeriod < + } while ((next_renewal + renewal_interval_ + kGracePeriod) < playback_end_restriction()); - // Attemt playing beyond the playback window. + // Attempt playing beyond the playback window. const uint64_t current_renewal = next_renewal; next_renewal = current_renewal + renewal_interval_; RenewAndTerminate(current_renewal, // start: when renewal is loaded. @@ -1087,7 +1087,7 @@ TEST_P(ODKUseCase_LicenseWithRenewal, Case6) { renewal_interval_ += 100; } while (next_renewal + renewal_interval_ + kGracePeriod < playback_end_restriction()); - // Attemt playing beyond the playback window: + // Attempt playing beyond the playback window: const uint64_t current_renewal = next_renewal; next_renewal = current_renewal + renewal_interval_; RenewAndTerminate(current_renewal, // start: when renewal is loaded. @@ -1171,7 +1171,6 @@ TEST_F(ODKUseCase_LimitedDurationLicense, Case1) { // Playback started after rental duration. TEST_F(ODKUseCase_LimitedDurationLicense, Case2) { start_of_playback_ = EndOfRentalWindow() + 1; - EXPECT_NEAR(start_of_playback_, GetSystemTime(150), 5); ForbidPlayback(start_of_playback_); } @@ -1181,7 +1180,8 @@ TEST_F(ODKUseCase_LimitedDurationLicense, Case3) { LoadAndTerminatePlayback(start_of_playback_, time_of_renewal_ + kGracePeriod); } -// Playback started within rental window and continues. +// Playback started within rental window, renewal is received, and playback +// continues. TEST_F(ODKUseCase_LimitedDurationLicense, Case4) { // Allow playback within the initial renewal window. LoadAndAllowPlayback(start_of_playback_, time_of_renewal_, @@ -1204,8 +1204,11 @@ TEST_F(ODKUseCase_LimitedDurationLicense, Case5) { EndOfPlaybackWindow(), // cutoff: when timer expires. renewal_duration); - uint64_t reload_time = play_for_one_hour + 100; + const uint64_t reload_time = play_for_one_hour + 100; ReloadLicense(reload_time); + // Simulate reloading the license, and then reloading the renewal, and then + // restarting playback. That is allowed, and playback shall be terminated at + // the end of the original playback window. RenewAndStart(reload_time, EndOfPlaybackWindow(), EndOfPlaybackWindow(), renewal_duration); // But not one second more.