Add header functions for license release

Bug: 295956275
Change-Id: I223937ea25544cfb562bc063e75b359e4d908984
This commit is contained in:
Vicky Min
2023-10-11 22:19:16 +00:00
committed by Robert Shih
parent 82c4165553
commit 417a9c7b77
2 changed files with 132 additions and 0 deletions

View File

@@ -719,6 +719,8 @@ typedef enum OEMCrypto_SignatureHashAlgorithm {
#define OEMCrypto_LoadLicense _oecc144
#define OEMCrypto_LoadProvisioning _oecc145
#define OEMCrypto_LoadProvisioningCast _oecc146
#define OEMCrypto_PrepAndSignLicenseRelease _oecc147
#define OEMCrypto_GetUsageEntryInfo _oecc148
// clang-format on
/// @addtogroup initcontrol
@@ -1076,6 +1078,80 @@ OEMCryptoResult OEMCrypto_PrepAndSignLicenseRequest(
OEMCrypto_SESSION session, uint8_t* message, size_t message_length,
size_t* core_message_size, uint8_t* signature, size_t* signature_length);
/**
* This function replaces both OEMCrypto_DeactivateUsageEntry and
* OEMCrypto_ReportUsage. As with other OEMCrypto_PrepAndSign* functions, it
* first verifies that the core_message_size is the right size. If not, it
* returns OEMCrypto_ERROR_SHORT_BUFFER.
* OEMCrypto will change the status of the usage entry to InactiveUsed if it was
* Active, or InactiveUnused if it was Unused. This also increments the entry's
* generation number by 2, and the header's master generation number. The
* corresponding generation number in the usage table header is also incremented
* so that it matches the one in the entry.
*
* OEMCrypto will use ODK_PrepareCoreLicenseRelease to prepare the core
* message. If it returns OEMCrypto_SUCCESS, then OEMCrypto shall sign the
* message body using the DRM certificate's private key. If it returns an
* error, the error should be returned by OEMCrypto to the CDM layer.
* ODK_PrepareCoreLicenseRelease is described in the document "Widevine Core
* Message Serialization".
*
* This function generates a HMAC-SHA256 signature using the mac_key[client]
* for license release signing under the license server protocol for CENC.
*
* The key used for signing should be the mac_key[client] that was generated
* for this session or loaded for this session by
* OEMCrypto_LoadLicense() or OEMCrypto_LoadUsageEntry().
*
* NOTE: if signature pointer is null and/or input signature_length is zero,
* this function returns OEMCrypto_ERROR_SHORT_BUFFER and sets output
* signature_length to the size needed to receive the output signature.
*
* @param[in] session: handle for the session to be used.
* @param[in,out] message: Pointer to memory for the entire message. Modified by
* OEMCrypto via the ODK library.
* @param[in] message_length: length of the entire message buffer.
* @param[in,out] core_message_size: length of the core message at the beginning
* of the message. (in) size of buffer reserved for the core message, in
* bytes. (out) actual length of the core message, in bytes.
* @param[out] signature: pointer to memory to receive the computed signature.
* @param[in,out] signature_length: (in) length of the signature buffer, in
* bytes. (out) actual length of the signature, in bytes.
*
* @retval OEMCrypto_SUCCESS success
* @retval OEMCrypto_ERROR_INVALID_SESSION
* @retval OEMCrypto_ERROR_SHORT_BUFFER if signature buffer is not large enough
* to hold the signature.
* @retval OEMCrypto_ERROR_INSUFFICIENT_RESOURCES
* @retval OEMCrypto_ERROR_NOT_IMPLEMENTED since OEMCrypto does not implement
* license release before v19
* @retval OEMCrypto_ERROR_UNKNOWN_FAILURE
* @retval OEMCrypto_ERROR_SIGNATURE_FAILURE
* @retval OEMCrypto_ERROR_BUFFER_TOO_LARGE
* @retval OEMCrypto_ERROR_SESSION_LOST_STATE
* @retval OEMCrypto_ERROR_SYSTEM_INVALIDATED
*
* @buffer_size
* OEMCrypto shall support message sizes as described in the section
* OEMCrypto_ResourceRatingTier().
* OEMCrypto shall return OEMCrypto_ERROR_BUFFER_TOO_LARGE if the buffer is
* larger than the supported size.
*
* @threading
* This is a "Session Function" and may be called simultaneously with session
* functions for other sessions but not simultaneously with other functions
* for this session. It will not be called simultaneously with initialization
* or usage table functions. It is as if the CDM holds a write lock for this
* session, and a read lock on the OEMCrypto system.
*
* @version
* This method is new in API version 19.
*/
OEMCryptoResult OEMCrypto_PrepAndSignLicenseRelease(
OEMCrypto_SESSION session, uint8_t* message, size_t message_length,
size_t* core_message_size, uint8_t* signature, size_t* signature_length);
/**
* OEMCrypto will use ODK_PrepareCoreRenewalRequest, as described in the
* document "Widevine Core Message Serialization", to prepare the core
@@ -4647,6 +4723,36 @@ OEMCryptoResult OEMCrypto_ReportUsage(OEMCrypto_SESSION session,
const uint8_t* pst, size_t pst_length,
uint8_t* buffer, size_t* buffer_length);
/**
* Fetches information from a license release without performing any signatures
* or deactivating the license.
*
* @param[in] session: handle for the session to be used.
* @param[out] status: the enumeration of OEMCrypto_Usage_Entry_Status.
* @param[out] seconds_since_license_received: the time since the license being
* requested in seconds.
* @param[out] seconds_since_first_decrypt: the time since playback has
* started in seconds.
*
* @retval OEMCrypto_SUCCESS success
* @retval OEMCrypto_ERROR_INVALID_SESSION no open session with that id.
* @retval OEMCrypto_ERROR_INVALID_CONTEXT
* @retval OEMCrypto_ERROR_NOT_IMPLEMENTED
* @retval OEMCrypto_ERROR_UNKNOWN_FAILURE
*
* @threading
* This is a "Usage Table Function" and will not be called simultaneously
* with any other function, as if the CDM holds a write lock on the OEMCrypto
* system.
*
* @version
* This method is new in API version 19.
*/
OEMCryptoResult OEMCrypto_GetUsageEntryInfo(
OEMCrypto_SESSION session, OEMCrypto_Usage_Entry_Status* status,
int64_t* seconds_since_license_received,
int64_t* seconds_since_first_decrypt);
/**
* Moves the entry associated with the current session from one location in
* the usage table header to another. This function is used by the CDM layer