1 /* 2 * Copyright (C) 2014 Intel Corporation. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /** 18 * @file drm_pr_api.h 19 * @brief Header file for Playready DRM API 20 */ 21 22 #ifndef __DRM_PR_API_H__ 23 #define __DRM_PR_API_H__ 24 25 /*! 26 * Defines 27 */ 28 #define PR_CLEAR_CONTENT_FLAG (1) 29 30 #define DRM_SECURE_CLOCK_FLAG_RESET (1) 31 32 /*! 33 * Structs 34 */ 35 36 /* 37 * This structure is used to provide necessary information for PlayReady video 38 * ciphertext decryption. 39 * 40 * The members are: 41 * 42 * iv - AES initialization vector. 43 * input_ciphertext_size - Input ciphertext data size in bytes. 44 * p_input_ciphertext - Pointer to the input ciphertext data. 45 */ 46 struct pr_drm_video_cipher 47 { 48 uint32_t key_index; 49 uint32_t key_type; 50 uint64_t iv; 51 uint64_t byte_offset; 52 uint32_t input_ciphertext_size; 53 uint8_t *p_input_ciphertext; 54 uint8_t flags; 55 uint8_t *p_output_enc_ciphertext; 56 uint32_t output_ciphertext_size; 57 }; 58 59 60 struct drm_nalu_headers 61 { 62 uint32_t frame_size; 63 uint32_t parse_size; 64 uint8_t *p_enc_ciphertext; 65 uint32_t hdrs_buf_len; 66 uint8_t *p_hdrs_buf; 67 }; 68 69 struct pr_av_secure_input_data_buffer 70 { 71 uint32_t session_id; 72 uint32_t size; 73 uint8_t *data; 74 uint32_t clear; 75 }; 76 77 78 /* 79 * Map to Oem_Hal_AllocateRegister 80 */ 81 uint32_t drm_pr_allocate_register(uint32_t key_type, 82 uint32_t *key_reg_index); 83 84 /* 85 * Map to Oem_Hal_FreeRegister 86 */ 87 uint32_t drm_pr_free_register(uint32_t key_type, 88 uint32_t key_reg_index); 89 90 /* 91 * Map to Oem_Hal_RegisterCount 92 */ 93 uint32_t drm_pr_register_count(uint32_t key_type, 94 uint32_t *total_regs, 95 uint32_t *allocated_regs); 96 97 /* 98 * Map to Oem_Hal_GetPreloadedIndex 99 */ 100 uint32_t drm_pr_get_preloaded_index(uint32_t key_type, 101 uint8_t *key_id, 102 uint32_t key_id_len, 103 uint32_t *key_index); 104 /* 105 * Map to Oem_Hal_Initialize 106 */ 107 uint32_t drm_pr_initialize(void); 108 109 /* 110 * Map to Oem_Hal_Deinitialize 111 */ 112 uint32_t drm_pr_deinitialize(void); 113 114 /* 115 * Map to Oem_Hal_VerifyMessageSignature 116 */ 117 uint32_t drm_pr_verify_message_signature(uint8_t *msg, 118 uint32_t msg_len, 119 const uint8_t *signature, 120 uint32_t signature_len, 121 uint32_t hash_type, 122 uint32_t signature_scheme, 123 uint32_t integrity_key_index); 124 125 /* 126 * Map to Oem_Hal_CreateMessageSignature 127 */ 128 uint32_t drm_pr_create_message_signature(uint8_t *msg, 129 uint32_t msg_len, 130 uint8_t *signature, 131 uint32_t *signature_len, 132 uint32_t hash_type, 133 uint32_t signature_scheme, 134 uint32_t key_type, 135 uint32_t integrity_key_index); 136 /* 137 * Map to Oem_Hal_VerifyOMAC1Signature 138 */ 139 uint32_t drm_pr_verify_omac1_signature(uint8_t *msg, 140 uint32_t msg_len, 141 uint8_t *signature, 142 uint32_t signature_len, 143 uint32_t key_type, 144 uint32_t index_key); 145 146 /* 147 * Map to Oem_Hal_CreateOMAC1Signature 148 */ 149 uint32_t drm_pr_create_omac1_signature(uint8_t *msg, 150 uint32_t msg_len, 151 uint8_t *signature, 152 uint32_t *signature_len, 153 uint32_t key_type, 154 uint32_t index_key); 155 156 /* 157 * Map to Oem_Hal_UnwrapKey 158 */ 159 uint32_t drm_pr_unwrap_get_keydata_type(uint32_t key_type, 160 uint32_t key_index, 161 uint32_t wrapping_key_type, 162 uint32_t wrapping_key_index, 163 uint32_t *key_data_type); 164 165 uint32_t drm_pr_unwrap_encrypted_key(uint32_t key_type, 166 uint32_t key_index, 167 uint32_t wrapping_key_type, 168 uint32_t wrapping_key_index, 169 uint8_t *encryption_key_info, 170 uint32_t key_info_size, 171 uint8_t *encrypted_key_data, 172 uint32_t key_data_size); 173 174 uint32_t drm_pr_unwrap_xmr_license(uint32_t key_type, 175 uint32_t key_index, 176 uint32_t wrapping_key_type, 177 uint32_t wrapping_key_index, 178 uint8_t *xmr_license, 179 uint32_t xmr_license_size, 180 uint8_t xmr_ignore_cksum, 181 uint8_t bb_ignore_cksum, 182 uint8_t *bb_cksum_data, 183 uint32_t bb_cksum_data_size, 184 uint8_t *bb_kid, 185 uint8_t bb_kid_size, 186 uint8_t *bb_v1_kid, 187 uint32_t bb_v1_kid_size); 188 189 uint32_t drm_pr_unwrap_key(uint32_t unwrap_key_type, 190 uint32_t unwrap_key_reg_index, 191 uint32_t wrapping_key_type, 192 uint32_t wrapping_key_index, 193 uint8_t *wrapped_key_data, 194 uint32_t wrapped_key_data_len, 195 const uint8_t *param_data, 196 uint32_t param_data_len); 197 198 /* 199 * Map to Oem_Hal_WrapKey 200 */ 201 uint32_t drm_pr_wrap_get_encryption_type(uint32_t key_type, 202 uint32_t key_index, 203 uint32_t wrapping_key_type, 204 uint32_t wrapping_key_index, 205 uint32_t *encryption_type); 206 207 uint32_t drm_pr_wrap_encrypted_key(uint32_t key_type, 208 uint32_t key_index, 209 uint32_t wrapping_key_type, 210 uint32_t wrapping_key_index, 211 uint8_t *encryption_key_info, 212 uint32_t key_info_size, 213 uint8_t *encrypted_key_data, 214 uint32_t encrypted_key_data_size); 215 216 uint32_t drm_pr_wrap_key(uint32_t wrap_key_type, 217 uint32_t wrap_key_reg_index, 218 uint32_t wrapping_key_type, 219 uint32_t wrapping_key_reg_index, 220 uint8_t *wrapped_key, 221 uint32_t *wrapped_key_len); 222 223 /* 224 * Map to Oem_Hal_GenerateKey 225 */ 226 uint32_t drm_pr_generate_key(uint32_t key_type, 227 uint32_t key_reg_index, 228 uint32_t security_level); 229 /* 230 * Map to Oem_Hal_LoadPlayReadyRevocationInfo 231 */ 232 uint32_t drm_pr_load_revoc_info(uint8_t *revoc_info, 233 uint32_t revoc_info_len, 234 uint32_t sign_key_reg_index); 235 /* 236 * Map to Oem_Hal_LoadPlayReadyCrl 237 */ 238 uint32_t drm_pr_load_crl(uint8_t *crl, 239 uint32_t crl_len, 240 uint32_t sign_key_reg_index); 241 /* 242 * Map to Oem_Hal_DecryptContentOpaque 243 */ 244 uint32_t drm_pr_decrypt_content_opaque(void *in_buffer, 245 void *out_buffer, 246 uint32_t data_len, 247 uint32_t key_type, 248 uint32_t key_index, 249 uint64_t iv, 250 uint64_t byte_offset); 251 252 uint32_t drm_pr_decrypt_content(uint8_t *out_buffer, 253 uint32_t data_len, 254 uint32_t key_type, 255 uint32_t key_index, 256 uint64_t iv, 257 uint64_t byte_offset); 258 259 /*! 260 *@brief Create a PlayReady session 261 * 262 */ 263 uint32_t drm_pr_create_session(uint32_t *session_id); 264 265 /*! 266 *@brief Returns NALU header 267 * 268 */ 269 uint32_t drm_pr_return_naluheaders(uint32_t session_id, 270 struct drm_nalu_headers *nalu_info); 271 272 /*! 273 *@brief Returns SRTC time 274 * 275 */ 276 uint32_t drm_pr_get_srtc_time(uint32_t *time, 277 uint32_t *flags); 278 #endif 279