odk: core serialization structs & functions
odk directory copied from wvgerrit. branch oemcrypto-v16 commit 0c9a7dc Bug: 140758896 Test: odk_test Change-Id: I0c631f771b794468a63e4395f6b9c3b60a1dfd4f
This commit is contained in:
96
libwvdrmengine/oemcrypto/odk/include/odk_structs.h
Normal file
96
libwvdrmengine/oemcrypto/odk/include/odk_structs.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary
|
||||
* source code may only be used and distributed under the Widevine Master
|
||||
* License Agreement.
|
||||
*/
|
||||
|
||||
#ifndef ODK_STRUCTS_H_
|
||||
#define ODK_STRUCTS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "OEMCryptoCENCCommon.h"
|
||||
|
||||
#define ODK_MAX_NUM_KEYS 32
|
||||
#define ODK_DEVICE_ID_LEN_MAX 64
|
||||
#define ODK_SHA256_HASH_SIZE 32
|
||||
|
||||
/*
|
||||
* ODK_TimerLimits is filled out by the function ODK_ParseLicense.
|
||||
*
|
||||
* The fields in this structure are defined in the core license response
|
||||
* message. This structure should be kept as part of the session and used
|
||||
* when calling the ODK timer functions described in the document "License
|
||||
* Duration and Renewal" distributed as part of the OEMCrypto v16 design.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t /*boolean*/ soft_expiry;
|
||||
uint64_t earliest_playback_start_seconds; // seconds since license signed.
|
||||
uint64_t latest_playback_start_seconds; // seconds since license signed.
|
||||
uint64_t initial_playback_duration_seconds; // seconds since playback start.
|
||||
uint64_t renewal_playback_duration_seconds; // seconds since renewal signed.
|
||||
uint64_t license_duration_seconds; // seconds since license signed.
|
||||
} ODK_TimerLimits;
|
||||
|
||||
/*
|
||||
* ODK_ParsedLicense holds fields from the core license response.
|
||||
*/
|
||||
typedef struct {
|
||||
OEMCrypto_Substring enc_mac_keys_iv;
|
||||
OEMCrypto_Substring enc_mac_keys;
|
||||
OEMCrypto_Substring pst;
|
||||
OEMCrypto_Substring srm_restriction_data;
|
||||
uint32_t /* OEMCrypto_LicenseType */ license_type;
|
||||
uint32_t nonce_required;
|
||||
ODK_TimerLimits timer_limits;
|
||||
uint8_t request_hash[ODK_SHA256_HASH_SIZE];
|
||||
uint32_t key_array_length; /* num_keys */
|
||||
OEMCrypto_KeyObject key_array[ODK_MAX_NUM_KEYS];
|
||||
} ODK_ParsedLicense;
|
||||
|
||||
/*
|
||||
* ODK_ParsedProvisioning holds fields from the core provisioning response.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t key_type;
|
||||
OEMCrypto_Substring enc_private_key;
|
||||
OEMCrypto_Substring enc_private_key_iv;
|
||||
OEMCrypto_Substring encrypted_message_key; /* Used for Prov 3.0 */
|
||||
} ODK_ParsedProvisioning;
|
||||
|
||||
/*
|
||||
* ODK_ClockValues keeps information about a session's current clock values
|
||||
* and timers.
|
||||
*
|
||||
* Most of the fields in this structure are saved in the usage entry for each
|
||||
* session. This structure should be initialized when a usage entry is
|
||||
* created or loaded, and should be used to save a usage entry. It is
|
||||
* updated using ODK functions listed in the document "License Duration and
|
||||
* Renewal". The time values are based on OEMCrypto’s system clock.
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t time_of_license_signed;
|
||||
uint64_t time_of_first_decrypt;
|
||||
uint64_t time_of_last_decrypt;
|
||||
uint64_t time_when_timer_expires;
|
||||
uint32_t timer_status;
|
||||
enum OEMCrypto_Usage_Entry_Status status;
|
||||
} ODK_ClockValues;
|
||||
|
||||
/*
|
||||
* ODK_NonceValues are used to match a license or provisioning request to a
|
||||
* license or provisioning response. For this reason, the api_version might be
|
||||
* lower than that supported by OEMCrypto. The api_version matches the version
|
||||
* of the license. Similarly the nonce and session_id match the session that
|
||||
* generated the license request. For an offline license, these might not match
|
||||
* the session that is loading the license. We use the nonce to prevent a
|
||||
* license from being replayed. By also including a session_id in the license
|
||||
* request and license response, we prevent an attack using the birthday paradox
|
||||
* to generate nonce collisions on a single device.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t api_version;
|
||||
uint32_t nonce;
|
||||
uint32_t session_id;
|
||||
} ODK_NonceValues;
|
||||
|
||||
#endif // ODK_STRUCTS_H_
|
||||
Reference in New Issue
Block a user