Source release 19.6.0
GitOrigin-RevId: 13a33e34413c19da1bfe76abcc66be519c9ac9d1
This commit is contained in:
@@ -26,9 +26,9 @@ struct CoreMessageFeatures {
|
||||
|
||||
// This is the published version of the ODK Core Message library. The default
|
||||
// behavior is for the server to restrict messages to at most this version
|
||||
// number. The default is 19.5.
|
||||
// number. The default is 19.6.
|
||||
uint32_t maximum_major_version = 19;
|
||||
uint32_t maximum_minor_version = 5;
|
||||
uint32_t maximum_minor_version = 6;
|
||||
|
||||
bool operator==(const CoreMessageFeatures &other) const;
|
||||
bool operator!=(const CoreMessageFeatures &other) const {
|
||||
|
||||
@@ -98,6 +98,36 @@ OEMCryptoResult ODK_InitializeSessionValues(ODK_TimerLimits* timer_limits,
|
||||
uint32_t api_major_version,
|
||||
uint32_t session_id);
|
||||
|
||||
/*
|
||||
* This function initializes the session's data structures. It shall be
|
||||
* called from OEMCrypto_OpenSession.
|
||||
*
|
||||
* This function is an extended "Ex" version of
|
||||
* ODK_InitializeSessionValues(). It is not intended for production systems;
|
||||
* ODK_InitializeSessionValues() should be used instead.
|
||||
*
|
||||
* This function is intentionally excluded from Doxygen.
|
||||
*
|
||||
* @param[out] timer_limits: the session's timer limits.
|
||||
* @param[out] clock_values: the session's clock values.
|
||||
* @param[out] nonce_values: the session's ODK nonce values.
|
||||
* @param[in] api_major_version: the API major version of OEMCrypto.
|
||||
* @param[in] api_minor_version: the API minor version of OEMCrypto.
|
||||
* @param[in] session_id: the session id of the newly created session.
|
||||
*
|
||||
* @retval OEMCrypto_SUCCESS
|
||||
* @retval OEMCrypto_ERROR_INVALID_CONTEXT
|
||||
*
|
||||
* @version
|
||||
* This method is new in version 19.6 of the API.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* This function sets the nonce value in the session's nonce structure. It
|
||||
* shall be called from OEMCrypto_GenerateNonce.
|
||||
|
||||
@@ -16,10 +16,10 @@ extern "C" {
|
||||
|
||||
/* The version of this library. */
|
||||
#define ODK_MAJOR_VERSION 19
|
||||
#define ODK_MINOR_VERSION 5
|
||||
#define ODK_MINOR_VERSION 6
|
||||
|
||||
/* ODK Version string. Date changed automatically on each release. */
|
||||
#define ODK_RELEASE_DATE "ODK v19.5 2025-03-11"
|
||||
#define ODK_RELEASE_DATE "ODK v19.6 2025-06-03"
|
||||
|
||||
/* The lowest version number for an ODK message. */
|
||||
#define ODK_FIRST_VERSION 16
|
||||
|
||||
@@ -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_
|
||||
@@ -1275,7 +1275,7 @@ std::vector<VersionParameters> TestCases() {
|
||||
{16, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 16, 5},
|
||||
{17, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 17, 2},
|
||||
{18, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 18, 4},
|
||||
{19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 5},
|
||||
{19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 6},
|
||||
// Here are some known good versions. Make extra sure they work.
|
||||
{ODK_MAJOR_VERSION, 16, 3, 16, 3},
|
||||
{ODK_MAJOR_VERSION, 16, 4, 16, 4},
|
||||
@@ -1291,6 +1291,7 @@ std::vector<VersionParameters> TestCases() {
|
||||
{ODK_MAJOR_VERSION, 19, 3, 19, 3},
|
||||
{ODK_MAJOR_VERSION, 19, 4, 19, 4},
|
||||
{ODK_MAJOR_VERSION, 19, 5, 19, 5},
|
||||
{ODK_MAJOR_VERSION, 19, 6, 19, 6},
|
||||
{0, 16, 3, 16, 3},
|
||||
{0, 16, 4, 16, 4},
|
||||
{0, 16, 5, 16, 5},
|
||||
@@ -1304,6 +1305,7 @@ std::vector<VersionParameters> TestCases() {
|
||||
{0, 19, 3, 19, 3},
|
||||
{0, 19, 4, 19, 4},
|
||||
{0, 19, 5, 19, 5},
|
||||
{0, 19, 6, 19, 6},
|
||||
};
|
||||
return test_cases;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user