4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
\r
7 * Mahendra Kumar Prajapat <mahendra.p@samsung.com>
\r
8 * Harsha Shekar <h.shekar@samsung.com>
\r
11 * Licensed under the Apache License, Version 2.0 (the "License");
\r
12 * you may not use this file except in compliance with the License.
\r
13 * You may obtain a copy of the License at
\r
15 * http://www.apache.org/licenses/LICENSE-2.0
\r
17 * Unless required by applicable law or agreed to in writing, software
\r
18 * distributed under the License is distributed on an "AS IS" BASIS,
\r
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
20 * See the License for the specific language governing permissions and
\r
21 * limitations under the License.
\r
26 * @file drm_trusted_client.cpp
\r
27 * @brief DRM Trusted Client API defintions.
\r
28 * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com)
\r
29 * @author Harsha Shekar (h.shekar@samsung.com)
\r
31 * @history 0.1: First version of DRM Trusted Client API Definitions.
\r
38 #include "drm_trusted_client.h"
\r
39 #include "drm_trusted_client_ipc.h"
\r
40 #include "drm_trusted_client_log.h"
\r
43 #define EXPORT_API __attribute__((visibility("default")))
\r
47 * An application can do particular request to DRM.
\r
49 * @param[in] request_type Request types as per enum drm_trusted_request_type_e.
\r
50 * @param[in] input Pointer to appropriate structure as per
\r
52 * @param[out] output Output data. Pointer to appropriate structure as
\r
55 * @return 0 on success, else a negative error value
\r
56 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
57 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
58 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
59 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
60 * @remarks Please typecast to appropriate data structures
\r
61 * as per data types.
\r
63 * if request_type = DRM_TRUSTED_REQ_TYPE_UPDATE_SECURE_CLK
\r
64 * then input type: input = pointer to struct drm_trusted_update_sec_clk_info_s
\r
65 * and output type: output = NULL
\r
67 * if request_type = DRM_TRUSTED_REQ_TYPE_SET_SECURE_CLK
\r
68 * then input type: input = pointer to struct drm_trusted_set_sec_clk_info_s
\r
69 * and output type: output = NULL
\r
71 * if request_type = DRM_TRUSTED_REQ_TYPE_SET_TRANSACTION_TRACKING
\r
72 * then input type: input = pointer to struct drm_trusted_set_transaction_trk_info_s
\r
73 * and output type: output = NULL
\r
75 * if request_type = DRM_TRUSTED_REQ_TYPE_MASTER_RESET
\r
76 * then input type: input = NULL
\r
77 * and output type: output = NULL
\r
79 * if request_type = DRM_TRUSTED_REQ_TYPE_VERIFY_ENCRYPTED_CERT
\r
80 * then input type: input = NULL
\r
81 * and output type: output = NULL
\r
83 * if request_type = DRM_TRUSTED_REQ_TYPE_CREATE_INIT_DB
\r
84 * then input type: input = NULL
\r
85 * and output type: output = NULL
\r
87 * if request_type = DRM_TRUSTED_REQ_TYPE_REINSTALL_CERT
\r
88 * then input type: input = NULL
\r
89 * and output type: output = NULL
\r
91 * if request_type = DRM_TRUSTED_REQ_TYPE_REMOVE_RO
\r
92 * then input type: input = pointer to struct drm_trusted_remove_ro_info_s
\r
93 * and output type: output = NULL
\r
95 * if request_type = DRM_TRUSTED_REQ_TYPE_REMOVE_ALL_RO
\r
96 * then input type: input = NULL
\r
97 * and output type: output = NULL
\r
99 * if request_type = DRM_TRUSTED_REQ_TYPE_GO_RIGHTS_URL
\r
100 * then input type: input = pointer to struct drm_trusted_go_rights_url_info_s
\r
101 * and output type: output = NULL
\r
103 * if request_type = DRM_TRUSTED_REQ_TYPE_PD_SET_DOWNLOAD_COMPLETE
\r
104 * then input type: input = pointer to struct drm_trusted_pd_set_dld_comp_info_s
\r
105 * and output type: output = NULL
\r
107 * if request_type = DRM_TRUSTED_REQ_TYPE_PD_GET_PARSE_STATUS_INFO
\r
108 * then input type: input = pointer to struct drm_trusted_pd_parse_status_info_s
\r
109 * and output type: output = pointer to struct drm_trusted_pd_parse_status_resp_s
\r
111 * if request_type = DRM_TRUSTED_REQ_TYPE_PIFF_GET_LICENSE
\r
112 * then input type: input = pointer to struct drm_trusted_piff_get_license_info_s
\r
113 * and output type: output = NULL
\r
115 * if request_type = DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE
\r
116 * then input type: input = pointer to struct drm_trusted_sapps_decrypt_package_info_s
\r
117 * and output type: output = NULL
\r
119 * if request_type = DRM_TRUSTED_REQ_TYPE_SAPPS_CONSUME_LICENSE
\r
120 * then input type: input = pointer to struct drm_trusted_sapps_consume_license_info_s
\r
121 * and output type: output = NULL
\r
123 * if request_type = DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_PURCHASE_REQUEST
\r
124 * then input type: input = pointer to struct drm_trusted_sapps_gen_purchase_req_info_s
\r
125 * and output type: output = pointer to struct drm_trusted_sapps_gen_purchase_req_resp_s
\r
127 * if request_type = DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_LICENSE_REQUEST
\r
128 * then input type: input = pointer to struct drm_trusted_sapps_gen_license_req_info_s
\r
129 * and output type: output = pointer to struct drm_trusted_sapps_gen_license_req_resp_s
\r
136 EXPORT_API int drm_trusted_handle_request(drm_trusted_request_type_e request_type,
\r
137 void *input, void *output)
\r
139 /* Local Variables */
\r
140 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
141 drm_trusted_request_data_s req_data;
\r
142 drm_trusted_response_data_s resp_data;
\r
146 /* memset the structures */
\r
147 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
148 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
150 DRM_TRUSTED_CLIENT_LOG("request_type = %d", request_type);
\r
152 /* Check Input & Output Parameters */
\r
153 switch (request_type) {
\r
155 case DRM_TRUSTED_REQ_TYPE_UPDATE_SECURE_CLK: {
\r
157 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p",
\r
159 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
161 /* Copy the input to Request Structure */
\r
162 memcpy(req_data.fixed_data.request_data, input,
\r
163 sizeof(drm_trusted_update_sec_clk_info_s));
\r
168 case DRM_TRUSTED_REQ_TYPE_SET_SECURE_CLK: {
\r
170 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p",
\r
172 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
174 /* Copy the input to Request Structure */
\r
175 memcpy(req_data.fixed_data.request_data, input,
\r
176 sizeof(drm_trusted_set_sec_clk_info_s));
\r
182 case DRM_TRUSTED_REQ_TYPE_SET_TRANSACTION_TRACKING: {
\r
184 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p",
\r
186 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
189 /* Copy the input to Request Structure */
\r
190 memcpy(req_data.fixed_data.request_data, input,
\r
191 sizeof(drm_trusted_set_transaction_trk_info_s));
\r
197 case DRM_TRUSTED_REQ_TYPE_MASTER_RESET:
\r
198 case DRM_TRUSTED_REQ_TYPE_VERIFY_ENCRYPTED_CERT:
\r
199 case DRM_TRUSTED_REQ_TYPE_CREATE_INIT_DB:
\r
200 case DRM_TRUSTED_REQ_TYPE_REINSTALL_CERT:
\r
201 case DRM_TRUSTED_REQ_TYPE_REMOVE_ALL_RO: {
\r
202 DRM_TRUSTED_CLIENT_LOG("No parameters to be read!!");
\r
206 case DRM_TRUSTED_REQ_TYPE_REMOVE_RO: {
\r
208 if (!input || (((drm_trusted_remove_ro_info_s*)input)->filePath[0]) == '\0') {
\r
209 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p, filepath = %s",
\r
210 input, (!input) ? "":((drm_trusted_remove_ro_info_s*)input)->filePath);
\r
211 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
214 /* Copy the input to Request Structure */
\r
215 memcpy(req_data.fixed_data.request_data, input,
\r
216 sizeof(drm_trusted_remove_ro_info_s));
\r
222 case DRM_TRUSTED_REQ_TYPE_GO_RIGHTS_URL: {
\r
224 if (!input || (((drm_trusted_go_rights_url_info_s*)input)->file_path[0]) == '\0') {
\r
225 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p, filepath = %s",
\r
226 input, (!input) ? "":((drm_trusted_go_rights_url_info_s*)input)->file_path);
\r
227 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
230 /* Copy the input to request Structure */
\r
231 memcpy(req_data.fixed_data.request_data, input,
\r
232 sizeof(drm_trusted_go_rights_url_info_s));
\r
234 if (((drm_trusted_go_rights_url_info_s*) input)->app_session_data.pData
\r
235 && ((drm_trusted_go_rights_url_info_s*) input)->app_session_data.size_pData != 0) {
\r
237 req_data.fixed_data.num_data_items = 1;
\r
239 /* Fill details pertaining to additional pointers to be sent */
\r
240 req_data.fixed_data.data_length[0] =
\r
241 ((drm_trusted_go_rights_url_info_s*) input)->app_session_data.size_pData;
\r
243 /* Allocate memory for data items */
\r
244 req_data.data_items[0] = (char*) malloc(
\r
245 req_data.fixed_data.data_length[0]);
\r
246 if (!req_data.data_items[0]) {
\r
247 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
248 req_data.data_items[0]);
\r
249 result = DRM_TRUSTED_RETURN_INSUFFICIENT_MEMORY;
\r
253 /* Copy the buffer into data items */
\r
254 memcpy(req_data.data_items[0],
\r
255 ((drm_trusted_go_rights_url_info_s*) input)->app_session_data.pData,
\r
256 ((drm_trusted_go_rights_url_info_s*) input)->app_session_data.size_pData);
\r
263 case DRM_TRUSTED_REQ_TYPE_PD_SET_DOWNLOAD_COMPLETE: {
\r
266 || (!((drm_trusted_pd_set_dld_comp_info_s*) (input))->pdHandle)) {
\r
267 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
268 "Invalid argument!!, input = %p, pdHandle = %p",
\r
269 input, (!input) ? NULL:((drm_trusted_pd_set_dld_comp_info_s*)(input))->pdHandle);
\r
270 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
273 /* Copy the input to Request Structure */
\r
274 req_data.fixed_data.pHandle =
\r
275 ((drm_trusted_pd_set_dld_comp_info_s*) (input))->pdHandle;
\r
281 case DRM_TRUSTED_REQ_TYPE_PD_GET_PARSE_STATUS_INFO: {
\r
284 || (((drm_trusted_pd_parse_status_info_s*) (input))->file_path[0] == '\0')
\r
286 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p, filepath = %s",
\r
287 input, (!input) ? "":((drm_trusted_pd_parse_status_info_s*)input)->file_path);
\r
288 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
291 /* Copy the input to Request Structure */
\r
292 memcpy(req_data.fixed_data.request_data, input,
\r
293 sizeof(drm_trusted_pd_parse_status_info_s));
\r
300 case DRM_TRUSTED_REQ_TYPE_PIFF_GET_LICENSE: {
\r
303 || (((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header
\r
305 || (((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header[0]
\r
307 || (((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header_len
\r
309 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p",
\r
311 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
314 /* Number of additional data items to be sent */
\r
315 req_data.fixed_data.num_data_items = 1;
\r
317 /* Fill details pertaining to additional pointers to be sent */
\r
318 req_data.fixed_data.data_length[0] = ((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header_len;
\r
320 /* Allocate memory for data items */
\r
321 req_data.data_items[0] = (char*) malloc(
\r
322 ((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header_len);
\r
323 if (!req_data.data_items[0]) {
\r
324 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
325 req_data.data_items[0]);
\r
326 result = DRM_TRUSTED_RETURN_INSUFFICIENT_MEMORY;
\r
330 /* Copy into data items */
\r
331 memcpy( req_data.data_items[0],
\r
332 ((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header,
\r
333 ((drm_trusted_piff_get_license_info_s*) (input))->lic_header.header_len);
\r
335 /* Copy the fixed value structure into request data */
\r
336 memcpy(req_data.fixed_data.request_data, input,
\r
337 sizeof(drm_trusted_piff_get_license_info_s));
\r
344 case DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE: {
\r
347 || (((drm_trusted_sapps_decrypt_package_info_s*) (input))->sadcf_filepath[0] == '\0')
\r
348 || (((drm_trusted_sapps_decrypt_package_info_s*) (input))->decrypt_filepath[0] == '\0')) {
\r
349 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input);
\r
350 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
353 /* Copy the input to Request Structure */
\r
354 memcpy(req_data.fixed_data.request_data, input,
\r
355 sizeof(drm_trusted_sapps_decrypt_package_info_s));
\r
361 case DRM_TRUSTED_REQ_TYPE_SAPPS_CONSUME_LICENSE: {
\r
363 if (!input || ((char*) input)[0] == '\0') {
\r
364 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p",
\r
366 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
369 /* Copy the input to Request Structure */
\r
370 memcpy(req_data.fixed_data.request_data, input,
\r
371 sizeof(drm_trusted_sapps_consume_license_info_s));
\r
376 case DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_PURCHASE_REQUEST: {
\r
379 || (((drm_trusted_sapps_gen_purchase_req_info_s*) input)->file_path[0] == '\0')
\r
380 || (((drm_trusted_sapps_gen_purchase_req_info_s*) input)->purchase_req_buff_len == 0)
\r
381 || (((drm_trusted_sapps_gen_purchase_req_info_s*) input)->rights_url_len == 0)) {
\r
382 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input);
\r
383 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
385 /* Copy the input to Request Structure */
\r
386 memcpy(req_data.fixed_data.request_data, input,
\r
387 sizeof(drm_trusted_sapps_gen_purchase_req_info_s));
\r
393 case DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_LICENSE_REQUEST: {
\r
396 ||(!((drm_trusted_sapps_gen_license_req_info_s*) input)->purchase_req_buff)
\r
397 || (((drm_trusted_sapps_gen_license_req_info_s*) input)->purchase_req_buff[0] == '\0')
\r
398 || (((drm_trusted_sapps_gen_license_req_info_s*) input)->purchase_req_buff_len == 0)
\r
399 || (((drm_trusted_sapps_gen_license_req_info_s*) input)->rights_url_len == 0)
\r
400 || (((drm_trusted_sapps_gen_license_req_info_s*) input)->lic_req_buff_len == 0)) {
\r
401 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input);
\r
402 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
405 /* Copy the input to Request Structure */
\r
406 memcpy(req_data.fixed_data.request_data, input,
\r
407 sizeof(drm_trusted_sapps_gen_license_req_info_s));
\r
409 /* Number of additional data items to be sent */
\r
410 req_data.fixed_data.num_data_items = 1;
\r
412 /* Fill details pertaining to additional pointers to be sent */
\r
413 req_data.fixed_data.data_length[0] =
\r
414 ((drm_trusted_sapps_gen_license_req_info_s*) input)->purchase_req_buff_len;
\r
416 /* Allocate memory for data items */
\r
417 req_data.data_items[0] = (char*) malloc(
\r
418 req_data.fixed_data.data_length[0]);
\r
419 if (!req_data.data_items[0]) {
\r
420 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
421 req_data.data_items[0]);
\r
422 result = DRM_TRUSTED_RETURN_INSUFFICIENT_MEMORY;
\r
426 /* Copy the buffer into data items */
\r
427 memcpy(req_data.data_items[0],
\r
428 ((drm_trusted_sapps_gen_license_req_info_s*) input)->purchase_req_buff,
\r
429 ((drm_trusted_sapps_gen_license_req_info_s*) input)->purchase_req_buff_len);
\r
436 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid argument!!, request_type = %d",
\r
438 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
442 DRM_TRUSTED_CLIENT_LOG("input=%p output=%p", input, output);
\r
444 /* Fill other parameters to be sent */
\r
446 /* Request type to be sent to the server */
\r
447 req_data.fixed_data.req_type = request_type;
\r
449 /* Tell the server which API to be used */
\r
450 req_data.fixed_data.api_name = DRM_TRUSTED_HANDLE_REQUEST;
\r
452 /* Send Data to DRM server */
\r
453 /* Call the Client Communication API */
\r
454 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
455 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
457 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
461 /* Copy the response obtained from the server into the output parameter */
\r
462 if (resp_data.fixed_data.resp_result != 0) {
\r
463 DRM_TRUSTED_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
464 resp_data.fixed_data.resp_result);
\r
466 result = resp_data.fixed_data.resp_result;
\r
469 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result);
\r
471 /* Copy the response structure if necessary */
\r
472 if (DRM_TRUSTED_REQ_TYPE_PD_GET_PARSE_STATUS_INFO == request_type) {
\r
474 /* Copy the response into the output data */
\r
475 memcpy(output, resp_data.fixed_data.response_data,
\r
476 sizeof(drm_trusted_pd_parse_status_resp_s));
\r
479 if (DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_PURCHASE_REQUEST
\r
482 /* Copy the response onto the output structure */
\r
483 memcpy(output, resp_data.fixed_data.response_data,
\r
484 sizeof(drm_trusted_sapps_gen_purchase_req_resp_s));
\r
486 /* Copy the data items */
\r
487 memcpy( ((drm_trusted_sapps_gen_purchase_req_resp_s*) output)->purchase_req_buff,
\r
488 resp_data.data_items[0],
\r
489 resp_data.fixed_data.data_length[0]);
\r
493 if (DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_LICENSE_REQUEST == request_type) {
\r
495 /* Copy the response onto the output structure */
\r
496 memcpy(output, resp_data.fixed_data.response_data,
\r
497 sizeof(drm_trusted_sapps_gen_license_req_resp_s));
\r
499 /* Copy the data items */
\r
500 memcpy( ((drm_trusted_sapps_gen_license_req_resp_s*) output)->lic_req_buff,
\r
501 resp_data.data_items[0],
\r
502 resp_data.fixed_data.data_length[0]);
\r
509 /* Free Request Data memory */
\r
510 for (int i = 0; i < req_data.fixed_data.num_data_items; i++) {
\r
511 if (req_data.data_items[i])
\r
512 free(req_data.data_items[i]);
\r
515 /* Free Response Data memory */
\r
516 for (int i = 0; i < resp_data.fixed_data.num_data_items; i++) {
\r
517 if (resp_data.data_items[i])
\r
518 free(resp_data.data_items[i]);
\r
521 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
523 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
527 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
534 * An application can Open Decrypt Session for consumption.
\r
536 * @param[in] input_data Pointer to drm_trusted_open_decrypt_info_s
\r
537 * @param[out] output_data Pointer to drm_trusted_open_decrypt_resp_data_s
\r
538 * @param[out] pHandle Pointer to DRM_DECRYPT_HANDLE
\r
540 * @return 0 on success, else a negative error value
\r
541 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
542 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
543 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
544 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
545 * @retval DRM_TRUSTED_RETURN_INSUFFICIENT_MEMORY if memory not available
\r
546 * @remarks In drm_trusted_open_decrypt_info_s structure
\r
547 * OMA, PR, OMA PD: filepath = DRM File path & lic_header = {0}
\r
548 * PIFF: filepath = {0} & lic_header = Header from manifest file
\r
552 EXPORT_API int drm_trusted_open_decrypt_session(drm_trusted_open_decrypt_info_s *input_data,
\r
553 drm_trusted_open_decrypt_resp_data_s *output_data, DRM_DECRYPT_HANDLE *pHandle)
\r
556 /* Local Variables */
\r
557 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
558 drm_trusted_request_data_s req_data;
\r
559 drm_trusted_response_data_s resp_data;
\r
562 /* memset the structures */
\r
563 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
564 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
566 /* Check Input & Output Parameters */
\r
568 || (input_data->filePath[0] == '\0'
\r
569 && (!(input_data->lic_header.header)
\r
570 || input_data->lic_header.header[0] == '\0'))
\r
571 || !output_data || !pHandle) {
\r
572 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
573 "Invalid Args, input_data = %p, output_data = %p, pHandle = %p",
\r
574 input_data, output_data, pHandle);
\r
575 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
578 DRM_TRUSTED_CLIENT_LOG("input_data = %p, output_data = %p, pHandle = %p",
\r
579 input_data, output_data, pHandle);
\r
581 /* Copy the input to Request Structure */
\r
582 memcpy(req_data.fixed_data.request_data, input_data,
\r
583 sizeof(drm_trusted_open_decrypt_info_s));
\r
585 /* Copy the handle into the request structure */
\r
586 req_data.fixed_data.pHandle = *pHandle;
\r
588 /* Tell the server which API to be used */
\r
589 req_data.fixed_data.api_name = DRM_TRUSTED_OPEN_DECRYPT_SESSION;
\r
592 if (input_data->lic_header.header != NULL
\r
593 && input_data->lic_header.header[0] != '\0'
\r
594 && input_data->lic_header.header_len > 0) {
\r
596 /* Number of additional data items to be sent */
\r
597 req_data.fixed_data.num_data_items = 1;
\r
599 /* Fill details pertaining to additional pointers to be sent */
\r
600 req_data.fixed_data.data_length[0] = input_data->lic_header.header_len;
\r
602 /* Allocate memory for data items */
\r
603 req_data.data_items[0] = (char*) malloc(
\r
604 input_data->lic_header.header_len);
\r
605 if (!req_data.data_items[0]) {
\r
606 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
607 req_data.data_items[0]);
\r
608 result = DRM_TRUSTED_RETURN_INSUFFICIENT_MEMORY;
\r
612 /* Copy into data items */
\r
613 memcpy(req_data.data_items[0], input_data->lic_header.header,
\r
614 input_data->lic_header.header_len);
\r
617 /* Send Data to DRM server */
\r
618 /* Call the Client Communication API */
\r
619 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
620 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
622 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
626 /* Copy the response obtained from the server into the output parameter */
\r
627 if (resp_data.fixed_data.resp_result != 0) {
\r
628 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
629 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
630 resp_data.fixed_data.resp_result);
\r
631 result = resp_data.fixed_data.resp_result;
\r
634 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
635 resp_data.fixed_data.resp_result);
\r
637 /* Store the handle from the server into input handle */
\r
638 *pHandle = resp_data.fixed_data.pHandle;
\r
640 /* Copy the response into the output data */
\r
641 memcpy(output_data, resp_data.fixed_data.response_data,
\r
642 sizeof(drm_trusted_open_decrypt_resp_data_s));
\r
647 /* Free Request Data memory */
\r
648 for (int i = 0; i < req_data.fixed_data.num_data_items; i++) {
\r
649 if (req_data.data_items[i])
\r
650 free(req_data.data_items[i]);
\r
653 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
655 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
659 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
667 * An application can Read Decrypt Session for consumption.
\r
669 * @param[in] pHandle DRM_DECRYPT_HANDLE obtained from Open Decrypt Session
\r
670 * @param[in] input_data Pointer to drm_trusted_payload_info_s
\r
671 * @param[out] output_data Pointer to drm_trusted_read_decrypt_resp_data_s
\r
673 * @return 0 on success, else a negative error value
\r
674 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
675 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
676 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
677 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
678 * @retval DRM_TRUSTED_RETURN_INSUFFICIENT_MEMORY if memory not available
\r
679 * @remarks In drm_trusted_payload_info_s structure
\r
680 * OMA,OMA_PD: input = payload_data (Encrypted buffer)
\r
681 * output = payload_data (Decrypted buffer)
\r
683 * PR,PIFF: input = payload_data (Encrypted buffer)
\r
684 * input = payload_iv (Initialisation Vector)
\r
685 * output = payload_data (Decrypted buffer)
\r
689 EXPORT_API int drm_trusted_read_decrypt_session(DRM_DECRYPT_HANDLE pHandle,
\r
690 drm_trusted_payload_info_s *input_data, drm_trusted_read_decrypt_resp_data_s *output_data)
\r
693 /* Local Variables */
\r
694 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
695 drm_trusted_request_data_s req_data;
\r
696 drm_trusted_response_data_s resp_data;
\r
699 /* memset the structures */
\r
700 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
701 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
703 /* Check Input & Output Parameters */
\r
704 if (!input_data || !output_data || !pHandle) {
\r
705 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
706 "Invalid Args, input_data = %p, output_data = %p, pHandle = %p",
\r
707 input_data, output_data, pHandle);
\r
708 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
711 DRM_TRUSTED_CLIENT_LOG("input_data = %p, output_data = %p, pHandle = %p",
\r
712 input_data, output_data, pHandle);
\r
714 /* Copy the input to Request Structure */
\r
715 memcpy(req_data.fixed_data.request_data, input_data,
\r
716 sizeof(drm_trusted_payload_info_s));
\r
718 /* Copy the handle into the request structure */
\r
719 req_data.fixed_data.pHandle = pHandle;
\r
721 /* Tell the server which API to be used */
\r
722 req_data.fixed_data.api_name = DRM_TRUSTED_READ_DECRYPT_SESSION;
\r
724 /* Number of additional data items to be sent */
\r
726 /* Send items that is filled by application */
\r
727 if (!(input_data->payload_data) || input_data->payload_data_len == 0) {
\r
728 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
729 "Invalid Args, payload_data = %p, payload_data_len = %d",
\r
730 input_data->payload_data, input_data->payload_data_len);
\r
731 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
733 req_data.fixed_data.num_data_items++;
\r
736 if ((input_data->payload_iv && input_data->payload_iv_len == 0)
\r
737 || (input_data->payload_iv_len != 0 && !(input_data->payload_iv))) {
\r
738 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
739 "Invalid Args, payload_iv = %p, payload_iv_len = %d",
\r
740 input_data->payload_iv, input_data->payload_iv_len);
\r
741 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
743 req_data.fixed_data.num_data_items++;
\r
746 /* Fill details pertaining to additional pointers to be sent */
\r
748 /* Copy Payload data */
\r
749 req_data.fixed_data.data_length[0] = input_data->payload_data_len;
\r
750 req_data.data_items[0] = (char*)malloc(req_data.fixed_data.data_length[0]);
\r
751 if (!req_data.data_items[0]) {
\r
752 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
753 req_data.data_items[0]);
\r
757 memcpy(req_data.data_items[0], input_data->payload_data,
\r
758 input_data->payload_data_len);
\r
760 /* Copy Payload IV */
\r
761 req_data.fixed_data.data_length[1] = input_data->payload_iv_len;
\r
762 req_data.data_items[1] = (char*)malloc(req_data.fixed_data.data_length[1]);
\r
763 if (!req_data.data_items[1]) {
\r
764 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
765 req_data.data_items[1]);
\r
769 memcpy(req_data.data_items[1], input_data->payload_iv,
\r
770 input_data->payload_iv_len);
\r
772 /* Send Data to DRM server */
\r
773 /* Call the Client Communication API */
\r
774 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
775 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
777 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
781 /* Copy the response obtained from the server into the output parameter */
\r
782 if (resp_data.fixed_data.resp_result != 0) {
\r
783 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
784 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
785 resp_data.fixed_data.resp_result);
\r
786 result = resp_data.fixed_data.resp_result;
\r
789 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
790 resp_data.fixed_data.resp_result);
\r
792 /* Copy the decrypted payload buffer */
\r
793 input_data->payload_data_len = resp_data.fixed_data.data_length[0];
\r
794 memcpy(input_data->payload_data, resp_data.data_items[0],
\r
795 resp_data.fixed_data.data_length[0]);
\r
797 /* Copy the response from the server into output data */
\r
798 memcpy(output_data, resp_data.fixed_data.response_data,
\r
799 sizeof(drm_trusted_read_decrypt_resp_data_s));
\r
804 /* Free Request data memory */
\r
805 for (int i = 0; i < req_data.fixed_data.num_data_items; i++) {
\r
806 if (req_data.data_items[i])
\r
807 free(req_data.data_items[i]);
\r
810 /* Free Response data memory */
\r
811 if (resp_data.data_items[0])
\r
812 free (resp_data.data_items[0]);
\r
814 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
816 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
820 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
827 * An application can Seek Decrypt Session for consumption.
\r
829 * @param[in] pHandle DRM_DECRYPT_HANDLE obtained from Open Decrypt Session
\r
830 * @param[in] input_data Pointer to drm_trusted_seek_decrypt_info_s
\r
832 * @return 0 on success, else a negative error value
\r
833 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
834 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
835 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
836 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
841 EXPORT_API int drm_trusted_seek_decrypt_session(DRM_DECRYPT_HANDLE pHandle,
\r
842 drm_trusted_seek_decrypt_info_s *input_data)
\r
844 /* Local Variables */
\r
845 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
846 drm_trusted_request_data_s req_data;
\r
847 drm_trusted_response_data_s resp_data;
\r
850 /* memset the structures */
\r
851 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
852 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
854 /* Check Input & Output Parameters */
\r
855 if (!input_data || !pHandle) {
\r
856 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
857 "Invalid Args, input_data = %p, pHandle = %p",
\r
858 input_data, pHandle);
\r
859 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
862 DRM_TRUSTED_CLIENT_LOG("input_data = %p, pHandle = %p",
\r
863 input_data, pHandle);
\r
865 /* Copy the input to Request Structure */
\r
866 memcpy(req_data.fixed_data.request_data, input_data,
\r
867 sizeof(drm_trusted_seek_decrypt_info_s));
\r
869 /* Copy the handle into the request structure */
\r
870 req_data.fixed_data.pHandle = pHandle;
\r
872 /* Tell the server which API to be used */
\r
873 req_data.fixed_data.api_name = DRM_TRUSTED_SEEK_DECRYPT_SESSION;
\r
875 /* Send Data to DRM server */
\r
876 /* Call the Client Communication API */
\r
877 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
878 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
880 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
884 /* Copy the response obtained from the server into the output parameter */
\r
885 if (resp_data.fixed_data.resp_result != 0) {
\r
886 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
887 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
888 resp_data.fixed_data.resp_result);
\r
889 result = resp_data.fixed_data.resp_result;
\r
892 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
893 resp_data.fixed_data.resp_result);
\r
898 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
900 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
904 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
911 * An application can Tell Decrypt Session for consumption.
\r
913 * @param[in] pHandle DRM_DECRYPT_HANDLE obtained from Open Decrypt Session
\r
914 * @param[out] output_data Pointer to drm_trusted_tell_decrypt_resp_data_s
\r
916 * @return 0 on success, else a negative error value
\r
917 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
918 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
919 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
920 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
925 EXPORT_API int drm_trusted_tell_decrypt_session(DRM_DECRYPT_HANDLE pHandle,
\r
926 drm_trusted_tell_decrypt_resp_data_s *output_data)
\r
928 /* Local Variables */
\r
929 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
930 drm_trusted_request_data_s req_data;
\r
931 drm_trusted_response_data_s resp_data;
\r
934 /* memset the structures */
\r
935 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
936 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
938 /* Check Input & Output Parameters */
\r
939 if (!output_data || !pHandle) {
\r
940 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
941 "Invalid Args, output_data = %p, pHandle = %p",
\r
942 output_data, pHandle);
\r
943 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
946 DRM_TRUSTED_CLIENT_LOG("output_data = %p, pHandle = %p",
\r
947 output_data, pHandle);
\r
949 /* Copy the handle into the request structure */
\r
950 req_data.fixed_data.pHandle = pHandle;
\r
952 /* Tell the server which API to be used */
\r
953 req_data.fixed_data.api_name = DRM_TRUSTED_TELL_DECRYPT_SESSION;
\r
955 /* Send Data to DRM server */
\r
956 /* Call the Client Communication API */
\r
957 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
958 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
960 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
964 /* Copy the response obtained from the server into the output parameter */
\r
965 if (resp_data.fixed_data.resp_result != 0) {
\r
966 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
967 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
968 resp_data.fixed_data.resp_result);
\r
969 result = resp_data.fixed_data.resp_result;
\r
972 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
973 resp_data.fixed_data.resp_result);
\r
975 /* Copy the response obtained from the server into the output data */
\r
976 memcpy(output_data, resp_data.fixed_data.response_data,
\r
977 sizeof(drm_trusted_tell_decrypt_resp_data_s));
\r
982 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
984 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
988 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
995 * An application can Set Decrypt state during consumption.
\r
997 * @param[in] pHandle DRM_DECRYPT_HANDLE obtained from Open Decrypt Session
\r
998 * @param[in] input_data Pointer to drm_trusted_set_consumption_state_info_s
\r
1000 * @return 0 on success, else a negative error value
\r
1001 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
1002 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
1003 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
1004 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
1009 EXPORT_API int drm_trusted_set_decrypt_state(DRM_DECRYPT_HANDLE pHandle,
\r
1010 drm_trusted_set_consumption_state_info_s *input_data)
\r
1013 /* Local Variables */
\r
1014 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
1015 drm_trusted_request_data_s req_data;
\r
1016 drm_trusted_response_data_s resp_data;
\r
1019 /* memset the structures */
\r
1020 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
1021 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
1023 /* Check Input & Output Parameters */
\r
1024 if (!input_data || !pHandle) {
\r
1025 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1026 "Invalid Args, input_data = %p, pHandle = %p",
\r
1027 input_data, pHandle);
\r
1028 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
1031 DRM_TRUSTED_CLIENT_LOG("input_data = %p, pHandle = %p",
\r
1032 input_data, pHandle);
\r
1034 /* Copy the input to Request Structure */
\r
1035 memcpy(req_data.fixed_data.request_data, input_data,
\r
1036 sizeof(drm_trusted_set_consumption_state_info_s));
\r
1038 /* Copy the handle into the request structure */
\r
1039 req_data.fixed_data.pHandle = pHandle;
\r
1041 /* Tell the server which API to be used */
\r
1042 req_data.fixed_data.api_name = DRM_TRUSTED_SET_DECRYPT_STATE;
\r
1044 /* Send Data to DRM server */
\r
1045 /* Call the Client Communication API */
\r
1046 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
1047 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
1049 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
1053 /* Copy the response obtained from the server into the output parameter */
\r
1054 if (resp_data.fixed_data.resp_result != 0) {
\r
1055 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1056 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
1057 resp_data.fixed_data.resp_result);
\r
1058 result = resp_data.fixed_data.resp_result;
\r
1061 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
1062 resp_data.fixed_data.resp_result);
\r
1067 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
1069 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
1073 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
1080 * An application can Close decrypt session for consumption.
\r
1082 * @param[in] pHandle Pointer to DRM_DECRYPT_HANDLE obtained from Open Decrypt Session
\r
1084 * @return 0 on success, else a negative error value
\r
1085 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
1086 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
1087 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
1088 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
1093 EXPORT_API int drm_trusted_close_decrypt_session(DRM_DECRYPT_HANDLE *pHandle)
\r
1095 /* Local Variables */
\r
1096 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
1097 drm_trusted_request_data_s req_data;
\r
1098 drm_trusted_response_data_s resp_data;
\r
1101 /* memset the structures */
\r
1102 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
1103 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
1105 /* Check Input & Output Parameters */
\r
1106 if (!pHandle || !(*pHandle)) {
\r
1107 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid Args, pHandle = %p, *pHandle = %p",
\r
1108 pHandle, (!pHandle) ? NULL : *pHandle);
\r
1109 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
1112 DRM_TRUSTED_CLIENT_LOG("pHandle = %p, *pHandle = %p",
\r
1113 pHandle, *pHandle);
\r
1115 /* Copy the handle into the request structure */
\r
1116 req_data.fixed_data.pHandle = *pHandle;
\r
1118 /* Tell the server which API to be used */
\r
1119 req_data.fixed_data.api_name = DRM_TRUSTED_CLOSE_DECRYPT_SESSION;
\r
1121 /* Send Data to DRM server */
\r
1122 /* Call the Client Communication API */
\r
1123 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
1124 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
1126 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
1130 /* Copy the response obtained from the server into the output parameter */
\r
1131 if (resp_data.fixed_data.resp_result != 0) {
\r
1132 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1133 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
1134 resp_data.fixed_data.resp_result);
\r
1135 result = resp_data.fixed_data.resp_result;
\r
1138 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
1139 resp_data.fixed_data.resp_result);
\r
1144 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
1146 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
1150 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
1157 * An application can prepare to convert a DRM file in OMADRM-v1.
\r
1158 * If a type of DRM file is FL, CD or FL-SD type, application can convert to SD type.
\r
1159 * This function prepare for converting and create file.
\r
1161 * @param[in] input Pointer to drm_trusted_opn_conv_info_s
\r
1162 * @param[out] hConvert Pointer to Open Convert Handle(DRM_TRUSTED_CONVERT_HANDLE)
\r
1164 * @return 0 on success, else a negative error value
\r
1165 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
1166 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
1167 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
1168 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
1173 EXPORT_API int drm_trusted_open_convert(drm_trusted_opn_conv_info_s *input,
\r
1174 DRM_TRUSTED_CONVERT_HANDLE *hConvert)
\r
1176 /* Local Variables */
\r
1177 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
1178 drm_trusted_request_data_s req_data;
\r
1179 drm_trusted_response_data_s resp_data;
\r
1182 /* memset the structures */
\r
1183 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
1184 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
1186 /* Check Input & Output Parameters */
\r
1187 if (!input || !hConvert) {
\r
1188 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1189 "Invalid Args, input = %p, hConvert = %p, *hConvert = %p",
\r
1190 input, hConvert, (!hConvert) ? NULL : *hConvert);
\r
1191 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
1194 /* Copy the input to Request Structure */
\r
1195 memcpy(req_data.fixed_data.request_data, input,
\r
1196 sizeof(drm_trusted_opn_conv_info_s));
\r
1198 /* Copy the handle into the request structure */
\r
1199 req_data.fixed_data.hConvert = *hConvert;
\r
1201 /* Tell the server which API to be used */
\r
1202 req_data.fixed_data.api_name = DRM_TRUSTED_OPEN_CONVERT;
\r
1204 /* Send Data to DRM server */
\r
1205 /* Call the Client Communication API */
\r
1206 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
1207 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
1209 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
1213 /* Copy the response obtained from the server into the output parameter */
\r
1214 if (resp_data.fixed_data.resp_result != 0) {
\r
1215 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1216 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
1217 resp_data.fixed_data.resp_result);
\r
1218 result = resp_data.fixed_data.resp_result;
\r
1221 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
1222 resp_data.fixed_data.resp_result);
\r
1224 /* Store the Convert handle from the server into input handle */
\r
1225 *hConvert = resp_data.fixed_data.hConvert;
\r
1230 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
1232 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
1236 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
1242 * An application can write converted data.
\r
1244 * @param[in] input Pointer to drm_trusted_opn_conv_info_s
\r
1245 * @param[out] output Pointer to drm_trusted_write_conv_resp_s
\r
1246 * @param[in] hConvert Pointer to Open Convert Handle(DRM_TRUSTED_CONVERT_HANDLE)
\r
1248 * @return 0 on success, else a negative error value
\r
1249 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
1250 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
1251 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
1252 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
1257 EXPORT_API int drm_trusted_write_convert(drm_trusted_write_conv_info_s *input,
\r
1258 drm_trusted_write_conv_resp_s *output,
\r
1259 DRM_TRUSTED_CONVERT_HANDLE hConvert)
\r
1261 /* Local Variables */
\r
1262 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
1263 drm_trusted_request_data_s req_data;
\r
1264 drm_trusted_response_data_s resp_data;
\r
1267 /* memset the structures */
\r
1268 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
1269 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
1271 /* Check Input & Output Parameters */
\r
1272 if (!input || !output || !hConvert) {
\r
1273 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1274 "Invalid Args, input = %p, output = %p, hConvert = %p",
\r
1275 input, output, hConvert);
\r
1276 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
1279 DRM_TRUSTED_CLIENT_LOG("input = %p, output = %p, hConvert = %p",
\r
1280 input, output, hConvert);
\r
1282 /* Copy the input to Request Structure */
\r
1283 memcpy(req_data.fixed_data.request_data, input,
\r
1284 sizeof(drm_trusted_write_conv_info_s));
\r
1286 /* Copy the handle into the request structure */
\r
1287 req_data.fixed_data.hConvert = hConvert;
\r
1289 /* Tell the server which API to be used */
\r
1290 req_data.fixed_data.api_name = DRM_TRUSTED_WRITE_CONVERT;
\r
1292 /* Number of additional data items to be sent */
\r
1293 /* Send items that is filled by application */
\r
1294 if (!(input->data) || input->data_len == 0) {
\r
1295 DRM_TRUSTED_CLIENT_EXCEPTION( "Invalid Args, data = %p, data_len = %d",
\r
1296 input->data, input->data_len);
\r
1297 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
1299 req_data.fixed_data.num_data_items++;
\r
1302 /* Fill details pertaining to additional pointers to be sent */
\r
1304 req_data.fixed_data.data_length[0] = input->data_len;
\r
1305 req_data.data_items[0] = (char*)malloc(req_data.fixed_data.data_length[0]);
\r
1306 if (!req_data.data_items[0]) {
\r
1307 DRM_TRUSTED_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p",
\r
1308 req_data.data_items[0]);
\r
1312 memcpy(req_data.data_items[0], input->data,
\r
1315 /* Send Data to DRM server */
\r
1316 /* Call the Client Communication API */
\r
1317 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
1318 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
1320 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
1324 /* Copy the response obtained from the server into the output parameter */
\r
1325 if (resp_data.fixed_data.resp_result != 0) {
\r
1326 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1327 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
1328 resp_data.fixed_data.resp_result);
\r
1329 result = resp_data.fixed_data.resp_result;
\r
1332 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
1333 resp_data.fixed_data.resp_result);
\r
1335 /* Copy the response from the server into output data */
\r
1336 memcpy(output, resp_data.fixed_data.response_data,
\r
1337 sizeof(drm_trusted_write_conv_resp_s));
\r
1341 /* Free Request data memory */
\r
1342 for (int i = 0; i < req_data.fixed_data.num_data_items; i++) {
\r
1343 if (req_data.data_items[i])
\r
1344 free(req_data.data_items[i]);
\r
1347 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
1349 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
1353 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r
1360 * An application can release a resource for converting.
\r
1362 * @param[in] hConvert Pointer to Open Convert Handle(DRM_TRUSTED_CONVERT_HANDLE)
\r
1364 * @return 0 on success, else a negative error value
\r
1365 * @retval DRM_TRUSTED_RETURN_SUCCESS on success
\r
1366 * @retval DRM_TRUSTED_RETURN_INVALID_ARG if arguments are invalid
\r
1367 * @retval DRM_TRUSTED_RETURN_COMMUNICATION_ERROR if socket error
\r
1368 * @retval DRM_TRUSTED_RETURN_INTERNAL_ERROR if operation error
\r
1373 EXPORT_API int drm_trusted_close_convert(DRM_TRUSTED_CONVERT_HANDLE *hConvert)
\r
1375 /* Local Variables */
\r
1376 drm_trusted_result_e result = DRM_TRUSTED_RETURN_SUCCESS;
\r
1377 drm_trusted_request_data_s req_data;
\r
1378 drm_trusted_response_data_s resp_data;
\r
1381 /* memset the structures */
\r
1382 memset(&req_data, 0x0, sizeof(drm_trusted_request_data_s));
\r
1383 memset(&resp_data, 0x0, sizeof(drm_trusted_response_data_s));
\r
1385 /* Check Input & Output Parameters */
\r
1386 if (!hConvert || !(*hConvert)) {
\r
1387 DRM_TRUSTED_CLIENT_EXCEPTION("Invalid Args, hConvert = %p, *hConvert = %p",
\r
1388 hConvert, (!hConvert) ? NULL : *hConvert);
\r
1389 return DRM_TRUSTED_RETURN_INVALID_ARG;
\r
1392 DRM_TRUSTED_CLIENT_LOG("hConvert = %p, *hConvert = %p",
\r
1393 hConvert, *hConvert);
\r
1395 /* Copy the handle into the request structure */
\r
1396 req_data.fixed_data.hConvert = *hConvert;
\r
1398 /* Tell the server which API to be used */
\r
1399 req_data.fixed_data.api_name = DRM_TRUSTED_CLOSE_CONVERT;
\r
1401 /* Send Data to DRM server */
\r
1402 /* Call the Client Communication API */
\r
1403 if ((ret_comm = drm_trusted_client_comm(&req_data, &resp_data)) != 0) {
\r
1404 DRM_TRUSTED_CLIENT_EXCEPTION("drm_trusted_client_comm error!!, ret_comm = %d",
\r
1406 result = DRM_TRUSTED_RETURN_COMMUNICATION_ERROR;
\r
1410 /* Copy the response obtained from the server into the output parameter */
\r
1411 if (resp_data.fixed_data.resp_result != 0) {
\r
1412 DRM_TRUSTED_CLIENT_EXCEPTION(
\r
1413 "Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x",
\r
1414 resp_data.fixed_data.resp_result);
\r
1415 result = resp_data.fixed_data.resp_result;
\r
1418 DRM_TRUSTED_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x",
\r
1419 resp_data.fixed_data.resp_result);
\r
1423 if (result != DRM_TRUSTED_RETURN_SUCCESS) {
\r
1425 DRM_TRUSTED_CLIENT_EXCEPTION("failed:result=0x%x", result);
\r
1429 DRM_TRUSTED_CLIENT_LOG("Success:result=0x%x", result);
\r