/* * drm-trusted client test utility * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Hakjoo Ko * Mahendra Kumar Prajapat * Harsha Shekar * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * @file test_drm_trusted_client.cpp * @brief Test case implementation specific to DRM trusted Client APIs. * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) * @author Harsha Shekar (h.shekar@samsung.com) * @version 0.1 * @history 0.1: First version of DRM trusted Client test utility. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "drm_trusted_client.h" #define drm_trusted_client_tid() (long int)syscall(__NR_gettid) #define DRM_TRUSTED_CLIENT_TEST_FILENAME(X) (strrchr((char*)(X), '/') ? (char*)(strrchr((char*)(X), '/') + 1) : ((char*)(X)) ) #define DRM_TRUSTED_CLIENT_TEST_LOG(FMT, ARG...) do{\ fprintf(stderr,"[PID=%ld]:[TID=%ld]:[%s:%s:%d]:",(long int)getpid(),drm_trusted_client_tid(),DRM_TRUSTED_CLIENT_TEST_FILENAME(__FILE__),__func__,__LINE__); \ fprintf(stderr,FMT,##ARG); \ fprintf(stderr,"\n"); \ } while(0); #define DRM_TRUSTED_CLIENT_TEST_EXCEPTION(FMT, ARG...) do{\ fprintf(stderr,"[PID=%ld]:[TID=%ld]:[%s:%s:%d]:",(long int)getpid(),drm_trusted_client_tid(),DRM_TRUSTED_CLIENT_TEST_FILENAME(__FILE__),__func__,__LINE__); \ fprintf(stderr,"[ERROR]"FMT,##ARG); \ fprintf(stderr,"\n"); \ } while(0); static void drm_trusted_print_buffer(const char* info, unsigned char* buffer, unsigned int buflen) { DRM_TRUSTED_CLIENT_TEST_LOG("\n********* %s:buflen=%u buffer=%p ******** \n",info,buflen,buffer); DRM_TRUSTED_CLIENT_TEST_LOG("********* %s:Start******** \n",info); unsigned int i; for(i=1;i<=buflen;i++) { fprintf(stderr,"0x%02X ",buffer[i-1]); if((i%16 )==0) fprintf(stderr,"\n"); } DRM_TRUSTED_CLIENT_TEST_LOG("********* %s:End ******** \n",info); } enum { DRM_TRUSTED_CLIENT_TEST_NONE, DRM_TRUSTED_CLIENT_TEST_handle_request, DRM_TRUSTED_CLIENT_TEST_consume_content, DRM_TRUSTED_CLIENT_TEST_CONVERT, DRM_TRUSTED_CLIENT_TEST_MAX }; void test_drm_trusted_operation_cb(drm_trusted_user_operation_info_s *operation_info, void *output_data) { DRM_TRUSTED_CLIENT_TEST_LOG("Callback Hit:test_drm_trusted_operation_cb"); DRM_TRUSTED_CLIENT_TEST_LOG("operation_status=%d",operation_info->operation_status); DRM_TRUSTED_CLIENT_TEST_LOG("operation_type=%d",operation_info->operation_type); } /* Statically allocate 10 MB 1 KB = 1024 B 1 MB = 1024 KB = 1024 * 1024 10 MB = 10 * 1024 * 1024 B */ //#define MAX_OUT_BUFFER_LEN (10 * 1024 * 1024) #define MAX_OUT_BUFFER_LEN (10 * 1024) void _handle_container_drm_content(DRM_DECRYPT_HANDLE pHandle, drm_trusted_file_type_e file_type) { DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p, file_type=%d",pHandle,file_type); drm_trusted_payload_info_s read_input_data; drm_trusted_read_decrypt_resp_data_s read_output_data; unsigned char out_file_path[256]={0}; unsigned char *out_buffer = NULL; FILE *fp_out=NULL; int ret = -1; unsigned int written_size = 0; /* Allocate memory for Out Buffer */ out_buffer = (unsigned char*)malloc(MAX_OUT_BUFFER_LEN); if (!out_buffer) { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Memory Allocation Error!!!"); return; } memset(&read_input_data,0x0,sizeof(drm_trusted_payload_info_s)); memset(&read_output_data,0x0,sizeof(drm_trusted_read_decrypt_resp_data_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter Output file name along with path where decrypted Data can be stored"); scanf("%s",out_file_path); DRM_TRUSTED_CLIENT_TEST_LOG("Output decrypted file=%s",out_file_path); fp_out = fopen((const char*)out_file_path,"w+b"); if(NULL == fp_out){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("fopen failed:error=%s",strerror(errno)); goto ErrorExit; } /* Actually exact plain text length should be used. * Plain text length can be obtained using drm_get_file_type */ read_input_data.payload_data = out_buffer; read_input_data.payload_data_len = (unsigned int)MAX_OUT_BUFFER_LEN; ret = drm_trusted_read_decrypt_session(pHandle,&read_input_data, &read_output_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x Actual read_size=%u " "Requested payload_data_len=%u", ret,read_output_data.read_size,read_input_data.payload_data_len); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_read_decrypt_session Failed!!, ret=0x%x", ret); } if(read_output_data.read_size > 0){ written_size= fwrite(read_input_data.payload_data,1, read_output_data.read_size,fp_out); DRM_TRUSTED_CLIENT_TEST_LOG("Actual written_size=%u " "Requested written size=%u", written_size,read_output_data.read_size); } fclose(fp_out); ErrorExit: if (out_buffer) free(out_buffer); } void _handle_stream_drm_content(DRM_DECRYPT_HANDLE pHandle, drm_trusted_file_type_e file_type) { DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p, file_type=%d",pHandle,file_type); drm_trusted_payload_info_s read_input_data; drm_trusted_read_decrypt_resp_data_s read_output_data; int ret = -1; memset(&read_input_data,0x0,sizeof(drm_trusted_payload_info_s)); memset(&read_output_data,0x0,sizeof(drm_trusted_read_decrypt_resp_data_s)); switch(file_type) { case DRM_TRUSTED_TYPE_PLAYREADY: { DRM_TRUSTED_CLIENT_TEST_LOG("PlayReady Content"); DRM_TRUSTED_CLIENT_TEST_LOG("Extract PayloadData,PayloadDataSize,ReplicatedData,ReplicatedDataSize & ObjectOffset From ASF parser application for EACH Payload"); DRM_TRUSTED_CLIENT_TEST_LOG("For testing purpose, currently it is hard-coded"); DRM_TRUSTED_CLIENT_TEST_LOG("These data are taken from 1st payload of jazz_AAC_V4AES.pya"); DRM_TRUSTED_CLIENT_TEST_LOG("As seen from corresponding clear file jazz_AAC.asf, Output decrypted buffer should be"); DRM_TRUSTED_CLIENT_TEST_LOG("0x20 0x00 0x20 0x00 0x00 0x80 0x0E"); unsigned char expected_output[] = {0x20, 0x00, 0x20, 0x00, 0x00, 0x80, 0x0E}; unsigned char PayloadData[] = {0xE5, 0x08, 0x6E, 0xAE, 0x61, 0xDF, 0x49}; unsigned int PayloadDataSize = sizeof(PayloadData) / sizeof(PayloadData[0]); DRM_TRUSTED_CLIENT_TEST_LOG("Actual Replicated data is last 8 bytes of Replicated Data as seen from ASF viewer"); DRM_TRUSTED_CLIENT_TEST_LOG("Thus ReplicatedDataSize will be 8 bytes"); unsigned char ReplicatedData[] = {0x14, 0x45, 0x0F, 0x0A, 0x28, 0x15, 0xBF, 0x42}; unsigned int ReplicatedDataSize = sizeof(ReplicatedData) / sizeof(ReplicatedData[0]); /* Start Decryption */ drm_trusted_print_buffer("Before:InputBuffer:",PayloadData,PayloadDataSize); read_input_data.media_offset = 0; read_input_data.payload_data = PayloadData; read_input_data.payload_data_len = PayloadDataSize; read_input_data.payload_iv = ReplicatedData; read_input_data.payload_iv_len = ReplicatedDataSize; ret = drm_trusted_read_decrypt_session(pHandle,&read_input_data, &read_output_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x Actual read_size=%u " "Requested payload_data_len=%u", ret,read_output_data.read_size,read_input_data.payload_data_len); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_read_decrypt_session Failed!!, ret=0x%x", ret); } drm_trusted_print_buffer("After:OutputBuffer:",read_input_data.payload_data,read_input_data.payload_data_len); if(0 == memcmp(read_input_data.payload_data,expected_output,read_input_data.payload_data_len)){ DRM_TRUSTED_CLIENT_TEST_LOG("Decrypt is successful for jazz_AAC_V4AES.pya"); } } break; case DRM_TRUSTED_TYPE_DIVX: { DRM_TRUSTED_CLIENT_TEST_LOG("DivX Content"); DRM_TRUSTED_CLIENT_TEST_LOG("Hard-coded testing is not available for DivX Content"); } break; default: DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "Unknown file_type=%d",file_type); } } void _handle_read_data(DRM_DECRYPT_HANDLE pHandle, drm_trusted_file_type_e file_type) { DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p, file_type=%d",pHandle,file_type); switch(file_type) { case DRM_TRUSTED_TYPE_OMA_V1: case DRM_TRUSTED_TYPE_OMA_V2: case DRM_TRUSTED_TYPE_PLAYREADY_ENVELOPE: DRM_TRUSTED_CLIENT_TEST_LOG("Container Based DRM file"); _handle_container_drm_content(pHandle,file_type); break; case DRM_TRUSTED_TYPE_PLAYREADY: case DRM_TRUSTED_TYPE_DIVX: DRM_TRUSTED_CLIENT_TEST_LOG("Stream Based DRM file"); _handle_stream_drm_content(pHandle,file_type); break; default: DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "Unknown file_type=%d",file_type); } } void _render_drm_content(drm_trusted_file_type_e file_type) { /* Initialize variables & structures */ drm_trusted_open_decrypt_info_s open_input_data; drm_trusted_open_decrypt_resp_data_s open_output_data; drm_trusted_seek_decrypt_info_s seek_input_data; drm_trusted_tell_decrypt_resp_data_s tell_output_data; drm_trusted_set_consumption_state_info_s state_input_data; DRM_DECRYPT_HANDLE pHandle = NULL; int ret = -1; drm_trusted_permission_type_e perm_type; char file_path[256]={0}; DRM_TRUSTED_CLIENT_TEST_LOG("Enter DRM content name along with path"); DRM_TRUSTED_CLIENT_TEST_LOG("Use jazz_AAC_V4AES.pya file if PlayReady decryption need to be tested"); scanf("%s",file_path); DRM_TRUSTED_CLIENT_TEST_LOG("file_path received=%s",file_path); DRM_TRUSTED_CLIENT_TEST_LOG("Enter permission type"); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_NONE",DRM_TRUSTED_PERMISSION_TYPE_NONE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_ANY",DRM_TRUSTED_PERMISSION_TYPE_ANY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_PLAY",DRM_TRUSTED_PERMISSION_TYPE_PLAY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_COLLABORATIVE_PLAY",DRM_TRUSTED_PERMISSION_TYPE_COLLABORATIVE_PLAY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_DISPLAY",DRM_TRUSTED_PERMISSION_TYPE_DISPLAY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_EXECUTE",DRM_TRUSTED_PERMISSION_TYPE_EXECUTE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_PRINT",DRM_TRUSTED_PERMISSION_TYPE_PRINT); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_EXPORT_COPY",DRM_TRUSTED_PERMISSION_TYPE_EXPORT_COPY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_EXPORT_MOVE",DRM_TRUSTED_PERMISSION_TYPE_EXPORT_MOVE); scanf("%d", (int*)&perm_type); DRM_TRUSTED_CLIENT_TEST_LOG("perm_type = %d file_path=%s",perm_type,file_path); /* memset the structures */ memset(&open_input_data,0x0,sizeof(drm_trusted_open_decrypt_info_s)); memset(&open_output_data,0x0,sizeof(drm_trusted_open_decrypt_resp_data_s)); memset(&seek_input_data,0x0,sizeof( drm_trusted_seek_decrypt_info_s)); memset(&tell_output_data,0x0,sizeof(drm_trusted_tell_decrypt_resp_data_s)); memset(&state_input_data,0x0,sizeof(drm_trusted_set_consumption_state_info_s)); /* Enter Appropriate Inputs */ memcpy(open_input_data.filePath,file_path,strlen(file_path)); open_input_data.file_type = file_type; open_input_data.permission = perm_type; open_input_data.operation_callback.callback = test_drm_trusted_operation_cb; /* Open Decrypt Session*/ ret = drm_trusted_open_decrypt_session(&open_input_data,&open_output_data, &pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_open_decrypt_session Failed!!, ret=0x%x", ret); return; } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("result_code = 0x%x",open_output_data.result_code); /* Just for testing seek & tell APIs */ seek_input_data.offset = 0; seek_input_data.seek_mode = DRM_SEEK_END; /* Set cursor to end */ DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_seek_decrypt_session(pHandle,&seek_input_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_seek_decrypt_session Failed!!, ret=0x%x", ret); } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_tell_decrypt_session(pHandle,&tell_output_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_tell_decrypt_session Failed!!, ret=0x%x", ret); } DRM_TRUSTED_CLIENT_TEST_LOG("file-size = %u",tell_output_data.offset); seek_input_data.offset = 0; seek_input_data.seek_mode = DRM_SEEK_SET; /* Again set cursor to beginning */ DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_seek_decrypt_session(pHandle,&seek_input_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_seek_decrypt_session Failed!!, ret=0x%x", ret); } /* Before Read, Appropriate state MUST be SET */ state_input_data.state = DRM_CONSUMPTION_STARTED; DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_set_decrypt_state(pHandle,&state_input_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_set_decrypt_state Failed!!, ret=0x%x", ret); goto Err; } /* Handle READ / DECRYPT operation */ _handle_read_data(pHandle,file_type); /* When rendering is stopped */ state_input_data.state = DRM_CONSUMPTION_STOPPED; DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_set_decrypt_state(pHandle,&state_input_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_set_decrypt_state Failed!!, ret=0x%x", ret); goto Err; } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_close_decrypt_session(&pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_close_decrypt_session Failed!!, ret=0x%x", ret); return; } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("SUCCESS"); return; Err: DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Failed, ret=0x%x", ret); drm_trusted_close_decrypt_session(&pHandle); } void _render_drm_oma_progressive_download_content(void) { DRM_TRUSTED_CLIENT_TEST_LOG("Progressive Download scenario"); DRM_TRUSTED_CLIENT_TEST_LOG("Hard-coded testing is not available for Progressive Download scenario"); } void _render_drm_piff_content(void) { /* Initialize variables & structures */ drm_trusted_open_decrypt_info_s open_input_data; drm_trusted_open_decrypt_resp_data_s open_output_data; drm_trusted_set_consumption_state_info_s state_input_data; drm_trusted_payload_info_s read_input_data; drm_trusted_read_decrypt_resp_data_s read_output_data; memset(&read_input_data,0x0,sizeof(drm_trusted_payload_info_s)); memset(&read_output_data,0x0,sizeof(drm_trusted_read_decrypt_resp_data_s)); DRM_DECRYPT_HANDLE pHandle = NULL; int ret = -1; drm_trusted_permission_type_e perm_type; DRM_TRUSTED_CLIENT_TEST_LOG("Enter permission type"); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_NONE",DRM_TRUSTED_PERMISSION_TYPE_NONE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_ANY",DRM_TRUSTED_PERMISSION_TYPE_ANY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_PLAY",DRM_TRUSTED_PERMISSION_TYPE_PLAY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_COLLABORATIVE_PLAY",DRM_TRUSTED_PERMISSION_TYPE_COLLABORATIVE_PLAY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_DISPLAY",DRM_TRUSTED_PERMISSION_TYPE_DISPLAY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_EXECUTE",DRM_TRUSTED_PERMISSION_TYPE_EXECUTE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_PRINT",DRM_TRUSTED_PERMISSION_TYPE_PRINT); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_EXPORT_COPY",DRM_TRUSTED_PERMISSION_TYPE_EXPORT_COPY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_PERMISSION_TYPE_EXPORT_MOVE",DRM_TRUSTED_PERMISSION_TYPE_EXPORT_MOVE); scanf("%d", (int*)&perm_type); DRM_TRUSTED_CLIENT_TEST_LOG("perm_type = %d",perm_type); DRM_TRUSTED_CLIENT_TEST_LOG("Sample Content => SuperSpeedway_720_230.ismv"); /* Content Header <.W.R.M.H.E.A.D.E.R. .x.m.l.n.s.=.".h.t.t.p.:././.s.c.h.e.m.a.s...m.i.c.r.o.s.o.f.t...c.o.m./.D.R.M./.2.0.0.7./.0.3./.P.l.a.y.R.e.a.d.y.H.e.a.d.e.r.". .v.e.r.s.i.o.n.=.".4...0...0...0.".>. * <.D.A.T.A.>. * <.P.R.O.T.E.C.T.I.N.F.O.>. * <.K.E.Y.L.E.N.>.1.6.<./.K.E.Y.L.E.N.>. * <.A.L.G.I.D.>.A.E.S.C.T.R.<./.A.L.G.I.D.>. * <./.P.R.O.T.E.C.T.I.N.F.O.>. * <.K.I.D.>.A.m.f.j.C.T.O.P.b.E.O.l.3.W.D./.5.m.c.e.c.A.=.=.<./.K.I.D.>. * <.C.H.E.C.K.S.U.M.>.B.G.w.1.a.Y.Z.1.Y.X.M.=.<./.C.H.E.C.K.S.U.M.>. * <.C.U.S.T.O.M.A.T.T.R.I.B.U.T.E.S.>. * <.I.I.S._.D.R.M._.V.E.R.S.I.O.N.>.7...1...1.0.6.4...0.<./.I.I.S._.D.R.M._.V.E.R.S.I.O.N.>. * <./.C.U.S.T.O.M.A.T.T.R.I.B.U.T.E.S.>. * <.L.A._.U.R.L.>.h.t.t.p.:././.p.l.a.y.r.e.a.d.y...d.i.r.e.c.t.t.a.p.s...n.e.t./.p.r./.s.v.c./.r.i.g.h.t.s.m.a.n.a.g.e.r...a.s.m.x.<./.L.A._.U.R.L.>. * <.D.S._.I.D.>.A.H.+.0.3.j.u.K.b.U.G.b.H.l.1.V./.Q.I.w.R.A.=.=.<./.D.S._.I.D.>. * <./.D.A.T.A.>. * <./.W.R.M.H.E.A.D.E.R.>... */ unsigned char ContentHeader[] ={0x3C,0x00,0x57,0x00,0x52,0x00,0x4D,0x00,0x48,0x00,0x45,0x00,0x41,0x00,0x44,0x00,0x45,0x00,0x52,0x00,0x20,0x00,0x78,0x00,0x6D,0x00,0x6C,0x00,0x6E,0x00, 0x73,0x00,0x3D,0x00,0x22,0x00,0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00,0x3A,0x00,0x2F,0x00,0x2F,0x00,0x73,0x00,0x63,0x00,0x68,0x00,0x65,0x00,0x6D,0x00, 0x61,0x00,0x73,0x00,0x2E,0x00,0x6D,0x00,0x69,0x00,0x63,0x00,0x72,0x00,0x6F,0x00,0x73,0x00,0x6F,0x00,0x66,0x00,0x74,0x00,0x2E,0x00,0x63,0x00,0x6F,0x00, 0x6D,0x00,0x2F,0x00,0x44,0x00,0x52,0x00,0x4D,0x00,0x2F,0x00,0x32,0x00,0x30,0x00,0x30,0x00,0x37,0x00,0x2F,0x00,0x30,0x00,0x33,0x00,0x2F,0x00,0x50,0x00, 0x6C,0x00,0x61,0x00,0x79,0x00,0x52,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x79,0x00,0x48,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x65,0x00,0x72,0x00,0x22,0x00, 0x20,0x00,0x76,0x00,0x65,0x00,0x72,0x00,0x73,0x00,0x69,0x00,0x6F,0x00,0x6E,0x00,0x3D,0x00,0x22,0x00,0x34,0x00,0x2E,0x00,0x30,0x00,0x2E,0x00,0x30,0x00, 0x2E,0x00,0x30,0x00,0x22,0x00,0x3E,0x00,0x3C,0x00,0x44,0x00,0x41,0x00,0x54,0x00,0x41,0x00,0x3E,0x00,0x3C,0x00,0x50,0x00,0x52,0x00,0x4F,0x00,0x54,0x00, 0x45,0x00,0x43,0x00,0x54,0x00,0x49,0x00,0x4E,0x00,0x46,0x00,0x4F,0x00,0x3E,0x00,0x3C,0x00,0x4B,0x00,0x45,0x00,0x59,0x00,0x4C,0x00,0x45,0x00,0x4E,0x00, 0x3E,0x00,0x31,0x00,0x36,0x00,0x3C,0x00,0x2F,0x00,0x4B,0x00,0x45,0x00,0x59,0x00,0x4C,0x00,0x45,0x00,0x4E,0x00,0x3E,0x00,0x3C,0x00,0x41,0x00,0x4C,0x00, 0x47,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x41,0x00,0x45,0x00,0x53,0x00,0x43,0x00,0x54,0x00,0x52,0x00,0x3C,0x00,0x2F,0x00,0x41,0x00,0x4C,0x00,0x47,0x00, 0x49,0x00,0x44,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00,0x50,0x00,0x52,0x00,0x4F,0x00,0x54,0x00,0x45,0x00,0x43,0x00,0x54,0x00,0x49,0x00,0x4E,0x00,0x46,0x00, 0x4F,0x00,0x3E,0x00,0x3C,0x00,0x4B,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x41,0x00,0x6D,0x00,0x66,0x00,0x6A,0x00,0x43,0x00,0x54,0x00,0x4F,0x00,0x50,0x00, 0x62,0x00,0x45,0x00,0x4F,0x00,0x6C,0x00,0x33,0x00,0x57,0x00,0x44,0x00,0x2F,0x00,0x35,0x00,0x6D,0x00,0x63,0x00,0x65,0x00,0x63,0x00,0x41,0x00,0x3D,0x00, 0x3D,0x00,0x3C,0x00,0x2F,0x00,0x4B,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x3C,0x00,0x43,0x00,0x48,0x00,0x45,0x00,0x43,0x00,0x4B,0x00,0x53,0x00,0x55,0x00, 0x4D,0x00,0x3E,0x00,0x42,0x00,0x47,0x00,0x77,0x00,0x31,0x00,0x61,0x00,0x59,0x00,0x5A,0x00,0x31,0x00,0x59,0x00,0x58,0x00,0x4D,0x00,0x3D,0x00,0x3C,0x00, 0x2F,0x00,0x43,0x00,0x48,0x00,0x45,0x00,0x43,0x00,0x4B,0x00,0x53,0x00,0x55,0x00,0x4D,0x00,0x3E,0x00,0x3C,0x00,0x43,0x00,0x55,0x00,0x53,0x00,0x54,0x00, 0x4F,0x00,0x4D,0x00,0x41,0x00,0x54,0x00,0x54,0x00,0x52,0x00,0x49,0x00,0x42,0x00,0x55,0x00,0x54,0x00,0x45,0x00,0x53,0x00,0x3E,0x00,0x3C,0x00,0x49,0x00, 0x49,0x00,0x53,0x00,0x5F,0x00,0x44,0x00,0x52,0x00,0x4D,0x00,0x5F,0x00,0x56,0x00,0x45,0x00,0x52,0x00,0x53,0x00,0x49,0x00,0x4F,0x00,0x4E,0x00,0x3E,0x00, 0x37,0x00,0x2E,0x00,0x31,0x00,0x2E,0x00,0x31,0x00,0x30,0x00,0x36,0x00,0x34,0x00,0x2E,0x00,0x30,0x00,0x3C,0x00,0x2F,0x00,0x49,0x00,0x49,0x00,0x53,0x00, 0x5F,0x00,0x44,0x00,0x52,0x00,0x4D,0x00,0x5F,0x00,0x56,0x00,0x45,0x00,0x52,0x00,0x53,0x00,0x49,0x00,0x4F,0x00,0x4E,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00, 0x43,0x00,0x55,0x00,0x53,0x00,0x54,0x00,0x4F,0x00,0x4D,0x00,0x41,0x00,0x54,0x00,0x54,0x00,0x52,0x00,0x49,0x00,0x42,0x00,0x55,0x00,0x54,0x00,0x45,0x00, 0x53,0x00,0x3E,0x00,0x3C,0x00,0x4C,0x00,0x41,0x00,0x5F,0x00,0x55,0x00,0x52,0x00,0x4C,0x00,0x3E,0x00,0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00,0x3A,0x00, 0x2F,0x00,0x2F,0x00,0x70,0x00,0x6C,0x00,0x61,0x00,0x79,0x00,0x72,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x79,0x00,0x2E,0x00,0x64,0x00,0x69,0x00,0x72,0x00, 0x65,0x00,0x63,0x00,0x74,0x00,0x74,0x00,0x61,0x00,0x70,0x00,0x73,0x00,0x2E,0x00,0x6E,0x00,0x65,0x00,0x74,0x00,0x2F,0x00,0x70,0x00,0x72,0x00,0x2F,0x00, 0x73,0x00,0x76,0x00,0x63,0x00,0x2F,0x00,0x72,0x00,0x69,0x00,0x67,0x00,0x68,0x00,0x74,0x00,0x73,0x00,0x6D,0x00,0x61,0x00,0x6E,0x00,0x61,0x00,0x67,0x00, 0x65,0x00,0x72,0x00,0x2E,0x00,0x61,0x00,0x73,0x00,0x6D,0x00,0x78,0x00,0x3C,0x00,0x2F,0x00,0x4C,0x00,0x41,0x00,0x5F,0x00,0x55,0x00,0x52,0x00,0x4C,0x00, 0x3E,0x00,0x3C,0x00,0x44,0x00,0x53,0x00,0x5F,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x41,0x00,0x48,0x00,0x2B,0x00,0x30,0x00,0x33,0x00,0x6A,0x00,0x75,0x00, 0x4B,0x00,0x62,0x00,0x55,0x00,0x47,0x00,0x62,0x00,0x48,0x00,0x6C,0x00,0x31,0x00,0x56,0x00,0x2F,0x00,0x51,0x00,0x49,0x00,0x77,0x00,0x52,0x00,0x41,0x00, 0x3D,0x00,0x3D,0x00,0x3C,0x00,0x2F,0x00,0x44,0x00,0x53,0x00,0x5F,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00,0x44,0x00,0x41,0x00,0x54,0x00, 0x41,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00,0x57,0x00,0x52,0x00,0x4D,0x00,0x48,0x00,0x45,0x00,0x41,0x00,0x44,0x00,0x45,0x00,0x52,0x00,0x3E,0x00,0x00,0x00}; /* Enter Appropriate Inputs */ open_input_data.file_type = DRM_TRUSTED_TYPE_PIFF; open_input_data.permission = perm_type; open_input_data.operation_callback.callback = test_drm_trusted_operation_cb; open_input_data.lic_header.header = ContentHeader; open_input_data.lic_header.header_len = sizeof(ContentHeader); /* Open Decrypt Session*/ ret = drm_trusted_open_decrypt_session(&open_input_data,&open_output_data, &pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_open_decrypt_session Failed!!, ret=0x%x", ret); return; } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("result_code = 0x%x",open_output_data.result_code); DRM_TRUSTED_CLIENT_TEST_LOG("Extract Payload and IV information and pass it through PIFF payload info"); DRM_TRUSTED_CLIENT_TEST_LOG("Sample Payload - Encrypted"); DRM_TRUSTED_CLIENT_TEST_LOG("0xE8,0xC6,0xF8,0x49,0xF3,0x0E,0x52,0xFB,0xC5,0xFA,0xF1"); DRM_TRUSTED_CLIENT_TEST_LOG("Corresponding Decrypted Payload"); DRM_TRUSTED_CLIENT_TEST_LOG("0x88,0x80,0x40,0x01,0x71,0xA3,0x7F,0xD9,0xEF,0xA7,0xF2"); DRM_TRUSTED_CLIENT_TEST_LOG("Sample IV"); DRM_TRUSTED_CLIENT_TEST_LOG("0xF4,0xB3,0x10,0x77,0x75,0x3F,0x69,0x94"); unsigned char PayLoadData[] = {0xE8,0xC6,0xF8,0x49,0xF3,0x0E,0x52,0xFB,0xC5,0xFA,0xF1}; unsigned char InitVect[] = {0xF4,0xB3,0x10,0x77,0x75,0x3F,0x69,0x94}; unsigned char expected_output[] = {0x88,0x80,0x40,0x01,0x71,0xA3,0x7F,0xD9,0xEF,0xA7,0xF2}; /* Before Read, Appropriate state MUST be SET */ state_input_data.state = DRM_CONSUMPTION_STARTED; DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_set_decrypt_state(pHandle,&state_input_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_set_decrypt_state Failed!!, ret=0x%x", ret); goto Err; } /* Start Decryption */ read_input_data.media_offset = 0; read_input_data.payload_data = PayLoadData; read_input_data.payload_data_len = sizeof(PayLoadData)/sizeof(PayLoadData[0]); read_input_data.payload_iv = InitVect; read_input_data.payload_iv_len = sizeof(InitVect)/sizeof(InitVect[0]); drm_trusted_print_buffer("Before:InputBuffer:",read_input_data.payload_data,read_input_data.payload_data_len); ret = drm_trusted_read_decrypt_session(pHandle,&read_input_data, &read_output_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x Actual read_size=%u " "Requested payload_data_len=%u", ret,read_output_data.read_size,read_input_data.payload_data_len); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_read_decrypt_session Failed!!, ret=0x%x", ret); } drm_trusted_print_buffer("After:OutputBuffer:",read_input_data.payload_data,read_input_data.payload_data_len); if(0 == memcmp(read_input_data.payload_data,expected_output,read_input_data.payload_data_len)){ DRM_TRUSTED_CLIENT_TEST_LOG("Decrypt is successful for SuperSpeedway_720_230.ismv"); } /* When rendering is stopped */ state_input_data.state = DRM_CONSUMPTION_STOPPED; DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_set_decrypt_state(pHandle,&state_input_data); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_set_decrypt_state Failed!!, ret=0x%x", ret); goto Err; } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); ret = drm_trusted_close_decrypt_session(&pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_close_decrypt_session Failed!!, ret=0x%x", ret); return; } DRM_TRUSTED_CLIENT_TEST_LOG("pHandle = %p",pHandle); DRM_TRUSTED_CLIENT_TEST_LOG("SUCCESS"); return; Err: DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Failed, ret=0x%x", ret); drm_trusted_close_decrypt_session(&pHandle); } void test_consume_content(void) { DRM_TRUSTED_CLIENT_TEST_LOG("Start"); drm_trusted_file_type_e file_type = DRM_TRUSTED_TYPE_UNDEFINED; /* Enter simulation information */ DRM_TRUSTED_CLIENT_TEST_LOG("Enter the file_type"); DRM_TRUSTED_CLIENT_TEST_LOG("Application can know file_type by calling" "drm_get_file_type"); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_OMA_V1 \n",DRM_TRUSTED_TYPE_OMA_V1); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_OMA_V2 \n",DRM_TRUSTED_TYPE_OMA_V2); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_PLAYREADY \n",DRM_TRUSTED_TYPE_PLAYREADY); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_PLAYREADY_ENVELOPE \n",DRM_TRUSTED_TYPE_PLAYREADY_ENVELOPE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_DIVX \n",DRM_TRUSTED_TYPE_DIVX); DRM_TRUSTED_CLIENT_TEST_LOG("Application can know about OMA DRM Progressive download" "when browser download OMA DD (Download descriptor)" "In DD, there is field progressiveDownloadFlag" "if progressiveDownloadFlag = true it means" "the content MUST be rendering in progressive download mode."); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_OMA_PD \n",DRM_TRUSTED_TYPE_OMA_PD); DRM_TRUSTED_CLIENT_TEST_LOG("Application can know about PIFF / Smooth Streaming" "when browser download Manifest file"); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TYPE_PIFF \n",DRM_TRUSTED_TYPE_PIFF); scanf("%d", (int*)&file_type); DRM_TRUSTED_CLIENT_TEST_LOG("file_type received=%d",file_type); switch(file_type){ case DRM_TRUSTED_TYPE_OMA_V1: case DRM_TRUSTED_TYPE_OMA_V2: case DRM_TRUSTED_TYPE_PLAYREADY: case DRM_TRUSTED_TYPE_PLAYREADY_ENVELOPE: case DRM_TRUSTED_TYPE_DIVX: DRM_TRUSTED_CLIENT_TEST_LOG("Handle file based rendering"); _render_drm_content(file_type); break; case DRM_TRUSTED_TYPE_OMA_PD: DRM_TRUSTED_CLIENT_TEST_LOG("Handle OMA DRM Progressive download rendering"); _render_drm_oma_progressive_download_content(); break; case DRM_TRUSTED_TYPE_PIFF: DRM_TRUSTED_CLIENT_TEST_LOG("Handle OMA DRM Progressive download rendering"); _render_drm_piff_content(); break; default: DRM_TRUSTED_CLIENT_TEST_LOG("UnKnown file_type=%d",file_type); return; } DRM_TRUSTED_CLIENT_TEST_LOG("Completed"); } void test_convert(char* SourceDMfilePath, char* DestDCFfilepath) { DRM_TRUSTED_CONVERT_HANDLE hConvert; drm_trusted_opn_conv_info_s input; drm_trusted_write_conv_info_s write_input; drm_trusted_write_conv_resp_s output; FILE *fp = NULL; int FileSize=0; unsigned char *buffer = NULL; struct stat statbuf; int readed_size = 0; int ret = -1; /* memset the structures */ memset(&hConvert, 0x0, sizeof(DRM_TRUSTED_CONVERT_HANDLE)); memset(&input, 0x0, sizeof(drm_trusted_opn_conv_info_s)); memset(&output, 0x0, sizeof(drm_trusted_write_conv_resp_s)); memset(&write_input, 0x0, sizeof(drm_trusted_opn_conv_info_s)); memset(&statbuf, 0x0, sizeof(struct stat)); memcpy(input.filePath,DestDCFfilepath,strlen(DestDCFfilepath)); input.install_RO = DRM_TRUSTED_FALSE; ret = drm_trusted_open_convert(&input,&hConvert); DRM_TRUSTED_CLIENT_TEST_LOG("drm_trusted_open_convert:ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_open_convert Failed!!, ret=0x%x", ret); return; } fp = fopen(SourceDMfilePath, "r"); if (fp == NULL){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("fopen error:error=%s",strerror(errno)); goto err; } if(stat(SourceDMfilePath, &statbuf) == 0 ){ FileSize = (unsigned int)statbuf.st_size; }else{ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("stat failed:error = %s",strerror(errno)); goto err; } DRM_TRUSTED_CLIENT_TEST_LOG("FileSize=%d",FileSize); if(0 == FileSize){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("%s is empty",SourceDMfilePath); goto err; } buffer = (unsigned char *)malloc(FileSize + 1); if(!buffer){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("malloc failed:error=%s",strerror(errno)); goto err; } memset(buffer, 0x0, FileSize+1); readed_size = fread(buffer,1,FileSize,fp); DRM_TRUSTED_CLIENT_TEST_LOG("read_size=%d FileSize=%d",readed_size,FileSize); if(ferror(fp)){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("fread failed:error=%s",strerror(errno)); goto err; } buffer[FileSize] = '\0'; write_input.data_len = readed_size; write_input.data = buffer; DRM_TRUSTED_CLIENT_TEST_LOG("data_len=%d",write_input.data_len); ret = drm_trusted_write_convert(&write_input,&output,hConvert); DRM_TRUSTED_CLIENT_TEST_LOG("drm_trusted_write_convert:ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_write_convert Failed!!, ret=0x%x", ret); goto err; } DRM_TRUSTED_CLIENT_TEST_LOG("bytes written=%u filesize=%d",output.write_size,FileSize); if((unsigned int)FileSize != output.write_size){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Data is not written successfully"); goto err; } ret = drm_trusted_close_convert(&hConvert); DRM_TRUSTED_CLIENT_TEST_LOG("drm_trusted_close_convert:ret = 0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS != ret){ DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "drm_trusted_close_convert Failed!!, ret=0x%x", ret); hConvert = NULL; goto err; } fclose(fp); free(buffer); DRM_TRUSTED_CLIENT_TEST_LOG("SUCCESS"); return; err: DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Failed"); if(hConvert) drm_trusted_close_convert(&hConvert); if(fp) fclose(fp); if(buffer) free(buffer); return; } int test_case(int option) { char filePath[300] = {0,}; char distfilePath[300] = {0,}; DRM_TRUSTED_CLIENT_TEST_LOG("option=[%d]", option); switch (option) { case DRM_TRUSTED_CLIENT_TEST_NONE: { DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_CLIENT_TEST_NONE start"); DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_CLIENT_TEST_NONE completed"); break; } case DRM_TRUSTED_CLIENT_TEST_handle_request: { DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_CLIENT_TEST_handle_request start"); drm_trusted_request_type_e request_type = DRM_TRUSTED_REQ_TYPE_NONE; DRM_TRUSTED_CLIENT_TEST_LOG("Enter the request type to be processed"); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_UPDATE_SECURE_CLK",DRM_TRUSTED_REQ_TYPE_UPDATE_SECURE_CLK); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_SET_SECURE_CLK",DRM_TRUSTED_REQ_TYPE_SET_SECURE_CLK); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_SET_TRANSACTION_TRACKING",DRM_TRUSTED_REQ_TYPE_SET_TRANSACTION_TRACKING); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_MASTER_RESET",DRM_TRUSTED_REQ_TYPE_MASTER_RESET); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_VERIFY_ENCRYPTED_CERT",DRM_TRUSTED_REQ_TYPE_VERIFY_ENCRYPTED_CERT); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_CREATE_INIT_DB",DRM_TRUSTED_REQ_TYPE_CREATE_INIT_DB); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_REINSTALL_CERT",DRM_TRUSTED_REQ_TYPE_REINSTALL_CERT); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_REMOVE_RO",DRM_TRUSTED_REQ_TYPE_REMOVE_RO); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_REMOVE_ALL_RO",DRM_TRUSTED_REQ_TYPE_REMOVE_ALL_RO); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_GO_RIGHTS_URL",DRM_TRUSTED_REQ_TYPE_GO_RIGHTS_URL); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_PD_SET_DOWNLOAD_COMPLETE",DRM_TRUSTED_REQ_TYPE_PD_SET_DOWNLOAD_COMPLETE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_PD_GET_PARSE_STATUS_INFO",DRM_TRUSTED_REQ_TYPE_PD_GET_PARSE_STATUS_INFO); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_PIFF_GET_LICENSE",DRM_TRUSTED_REQ_TYPE_PIFF_GET_LICENSE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE",DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE); DRM_TRUSTED_CLIENT_TEST_LOG(" %d ==> DRM_TRUSTED_REQ_TYPE_SAPPS_CONSUME_LICENSE",DRM_TRUSTED_REQ_TYPE_SAPPS_CONSUME_LICENSE); scanf("%d", (int*)&request_type); DRM_TRUSTED_CLIENT_TEST_LOG("request_type received=%d",request_type); switch(request_type) { case DRM_TRUSTED_REQ_TYPE_UPDATE_SECURE_CLK: { struct tm* tmst = NULL; long int delta = 0, newtime = 0, oldtime = 0; int ret = -1; drm_trusted_update_sec_clk_info_s upd_clk_info = { 0, }; DRM_TRUSTED_CLIENT_TEST_LOG("Enter delta sec \n"); scanf("%ld",&delta); DRM_TRUSTED_CLIENT_TEST_LOG("delta = %ld \n",delta); oldtime = (long int)time(NULL); DRM_TRUSTED_CLIENT_TEST_LOG("Old Local Time = %ld = %s \n",oldtime,ctime(&oldtime)); newtime = oldtime + delta; tmst = localtime(&newtime); DRM_TRUSTED_CLIENT_TEST_LOG("New Local Time = %ld = %s \n",newtime,asctime(tmst)); upd_clk_info.before = oldtime; upd_clk_info.after = newtime; ret = drm_trusted_handle_request(request_type, (void *) &upd_clk_info, NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("Update Secure Clock Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "Update Secure Clock Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_SET_SECURE_CLK: { DRM_TRUSTED_CLIENT_TEST_LOG("Set Secure Clock!!"); struct tm* tmst = NULL; long int delta = 0, locatime = 0, securetime = 0; int ret = -1; drm_trusted_set_sec_clk_info_s sec_clk_info; memset(&sec_clk_info, 0x00, sizeof(drm_trusted_set_sec_clk_info_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter delta sec \n"); scanf("%ld",&delta); DRM_TRUSTED_CLIENT_TEST_LOG("delta = %ld \n",delta); locatime = (long int)time(NULL); DRM_TRUSTED_CLIENT_TEST_LOG("Current Local Time = %ld = %s \n",locatime,ctime(&locatime)); securetime = locatime + delta; tmst = localtime(&securetime); DRM_TRUSTED_CLIENT_TEST_LOG("Current Secure Time = %ld = %s \n", securetime, asctime(tmst)); memcpy(&sec_clk_info.secure_time, tmst, sizeof(struct tm)); sec_clk_info.source_type = DRM_TRUSTED_TS_NITZ; ret = drm_trusted_handle_request(request_type, (void *) &sec_clk_info, NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("Set Secure Clock Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "Set Secure Clock Failed!!, ret=0x%x", ret); } break; break; } case DRM_TRUSTED_REQ_TYPE_SET_TRANSACTION_TRACKING: { int ret = -1; drm_trusted_set_transaction_trk_info_s trk_info; int value = 0; memset(&trk_info, 0x00, sizeof(drm_trusted_set_transaction_trk_info_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter 1 for tracking ON and 0 for OFF"); scanf("%d", &value); if (1 == value) { trk_info.tracking_on = DRM_TRUSTED_TRUE; } else if (0 == value) { trk_info.tracking_on = DRM_TRUSTED_FALSE; } else { trk_info.tracking_on = DRM_TRUSTED_UNKNOWN; } ret = drm_trusted_handle_request(request_type, (void *) &trk_info, NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("Set Transaction Tracking Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION( "Set Transaction Tracking Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_MASTER_RESET: { int ret = -1; DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_REQ_TYPE_MASTER_RESET"); ret = drm_trusted_handle_request(request_type,NULL,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS == ret){ DRM_TRUSTED_CLIENT_TEST_LOG("MASTER RESET Success"); }else{ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("MASTER RESET FAILED: ret=0x%x", ret); } } break; case DRM_TRUSTED_REQ_TYPE_VERIFY_ENCRYPTED_CERT: { int ret = -1; DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_REQ_TYPE_VERIFY_ENCRYPTED_CERT"); ret = drm_trusted_handle_request(request_type,NULL,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS == ret){ DRM_TRUSTED_CLIENT_TEST_LOG("verifying encrypted certificate Success"); }else{ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("verifying encrypted certificate FAILED: ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_CREATE_INIT_DB: { int ret = -1; DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_REQ_TYPE_CREATE_INIT_DB"); ret = drm_trusted_handle_request(request_type,NULL,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS == ret){ DRM_TRUSTED_CLIENT_TEST_LOG("CREATE_INIT_DB Success"); }else{ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("CREATE_INIT_DB FAILED: ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_REINSTALL_CERT: { int ret = -1; DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_REQ_TYPE_REINSTALL_CERT"); ret = drm_trusted_handle_request(request_type,NULL,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS == ret){ DRM_TRUSTED_CLIENT_TEST_LOG("REINSTALL_CERT Success"); }else{ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("REINSTALL_CERT FAILED: ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_REMOVE_RO: { int ret = -1; DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_REQ_TYPE_REMOVE_RO"); drm_trusted_remove_ro_info_s remove_ro_info; memset(&remove_ro_info, 0x00, sizeof(drm_trusted_remove_ro_info_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter the file path"); scanf("%s",remove_ro_info.filePath); DRM_TRUSTED_CLIENT_TEST_LOG("file path=%s",remove_ro_info.filePath); ret = drm_trusted_handle_request(request_type,(void *)&remove_ro_info, NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("REMOVE_RO Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("REMOVE_RO Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_REMOVE_ALL_RO: { int ret = -1; DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_REQ_TYPE_REMOVE_ALL_RO"); ret = drm_trusted_handle_request(request_type,NULL,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x",ret); if(DRM_TRUSTED_RETURN_SUCCESS == ret){ DRM_TRUSTED_CLIENT_TEST_LOG("REMOVE_ALL_RO Success"); }else{ DRM_TRUSTED_CLIENT_TEST_EXCEPTION("REMOVE_ALL_RO FAILED: ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_GO_RIGHTS_URL: { int ret = -1; drm_trusted_go_rights_url_info_s rights_url_info; memset(&rights_url_info, 0x00, sizeof(drm_trusted_go_rights_url_info_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter the file path"); scanf("%s",rights_url_info.file_path); DRM_TRUSTED_CLIENT_TEST_LOG("Enter=%d => DRM_ROURL_METHOD_ROPAYLOAD",DRM_ROURL_METHOD_ROPAYLOAD); DRM_TRUSTED_CLIENT_TEST_LOG("Enter=%d => DRM_ROURL_METHOD_SILENT",DRM_ROURL_METHOD_SILENT); DRM_TRUSTED_CLIENT_TEST_LOG("Enter the RO URL Type"); scanf("%d",(int*)&(rights_url_info.rourl_type)); DRM_TRUSTED_CLIENT_TEST_LOG("file_path=%s rourl_type=%d",rights_url_info.file_path,rights_url_info.rourl_type); ret = drm_trusted_handle_request(request_type,(void *)&rights_url_info, NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("GO_RIGHTS_URL Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("GO_RIGHTS_URL Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_PD_SET_DOWNLOAD_COMPLETE: { int ret = -1; drm_trusted_pd_set_dld_comp_info_s download_cmp_info; memset(&download_cmp_info, 0x00, sizeof(drm_trusted_pd_set_dld_comp_info_s)); ret = drm_trusted_handle_request(request_type,(void *)&download_cmp_info, NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("PD_SET_DOWNLOAD_COMPLETE Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("PD_SET_DOWNLOAD_COMPLETE Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_PD_GET_PARSE_STATUS_INFO: { int ret = -1; drm_trusted_pd_parse_status_info_s info_status; drm_trusted_pd_parse_status_resp_s resp_status; memset(&info_status, 0x00, sizeof(drm_trusted_pd_parse_status_info_s)); memset(&resp_status, 0x00, sizeof(drm_trusted_pd_parse_status_resp_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter the file path"); scanf("%s",info_status.file_path); DRM_TRUSTED_CLIENT_TEST_LOG("file_path=%s",info_status.file_path); ret = drm_trusted_handle_request(request_type,(void *)&info_status, (void *)&resp_status); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("PD_GET_PARSE_STATUS_INFO Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("PD_GET_PARSE_STATUS_INFO Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_PIFF_GET_LICENSE: { int ret = -1; drm_trusted_piff_get_license_info_s license_info; /* Sample Content => SuperSpeedway_720_230.ismv */ /* Content Header <.W.R.M.H.E.A.D.E.R. .x.m.l.n.s.=.".h.t.t.p.:././.s.c.h.e.m.a.s...m.i.c.r.o.s.o.f.t...c.o.m./.D.R.M./.2.0.0.7./.0.3./.P.l.a.y.R.e.a.d.y.H.e.a.d.e.r.". .v.e.r.s.i.o.n.=.".4...0...0...0.".>. * <.D.A.T.A.>. * <.P.R.O.T.E.C.T.I.N.F.O.>. * <.K.E.Y.L.E.N.>.1.6.<./.K.E.Y.L.E.N.>. * <.A.L.G.I.D.>.A.E.S.C.T.R.<./.A.L.G.I.D.>. * <./.P.R.O.T.E.C.T.I.N.F.O.>. * <.K.I.D.>.A.m.f.j.C.T.O.P.b.E.O.l.3.W.D./.5.m.c.e.c.A.=.=.<./.K.I.D.>. * <.C.H.E.C.K.S.U.M.>.B.G.w.1.a.Y.Z.1.Y.X.M.=.<./.C.H.E.C.K.S.U.M.>. * <.C.U.S.T.O.M.A.T.T.R.I.B.U.T.E.S.>. * <.I.I.S._.D.R.M._.V.E.R.S.I.O.N.>.7...1...1.0.6.4...0.<./.I.I.S._.D.R.M._.V.E.R.S.I.O.N.>. * <./.C.U.S.T.O.M.A.T.T.R.I.B.U.T.E.S.>. * <.L.A._.U.R.L.>.h.t.t.p.:././.p.l.a.y.r.e.a.d.y...d.i.r.e.c.t.t.a.p.s...n.e.t./.p.r./.s.v.c./.r.i.g.h.t.s.m.a.n.a.g.e.r...a.s.m.x.<./.L.A._.U.R.L.>. * <.D.S._.I.D.>.A.H.+.0.3.j.u.K.b.U.G.b.H.l.1.V./.Q.I.w.R.A.=.=.<./.D.S._.I.D.>. * <./.D.A.T.A.>. * <./.W.R.M.H.E.A.D.E.R.>... */ unsigned char ContentHeader[] ={0x3C,0x00,0x57,0x00,0x52,0x00,0x4D,0x00,0x48,0x00,0x45,0x00,0x41,0x00,0x44,0x00,0x45,0x00,0x52,0x00,0x20,0x00,0x78,0x00,0x6D,0x00,0x6C,0x00,0x6E,0x00, 0x73,0x00,0x3D,0x00,0x22,0x00,0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00,0x3A,0x00,0x2F,0x00,0x2F,0x00,0x73,0x00,0x63,0x00,0x68,0x00,0x65,0x00,0x6D,0x00, 0x61,0x00,0x73,0x00,0x2E,0x00,0x6D,0x00,0x69,0x00,0x63,0x00,0x72,0x00,0x6F,0x00,0x73,0x00,0x6F,0x00,0x66,0x00,0x74,0x00,0x2E,0x00,0x63,0x00,0x6F,0x00, 0x6D,0x00,0x2F,0x00,0x44,0x00,0x52,0x00,0x4D,0x00,0x2F,0x00,0x32,0x00,0x30,0x00,0x30,0x00,0x37,0x00,0x2F,0x00,0x30,0x00,0x33,0x00,0x2F,0x00,0x50,0x00, 0x6C,0x00,0x61,0x00,0x79,0x00,0x52,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x79,0x00,0x48,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x65,0x00,0x72,0x00,0x22,0x00, 0x20,0x00,0x76,0x00,0x65,0x00,0x72,0x00,0x73,0x00,0x69,0x00,0x6F,0x00,0x6E,0x00,0x3D,0x00,0x22,0x00,0x34,0x00,0x2E,0x00,0x30,0x00,0x2E,0x00,0x30,0x00, 0x2E,0x00,0x30,0x00,0x22,0x00,0x3E,0x00,0x3C,0x00,0x44,0x00,0x41,0x00,0x54,0x00,0x41,0x00,0x3E,0x00,0x3C,0x00,0x50,0x00,0x52,0x00,0x4F,0x00,0x54,0x00, 0x45,0x00,0x43,0x00,0x54,0x00,0x49,0x00,0x4E,0x00,0x46,0x00,0x4F,0x00,0x3E,0x00,0x3C,0x00,0x4B,0x00,0x45,0x00,0x59,0x00,0x4C,0x00,0x45,0x00,0x4E,0x00, 0x3E,0x00,0x31,0x00,0x36,0x00,0x3C,0x00,0x2F,0x00,0x4B,0x00,0x45,0x00,0x59,0x00,0x4C,0x00,0x45,0x00,0x4E,0x00,0x3E,0x00,0x3C,0x00,0x41,0x00,0x4C,0x00, 0x47,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x41,0x00,0x45,0x00,0x53,0x00,0x43,0x00,0x54,0x00,0x52,0x00,0x3C,0x00,0x2F,0x00,0x41,0x00,0x4C,0x00,0x47,0x00, 0x49,0x00,0x44,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00,0x50,0x00,0x52,0x00,0x4F,0x00,0x54,0x00,0x45,0x00,0x43,0x00,0x54,0x00,0x49,0x00,0x4E,0x00,0x46,0x00, 0x4F,0x00,0x3E,0x00,0x3C,0x00,0x4B,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x41,0x00,0x6D,0x00,0x66,0x00,0x6A,0x00,0x43,0x00,0x54,0x00,0x4F,0x00,0x50,0x00, 0x62,0x00,0x45,0x00,0x4F,0x00,0x6C,0x00,0x33,0x00,0x57,0x00,0x44,0x00,0x2F,0x00,0x35,0x00,0x6D,0x00,0x63,0x00,0x65,0x00,0x63,0x00,0x41,0x00,0x3D,0x00, 0x3D,0x00,0x3C,0x00,0x2F,0x00,0x4B,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x3C,0x00,0x43,0x00,0x48,0x00,0x45,0x00,0x43,0x00,0x4B,0x00,0x53,0x00,0x55,0x00, 0x4D,0x00,0x3E,0x00,0x42,0x00,0x47,0x00,0x77,0x00,0x31,0x00,0x61,0x00,0x59,0x00,0x5A,0x00,0x31,0x00,0x59,0x00,0x58,0x00,0x4D,0x00,0x3D,0x00,0x3C,0x00, 0x2F,0x00,0x43,0x00,0x48,0x00,0x45,0x00,0x43,0x00,0x4B,0x00,0x53,0x00,0x55,0x00,0x4D,0x00,0x3E,0x00,0x3C,0x00,0x43,0x00,0x55,0x00,0x53,0x00,0x54,0x00, 0x4F,0x00,0x4D,0x00,0x41,0x00,0x54,0x00,0x54,0x00,0x52,0x00,0x49,0x00,0x42,0x00,0x55,0x00,0x54,0x00,0x45,0x00,0x53,0x00,0x3E,0x00,0x3C,0x00,0x49,0x00, 0x49,0x00,0x53,0x00,0x5F,0x00,0x44,0x00,0x52,0x00,0x4D,0x00,0x5F,0x00,0x56,0x00,0x45,0x00,0x52,0x00,0x53,0x00,0x49,0x00,0x4F,0x00,0x4E,0x00,0x3E,0x00, 0x37,0x00,0x2E,0x00,0x31,0x00,0x2E,0x00,0x31,0x00,0x30,0x00,0x36,0x00,0x34,0x00,0x2E,0x00,0x30,0x00,0x3C,0x00,0x2F,0x00,0x49,0x00,0x49,0x00,0x53,0x00, 0x5F,0x00,0x44,0x00,0x52,0x00,0x4D,0x00,0x5F,0x00,0x56,0x00,0x45,0x00,0x52,0x00,0x53,0x00,0x49,0x00,0x4F,0x00,0x4E,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00, 0x43,0x00,0x55,0x00,0x53,0x00,0x54,0x00,0x4F,0x00,0x4D,0x00,0x41,0x00,0x54,0x00,0x54,0x00,0x52,0x00,0x49,0x00,0x42,0x00,0x55,0x00,0x54,0x00,0x45,0x00, 0x53,0x00,0x3E,0x00,0x3C,0x00,0x4C,0x00,0x41,0x00,0x5F,0x00,0x55,0x00,0x52,0x00,0x4C,0x00,0x3E,0x00,0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00,0x3A,0x00, 0x2F,0x00,0x2F,0x00,0x70,0x00,0x6C,0x00,0x61,0x00,0x79,0x00,0x72,0x00,0x65,0x00,0x61,0x00,0x64,0x00,0x79,0x00,0x2E,0x00,0x64,0x00,0x69,0x00,0x72,0x00, 0x65,0x00,0x63,0x00,0x74,0x00,0x74,0x00,0x61,0x00,0x70,0x00,0x73,0x00,0x2E,0x00,0x6E,0x00,0x65,0x00,0x74,0x00,0x2F,0x00,0x70,0x00,0x72,0x00,0x2F,0x00, 0x73,0x00,0x76,0x00,0x63,0x00,0x2F,0x00,0x72,0x00,0x69,0x00,0x67,0x00,0x68,0x00,0x74,0x00,0x73,0x00,0x6D,0x00,0x61,0x00,0x6E,0x00,0x61,0x00,0x67,0x00, 0x65,0x00,0x72,0x00,0x2E,0x00,0x61,0x00,0x73,0x00,0x6D,0x00,0x78,0x00,0x3C,0x00,0x2F,0x00,0x4C,0x00,0x41,0x00,0x5F,0x00,0x55,0x00,0x52,0x00,0x4C,0x00, 0x3E,0x00,0x3C,0x00,0x44,0x00,0x53,0x00,0x5F,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x41,0x00,0x48,0x00,0x2B,0x00,0x30,0x00,0x33,0x00,0x6A,0x00,0x75,0x00, 0x4B,0x00,0x62,0x00,0x55,0x00,0x47,0x00,0x62,0x00,0x48,0x00,0x6C,0x00,0x31,0x00,0x56,0x00,0x2F,0x00,0x51,0x00,0x49,0x00,0x77,0x00,0x52,0x00,0x41,0x00, 0x3D,0x00,0x3D,0x00,0x3C,0x00,0x2F,0x00,0x44,0x00,0x53,0x00,0x5F,0x00,0x49,0x00,0x44,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00,0x44,0x00,0x41,0x00,0x54,0x00, 0x41,0x00,0x3E,0x00,0x3C,0x00,0x2F,0x00,0x57,0x00,0x52,0x00,0x4D,0x00,0x48,0x00,0x45,0x00,0x41,0x00,0x44,0x00,0x45,0x00,0x52,0x00,0x3E,0x00,0x00,0x00}; memset(&license_info, 0x00, sizeof(drm_trusted_piff_get_license_info_s)); license_info.lic_header.header = (unsigned char*)ContentHeader; license_info.lic_header.header_len = sizeof(ContentHeader); ret = drm_trusted_handle_request(request_type,(void *)&license_info,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("PIFF_GET_LICENSE Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("PIFF_GET_LICENSE Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE: { int ret = -1; drm_trusted_sapps_decrypt_package_info_s package_info; memset(&package_info, 0x00, sizeof(drm_trusted_sapps_decrypt_package_info_s)); DRM_TRUSTED_CLIENT_TEST_LOG("Enter Samsung Apps DRM File Path"); scanf("%s",package_info.sadcf_filepath); DRM_TRUSTED_CLIENT_TEST_LOG("Enter Decrypted File Path"); scanf("%s",package_info.decrypt_filepath); DRM_TRUSTED_CLIENT_TEST_LOG("SamsungAppsDRMFilePath=%s",package_info.sadcf_filepath); DRM_TRUSTED_CLIENT_TEST_LOG("Decrypted-FilePath=%s",package_info.decrypt_filepath); ret = drm_trusted_handle_request(request_type,(void *)&package_info,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("SAPPS_DECRYPT_PACKAGE Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("SAPPS_DECRYPT_PACKAGE Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_SAPPS_CONSUME_LICENSE: { int ret = -1; drm_trusted_sapps_consume_license_info_s cons_license_info; memset(&cons_license_info, 0x00, sizeof(drm_trusted_sapps_consume_license_info_s)); ret = drm_trusted_handle_request(request_type,(void *)&cons_license_info,NULL); DRM_TRUSTED_CLIENT_TEST_LOG("ret=0x%x", ret); if (DRM_TRUSTED_RETURN_SUCCESS == ret) { DRM_TRUSTED_CLIENT_TEST_LOG("SAPPS_CONSUME_LICENSE Success!!"); } else { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("SAPPS_CONSUME_LICENSE Failed!!, ret=0x%x", ret); } break; } case DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_PURCHASE_REQUEST: { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Test-environment is not available:" "DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_PURCHASE_REQUEST"); break; } case DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_LICENSE_REQUEST: { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Test-environment is not available:" "DRM_TRUSTED_REQ_TYPE_SAPPS_GENERATE_LICENSE_REQUEST"); break; } default: { DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Invalid option!!"); break; } } break; } case DRM_TRUSTED_CLIENT_TEST_consume_content: { DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_CLIENT_TEST_consume_content"); test_consume_content(); break; } case DRM_TRUSTED_CLIENT_TEST_CONVERT: { DRM_TRUSTED_CLIENT_TEST_LOG("Your choice is DRM_TRUSTED_CLIENT_TEST_CONVERT"); DRM_TRUSTED_CLIENT_TEST_LOG("Enter complete Source file path"); scanf("%s", filePath); DRM_TRUSTED_CLIENT_TEST_LOG("Enter complete Destination file path"); scanf("%s", distfilePath); DRM_TRUSTED_CLIENT_TEST_LOG("test_convert: sourcefile=%s destfile=%s",filePath,distfilePath); test_convert(filePath,distfilePath); DRM_TRUSTED_CLIENT_TEST_LOG("test_convert finishes"); break; } case DRM_TRUSTED_CLIENT_TEST_MAX: { DRM_TRUSTED_CLIENT_TEST_LOG("DRM_TRUSTED_CLIENT_TEST_MAX"); DRM_TRUSTED_CLIENT_TEST_LOG("SUCCESS"); return 0; } default: DRM_TRUSTED_CLIENT_TEST_EXCEPTION("Wrong choice=%d",option); goto ERR; } DRM_TRUSTED_CLIENT_TEST_LOG("SUCCESS"); return 1; ERR: DRM_TRUSTED_CLIENT_TEST_EXCEPTION("test_case:Error:Exit from DRM CLIENT Test utility"); return 0; } int main(int argc, char* argv[]) { int pid = getpid(); int choice = DRM_TRUSTED_CLIENT_TEST_NONE; DRM_TRUSTED_CLIENT_TEST_LOG("main:pid=[%d]", pid); do { DRM_TRUSTED_CLIENT_TEST_LOG("choice=%d -> DRM_TRUSTED_CLIENT_TEST_NONE",DRM_TRUSTED_CLIENT_TEST_NONE); DRM_TRUSTED_CLIENT_TEST_LOG("choice=%d -> DRM_TRUSTED_CLIENT_TEST_handle_request",DRM_TRUSTED_CLIENT_TEST_handle_request); DRM_TRUSTED_CLIENT_TEST_LOG("choice=%d -> DRM_TRUSTED_CLIENT_TEST_consume_content",DRM_TRUSTED_CLIENT_TEST_consume_content); DRM_TRUSTED_CLIENT_TEST_LOG("choice=%d -> DRM_TRUSTED_CLIENT_TEST_CONVERT",DRM_TRUSTED_CLIENT_TEST_CONVERT); DRM_TRUSTED_CLIENT_TEST_LOG("choice=%d -> Exit from TEST Script",DRM_TRUSTED_CLIENT_TEST_MAX); DRM_TRUSTED_CLIENT_TEST_LOG("Enter Your choice:1 to %d:Use choice no-%d to exit the test-program",DRM_TRUSTED_CLIENT_TEST_MAX, DRM_TRUSTED_CLIENT_TEST_MAX); scanf("%3d", &choice); } while (1 == test_case(choice)); DRM_TRUSTED_CLIENT_TEST_LOG("Exiting process=[%d] from main", pid); return 0; }