From 8054b9e2c32f51aa4d55e6d3a180e37529b2a36d Mon Sep 17 00:00:00 2001 From: Yimei Sun Date: Tue, 1 Aug 2017 17:11:52 -0700 Subject: Fugu-O supprot OEMCrypto v13 requirements Interface update to support OEMCrypto v13 API changes for Fugu O upgrade. Fugu only change. TV only change. Change-Id: I43009da92792e43bdb9ecdde0801266dd4c3fef7 Tracked-On: IMINAN-51561 Bug: 64317229 Test: netflix, play movies, youtube Signed-off-by: Yimei Sun (cherry picked from commit 192da5037e35ed7659874fea6bb3a4a3e33d563f) --- DRM/cc54/inc/wv_mod_drm_api.h | 87 ++++++++++++++++++++++++++++++++++++---- DRM/cc54/inc/wv_mod_drm_error.h | 12 +++++- DRM/cc54/inc/wv_mod_oem_crypto.h | 10 +++++ 3 files changed, 100 insertions(+), 9 deletions(-) diff --git a/DRM/cc54/inc/wv_mod_drm_api.h b/DRM/cc54/inc/wv_mod_drm_api.h index 4e5cab0..d3be933 100755 --- a/DRM/cc54/inc/wv_mod_drm_api.h +++ b/DRM/cc54/inc/wv_mod_drm_api.h @@ -165,7 +165,8 @@ uint32_t drm_wv_mod_v9_load_keys(uint32_t session_id, uint32_t num_keys, const struct drm_wv_mod_key_object *key_array, const uint8_t *pst, - uint32_t pst_length); + uint32_t pst_length, + const uint8_t *srm_restriction_data); uint32_t drm_wv_mod_v9_generate_rsa_signature(uint32_t session_id, const uint8_t *message, @@ -213,7 +214,6 @@ uint32_t drm_wv_mod_load_usage_table(const uint8_t *const usage_table_data, * Flag indicating if the table has changed since the last * update_usage_table or load_usage_table call. * - * TODO: Return documentation */ uint32_t drm_wv_mod_update_usage_table(uint8_t *const usage_table_data, uint32_t data_size, @@ -221,8 +221,8 @@ uint32_t drm_wv_mod_update_usage_table(uint8_t *const usage_table_data, // NOTE: drm_wv_mod_update_usage_table shall be called after calling this // function -// TODO: Documentation -uint32_t drm_wv_mod_deactivate_usage_entry(const uint8_t *const pst, +uint32_t drm_wv_mod_deactivate_usage_entry(uint32_t session_id, + const uint8_t *const pst, uint32_t pst_length); /** @@ -243,7 +243,6 @@ uint32_t drm_wv_mod_deactivate_usage_entry(const uint8_t *const pst, * sizeof(struct OEMCrypto_PST_Report) in length. If extra space is provided, * this field will reflect the actual size of the returned report. * - * TODO: Return documentation */ uint32_t drm_wv_mod_report_usage(uint32_t session_id, const uint8_t *const pst, @@ -271,7 +270,6 @@ uint32_t drm_wv_mod_report_usage(uint32_t session_id, * @param[in] signature_length * Length of signature buffer in bytes * - * TODO: Return Documentation */ uint32_t drm_wv_mod_delete_usage_entry(uint32_t session_id, const uint8_t *const pst, @@ -283,7 +281,6 @@ uint32_t drm_wv_mod_delete_usage_entry(uint32_t session_id, // This will only clear Chaabi TEE memory. Caller is responsible for deleting // usage table file from file system. -// TODO: Documentation uint32_t drm_wv_mod_delete_usage_table(void); @@ -350,4 +347,80 @@ uint32_t drm_wv_mod_glue_block(uint32_t session_id, uint32_t cleartext_length, const uint8_t *iv); +/*! Version 13 specific APIs */ + +/*! + * Create a new Usage Table Header with no entries. + */ +uint32_t drm_wv_mod_create_usage_table_header(uint8_t *header_buffer, + uint32_t *header_buffer_length, + uint64_t system_time); + +/*! + * Loads the usage table header into TEE. + */ +uint32_t drm_wv_mod_load_usage_table_header(const uint8_t *buffer, + uint32_t buffer_length, + uint64_t system_time); + +/*! + * Create a new usage entry. + */ +uint32_t drm_wv_mod_create_new_usage_entry(uint32_t session_id, + uint32_t *usage_entry_number); + +/*! + * Load a usage table saved by update usage entry. + */ +uint32_t drm_wv_mod_load_usage_entry(uint32_t session_id, + uint32_t index, + const uint8_t *buffer, + uint32_t buffer_length); + +/*! + * Updates session usage entry. + */ +uint32_t drm_wv_mod_update_usage_entry(uint32_t session_id, + uint8_t *header_buffer, + uint32_t *header_buffer_length, + uint8_t *entry_buffer, + uint32_t *entry_buffer_length); + +/*! + * Move usage entry with current session from one location in header to another. + */ +uint32_t drm_wv_mod_move_entry(uint32_t session_id, + uint32_t new_index); + +/*! + * Shrinks the usage table and the header. + */ +uint32_t drm_wv_mod_shrink_usage_table_header(uint32_t new_entry_count, + uint8_t *header_buffer, + uint32_t *header_buffer_length); + +/*! + * Copies an entry from old v12(or earlier) usage table to new table. + */ +uint32_t drm_wv_mod_copy_old_usage_entry(uint32_t session_id, + const uint8_t *pst, + uint32_t pst_length); + +/*! + * Delete the old usage table. + */ +uint32_t drm_wv_mod_delete_old_usage_table(void); + +/*! + * Create old usage entry. + */ +uint32_t drm_wv_mod_create_old_usage_entry(uint64_t time_since_license_received, + uint64_t time_since_first_decrypt, + uint64_t time_since_last_decrypt, + enum drm_wv_mod_usage_entry_status status, + uint8_t *server_mac_key, + uint8_t *client_mac_key, + const uint8_t *pst, + uint32_t pst_length); + #endif /* __WV_MOD_DRM_API_H_ */ diff --git a/DRM/cc54/inc/wv_mod_drm_error.h b/DRM/cc54/inc/wv_mod_drm_error.h index b10c2eb..6b33d08 100755 --- a/DRM/cc54/inc/wv_mod_drm_error.h +++ b/DRM/cc54/inc/wv_mod_drm_error.h @@ -58,7 +58,7 @@ enum drm_wv_mod_result DRM_WV_MOD_ENCRYPTION_DECRYPTION_SIZE_INCORRECT, DRM_WV_MOD_ERROR_BUFFER_TOO_SMALL, DRM_WV_MOD_ERROR_BUFFER_TYPE_INVALID, - DRM_WV_MOD_ERROR_DATA_SIZE_TOO_LARGE, + DRM_WV_MOD_ERROR_BUFFER_TOO_LARGE, DRM_WV_MOD_ERROR_RETURN_BUFFER_TOO_SMALL, DRM_WV_MOD_ERROR_DMA_DATA_SIZE_TOO_LARGE, DRM_WV_MOD_ERROR_NONCE_GENERATION_FAILURE, @@ -74,7 +74,15 @@ enum drm_wv_mod_result DRM_WV_MOD_ERROR_INVALID_USAGE_TABLE_GENERATION_NUM, DRM_WV_MOD_ERROR_INVALID_USAGE_TABLE_MAGIC, DRM_WV_MOD_ERROR_USAGE_TABLE_NOT_INITIALIZED, - DRM_WV_MOD_ERROR_INVALID_CIPHER_MODE + DRM_WV_MOD_ERROR_INVALID_CIPHER_MODE, + DRM_WV_MOD_ERROR_GENERATION_NUM_SKEW, + DRM_WV_MOD_WARNING_GENERATION_NUM_SKEW, + DRM_WV_MOD_ERROR_ENTRY_IN_USE, + DRM_WV_MOD_ERROR_ENTRY_NEEDS_UPDATE, + DRM_WV_MOD_ERROR_ANALOG_OUTPUT, + DRM_WV_MOD_ERROR_WRONG_PST, + DRM_WV_MOD_ERROR_MISSING_MASTER, + DRM_WV_MOD_ERROR_LICENSE_INACTIVE }; #endif diff --git a/DRM/cc54/inc/wv_mod_oem_crypto.h b/DRM/cc54/inc/wv_mod_oem_crypto.h index 42ed033..bdba935 100755 --- a/DRM/cc54/inc/wv_mod_oem_crypto.h +++ b/DRM/cc54/inc/wv_mod_oem_crypto.h @@ -32,6 +32,16 @@ enum drm_wv_mod_rsa_padding_scheme DRM_WV_MOD_RSA_PADDING_SCHEME_MAX_VALUE }; +enum drm_wv_mod_usage_entry_status +{ + k_free = -1, + k_unused = 0, + k_active = 1, + k_inactive = 2, // deprecated in v13 + k_inactive_used = 3, + k_inactive_unused = 4 +}; + struct drm_wv_mod_key_object { const uint8_t *key_id; -- cgit v1.2.3