1294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores/********************************************************************** 2294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* Copyright (C) 2014 Intel Corporation. All rights reserved. 3294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 4294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* Licensed under the Apache License, Version 2.0 (the "License"); 5294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* you may not use this file except in compliance with the License. 6294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* You may obtain a copy of the License at 7294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 8294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* http://www.apache.org/licenses/LICENSE-2.0 9294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 10294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* Unless required by applicable law or agreed to in writing, software 11294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* distributed under the License is distributed on an "AS IS" BASIS, 12294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* See the License for the specific language governing permissions and 14294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores* limitations under the License. 15294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores**********************************************************************/ 1658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 1758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#ifndef __WV_MOD_DRM_API_H_ 1858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#define __WV_MOD_DRM_API_H_ 1958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 2058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#include <inttypes.h> 2158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#include "drm_common_api.h" 2258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#include "wv_mod_oem_crypto.h" 2358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 2458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/*! 2558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Defines 2658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 2758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#define DRM_WV_MOD_CLEAR_CONTENT_FLAG (1) 2858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#define DRM_WV_MOD_AUDIO_CONTENT_FLAG (1 << 1) 2958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#define DRM_WV_MOD_SECURE_CONTENT_FLAG (1 << 2) 3058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 31294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores// HDCP version values 32294646c31bc87072c1b9f3c0459c05292fbf02edRyan Safforesenum hdcp_version_type 33294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores{ 34294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores DRM_WV_MOD_HDCP_VERSION_ANY = 0, 35294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores DRM_WV_MOD_HDCP_VERSION_1_0, 36294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores DRM_WV_MOD_HDCP_VERSION_2_0, 37294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores DRM_WV_MOD_HDCP_VERSION_2_1, 38294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores DRM_WV_MOD_HDCP_VERSION_2_2, 39294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores DRM_WV_MOD_HDCP_VERSION_NONE = 0xFF 40294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores}; 41294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 42294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 4358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/*! 4458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * APIs 4558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 4658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_open_session(uint32_t *session_id); 4758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 4858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_close_session(uint32_t session_id); 4958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 5058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_start_playback(uint32_t session_id); 5158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 5258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_stop_playback(uint32_t session_id); 5358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 5458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generate_derived_keys(uint32_t session_id, 5558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *mac_key_context, 5658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t mac_key_context_length, 5758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_key_context, 5858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t enc_key_context_length); 5958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 6058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generate_nonce(uint32_t session_id, 6158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *nonce); 6258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 6358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generate_signature(uint32_t session_id, 6458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 6558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 6658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *signature, 6758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *signature_length); 6858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 6958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_load_keys(uint32_t session_id, 7058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 7158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 7258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *signature, 7358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t signature_length, 7458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_mac_keys_iv, 7558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_mac_keys, 7658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t num_keys, 7758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const struct drm_wv_mod_key_object *key_array); 7858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 7958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_refresh_keys(uint32_t session_id, 8058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 8158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 8258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *signature, 8358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t signature_length, 8458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t num_keys, 8558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const struct drm_wv_mod_key_refresh_object *key_array); 8658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 8758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_select_key(uint32_t session_id, 8858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *key_id, 8958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t key_id_length); 9058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 9158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_decrypt_ctr(uint32_t session_id, 9258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *inp_data_buffer, 9358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t inp_data_size, 9458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *out_data_buffer, 9558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t out_data_size, 9658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *iv, 9758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t flags); 9858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 9958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_rewrap_device_rsa_key(uint32_t session_id, 10058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 10158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 10258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *signature, 10358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t signature_length, 10458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *nonce, 10558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_rsa_key, 10658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t enc_rsa_key_length, 10758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_rsa_key_iv, 10858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *wrapped_rsa_key, 10958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *wrapped_rsa_key_length); 11058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 11158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_load_device_rsa_key(uint32_t session_id, 11258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *wrapped_rsa_key, 11358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t wrapped_rsa_key_length); 11458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 11558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generate_rsa_signature(uint32_t session_id, 11658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 11758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 11858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *signature, 11958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *signature_length); 12058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 12158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_derive_keys_from_session_key(uint32_t session_id, 12258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_session_key, 12358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t enc_session_key_length, 12458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *mac_key_context, 12558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t mac_key_context_length, 12658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_key_context, 12758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t enc_key_context_length); 12858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 12958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generic_encrypt(uint32_t session_id, 13058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *in_buffer, 13158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t buffer_size, 13258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *iv, 13358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel enum drm_wv_mod_algorithm algorithm, 13458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *out_buffer); 13558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 13658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generic_decrypt(uint32_t session_id, 13758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *in_buffer, 13858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t buffer_size, 13958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *iv, 14058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel enum drm_wv_mod_algorithm algorithm, 14158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *out_buffer); 14258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 14358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generic_sign(uint32_t session_id, 14458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *in_buffer, 14558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t buffer_size, 14658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel enum drm_wv_mod_algorithm algorithm, 14758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *signature, 14858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *signature_size); 14958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 15058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_generic_verify(uint32_t session_id, 15158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *in_buffer, 15258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t buffer_size, 15358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel enum drm_wv_mod_algorithm algorithm, 15458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *signature, 15558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t signature_size); 15658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 15758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/*! Version 9 specific APIs */ 15858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_v9_load_keys(uint32_t session_id, 15958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 16058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 16158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *signature, 16258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t signature_length, 16358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_mac_keys_iv, 16458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *enc_mac_keys, 16558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t num_keys, 16658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const struct drm_wv_mod_key_object *key_array, 16758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *pst, 1680d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenas uint32_t pst_length); 16958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 17058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_v9_generate_rsa_signature(uint32_t session_id, 17158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *message, 17258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t message_length, 17358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *signature, 17458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *signature_length, 17558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel enum drm_wv_mod_rsa_padding_scheme padding_scheme); 17658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 17758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 17858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/** 17958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @brief Loads an existing usage table into chaabi secure memory 18058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 18158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * This should be first called prior to load keys. Caller shall call 18258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * drm_wv_mod_update_usage_table after making this call. 18358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 18458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] usage_table_data 18558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Existing usage table blob to load. If NULL, chaabi will 18658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * return required table size. 18758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in,out] data_size 18858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Size of the passed-in usage_table_data, in bytes. This 18958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * will always be updated to the required table size. 190294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @param[in] system_time 191294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * current system time. Time in seconds since 1970. 19258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 19358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_load_usage_table(const uint8_t *const usage_table_data, 194294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores uint32_t *const data_size, 195294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores uint64_t system_time); 19658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 19758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/* @brief Update usage table and return it 19858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 19958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Chaabi will update the usage table from its TEE memory and set the flag 20058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * is_updated. 20158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 20258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Upon returning DRM_WV_MOD_SUCCESS and is_updated == 1, caller should 20358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * write save the usage table to the file system. 20458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 20558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[out] usage_table_data 20658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Buffer where the usage table will be returned. Input is ignored. 20758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * This will only contain data if is_updated == 1. 20858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] data_size 20958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Size of the usage_table_data buffer, which must be large enough to 21058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * hold the entire structure. This size can be obtained via the 21158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * load_usage_table API or by re-using the size of a previous table blob. 21258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[out] is_updated 21358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Flag indicating if the table has changed since the last 21458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * update_usage_table or load_usage_table call. 21558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 2160d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenas * TODO: Return documentation 21758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 21858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_update_usage_table(uint8_t *const usage_table_data, 21958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t data_size, 22058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *const is_updated); 22158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 22258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel// NOTE: drm_wv_mod_update_usage_table shall be called after calling this 22358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel// function 2240d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenas// TODO: Documentation 2250d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenasuint32_t drm_wv_mod_deactivate_usage_entry(const uint8_t *const pst, 22658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t pst_length); 22758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 22858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/** 22958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @brief Returns the usage entry information for a particular pst 23058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 23158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Caller shall call drm_wv_mod_update_usage_table after making this call. 23258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 23358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] session_id 23458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Session ID to be associated with the pst entry 23558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] pst 23658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Pointer to pst data used as an index into the usage table 23758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] pst_length 23858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Length of pst buffer in bytes 23958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[out] pst_report_buffer 24058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Pointer to caller-allocated memory where the usage report shall be placed 24158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in,out] pst_report_buffer_length 24258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Length of provided pst_report_buffer in bytes. Should be sizeof(pst) + 24358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * sizeof(struct OEMCrypto_PST_Report) in length. If extra space is provided, 24458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * this field will reflect the actual size of the returned report. 24558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 2460d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenas * TODO: Return documentation 24758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 24858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_report_usage(uint32_t session_id, 24958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *const pst, 25058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t pst_length, 25158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint8_t *const pst_report_buffer, 25258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t *const pst_report_buffer_length); 25358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 25458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/** 25558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @brief Deletes a previously-reported entry from the usage table 25658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 25758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Caller shall call drm_wv_mod_update_usage_table after making this call. 25858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 25958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] session_id 26058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Session ID previously associated with the pst 26158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] pst 26258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Pointer to pst data used as an index into the usage table 26358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] pst_length 26458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Length of pst buffer in bytes 26558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] msg 26658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Pointer to message to be verified 26758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] msg_len 26858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Length of msg buffer in bytes 26958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] signature 27058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Pointer to signature to verify against 27158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * @param[in] signature_length 27258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Length of signature buffer in bytes 27358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 2740d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenas * TODO: Return Documentation 27558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 27658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_delete_usage_entry(uint32_t session_id, 27758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *const pst, 27858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t pst_length, 27958ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *const msg, 28058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t msg_length, 28158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel const uint8_t *const signature, 28258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel uint32_t signature_length); 28358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 28458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel// This will only clear Chaabi TEE memory. Caller is responsible for deleting 28558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel// usage table file from file system. 2860d4936b25f6e5975f34c41af829b2b43ff4246e5Daniel Cardenas// TODO: Documentation 28758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_delete_usage_table(void); 28858ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 289294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 29058ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel/** 29158ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * brief Clear session context 29258ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * 29358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * This API is used to reset all sessions context. 29458ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel * Typically called to cleanup sessions resulting from a application crash. 29558ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel */ 29658ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudeluint32_t drm_wv_mod_reset_session_context(void); 29758ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel 298294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores/** 299294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @brief Returns the maximum and current HDCP version supported by the device 300294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * 301294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @param[out] current_ver 302294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * Current HDCP version supported by the device 303294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @param[out] maximum_ver 304294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * Maximum HDCP version supported by the device 305294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * 306294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores */ 307294646c31bc87072c1b9f3c0459c05292fbf02edRyan Safforesuint32_t drm_wv_mod_get_hdcp_capability(enum hdcp_version_type *const current_ver, 308294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores enum hdcp_version_type *const maximum_ver); 309294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 310294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores/*! Version 10 specific APIs. */ 311294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 312294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores/** 313294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @brief Get current number of open sessions along with maximum number of 314294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * supported sessions. 315294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores */ 316294646c31bc87072c1b9f3c0459c05292fbf02edRyan Safforesuint32_t drm_wv_mod_get_num_sessions(uint32_t *open_sessions, uint32_t *max_sessions); 317294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 318294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores/** 319294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @brief Deletes an entry from session usage table. 320294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * 321294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * This API is used to delete stale entries without a signed request from server. 322294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores */ 323294646c31bc87072c1b9f3c0459c05292fbf02edRyan Safforesuint32_t drm_wv_mod_force_delete_usage_entry(const uint8_t *pst, uint32_t pst_length); 324294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 325294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores/** 326294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores * @brief Returns the decrypted key control block for the given key_id. 327294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores */ 328294646c31bc87072c1b9f3c0459c05292fbf02edRyan Safforesuint32_t drm_wv_mod_query_key_control(const uint32_t session_id, 329294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores const uint8_t *key_id, 330294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores uint32_t key_id_length, 331294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores uint8_t *key_control_block, 332294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores uint32_t *key_control_block_length); 333294646c31bc87072c1b9f3c0459c05292fbf02edRyan Saffores 33481e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi/*! Version 11 specific APIs */ 33581e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choiuint32_t drm_wv_mod_security_patch_level(uint32_t *security_patch_level); 33681e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi 33781e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choiuint32_t drm_wv_mod_api_version(uint32_t *api_version); 33881e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi 33981e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choiuint32_t drm_wv_mod_decrypt_cenc(uint32_t session_id, 34081e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi const uint8_t *inp_data_buffer, 34181e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi uint32_t inp_data_size, 34281e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi uint8_t *out_data_buffer, 34381e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi uint32_t out_data_size, 34481e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi const uint8_t *iv, 34581e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi uint8_t flags); 34681e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi 34781e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choiuint32_t drm_wv_mod_glue_block(uint32_t session_id, 34881e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi uint8_t *encrypted, 34981e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi const uint8_t *cleartext, 35081e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi uint32_t cleartext_length, 35181e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi const uint8_t *iv); 35281e89cc453365edbbc17377a6d8a9cbadac38393Hyunchang Choi 35358ab4ceb5ea3d2733f108cacfcccb93e0c8d84daThierry Strudel#endif /* __WV_MOD_DRM_API_H_ */ 354