67 lines
3.0 KiB
C
67 lines
3.0 KiB
C
/* Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
|
source code may only be used and distributed under the Widevine License
|
|
Agreement. */
|
|
|
|
#ifndef OEMCRYPTO_TA_OEMCRYPTO_ENTITLED_KEY_SESSION_H_
|
|
#define OEMCRYPTO_TA_OEMCRYPTO_ENTITLED_KEY_SESSION_H_
|
|
|
|
#include "OEMCryptoCENC.h"
|
|
#include "oemcrypto_compiler_attributes.h"
|
|
#include "oemcrypto_key.h"
|
|
#include "wtpi_config_interface.h"
|
|
|
|
typedef struct EntitlementKeyInfo {
|
|
uint8_t entitlement_key_id[KEY_ID_MAX_SIZE];
|
|
size_t entitlement_key_id_size;
|
|
} EntitlementKeyInfo;
|
|
|
|
typedef struct DecryptHash {
|
|
/* These are used when doing full decrypt path testing. */
|
|
bool compute_hash; /* True if the current frame needs a hash. */
|
|
uint32_t current_hash; /* Running CRC hash of frame. */
|
|
uint32_t given_hash; /* True CRC hash of frame. */
|
|
uint32_t current_frame_number; /* Current frame for CRC hash. */
|
|
uint32_t bad_frame_number; /* Frame number with bad hash. */
|
|
OEMCryptoResult hash_error; /* Error code for first bad frame. */
|
|
} DecryptHash;
|
|
|
|
typedef struct OEMCryptoEntitledKeySession {
|
|
OEMCrypto_SESSION key_session_id;
|
|
uint32_t current_entitled_content_key_index;
|
|
SymmetricKey* entitled_content_keys[CONTENT_KEYS_PER_SESSION];
|
|
uint32_t num_entitled_content_keys;
|
|
/* entitlement key info of each entitled content key. */
|
|
EntitlementKeyInfo entitlement_keys[CONTENT_KEYS_PER_SESSION];
|
|
/* the OEMCrypto session that this entitled key session is associated with. */
|
|
OEMCrypto_SESSION entitlement_session_id;
|
|
DecryptHash decrypt_hash;
|
|
#ifdef SUPPORT_CAS
|
|
/* CAS only. Contains info of the key slot associated to this key session. The
|
|
* interpretation of key slot descriptor can be vendor-specific. */
|
|
void* key_slot_descriptor;
|
|
#endif
|
|
} OEMCryptoEntitledKeySession;
|
|
|
|
/* Initializes entitled key session |session| with id |key_session_id| and the
|
|
entitlement session id |entitlement_session_id|. Returns OEMCrypto_SUCCESS.
|
|
Caller retains ownership of |session| and it must not be NULL. */
|
|
NO_IGNORE_RESULT OEMCryptoResult OPKI_InitializeEntitledKeySession(
|
|
OEMCryptoEntitledKeySession* session, OEMCrypto_SESSION key_session_id,
|
|
OEMCrypto_SESSION entitlement_session_id);
|
|
|
|
/* Cleans up the entitled key session by freeing any used keys and clearing any
|
|
state. Returns the result of freeing the keys in the session.
|
|
Caller retains ownership of |session| and it must not be NULL. */
|
|
NO_IGNORE_RESULT OEMCryptoResult
|
|
OPKI_TerminateEntitledKeySession(OEMCryptoEntitledKeySession* session);
|
|
|
|
/* Finds the entitled content key from the key table in |session| with the given
|
|
|key_id| and |key_id_length|. Returns either the key if there is a match or
|
|
NULL otherwise. |key_id_length| must be > 0.
|
|
Caller retains ownership of all parameters and they must not be NULL. */
|
|
SymmetricKey* OPKI_FindEntitledContentKeyFromTable(
|
|
OEMCryptoEntitledKeySession* session, const uint8_t* key_id,
|
|
size_t key_id_length);
|
|
|
|
#endif /* OEMCRYPTO_TA_OEMCRYPTO_ENTITLED_KEY_SESSION_H_ */
|