Source release 19.6.0
GitOrigin-RevId: 13a33e34413c19da1bfe76abcc66be519c9ac9d1
This commit is contained in:
@@ -89,10 +89,8 @@ bool ParseRequest(uint32_t message_type,
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
static bool GetNonceFromMessage(const std::string& oemcrypto_core_message,
|
||||
ODK_NonceValues* nonce_values) {
|
||||
bool GetNonceFromMessage(const std::string& oemcrypto_core_message,
|
||||
ODK_NonceValues* nonce_values) {
|
||||
if (nonce_values == nullptr) return false;
|
||||
if (oemcrypto_core_message.size() < sizeof(ODK_CoreMessage)) return false;
|
||||
|
||||
@@ -125,6 +123,8 @@ bool CopyCounterInfo(ODK_MessageCounter* dest, ODK_MessageCounterInfo* src) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool CoreLicenseRequestFromMessage(const std::string& oemcrypto_core_message,
|
||||
ODK_LicenseRequest* core_license_request) {
|
||||
ODK_NonceValues nonce;
|
||||
|
||||
@@ -33,7 +33,7 @@ CoreMessageFeatures CoreMessageFeatures::DefaultFeatures(
|
||||
features.maximum_minor_version = 4; // 18.4
|
||||
break;
|
||||
case 19:
|
||||
features.maximum_minor_version = 5; // 19.5
|
||||
features.maximum_minor_version = 6; // 19.6
|
||||
break;
|
||||
default:
|
||||
features.maximum_minor_version = 0;
|
||||
|
||||
@@ -3,12 +3,16 @@
|
||||
// License Agreement.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "odk.h"
|
||||
#include "odk_attributes.h"
|
||||
#include "odk_overflow.h"
|
||||
#include "odk_structs_priv.h"
|
||||
#include "odk_versions.h"
|
||||
|
||||
/* This is a special value used to signal that the latest API
|
||||
* minor version should be used for a particular API major version. */
|
||||
#define ODK_LATEST_API_MINOR_VERSION UINT32_MAX
|
||||
|
||||
/* Private function. Checks to see if the license is active. Returns
|
||||
* ODK_TIMER_EXPIRED if the license is valid but inactive. Returns
|
||||
@@ -241,6 +245,62 @@ OEMCryptoResult ODK_ComputeRenewalDuration(const ODK_TimerLimits* timer_limits,
|
||||
return ODK_SET_TIMER;
|
||||
}
|
||||
|
||||
/* Private function. Initialize the timer limits to default values. */
|
||||
static void InitializeTimerLimits(ODK_TimerLimits* timer_limits) {
|
||||
if (timer_limits == NULL) {
|
||||
return;
|
||||
}
|
||||
timer_limits->soft_enforce_rental_duration = false;
|
||||
timer_limits->soft_enforce_playback_duration = false;
|
||||
timer_limits->earliest_playback_start_seconds = 0;
|
||||
timer_limits->rental_duration_seconds = 0;
|
||||
timer_limits->total_playback_duration_seconds = 0;
|
||||
timer_limits->initial_renewal_duration_seconds = 0;
|
||||
}
|
||||
|
||||
/* Private function. Obtains the maximum minor version for a given major
|
||||
* version. */
|
||||
static uint32_t GetApiMinorVersion(uint32_t api_major_version) {
|
||||
/* This needs to be updated with new major version releases. */
|
||||
switch (api_major_version) {
|
||||
case 16:
|
||||
return ODK_V16_MINOR_VERSION;
|
||||
case 17:
|
||||
return ODK_V17_MINOR_VERSION;
|
||||
case 18:
|
||||
return ODK_V18_MINOR_VERSION;
|
||||
case 19:
|
||||
return ODK_V19_MINOR_VERSION;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Private function. Initialize the nonce values.
|
||||
* Note: |api_minor_version| may be set to ODK_LATEST_API_MINOR_VERSION.*/
|
||||
static void InitializeNonceValues(ODK_NonceValues* nonce_values,
|
||||
uint32_t api_major_version,
|
||||
uint32_t api_minor_version,
|
||||
uint32_t session_id) {
|
||||
if (nonce_values == NULL) {
|
||||
return;
|
||||
}
|
||||
if (api_major_version > ODK_MAJOR_VERSION) {
|
||||
api_major_version = ODK_MAJOR_VERSION;
|
||||
}
|
||||
/* Floor the API minor version to the maximum minor version for the API major
|
||||
* version. */
|
||||
const uint32_t max_api_minor_version = GetApiMinorVersion(api_major_version);
|
||||
if (api_minor_version > max_api_minor_version) {
|
||||
api_minor_version = max_api_minor_version;
|
||||
}
|
||||
|
||||
nonce_values->api_major_version = api_major_version;
|
||||
nonce_values->api_minor_version = api_minor_version;
|
||||
nonce_values->nonce = 0;
|
||||
nonce_values->session_id = session_id;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/************************************************************************/
|
||||
/* Public functions, declared in odk.h. */
|
||||
@@ -254,38 +314,27 @@ OEMCryptoResult ODK_InitializeSessionValues(ODK_TimerLimits* timer_limits,
|
||||
if (timer_limits == NULL || clock_values == NULL || nonce_values == NULL) {
|
||||
return OEMCrypto_ERROR_INVALID_CONTEXT;
|
||||
}
|
||||
timer_limits->soft_enforce_rental_duration = false;
|
||||
timer_limits->soft_enforce_playback_duration = false;
|
||||
timer_limits->earliest_playback_start_seconds = 0;
|
||||
timer_limits->rental_duration_seconds = 0;
|
||||
timer_limits->total_playback_duration_seconds = 0;
|
||||
timer_limits->initial_renewal_duration_seconds = 0;
|
||||
|
||||
InitializeTimerLimits(timer_limits);
|
||||
ODK_InitializeClockValues(clock_values, 0);
|
||||
InitializeNonceValues(nonce_values, api_major_version,
|
||||
ODK_LATEST_API_MINOR_VERSION, session_id);
|
||||
return OEMCrypto_SUCCESS;
|
||||
}
|
||||
|
||||
nonce_values->api_major_version = api_major_version;
|
||||
// This needs to be updated with new version releases in the default features
|
||||
// of core message features.
|
||||
switch (nonce_values->api_major_version) {
|
||||
case 16:
|
||||
nonce_values->api_minor_version = 5;
|
||||
break;
|
||||
case 17:
|
||||
nonce_values->api_minor_version = 2;
|
||||
break;
|
||||
case 18:
|
||||
nonce_values->api_minor_version = 4;
|
||||
break;
|
||||
case 19:
|
||||
nonce_values->api_minor_version = 5;
|
||||
break;
|
||||
default:
|
||||
nonce_values->api_minor_version = 0;
|
||||
break;
|
||||
/* This is called when certain OEMCrypto implementations opens a new session. */
|
||||
OEMCryptoResult ODK_InitializeSessionValuesEx(ODK_TimerLimits* timer_limits,
|
||||
ODK_ClockValues* clock_values,
|
||||
ODK_NonceValues* nonce_values,
|
||||
uint32_t api_major_version,
|
||||
uint32_t api_minor_version,
|
||||
uint32_t session_id) {
|
||||
if (timer_limits == NULL || clock_values == NULL || nonce_values == NULL) {
|
||||
return OEMCrypto_ERROR_INVALID_CONTEXT;
|
||||
}
|
||||
nonce_values->nonce = 0;
|
||||
nonce_values->session_id = session_id;
|
||||
|
||||
InitializeTimerLimits(timer_limits);
|
||||
ODK_InitializeClockValues(clock_values, 0);
|
||||
InitializeNonceValues(nonce_values, api_major_version, api_minor_version,
|
||||
session_id);
|
||||
return OEMCrypto_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
24
oemcrypto/odk/src/odk_versions.h
Normal file
24
oemcrypto/odk/src/odk_versions.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2025 Google LLC. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine
|
||||
// License Agreement.
|
||||
|
||||
#ifndef WIDEVINE_ODK_SRC_ODK_VERSIONS_H_
|
||||
#define WIDEVINE_ODK_SRC_ODK_VERSIONS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "odk_structs.h"
|
||||
|
||||
/* Highest ODK minor version number by major version. */
|
||||
#define ODK_V16_MINOR_VERSION 5
|
||||
#define ODK_V17_MINOR_VERSION 8
|
||||
#define ODK_V18_MINOR_VERSION 10
|
||||
|
||||
/* Whenever the next major version is released, this should be updated to the
|
||||
* new major version. */
|
||||
#if ODK_MAJOR_VERSION != 19
|
||||
# error "ODK_MAJOR_VERSION has changed. Please update this file."
|
||||
#endif
|
||||
#define ODK_V19_MINOR_VERSION ODK_MINOR_VERSION
|
||||
|
||||
#endif // WIDEVINE_ODK_SRC_ODK_VERSIONS_H_
|
||||
Reference in New Issue
Block a user