Remove tz platform config devel dependency
[platform/core/security/drm-service-core-tizen.git] / test / drm_testapps.cpp
1 /*
2  * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "drm-tizen-apps.h"
18 #include "drm-tizen-error.h"
19 #include "TADC_Core.h"
20 #include "TADC_IF.h"
21 #include "DrmFileMgr.h"
22
23 #include "DTapps2Rights.h"
24 #include "drm_testutil.h"
25 #include <tzplatform_config.h>
26
27 #if 1
28 static int first_key = 0;
29 static int second_key = 0;
30 static int third_key = 0;
31
32 bool _write_logfile(const char *filename, char *buf, unsigned int len)
33 {
34         FILE *fd = NULL;
35         
36         if ((fd = fopen(filename,"w+b")) == NULL)
37         {
38                 return false;
39         }
40
41         fwrite(buf, 1, len,fd); 
42         fclose(fd);
43
44         return true;
45 }
46
47 bool _read_logfile(const char *filename, char *buf, unsigned int *pLen)
48 {
49         FILE *fd = NULL;
50         int  nReadLen = 0;
51         
52         if ((fd = fopen(filename,"r+b")) == NULL)
53         {
54                 return false;
55         }
56
57         nReadLen = fread(buf, 1, *pLen,fd); 
58         *pLen = nReadLen;
59
60         fclose(fd);
61
62         return true;
63 }
64
65 bool tc01_VerifyRoSignature_Positive_01(void)
66 {
67         char Buf[1024*10] = {0, };      
68         const char *pRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.ro");
69
70         FILE *fd = NULL;
71         int     nReadLen = 0;
72         long lSize = 0;
73         int nRet = 0;
74
75         printf("tc01_VerifyRoSignature_Positive_01() -------- Started! \n");
76
77         fd = fopen(pRo, "rb");
78         if (fd == NULL)
79         {
80                 printf("File is not exist! : %s\n", pRo);
81                 goto CATCH;
82         }
83
84         fseek(fd, 0, SEEK_END);
85         lSize = ftell(fd);
86         if (lSize < 0)
87         {
88                 printf("fseek() and ftell() failed.");
89                 goto CATCH;
90         }
91         rewind(fd);
92
93         memset(Buf, 0x00, sizeof(Buf));
94         nReadLen = fread(Buf, 1, lSize, fd);
95         if (nReadLen >= sizeof(Buf))
96         {
97                 printf("Buffer error! : %s\n", pRo);
98                 goto CATCH;
99         }
100
101         if (nReadLen != lSize)
102         {
103                 printf("File read error! : %s\n", pRo);
104                 goto CATCH;
105         }
106
107         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
108         if (nRet != 0)
109         {
110                 printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
111                 goto CATCH;
112         }
113         if (fd != NULL)
114         {
115                 fclose(fd);
116         }
117
118         printf("tc01_VerifyRoSignature_Positive_01() finished! -------- success \n");
119         return true;
120
121 CATCH:
122         if (fd != NULL)
123         {
124                 fclose(fd);
125         }
126         return false;
127 }
128
129 bool tc01_VerifyRoSignature_Positive_02(void)
130 {
131         char Buf[1024*10] = {0, };      
132         const char *pRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/8SPXfqc6iL-1.0.0.ro");
133
134         FILE *fd = NULL;
135         int     nReadLen = 0;
136         long lSize = 0;
137         int nRet = 0;
138
139         printf("tc01_VerifyRoSignature_Positive_02() -------- Started! \n");
140
141         fd = fopen(pRo, "rb");
142         if (fd == NULL)
143         {
144                 printf("File is not exist! : %s\n", pRo);
145                 goto CATCH;
146         }
147
148         fseek(fd, 0, SEEK_END);
149         lSize = ftell(fd);
150         if (lSize < 0)
151         {
152                 printf("fseek() and ftell() failed.");
153                 goto CATCH;
154         }
155         rewind(fd);
156
157         memset(Buf, 0x00, sizeof(Buf));
158         nReadLen = fread(Buf, 1, lSize, fd);
159         if (nReadLen >= sizeof(Buf))
160         {
161                 printf("Buffer error! : %s\n", pRo);
162                 goto CATCH;
163         }
164
165         if (nReadLen != lSize)
166         {
167                 printf("File read error! : %s\n", pRo);
168                 goto CATCH;
169         }
170
171         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
172         if (nRet != 0)
173         {
174                 printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
175                 goto CATCH;
176         }
177         if (fd != NULL)
178         {
179                 fclose(fd);
180         }
181
182         printf("tc01_VerifyRoSignature_Positive_02() finished! -------- success \n");
183         return true;
184
185 CATCH:
186         if (fd != NULL)
187         {
188                 fclose(fd);
189         }
190         return false;
191 }
192
193 bool tc01_VerifyRoSignature_Positive_03(void)
194 {
195         char Buf[1024*10] = {0, };      
196         const char *pRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/FightGuiIF-1.0.0.ro");
197
198         FILE *fd = NULL;
199         int     nReadLen = 0;
200         long lSize = 0;
201         int nRet = 0;
202
203         printf("tc01_VerifyRoSignature_Positive_03() -------- Started! \n");
204
205         fd = fopen(pRo, "rb");
206         if (fd == NULL)
207         {
208                 printf("File is not exist! : %s\n", pRo);
209                 goto CATCH;
210         }
211
212         fseek(fd, 0, SEEK_END);
213         lSize = ftell(fd);
214         if (lSize < 0)
215         {
216                 printf("fseek() and ftell() failed.");
217                 goto CATCH;
218         }
219         rewind(fd);
220
221         memset(Buf, 0x00, sizeof(Buf));
222         nReadLen = fread(Buf, 1, lSize, fd);
223         if (nReadLen >= sizeof(Buf))
224         {
225                 printf("Buffer error! : %s\n", pRo);
226                 goto CATCH;
227         }
228
229         if (nReadLen != lSize)
230         {
231                 printf("File read error! : %s\n", pRo);
232                 goto CATCH;
233         }
234
235         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
236         if (nRet != 0)
237         {
238                 printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
239                 goto CATCH;
240         }
241         if (fd != NULL)
242         {
243                 fclose(fd);
244         }
245
246         printf("tc01_VerifyRoSignature_Positive_03() finished! -------- success \n");
247         return true;
248
249 CATCH:
250         if (fd != NULL)
251         {
252                 fclose(fd);
253         }
254         return false;
255 }
256
257 bool tc02_VerifyRoSignature_Negative_Cert_01(void)
258 {
259         char Buf[1024*10] = {0, };      
260         const char *pRo  = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.cert_only_selfsigned.ro");
261         FILE *fd = NULL;
262         int     nReadLen = 0;
263         long lSize = 0;
264         int nRet = 0;
265
266         printf("tc02_VerifyRoSignature_Negative_Cert_01() -------- Started! \n");
267
268         fd = fopen(pRo, "rb");
269         if (fd == NULL)
270         {
271                 printf("File is not exist! : %s\n", pRo);
272                 goto CATCH;
273         }
274
275         fseek(fd, 0, SEEK_END);
276         lSize = ftell(fd);
277         if (lSize < 0)
278         {
279                 printf("fseek() and ftell() failed.");
280                 goto CATCH;
281         }
282         rewind(fd);
283
284         memset(Buf, 0x00, sizeof(Buf));
285         nReadLen = fread(Buf, 1, lSize, fd);
286         if (nReadLen >= sizeof(Buf))
287         {
288                 printf("Buffer error! : %s\n", pRo);
289                 goto CATCH;
290         }
291
292         if (nReadLen != lSize)
293         {
294                 printf("File read error! : %s\n", pRo);
295                 goto CATCH;
296         }
297
298         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
299         if (nRet >= 0)
300         {
301                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
302                 goto CATCH;
303         }
304         if (fd != NULL)
305         {
306                 fclose(fd);
307         }
308
309         printf("tc02_VerifyRoSignature_Negative_Cert_01 finished! -------- success \n");
310         return true;
311
312 CATCH:
313         if (fd != NULL)
314         {
315                 fclose(fd);
316         }
317         return false;
318 }
319
320 bool tc02_VerifyRoSignature_Negative_Cert_02(void)
321 {
322         char Buf[1024*10] = {0, };      
323         const char *pRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.cert_chain_invalid.ro");
324         FILE *fd = NULL;
325         int     nReadLen = 0;
326         long lSize = 0;
327         int nRet = 0;
328
329         printf("tc02_VerifyRoSignature_Negative_Cert_02() -------- Started! \n");
330
331         fd = fopen(pRo, "rb");
332         if (fd == NULL)
333         {
334                 printf("File is not exist! : %s\n", pRo);
335                 goto CATCH;
336         }
337
338         fseek(fd, 0, SEEK_END);
339         lSize = ftell(fd);
340         if (lSize < 0)
341         {
342                 printf("fseek() and ftell() failed.");
343                 goto CATCH;
344         }
345         rewind(fd);
346
347         memset(Buf, 0x00, sizeof(Buf));
348         nReadLen = fread(Buf, 1, lSize, fd);
349         if (nReadLen >= sizeof(Buf))
350         {
351                 printf("Buffer error! : %s\n", pRo);
352                 goto CATCH;
353         }
354
355         if (nReadLen != lSize)
356         {
357                 printf("File read error! : %s\n", pRo);
358                 goto CATCH;
359         }
360
361         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
362         if (nRet >= 0)
363         {
364                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
365                 goto CATCH;
366         }
367         if (fd != NULL)
368         {
369                 fclose(fd);
370         }
371
372         printf("tc02_VerifyRoSignature_Negative_Cert_02 finished! -------- success \n");
373         return true;
374
375 CATCH:
376         if (fd != NULL)
377         {
378                 fclose(fd);
379         }
380         return false;
381 }
382
383 bool tc02_VerifyRoSignature_Negative_Cert_03(void)
384 {
385         char Buf[1024*10] = {0, };      
386         const char *pRo  = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.cert_invalid.ro");
387         FILE *fd = NULL;
388         int     nReadLen = 0;
389         long lSize = 0;
390         int nRet = 0;
391
392         printf("tc02_VerifyRoSignature_Negative_Cert_03() -------- Started! \n");
393
394         fd = fopen(pRo, "rb");
395         if (fd == NULL)
396         {
397                 printf("File is not exist! : %s\n", pRo);
398                 goto CATCH;
399         }
400
401         fseek(fd, 0, SEEK_END);
402         lSize = ftell(fd);
403         if (lSize < 0)
404         {
405                 printf("fseek() and ftell() failed.");
406                 goto CATCH;
407         }
408         rewind(fd);
409
410         memset(Buf, 0x00, sizeof(Buf));
411         nReadLen = fread(Buf, 1, lSize, fd);
412         if (nReadLen >= sizeof(Buf))
413         {
414                 printf("Buffer error! : %s\n", pRo);
415                 goto CATCH;
416         }
417
418         if (nReadLen != lSize)
419         {
420                 printf("File read error! : %s\n", pRo);
421                 goto CATCH;
422         }
423
424         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
425         if (nRet >= 0)
426         {
427                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
428                 goto CATCH;
429         }
430         if (fd != NULL)
431         {
432                 fclose(fd);
433         }
434
435         printf("tc02_VerifyRoSignature_Negative_Cert_03 finished! -------- success \n");
436         return true;
437
438 CATCH:
439         if (fd != NULL)
440         {
441                 fclose(fd);
442         }
443         return false;
444 }
445
446 bool tc03_VerifyRoSignature_Negative_Signature_01(void)
447 {
448         char Buf[1024*10] = {0, };      
449         const char *pRo   = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/FightGuiIF-1.0.0.signature_invalid.ro");
450         FILE *fd = NULL;
451         int     nReadLen = 0;
452         long lSize = 0;
453         int nRet = 0;
454
455         printf("tc03_VerifyRoSignature_Negative_Signature_01() -------- Started! \n");
456
457         fd = fopen(pRo, "rb");
458         if (fd == NULL)
459         {
460                 printf("File is not exist! : %s\n", pRo);
461                 goto CATCH;
462         }
463
464         fseek(fd, 0, SEEK_END);
465         lSize = ftell(fd);
466         if (lSize < 0)
467         {
468                 printf("fseek() and ftell() failed.");
469                 goto CATCH;
470         }
471         rewind(fd);
472
473         memset(Buf, 0x00, sizeof(Buf));
474         nReadLen = fread(Buf, 1, lSize, fd);
475         if (nReadLen >= sizeof(Buf))
476         {
477                 printf("Buffer error! : %s\n", pRo);
478                 goto CATCH;
479         }
480
481         if (nReadLen != lSize)
482         {
483                 printf("File read error! : %s\n", pRo);
484                 goto CATCH;
485         }
486
487         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
488         if (nRet >= 0)
489         {
490                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
491                 goto CATCH;
492         }
493         if (fd != NULL)
494         {
495                 fclose(fd);
496         }
497
498         printf("tc03_VerifyRoSignature_Negative_Signature_01() finished! -------- success \n");
499
500         return true;
501
502 CATCH:
503         if (fd != NULL)
504         {
505                 fclose(fd);
506         }
507         return false;
508 }
509
510 bool tc03_VerifyRoSignature_Negative_Signature_02(void)
511 {
512         char Buf[1024*10] = {0, };      
513         const char *pRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.signature_invalid.ro");
514         FILE *fd = NULL;
515         int     nReadLen = 0;
516         long lSize = 0;
517         int nRet = 0;
518
519         printf("tc03_VerifyRoSignature_Negative_Signature_02() -------- Started! \n");
520
521         fd = fopen(pRo, "rb");
522         if (fd == NULL)
523         {
524                 printf("File is not exist! : %s\n", pRo);
525                 goto CATCH;
526         }
527
528         fseek(fd, 0, SEEK_END);
529         lSize = ftell(fd);
530         if (lSize < 0)
531         {
532                 printf("fseek() and ftell() failed.");
533                 goto CATCH;
534         }
535         rewind(fd);
536
537         memset(Buf, 0x00, sizeof(Buf));
538         nReadLen = fread(Buf, 1, lSize, fd);
539         if (nReadLen >= sizeof(Buf))
540         {
541                 printf("Buffer error! : %s\n", pRo);
542                 goto CATCH;
543         }
544
545         if (nReadLen != lSize)
546         {
547                 printf("File read error! : %s\n", pRo);
548                 goto CATCH;
549         }
550
551         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
552         if (nRet >= 0)
553         {
554                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
555                 goto CATCH;
556         }
557         if (fd != NULL)
558         {
559                 fclose(fd);
560         }
561
562         printf("tc03_VerifyRoSignature_Negative_Signature_01() finished! -------- success \n");
563
564         return true;
565
566 CATCH:
567         if (fd != NULL)
568         {
569                 fclose(fd);
570         }
571         return false;
572 }
573
574 bool tc03_VerifyRoSignature_Negative_Signature_03(void)
575 {
576         char Buf[1024*10] = {0, };      
577         const char *pRo  = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/8SPXfqc6iL-1.0.0.signature_invalid.ro");
578         FILE *fd = NULL;
579         int     nReadLen = 0;
580         long lSize = 0;
581         int nRet = 0;
582
583         printf("tc03_VerifyRoSignature_Negative_Signature_03() -------- Started! \n");
584
585         fd = fopen(pRo, "rb");
586         if (fd == NULL)
587         {
588                 printf("File is not exist! : %s\n", pRo);
589                 goto CATCH;
590         }
591
592         fseek(fd, 0, SEEK_END);
593         lSize = ftell(fd);
594         if (lSize < 0)
595         {
596                 printf("fseek() and ftell() failed.");
597                 goto CATCH;
598         }
599         rewind(fd);
600
601         memset(Buf, 0x00, sizeof(Buf));
602         nReadLen = fread(Buf, 1, lSize, fd);
603         if (nReadLen >= sizeof(Buf))
604         {
605                 printf("Buffer error! : %s\n", pRo);
606                 goto CATCH;
607         }
608
609         if (nReadLen != lSize)
610         {
611                 printf("File read error! : %s\n", pRo);
612                 goto CATCH;
613         }
614
615         nRet = TADC_VerifyROSignature((unsigned char*) Buf);
616         if (nRet >= 0)
617         {
618                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
619                 goto CATCH;
620         }
621         if (fd != NULL)
622         {
623                 fclose(fd);
624         }
625
626         printf("tc03_VerifyRoSignature_Negative_Signature_03() finished! -------- success \n");
627
628         return true;
629
630 CATCH:
631         if (fd != NULL)
632         {
633                 fclose(fd);
634         }
635         return false;
636 }
637
638 bool tc04_isDrmFile_Positive_01(void)
639 {
640         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/38EIfBurLJ.tpk");
641         int nRet = 0;
642
643         printf("tc04_isDrmFile_Positive_01() -------- Started!\n");
644
645         nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
646         if (nRet != TADC_SUCCESS)
647         {
648                 printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
649                 printf("%s file is not TADC file!\n", pDCF);
650                 return false;
651         }
652
653         printf("tc04_isDrmFile_Positive_01() finished! -------- success \n");
654
655         return true;
656 }
657
658 bool tc04_isDrmFile_Positive_02(void)
659 {
660         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/8SPXfqc6iL.tpk");
661         int nRet = 0;
662
663         printf("tc04_isDrmFile_Positive_02() -------- Started!\n");
664
665         nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
666         if (nRet != TADC_SUCCESS)
667         {
668                 printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
669                 printf("%s file is not TADC file!\n", pDCF);
670                 return false;
671         }
672
673         printf("tc04_isDrmFile_Positive_02() finished! -------- success \n");
674
675         return true;
676 }
677
678 bool tc04_isDrmFile_Positive_03(void)
679 {
680         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/FightGuiIF.tpk");
681         int nRet = 0;
682
683         printf("tc04_isDrmFile_Positive_03() -------- Started!\n");
684
685         nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
686         if (nRet != TADC_SUCCESS)
687         {
688                 printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
689                 printf("%s file is not TADC file!\n", pDCF);
690                 return false;
691         }
692
693         printf("tc04_isDrmFile_Positive_03() finished! -------- success \n");
694
695         return true;
696 }
697
698 bool tc05_isDrmFile_Negative_01(void)
699 {
700         const char *pApp = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DecryptedApp/38EIfBurLJ_dec.tpk");
701         int nRet = 0;
702
703         printf("tc05_isDrmFile_Negative_01() -------- Started! \n");
704
705         nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
706         if(nRet == TADC_SUCCESS)
707         {
708                 printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
709                 return false;
710         }
711
712         printf("tc05_isDrmFile_Negative_01 finished! -------- success \n");
713
714         return true;
715 }
716
717 bool tc05_isDrmFile_Negative_02(void)
718 {
719         const char *pApp = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DecryptedApp/8SPXfqc6iL_dec.tpk");
720         int nRet = 0;
721
722         printf("tc05_isDrmFile_Negative_02() -------- Started! \n");
723
724         nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
725         if(nRet == TADC_SUCCESS)
726         {
727                 printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
728                 return false;
729         }
730
731         printf("tc05_isDrmFile_Negative_02 finished! -------- success \n");
732
733         return true;
734 }
735
736 bool tc05_isDrmFile_Negative_03(void)
737 {
738         const char *pApp = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DecryptedApp/FightGuiIF_dec.tpk");
739         int nRet = 0;
740
741         printf("tc05_isDrmFile_Negative_03() -------- Started! \n");
742
743         nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
744         if(nRet == TADC_SUCCESS)
745         {
746                 printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
747                 return false;
748         }
749
750         printf("tc05_isDrmFile_Negative_03 finished! -------- success \n");
751
752         return true;
753 }
754
755 bool
756 tc06_DrmFileHandlerPositive_01(void)
757 {
758         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/38EIfBurLJ.tpk");
759         DrmFileHandler* pDcfHandler = NULL;
760         unsigned char* pBufCEK = NULL;
761         unsigned char pCEK[CEK_SIZE + 1] = {0xB1, 0x03, 0x4F, 0x30, 0xC8, 0x52, 0x45, 0x7E, 0x9D, 0xA2, 0x52, 0x25, 0x2E, 0xA9, 0x9B, 0x2B, 0x25, 0x36, 0xF1, 0x8D, 0x04, 0xD1, 0x4C, 0xE3, 0x96, 0x81, 0xD9, 0x98, 0xBB, 0xD7, 0x7E, 0xCA, 0x00};
762         unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
763
764         long encryptionLevel = 17;
765         long long encryptionRange = 10;
766         long long plainTextSize = 1630724;
767         long long originalEndOffset = 1631570;
768         int nRet = 0;
769
770         printf("tc06_DrmFileHandlerPositive_01() -------- Started! \n");
771
772         pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
773         memset(pBufCEK, 0x00, CEK_SIZE + 1);
774
775         pDcfHandler = new DrmFileHandler();
776         if (pDcfHandler == NULL)
777         {
778                 goto CATCH;
779         }
780
781         nRet = pDcfHandler->Construct(pDCF);
782         if (nRet != 1)
783         {
784                 printf("tc06_DrmFileHandlerPositive_01 - Construct() failed : %s, %x\n", pDCF, nRet);
785                 goto CATCH;
786         }
787
788         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
789         {
790                 printf("tc06_DrmFileHandlerPositive_01 - CEK Comparison failed : %s\n", pDCF);
791                 goto CATCH;
792         }
793
794         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
795         {
796                 printf("tc06_DrmFileHandlerPositive_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
797                 goto CATCH;
798         }
799
800         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
801         {
802                 printf("tc06_DrmFileHandlerPositive_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
803                 goto CATCH;
804         }
805
806         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
807         {
808                 printf("tc06_DrmFileHandlerPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
809                 goto CATCH;
810         }
811
812         if (pDcfHandler->m_encryptionRange != encryptionRange)
813         {
814                 printf("tc06_DrmFileHandlerPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
815                 goto CATCH;
816         }
817
818         if (pDcfHandler->m_plaintextSize != plainTextSize)
819         {
820                 printf("tc06_DrmFileHandlerPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
821                 goto CATCH;
822         }
823
824         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
825         {
826                 printf("tc06_DrmFileHandlerPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
827                 goto CATCH;
828         }
829
830         if (pDcfHandler != NULL)
831         {
832                 delete pDcfHandler;
833         }
834
835         if (pBufCEK != NULL)
836         {
837                 free(pBufCEK);
838         }
839
840         printf("tc06_DrmFileHandlerPositive_01 finished! -------- success \n");
841
842         return true;
843
844 CATCH:
845         if (pDcfHandler != NULL)
846         {
847                 delete pDcfHandler;
848         }
849
850         if (pBufCEK != NULL)
851         {
852                 free(pBufCEK);
853         }
854
855         return false;
856 }
857
858 bool
859 tc06_DrmFileHandlerPositive_02(void)
860 {
861         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/8SPXfqc6iL.tpk");
862         unsigned char* pBufCEK = NULL;
863         DrmFileHandler* pDcfHandler = NULL;
864         unsigned char pCEK[CEK_SIZE + 1] = {0xBB, 0x87, 0x5D, 0xA8, 0x2C, 0xC4, 0x47, 0x81, 0x90, 0xBA, 0xD9, 0xB0, 0x0C, 0xD2, 0x94, 0xE9, 0x19, 0x0F, 0x24, 0x62, 0x5B, 0x0B, 0x49, 0x7A, 0xAE, 0x8E, 0x1D, 0x88, 0x7F, 0xF9, 0x96, 0xDB, 0x00};
865         unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
866
867         long encryptionLevel = 17;
868         long long encryptionRange = 10;
869         long long plainTextSize = 705072;
870         long long originalEndOffset = 705914;
871         int nRet = 0;
872
873         printf("tc06_DrmFileHandlerPositive_02() -------- Started! \n");
874
875         pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
876         memset(pBufCEK, 0x00, CEK_SIZE + 1);
877
878         pDcfHandler = new DrmFileHandler();
879         if (pDcfHandler == NULL)
880         {
881                 goto CATCH;
882         }
883
884         nRet = pDcfHandler->Construct(pDCF);
885         if (nRet != 1)
886         {
887                 printf("tc06_DrmFileHandlerPositive_02 - Construct() failed : %s, %x\n", pDCF, nRet);
888                 goto CATCH;
889         }
890
891         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
892         {
893                 printf("tc06_DrmFileHandlerPositive_02 - CEK Comparison failed : %s\n", pDCF);
894                 goto CATCH;
895         }
896
897         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
898         {
899                 printf("tc06_DrmFileHandlerPositive_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
900                 goto CATCH;
901         }
902
903         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
904         {
905                 printf("tc06_DrmFileHandlerPositive_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
906                 goto CATCH;
907         }
908
909         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
910         {
911                 printf("tc06_DrmFileHandlerPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
912                 goto CATCH;
913         }
914
915         if (pDcfHandler->m_encryptionRange != encryptionRange)
916         {
917                 printf("tc06_DrmFileHandlerPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
918                 goto CATCH;
919         }
920
921         if (pDcfHandler->m_plaintextSize != plainTextSize)
922         {
923                 printf("tc06_DrmFileHandlerPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
924                 goto CATCH;
925         }
926
927         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
928         {
929                 printf("tc06_DrmFileHandlerPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
930                 goto CATCH;
931         }
932
933         if (pDcfHandler != NULL)
934         {
935                 delete pDcfHandler;
936         }
937
938         if (pBufCEK != NULL)
939         {
940                 free(pBufCEK);
941         }
942
943         printf("tc06_DrmFileHandlerPositive_02 finished! -------- success \n");
944
945         return true;
946
947 CATCH:
948         if (pDcfHandler != NULL)
949         {
950                 delete pDcfHandler;
951         }
952
953         if (pBufCEK != NULL)
954         {
955                 free(pBufCEK);
956         }
957
958         return false;
959 }
960
961 bool
962 tc06_DrmFileHandlerPositive_03(void)
963 {
964         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/FightGuiIF.tpk");
965         unsigned char* pBufCEK = NULL;
966         DrmFileHandler* pDcfHandler = NULL;
967         unsigned char pCEK[CEK_SIZE + 1] = {0x34, 0x5A, 0x94, 0x28, 0xC3, 0xF4, 0x44, 0x3F, 0x86, 0x6D, 0xCF, 0xC5, 0x78, 0x1F, 0x23, 0xCE, 0xE9, 0x9B, 0xC4, 0x45, 0xA3, 0x30, 0x47, 0x1E, 0xB4, 0xE0, 0xAF, 0x96, 0x0F, 0xDE, 0xA9, 0xB4, 0x00};
968         unsigned char pCID[32] = "FightGuiIF-1.0.0";
969
970         long encryptionLevel = 17;
971         long long encryptionRange = 10;
972         long long plainTextSize = 45193789;
973         long long originalEndOffset = 45194636;
974         int nRet = 0;
975
976         printf("tc06_DrmFileHandlerPositive_03() -------- Started! \n");
977
978         pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
979         memset(pBufCEK, 0x00, CEK_SIZE + 1);
980
981         pDcfHandler = new DrmFileHandler();
982         if (pDcfHandler == NULL)
983         {
984                 goto CATCH;
985         }
986
987         nRet = pDcfHandler->Construct(pDCF);
988         if (nRet != 1)
989         {
990                 printf("tc06_DrmFileHandlerPositive_03 - Construct() failed : %s, %x\n", pDCF, nRet);
991                 goto CATCH;
992         }
993
994         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
995         {
996                 printf("tc06_DrmFileHandlerPositive_03 - CEK Comparison failed : %s\n", pDCF);
997                 goto CATCH;
998         }
999
1000         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1001         {
1002                 printf("tc06_DrmFileHandlerPositive_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1003                 goto CATCH;
1004         }
1005
1006         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1007         {
1008                 printf("tc06_DrmFileHandlerPositive_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1009                 goto CATCH;
1010         }
1011
1012         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1013         {
1014                 printf("tc06_DrmFileHandlerPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1015                 goto CATCH;
1016         }
1017
1018         if (pDcfHandler->m_encryptionRange != encryptionRange)
1019         {
1020                 printf("tc06_DrmFileHandlerPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1021                 goto CATCH;
1022         }
1023
1024         if (pDcfHandler->m_plaintextSize != plainTextSize)
1025         {
1026                 printf("tc06_DrmFileHandlerPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1027                 goto CATCH;
1028         }
1029
1030         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1031         {
1032                 printf("tc06_DrmFileHandlerPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1033                 goto CATCH;
1034         }
1035
1036         if (pDcfHandler != NULL)
1037         {
1038                 delete pDcfHandler;
1039         }
1040
1041         if (pBufCEK != NULL)
1042         {
1043                 free(pBufCEK);
1044         }
1045
1046         printf("tc06_DrmFileHandlerPositive_03 finished! -------- success \n");
1047
1048         return true;
1049
1050 CATCH:
1051         if (pDcfHandler != NULL)
1052         {
1053                 delete pDcfHandler;
1054         }
1055
1056         if (pBufCEK != NULL)
1057         {
1058                 free(pBufCEK);
1059         }
1060
1061         return false;
1062 }
1063
1064 bool tc07_DrmFileMgrPositive_01(void)
1065 {
1066         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/38EIfBurLJ.tpk");
1067         int nRet = TADC_SUCCESS;
1068
1069         DrmFileMgr* pDrmFileMgr = NULL;
1070         DrmFileHandler *pDcfHandler = NULL;
1071
1072         unsigned char pCEK[CEK_SIZE + 1] = {0xB1, 0x03, 0x4F, 0x30, 0xC8, 0x52, 0x45, 0x7E, 0x9D, 0xA2, 0x52, 0x25, 0x2E, 0xA9, 0x9B, 0x2B, 0x25, 0x36, 0xF1, 0x8D, 0x04, 0xD1, 0x4C, 0xE3, 0x96, 0x81, 0xD9, 0x98, 0xBB, 0xD7, 0x7E, 0xCA, 0x00};
1073
1074         unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
1075         long encryptionLevel = 17;
1076         long long encryptionRange = 10;
1077         long long plainTextSize = 1630724;
1078         long long originalEndOffset = 1631570;
1079
1080         printf("tc07_DrmFileMgrPositive_01() -------- Started! \n");
1081
1082         pDrmFileMgr = DrmFileMgr::GetInstance();
1083
1084         nRet = pDrmFileMgr->OpenFileHandler(pDCF, 1, &first_key);
1085         if (nRet != TADC_SUCCESS)
1086         {
1087                 printf("tc07_DrmFileMgrPositive_01 - OpenFileHandler() failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
1088                 goto CATCH;
1089         }
1090
1091         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
1092         if (nRet != TADC_SUCCESS)
1093         {
1094                 printf("tc07_DrmFileMgrPositive_01 - GetFileHandler() failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
1095                 goto CATCH;
1096         }
1097
1098         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1099         {
1100                 printf("tc07_DrmFileMgrPositive_01 - CEK Comparison failed : %s\n", pDCF);
1101                 goto CATCH;
1102         }
1103
1104         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1105         {
1106                 printf("tc07_DrmFileMgrPositive_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1107                 goto CATCH;
1108         }
1109
1110         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1111         {
1112                 printf("tc07_DrmFileMgrPositive_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1113                 goto CATCH;
1114         }
1115
1116         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1117         {
1118                 printf("tc07_DrmFileMgrPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1119                 goto CATCH;
1120         }
1121
1122         if (pDcfHandler->m_encryptionRange != encryptionRange)
1123         {
1124                 printf("tc07_DrmFileMgrPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1125                 goto CATCH;
1126         }
1127
1128         if (pDcfHandler->m_plaintextSize != plainTextSize)
1129         {
1130                 printf("tc07_DrmFileMgrPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1131                 goto CATCH;
1132         }
1133
1134         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1135         {
1136                 printf("tc07_DrmFileMgrPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1137                 goto CATCH;
1138         }
1139
1140         printf("tc07_DrmFileMgrPositive_01 finished! -------- success \n");
1141
1142         return true;
1143
1144 CATCH:
1145
1146         return false;
1147 }
1148
1149 bool tc07_DrmFileMgrPositive_02(void)
1150 {
1151         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/8SPXfqc6iL.tpk");
1152         int nRet = TADC_SUCCESS;
1153
1154         DrmFileMgr* pDrmFileMgr = NULL;
1155         DrmFileHandler *pDcfHandler = NULL;
1156
1157         unsigned char pCEK[CEK_SIZE + 1] = {0xBB, 0x87, 0x5D, 0xA8, 0x2C, 0xC4, 0x47, 0x81, 0x90, 0xBA, 0xD9, 0xB0, 0x0C, 0xD2, 0x94, 0xE9, 0x19, 0x0F, 0x24, 0x62, 0x5B, 0x0B, 0x49, 0x7A, 0xAE, 0x8E, 0x1D, 0x88, 0x7F, 0xF9, 0x96, 0xDB, 0x00};
1158         unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
1159
1160         long encryptionLevel = 17;
1161         long long encryptionRange = 10;
1162         long long plainTextSize = 705072;
1163         long long originalEndOffset = 705914;
1164
1165         printf("tc07_DrmFileMgrPositive_02() -------- Started! \n");
1166
1167         pDrmFileMgr = DrmFileMgr::GetInstance();
1168
1169         nRet = pDrmFileMgr->OpenFileHandler(pDCF, 1, &second_key);
1170         if (nRet != TADC_SUCCESS)
1171         {
1172                 printf("tc07_DrmFileMgrPositive_02 - OpenFileHandler() failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
1173                 goto CATCH;
1174         }
1175
1176         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1177         if (nRet != TADC_SUCCESS)
1178         {
1179                 printf("tc07_DrmFileMgrPositive_02 - GetFileHandler() failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
1180                 goto CATCH;
1181         }
1182
1183         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1184         {
1185                 printf("tc07_DrmFileMgrPositive_02 - CEK Comparison failed : %s\n", pDCF);
1186                 goto CATCH;
1187         }
1188
1189         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1190         {
1191                 printf("tc07_DrmFileMgrPositive_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1192                 goto CATCH;
1193         }
1194
1195         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1196         {
1197                 printf("tc07_DrmFileMgrPositive_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1198                 goto CATCH;
1199         }
1200
1201         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1202         {
1203                 printf("tc07_DrmFileMgrPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1204                 goto CATCH;
1205         }
1206
1207         if (pDcfHandler->m_encryptionRange != encryptionRange)
1208         {
1209                 printf("tc07_DrmFileMgrPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1210                 goto CATCH;
1211         }
1212
1213         if (pDcfHandler->m_plaintextSize != plainTextSize)
1214         {
1215                 printf("tc07_DrmFileMgrPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1216                 goto CATCH;
1217         }
1218
1219         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1220         {
1221                 printf("tc07_DrmFileMgrPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1222                 goto CATCH;
1223         }
1224
1225         printf("tc07_DrmFileMgrPositive_02 finished! -------- success \n");
1226
1227         return true;
1228
1229 CATCH:
1230
1231         return false;
1232 }
1233
1234 bool tc07_DrmFileMgrPositive_03(void)
1235 {
1236         const char *pDCF  = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/FightGuiIF.tpk");
1237         int nRet = TADC_SUCCESS;
1238
1239         DrmFileMgr* pDrmFileMgr = NULL;
1240         DrmFileHandler *pDcfHandler = NULL;
1241
1242         unsigned char pCEK[CEK_SIZE + 1] = {0x34, 0x5A, 0x94, 0x28, 0xC3, 0xF4, 0x44, 0x3F, 0x86, 0x6D, 0xCF, 0xC5, 0x78, 0x1F, 0x23, 0xCE, 0xE9, 0x9B, 0xC4, 0x45, 0xA3, 0x30, 0x47, 0x1E, 0xB4, 0xE0, 0xAF, 0x96, 0x0F, 0xDE, 0xA9, 0xB4, 0x00};
1243
1244         unsigned char pCID[32] = "FightGuiIF-1.0.0";
1245
1246         long encryptionLevel = 17;
1247         long long encryptionRange = 10;
1248         long long plainTextSize = 45193789;
1249         long long originalEndOffset = 45194636;
1250
1251         printf("tc07_DrmFileMgrPositive_03() -------- Started! \n");
1252
1253         pDrmFileMgr = DrmFileMgr::GetInstance();
1254
1255         nRet = pDrmFileMgr->OpenFileHandler(pDCF, 1, &third_key);
1256         if (nRet != TADC_SUCCESS)
1257         {
1258                 printf("tc07_DrmFileMgrPositive_03 - OpenFileHandler() failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
1259                 goto CATCH;
1260         }
1261
1262         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1263         if (nRet != TADC_SUCCESS)
1264         {
1265                 printf("tc07_DrmFileMgrPositive_03 - GetFileHandler() failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
1266                 goto CATCH;
1267         }
1268
1269         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1270         {
1271                 printf("tc07_DrmFileMgrPositive_03 - CEK Comparison failed : %s\n", pDCF);
1272                 goto CATCH;
1273         }
1274
1275         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1276         {
1277                 printf("tc07_DrmFileMgrPositive_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1278                 goto CATCH;
1279         }
1280
1281         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1282         {
1283                 printf("tc07_DrmFileMgrPositive_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1284                 goto CATCH;
1285         }
1286
1287         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1288         {
1289                 printf("tc07_DrmFileMgrPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1290                 goto CATCH;
1291         }
1292
1293         if (pDcfHandler->m_encryptionRange != encryptionRange)
1294         {
1295                 printf("tc07_DrmFileMgrPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1296                 goto CATCH;
1297         }
1298
1299         if (pDcfHandler->m_plaintextSize != plainTextSize)
1300         {
1301                 printf("tc07_DrmFileMgrPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1302                 goto CATCH;
1303         }
1304
1305         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1306         {
1307                 printf("tc07_DrmFileMgrPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1308                 goto CATCH;
1309         }
1310
1311         printf("tc07_DrmFileMgrPositive_03 finished! -------- success \n");
1312
1313         return true;
1314
1315 CATCH:
1316
1317         return false;
1318 }
1319
1320 bool tc08_DrmFileMgrPositive_GetFileHandler_01(void)
1321 {
1322         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/38EIfBurLJ.tpk");
1323         int nRet = TADC_SUCCESS;
1324
1325         DrmFileMgr* pDrmFileMgr = NULL;
1326         DrmFileHandler *pDcfHandler = NULL;
1327
1328         unsigned char pCEK[CEK_SIZE + 1] = {0xB1, 0x03, 0x4F, 0x30, 0xC8, 0x52, 0x45, 0x7E, 0x9D, 0xA2, 0x52, 0x25, 0x2E, 0xA9, 0x9B, 0x2B, 0x25, 0x36, 0xF1, 0x8D, 0x04, 0xD1, 0x4C, 0xE3, 0x96, 0x81, 0xD9, 0x98, 0xBB, 0xD7, 0x7E, 0xCA, 0x00};
1329
1330         unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
1331
1332         long encryptionLevel = 17;
1333         long long encryptionRange = 10;
1334         long long plainTextSize = 1630724;
1335         long long originalEndOffset = 1631570;
1336
1337         printf("tc08_DrmFileMgrPositive_GetFileHandler_01() -------- Started! \n");
1338
1339         pDrmFileMgr = DrmFileMgr::GetInstance();
1340
1341         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
1342         if (nRet != TADC_SUCCESS)
1343         {
1344                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
1345                 goto CATCH;
1346         }
1347
1348         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1349         {
1350                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CEK Comparison failed : %s\n", pDCF);
1351                 goto CATCH;
1352         }
1353
1354         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1355         {
1356                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1357                 goto CATCH;
1358         }
1359
1360         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1361         {
1362                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1363                 goto CATCH;
1364         }
1365
1366         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1367         {
1368                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1369                 goto CATCH;
1370         }
1371
1372         if (pDcfHandler->m_encryptionRange != encryptionRange)
1373         {
1374                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1375                 goto CATCH;
1376         }
1377
1378         if (pDcfHandler->m_plaintextSize != plainTextSize)
1379         {
1380                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1381                 goto CATCH;
1382         }
1383
1384         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1385         {
1386                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1387                 goto CATCH;
1388         }
1389
1390         printf("tc08_DrmFileMgrPositive_GetFileHandler_01 finished! -------- success \n");
1391
1392         return true;
1393
1394 CATCH:
1395
1396         return false;
1397 }
1398
1399 bool tc08_DrmFileMgrPositive_GetFileHandler_02(void)
1400 {
1401         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/8SPXfqc6iL.tpk");
1402         int nRet = TADC_SUCCESS;
1403
1404         DrmFileMgr* pDrmFileMgr = NULL;
1405         DrmFileHandler *pDcfHandler = NULL;
1406
1407         unsigned char pCEK[CEK_SIZE + 1] = {0xBB, 0x87, 0x5D, 0xA8, 0x2C, 0xC4, 0x47, 0x81, 0x90, 0xBA, 0xD9, 0xB0, 0x0C, 0xD2, 0x94, 0xE9, 0x19, 0x0F, 0x24, 0x62, 0x5B, 0x0B, 0x49, 0x7A, 0xAE, 0x8E, 0x1D, 0x88, 0x7F, 0xF9, 0x96, 0xDB, 0x00};
1408
1409         unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
1410
1411         long encryptionLevel = 17;
1412         long long encryptionRange = 10;
1413         long long plainTextSize = 705072;
1414         long long originalEndOffset = 705914;
1415
1416         printf("tc08_DrmFileMgrPositive_GetFileHandler_02() -------- Started! \n");
1417
1418         pDrmFileMgr = DrmFileMgr::GetInstance();
1419
1420         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1421         if (nRet != TADC_SUCCESS)
1422         {
1423                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
1424                 goto CATCH;
1425         }
1426
1427         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1428         {
1429                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CEK Comparison failed : %s\n", pDCF);
1430                 goto CATCH;
1431         }
1432
1433         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1434         {
1435                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1436                 goto CATCH;
1437         }
1438
1439         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1440         {
1441                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1442                 goto CATCH;
1443         }
1444
1445         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1446         {
1447                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1448                 goto CATCH;
1449         }
1450
1451         if (pDcfHandler->m_encryptionRange != encryptionRange)
1452         {
1453                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1454                 goto CATCH;
1455         }
1456
1457         if (pDcfHandler->m_plaintextSize != plainTextSize)
1458         {
1459                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1460                 goto CATCH;
1461         }
1462
1463         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1464         {
1465                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1466                 goto CATCH;
1467         }
1468
1469         printf("tc08_DrmFileMgrPositive_GetFileHandler_02 finished! -------- success \n");
1470
1471         return true;
1472
1473 CATCH:
1474
1475         return false;
1476 }
1477
1478 bool tc08_DrmFileMgrPositive_GetFileHandler_03(void)
1479 {
1480         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/FightGuiIF.tpk");
1481         int nRet = TADC_SUCCESS;
1482
1483         DrmFileMgr* pDrmFileMgr = NULL;
1484         DrmFileHandler *pDcfHandler = NULL;
1485
1486         unsigned char pCEK[CEK_SIZE + 1] = {0x34, 0x5A, 0x94, 0x28, 0xC3, 0xF4, 0x44, 0x3F, 0x86, 0x6D, 0xCF, 0xC5, 0x78, 0x1F, 0x23, 0xCE, 0xE9, 0x9B, 0xC4, 0x45, 0xA3, 0x30, 0x47, 0x1E, 0xB4, 0xE0, 0xAF, 0x96, 0x0F, 0xDE, 0xA9, 0xB4, 0x00};
1487
1488         unsigned char pCID[32] = "FightGuiIF-1.0.0";
1489
1490         long encryptionLevel = 17;
1491         long long encryptionRange = 10;
1492         long long plainTextSize = 45193789;
1493         long long originalEndOffset = 45194636;
1494
1495         printf("tc08_DrmFileMgrPositive_GetFileHandler_03() -------- Started! \n");
1496
1497         pDrmFileMgr = DrmFileMgr::GetInstance();
1498
1499         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1500         if (nRet != TADC_SUCCESS)
1501         {
1502                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
1503                 goto CATCH;
1504         }
1505
1506         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1507         {
1508                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CEK Comparison failed : %s\n", pDCF);
1509                 goto CATCH;
1510         }
1511
1512         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1513         {
1514                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1515                 goto CATCH;
1516         }
1517
1518         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1519         {
1520                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1521                 goto CATCH;
1522         }
1523
1524         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1525         {
1526                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1527                 goto CATCH;
1528         }
1529
1530         if (pDcfHandler->m_encryptionRange != encryptionRange)
1531         {
1532                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1533                 goto CATCH;
1534         }
1535
1536         if (pDcfHandler->m_plaintextSize != plainTextSize)
1537         {
1538                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1539                 goto CATCH;
1540         }
1541
1542         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1543         {
1544                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1545                 goto CATCH;
1546         }
1547
1548         printf("tc08_DrmFileMgrPositive_GetFileHandler_03 finished! -------- success \n");
1549
1550         return true;
1551
1552 CATCH:
1553
1554         return false;
1555 }
1556
1557 bool tc09_DrmFileMgrPositive_FileAPI_01(void)
1558 {
1559         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/38EIfBurLJ.tpk");
1560         int nRet = TADC_SUCCESS;
1561
1562         DrmFileMgr* pDrmFileMgr = NULL;
1563         DrmFileHandler *pDcfHandler = NULL;
1564
1565         long long originalEndOffset = 1631570;
1566         long long DrmCurOffset = 0;
1567         long long OriginCurOffset = 846;
1568         long long i = 0;
1569
1570         printf("tc09_DrmFileMgrPositive_FileAPI_01() -------- Started! \n");
1571
1572         pDrmFileMgr = DrmFileMgr::GetInstance();
1573
1574         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
1575         if (nRet != TADC_SUCCESS)
1576         {
1577                 printf("tc09_DrmFileMgrPositive_FileAPI_01 failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
1578                 goto CATCH;
1579         }
1580
1581         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1582         {
1583                 printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1584                 goto CATCH;
1585         }
1586
1587         if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
1588         {
1589                 printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
1590                 goto CATCH;
1591         }
1592
1593         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1594         {
1595                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1596                 if (nRet != TADC_SUCCESS)
1597                 {
1598                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", first_key, pDCF, i, nRet);
1599                         goto CATCH;
1600                 }
1601
1602                 DrmCurOffset = pDcfHandler->DrmTell();
1603                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1604                 {
1605                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1606                         goto CATCH;
1607                 }
1608         }
1609         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1610         {
1611                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1612                 goto CATCH;
1613         }
1614
1615         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1616         {
1617                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1618                 if (nRet != TADC_SUCCESS)
1619                 {
1620                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1621                         goto CATCH;
1622                 }
1623
1624                 DrmCurOffset = pDcfHandler->DrmTell();
1625                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1626                 {
1627                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1628                         goto CATCH;
1629                 }
1630         }
1631         if (DrmCurOffset != 0)
1632         {
1633                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1634                 goto CATCH;
1635         }
1636
1637         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1638         {
1639                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1640                 if (nRet != TADC_SUCCESS)
1641                 {
1642                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1643                         goto CATCH;
1644                 }
1645
1646                 DrmCurOffset = pDcfHandler->DrmTell();
1647                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1648                 {
1649                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1650                         goto CATCH;
1651                 }
1652         }
1653         if (DrmCurOffset != 0)
1654         {
1655                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1656                 goto CATCH;
1657         }
1658
1659         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1660         {
1661                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1662                 if (nRet != TADC_SUCCESS)
1663                 {
1664                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1665                         goto CATCH;
1666                 }
1667
1668                 DrmCurOffset = pDcfHandler->DrmTell();
1669                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1670                 {
1671                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1672                         goto CATCH;
1673                 }
1674         }
1675         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1676         {
1677                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1678                 goto CATCH;
1679         }
1680
1681         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1682         {
1683                 nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
1684                 if (nRet != TADC_SUCCESS)
1685                 {
1686                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1687                         goto CATCH;
1688                 }
1689
1690                 DrmCurOffset = pDcfHandler->DrmTell();
1691                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1692                 {
1693                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
1694                         goto CATCH;
1695                 }
1696         }
1697         if (DrmCurOffset != 0)
1698         {
1699                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1700                 goto CATCH;
1701         }
1702
1703         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1704         {
1705                 nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
1706                 if (nRet != TADC_SUCCESS)
1707                 {
1708                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1709                         goto CATCH;
1710                 }
1711
1712                 DrmCurOffset = pDcfHandler->DrmTell();
1713                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1714                 {
1715                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1716                         goto CATCH;
1717                 }
1718         }
1719         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1720         {
1721                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1722                 goto CATCH;
1723         }
1724
1725         printf("tc09_DrmFileMgrPositive_FileAPI_01 finished! -------- success \n");
1726
1727         return true;
1728
1729 CATCH:
1730         return false;
1731 }
1732
1733 bool tc09_DrmFileMgrPositive_FileAPI_02(void)
1734 {
1735         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/8SPXfqc6iL.tpk");
1736         int nRet = TADC_SUCCESS;
1737
1738         DrmFileMgr* pDrmFileMgr = NULL;
1739         DrmFileHandler *pDcfHandler = NULL;
1740
1741         long long originalEndOffset = 705914;
1742         long long DrmCurOffset = 0;
1743         long long OriginCurOffset = 842;
1744         long long i = 0;
1745
1746         printf("tc09_DrmFileMgrPositive_FileAPI_02() -------- Started! \n");
1747
1748         pDrmFileMgr = DrmFileMgr::GetInstance();
1749
1750         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1751         if (nRet != TADC_SUCCESS)
1752         {
1753                 printf("tc09_DrmFileMgrPositive_FileAPI_02 failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
1754                 goto CATCH;
1755         }
1756
1757         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1758         {
1759                 printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1760                 goto CATCH;
1761         }
1762
1763         if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
1764         {
1765                 printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
1766                 goto CATCH;
1767         }
1768
1769         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1770         {
1771                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1772                 if (nRet != TADC_SUCCESS)
1773                 {
1774                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", second_key, pDCF, i, nRet);
1775                         goto CATCH;
1776                 }
1777
1778                 DrmCurOffset = pDcfHandler->DrmTell();
1779                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1780                 {
1781                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, forward : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1782                         goto CATCH;
1783                 }
1784         }
1785         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1786         {
1787                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1788                 goto CATCH;
1789         }
1790
1791         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1792         {
1793                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1794                 if (nRet != TADC_SUCCESS)
1795                 {
1796                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1797                         goto CATCH;
1798                 }
1799
1800                 DrmCurOffset = pDcfHandler->DrmTell();
1801                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1802                 {
1803                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1804                         goto CATCH;
1805                 }
1806         }
1807         if (DrmCurOffset != 0)
1808         {
1809                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1810                 goto CATCH;
1811         }
1812
1813         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1814         {
1815                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1816                 if (nRet != TADC_SUCCESS)
1817                 {
1818                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1819                         goto CATCH;
1820                 }
1821
1822                 DrmCurOffset = pDcfHandler->DrmTell();
1823                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1824                 {
1825                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1826                         goto CATCH;
1827                 }
1828         }
1829         if (DrmCurOffset != 0)
1830         {
1831                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1832                 goto CATCH;
1833         }
1834
1835         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1836         {
1837                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1838                 if (nRet != TADC_SUCCESS)
1839                 {
1840                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1841                         goto CATCH;
1842                 }
1843
1844                 DrmCurOffset = pDcfHandler->DrmTell();
1845                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1846                 {
1847                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1848                         goto CATCH;
1849                 }
1850         }
1851         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1852         {
1853                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1854                 goto CATCH;
1855         }
1856
1857         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1858         {
1859                 nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
1860                 if (nRet != TADC_SUCCESS)
1861                 {
1862                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1863                         goto CATCH;
1864                 }
1865
1866                 DrmCurOffset = pDcfHandler->DrmTell();
1867                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1868                 {
1869                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
1870                         goto CATCH;
1871                 }
1872         }
1873         if (DrmCurOffset != 0)
1874         {
1875                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1876                 goto CATCH;
1877         }
1878
1879         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1880         {
1881                 nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
1882                 if (nRet != TADC_SUCCESS)
1883                 {
1884                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1885                         goto CATCH;
1886                 }
1887
1888                 DrmCurOffset = pDcfHandler->DrmTell();
1889                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1890                 {
1891                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1892                         goto CATCH;
1893                 }
1894         }
1895         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1896         {
1897                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1898                 goto CATCH;
1899         }
1900
1901         printf("tc09_DrmFileMgrPositive_FileAPI_02 finished! -------- success \n");
1902
1903         return true;
1904
1905 CATCH:
1906         return false;
1907 }
1908
1909 bool tc09_DrmFileMgrPositive_FileAPI_03(void)
1910 {
1911         const char *pDCF = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/FightGuiIF.tpk");
1912         int nRet = TADC_SUCCESS;
1913
1914         DrmFileMgr* pDrmFileMgr = NULL;
1915         DrmFileHandler *pDcfHandler = NULL;
1916
1917         long long originalEndOffset = 45194636;
1918         long long DrmCurOffset = 0;
1919         long long OriginCurOffset = 847;
1920         long long i = 0;
1921
1922         printf("tc09_DrmFileMgrPositive_FileAPI_03() -------- Started! \n");
1923
1924         pDrmFileMgr = DrmFileMgr::GetInstance();
1925
1926         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1927         if (nRet != TADC_SUCCESS)
1928         {
1929                 printf("tc09_DrmFileMgrPositive_FileAPI_03 failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
1930                 goto CATCH;
1931         }
1932
1933         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1934         {
1935                 printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1936                 goto CATCH;
1937         }
1938
1939         if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
1940         {
1941                 printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
1942                 goto CATCH;
1943         }
1944
1945         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1946         {
1947                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1948                 if (nRet != TADC_SUCCESS)
1949                 {
1950                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", third_key, pDCF, i, nRet);
1951                         goto CATCH;
1952                 }
1953
1954                 DrmCurOffset = pDcfHandler->DrmTell();
1955                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1956                 {
1957                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1958                         goto CATCH;
1959                 }
1960         }
1961         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1962         {
1963                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1964                 goto CATCH;
1965         }
1966
1967         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1968         {
1969                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1970                 if (nRet != TADC_SUCCESS)
1971                 {
1972                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1973                         goto CATCH;
1974                 }
1975
1976                 DrmCurOffset = pDcfHandler->DrmTell();
1977                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1978                 {
1979                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1980                         goto CATCH;
1981                 }
1982         }
1983         if (DrmCurOffset != 0)
1984         {
1985                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1986                 goto CATCH;
1987         }
1988
1989         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1990         {
1991                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1992                 if (nRet != TADC_SUCCESS)
1993                 {
1994                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1995                         goto CATCH;
1996                 }
1997
1998                 DrmCurOffset = pDcfHandler->DrmTell();
1999                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
2000                 {
2001                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
2002                         goto CATCH;
2003                 }
2004         }
2005         if (DrmCurOffset != 0)
2006         {
2007                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
2008                 goto CATCH;
2009         }
2010
2011         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
2012         {
2013                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
2014                 if (nRet != TADC_SUCCESS)
2015                 {
2016                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
2017                         goto CATCH;
2018                 }
2019
2020                 DrmCurOffset = pDcfHandler->DrmTell();
2021                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
2022                 {
2023                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
2024                         goto CATCH;
2025                 }
2026         }
2027         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
2028         {
2029                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
2030                 goto CATCH;
2031         }
2032
2033         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
2034         {
2035                 nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
2036                 if (nRet != TADC_SUCCESS)
2037                 {
2038                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
2039                         goto CATCH;
2040                 }
2041
2042                 DrmCurOffset = pDcfHandler->DrmTell();
2043                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
2044                 {
2045                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
2046                         goto CATCH;
2047                 }
2048         }
2049         if (DrmCurOffset != 0)
2050         {
2051                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
2052                 goto CATCH;
2053         }
2054
2055         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
2056         {
2057                 nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
2058                 if (nRet != TADC_SUCCESS)
2059                 {
2060                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
2061                         goto CATCH;
2062                 }
2063
2064                 DrmCurOffset = pDcfHandler->DrmTell();
2065                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
2066                 {
2067                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
2068                         goto CATCH;
2069                 }
2070         }
2071         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
2072         {
2073                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
2074                 goto CATCH;
2075         }
2076
2077         printf("tc09_DrmFileMgrPositive_FileAPI_03 finished! -------- success \n");
2078
2079         return true;
2080
2081 CATCH:
2082         return false;
2083 }
2084
2085 bool tc10_DrmFileMgrPositive_CloseFileHandler_01(void)
2086 {
2087         int nRet = TADC_SUCCESS;
2088
2089         DrmFileMgr* pDrmFileMgr = NULL;
2090         DrmFileHandler *pDcfHandler = NULL;
2091
2092         printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 -------- Started! \n");
2093
2094         pDrmFileMgr = DrmFileMgr::GetInstance();
2095
2096         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
2097         if (nRet != TADC_SUCCESS)
2098         {
2099                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n", first_key, nRet);
2100                 goto CATCH;
2101         }
2102
2103         nRet = pDrmFileMgr->CloseFileHandler(first_key);
2104         if (nRet != TADC_SUCCESS)
2105         {
2106                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n", first_key, nRet);
2107                 goto CATCH;
2108         }
2109
2110         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
2111         if (nRet == TADC_SUCCESS)
2112         {
2113                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d\n", first_key);
2114                 goto CATCH;
2115         }
2116
2117         printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 finished! -------- success \n");
2118
2119         return true;
2120
2121 CATCH:
2122         return false;
2123 }
2124
2125 bool tc10_DrmFileMgrPositive_CloseFileHandler_02(void)
2126 {
2127         int nRet = TADC_SUCCESS;
2128
2129         DrmFileMgr* pDrmFileMgr = NULL;
2130         DrmFileHandler *pDcfHandler = NULL;
2131
2132         printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 -------- Started! \n");
2133
2134         pDrmFileMgr = DrmFileMgr::GetInstance();
2135
2136         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
2137         if (nRet != TADC_SUCCESS)
2138         {
2139                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n", second_key, nRet);
2140                 goto CATCH;
2141         }
2142
2143         nRet = pDrmFileMgr->CloseFileHandler(second_key);
2144         if (nRet != TADC_SUCCESS)
2145         {
2146                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n", second_key, nRet);
2147                 goto CATCH;
2148         }
2149
2150         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
2151         if (nRet == TADC_SUCCESS)
2152         {
2153                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d\n", second_key);
2154                 goto CATCH;
2155         }
2156
2157         printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 finished! -------- success \n");
2158
2159         return true;
2160
2161 CATCH:
2162         return false;
2163 }
2164
2165 bool tc10_DrmFileMgrPositive_CloseFileHandler_03(void)
2166 {
2167         int nRet = TADC_SUCCESS;
2168
2169         DrmFileMgr* pDrmFileMgr = NULL;
2170         DrmFileHandler *pDcfHandler = NULL;
2171
2172         printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 -------- Started! \n");
2173
2174         pDrmFileMgr = DrmFileMgr::GetInstance();
2175
2176         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
2177         if (nRet != TADC_SUCCESS)
2178         {
2179                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n", third_key, nRet);
2180                 goto CATCH;
2181         }
2182
2183         nRet = pDrmFileMgr->CloseFileHandler(third_key);
2184         if (nRet != TADC_SUCCESS)
2185         {
2186                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n", third_key, nRet);
2187                 goto CATCH;
2188         }
2189
2190         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
2191         if (nRet == TADC_SUCCESS)
2192         {
2193                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d\n", third_key);
2194                 goto CATCH;
2195         }
2196
2197         printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 finished! -------- success \n");
2198
2199         return true;
2200
2201 CATCH:
2202         return false;
2203 }
2204
2205 bool tc11_GetDeviceId_01(void)
2206 {
2207         unsigned char DUID[33] = {0,};
2208         int nRet = 0;
2209
2210         printf("tc11_GetDeviceID_01() -------- Started! \n");
2211
2212         nRet = TADC_IF_GetDUID((char*)DUID);
2213         if (nRet !=TADC_SUCCESS)
2214         {
2215                 printf("tc11_GetDeviceID_01() failed.");
2216                 return false;
2217         }
2218
2219         printf("DUID=%s\n", (char*)DUID);
2220         printf("tc11_GetDeviceID_01() finished! -------- success \n");
2221
2222         return true;
2223 }
2224
2225 bool tc12_TADC_SetDeviceInfo_01(void)
2226 {
2227         int     nRet = TADC_SUCCESS;
2228         T_DEVICE_INFO   t_DeviceInfo;
2229
2230         printf("tc12_TADC_SetDeviceInfo_01() -------- Started! \n");
2231
2232         nRet = TADC_SetDeviceInfo(&t_DeviceInfo);
2233         if (nRet != TADC_SUCCESS)
2234         {
2235                 printf("tc12_TADC_SetDeviceInfo_01() failed.\n");
2236                 return false;
2237         }
2238         printf("DUID=%s\n", (char*)t_DeviceInfo.DUID);
2239         printf("tc12_TADC_SetDeviceInfo_01() finished! -------- success \n");
2240         
2241         return true;
2242 }
2243
2244 bool
2245 tc13_DTappsInstallLicense_01(void)
2246 {
2247         int nRet = TADC_SUCCESS;
2248         char Buf[1024*10] = {0, };      
2249         const char *pFirstRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.ro");
2250         FILE* fd = NULL;
2251         int     nReadLen = 0;
2252         long lSize = 0;
2253         bool res = true;
2254
2255         printf("tc13_DTappsInstallLicense_01() -------- Started! \n");
2256
2257         fd = fopen(pFirstRo, "rb");
2258         if (fd == NULL)
2259         {
2260                 printf("File is not exist! : %s\n", pFirstRo);
2261                 res = false;
2262                 goto CATCH;
2263         }
2264
2265         fseek(fd, 0, SEEK_END);
2266         lSize = ftell(fd);
2267         if (lSize < 0)
2268         {
2269                 printf("fseek() and ftell() failed.");
2270                 res = false;
2271                 goto CATCH;
2272         }
2273         rewind(fd);
2274
2275         memset(Buf, 0x00, sizeof(Buf));
2276         nReadLen = fread(Buf, 1, lSize, fd);
2277         if (nReadLen >= sizeof(Buf))
2278         {
2279                 printf("Buffer error! : %s\n", pFirstRo);
2280                 goto CATCH;
2281         }
2282
2283         if (nReadLen != lSize)
2284         {
2285                 printf("File read error! : %s\n", pFirstRo);
2286                 res = false;
2287                 goto CATCH;
2288         }
2289
2290         nRet = DTappsInstallLicense(Buf);
2291         if (nRet != TADC_SUCCESS)
2292         {
2293                 printf("tc13_DTappsInstallLicense_01() failed. nRet=%d\n", nRet);
2294                 res = false;
2295                 goto CATCH;
2296         }
2297
2298         printf("tc13_DTappsInstallLicense_01() finished! -------- success \n");
2299
2300 CATCH:
2301         if (fd != NULL)
2302         {
2303                 fclose(fd);
2304         }
2305         return res;
2306 }
2307
2308 bool
2309 tc13_DTappsInstallLicense_02(void)
2310 {
2311         int     nRet = TADC_SUCCESS;
2312         char Buf[1024*10] = {0, };      
2313         const char *pFirstRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/8SPXfqc6iL-1.0.0.ro");
2314         FILE* fd = NULL;
2315         int     nReadLen = 0;
2316         long lSize = 0;
2317         bool res = true;
2318
2319         printf("tc13_DTappsInstallLicense_02() -------- Started! \n");
2320
2321         fd = fopen(pFirstRo, "rb");
2322         if (fd == NULL)
2323         {
2324                 printf("File is not exist! : %s\n", pFirstRo);
2325                 res = false;
2326                 goto CATCH;
2327         }
2328
2329         fseek(fd, 0, SEEK_END);
2330         lSize = ftell(fd);
2331         if (lSize < 0)
2332         {
2333                 printf("fseek() and ftell() failed.");
2334                 res = false;
2335                 goto CATCH;
2336         }
2337         rewind(fd);
2338
2339         memset(Buf, 0x00, sizeof(Buf));
2340         nReadLen = fread(Buf, 1, lSize, fd);
2341         if (nReadLen >= sizeof(Buf))
2342         {
2343                 printf("Buffer error! : %s\n", pFirstRo);
2344                 goto CATCH;
2345         }
2346
2347         if (nReadLen != lSize)
2348         {
2349                 printf("File read error! : %s\n", pFirstRo);
2350                 res = false;
2351                 goto CATCH;
2352         }
2353
2354         nRet = DTappsInstallLicense(Buf);
2355         if (nRet != TADC_SUCCESS)
2356         {
2357                 printf("tc13_DTappsInstallLicense_02() failed. nRet=%d\n", nRet);
2358                 res = false;
2359                 goto CATCH;
2360         }
2361
2362         printf("tc13_DTappsInstallLicense_02() finished! -------- success \n");
2363
2364 CATCH:
2365         if (fd != NULL)
2366         {
2367                 fclose(fd);
2368         }
2369         return res;
2370 }
2371
2372 bool
2373 tc13_DTappsInstallLicense_03(void)
2374 {
2375         int     nRet = TADC_SUCCESS;
2376         char Buf[1024*10] = {0, };      
2377         const char *pFirstRo = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/FightGuiIF-1.0.0.ro");
2378         FILE* fd = NULL;
2379         int     nReadLen = 0;
2380         long lSize = 0;
2381         bool res = true;
2382
2383         printf("tc13_DTappsInstallLicense_03() -------- Started! \n");
2384
2385         fd = fopen(pFirstRo, "rb");
2386         if (fd == NULL)
2387         {
2388                 printf("File is not exist! : %s\n", pFirstRo);
2389                 res = false;
2390                 goto CATCH;
2391         }
2392
2393         fseek(fd, 0, SEEK_END);
2394         lSize = ftell(fd);
2395         if (lSize < 0)
2396         {
2397                 printf("fseek() and ftell() failed.");
2398                 res = false;
2399                 goto CATCH;
2400         }
2401         rewind(fd);
2402
2403         memset(Buf, 0x00, sizeof(Buf));
2404         nReadLen = fread(Buf, 1, lSize, fd);
2405         if (nReadLen >= sizeof(Buf))
2406         {
2407                 printf("Buffer error! : %s\n", pFirstRo);
2408                 goto CATCH;
2409         }
2410
2411         if (nReadLen != lSize)
2412         {
2413                 printf("File read error! : %s\n", pFirstRo);
2414                 res = false;
2415                 goto CATCH;
2416         }
2417
2418         nRet = DTappsInstallLicense(Buf);
2419         if (nRet != TADC_SUCCESS)
2420         {
2421                 printf("tc13_DTappsInstallLicense_03() failed. nRet=%d\n", nRet);
2422                 res = false;
2423                 goto CATCH;
2424         }
2425
2426         printf("tc13_DTappsInstallLicense_03() finished! -------- success \n");
2427
2428 CATCH:
2429         if (fd != NULL)
2430         {
2431                 fclose(fd);
2432         }
2433         return res;
2434 }
2435
2436 bool
2437 tc_local_01_drm_tizen_generate_license_request_p(void)
2438 {
2439     bool res = true;
2440     int ret_value = DRMTEST_SUCCESS;
2441
2442     char *purchase_response = NULL;
2443     char *req_id = NULL;
2444     unsigned int  req_buff_len = 1024*5;
2445     char req_buff[req_buff_len] = {0, };
2446     unsigned int  url_buff_len = 1024;
2447     char url_buff[url_buff_len] = {0, };
2448
2449     printf("[%s] test started\n", __func__);
2450     ret_value = generate_purchase_response(&purchase_response, &req_id);
2451     if(ret_value != DRMTEST_SUCCESS) {
2452         res = false;
2453         goto CATCH;
2454     }
2455     printf("...purchase_response:\n%s\n", purchase_response);
2456
2457     ret_value = drm_tizen_generate_license_request(purchase_response, strlen(purchase_response),
2458                                              req_buff, &req_buff_len, url_buff, &url_buff_len);
2459     if(ret_value != TADC_SUCCESS) {
2460         printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
2461         res = false;
2462         goto CATCH;
2463     }
2464     printf("...license_request_url:%s\n", url_buff);
2465     printf("...license_request:\n%s\n", req_buff);
2466
2467     printf("[%s] test ended: result=%d\n", __func__, ret_value);
2468
2469 CATCH:
2470     if(purchase_response != NULL)
2471         free(purchase_response);
2472     if(req_id != NULL)
2473         free(req_id);
2474
2475     return res;
2476 }
2477
2478 bool
2479 tc_local_01_drm_tizen_full_test_p(void)
2480 {
2481     bool res = true;
2482     int ret_value = DRMTEST_SUCCESS;
2483
2484     char *purchase_response = NULL;
2485     char *req_id = NULL;
2486     unsigned int  req_buff_len = 1024*5;
2487     char req_buff[req_buff_len] = {0, };
2488     unsigned int  url_buff_len = 1024;
2489     char url_buff[url_buff_len] = {0, };
2490
2491     char* ro_request_buff = NULL;
2492     char* ro_response_buff = NULL;
2493     char* dh_key_p = NULL;
2494     char* dh_key_g = NULL;
2495     char* dh_key_a = NULL;
2496
2497     unsigned char duid[33] = {0,};
2498     const char* cid = "38EIfBurLJ-1.0.2";
2499     const char* ro_template_path = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/RO/38EIfBurLJ-1.0.2.ro_template");
2500
2501     const char* encrypted_file_path = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DCF/38EIfBurLJ.tpk");
2502     const char* plaintext_file_path = tzplatform_mkpath(TZ_SYS_DATA,"drm_test/DecryptedApp/38EIfBurLJ_dec.tpk");
2503     const char* decrypted_file_path = "/tmp/38EIfBurLJ.tpk";
2504
2505     int identical = DRMTEST_NOTIDENTICAL;
2506
2507     printf("[%s] test started\n", __func__);
2508
2509     if(ret_value != DRMTEST_SUCCESS) {
2510         res = false;
2511         goto CATCH;
2512     }
2513
2514     ret_value = generate_purchase_response(&purchase_response, &req_id);
2515     if(ret_value != DRMTEST_SUCCESS) {
2516         res = false;
2517         goto CATCH;
2518     }
2519     //printf("...purchase_response:\n%s\n", purchase_response);
2520
2521     ret_value = drm_tizen_generate_license_request(purchase_response, strlen(purchase_response),
2522                                              req_buff, &req_buff_len, url_buff, &url_buff_len);
2523     if(ret_value != TADC_SUCCESS) {
2524         printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
2525         res = false;
2526         goto CATCH;
2527     }
2528     printf("...license_request_url:%s\n", url_buff);
2529     printf("...license_request:\n%s\n", req_buff);
2530
2531     ret_value = get_dh_key_from_ro_request(req_buff, &dh_key_p, &dh_key_g, &dh_key_a);
2532     if(ret_value != DRMTEST_SUCCESS) {
2533         res = false;
2534         goto CATCH;
2535     }
2536     //printf("...DH key: p=%s, g=%s, a=%s\n", dh_key_p, dh_key_g, dh_key_a);
2537
2538     ret_value = TADC_IF_GetDUID((char*)duid);
2539     if (ret_value != TADC_SUCCESS) {
2540         return false;
2541     }
2542     printf("duid=%s\n", (char*)duid);
2543
2544     ret_value = generate_right_object_response(dh_key_p, dh_key_g, dh_key_a, req_id,
2545                                                cid, ro_template_path, (const char*)duid, &ro_response_buff);
2546     if(ret_value != DRMTEST_SUCCESS) {
2547         res = false;
2548         goto CATCH;
2549     }
2550     printf("...right_object_response:\n%s\n", ro_response_buff);
2551
2552     ret_value = drm_tizen_register_license(ro_response_buff, strlen(ro_response_buff));
2553     if(ret_value != TADC_SUCCESS) {
2554         printf("...drm_tizen_register_license failed. ret=%d\n", ret_value);
2555         res = false;
2556         goto CATCH;
2557     }
2558     printf("...drm_tizen_register_license: succeeded\n");
2559
2560     ret_value = drm_tizen_decrypt_package(encrypted_file_path, strlen(encrypted_file_path),
2561                                           decrypted_file_path, strlen(decrypted_file_path));
2562     if(ret_value != TADC_SUCCESS) {
2563         printf("...drm_tizen_decrypt_package failed. ret=%d\n", ret_value);
2564         res = false;
2565         goto CATCH;
2566     }
2567     printf("...drm_tizen_decrypt_package: succeeded\n");
2568
2569     ret_value = is_identical_files(plaintext_file_path, decrypted_file_path, &identical);
2570     if(ret_value != DRMTEST_SUCCESS) {
2571         printf("...is_identical_files failed. ret=%d\n", ret_value);
2572         res = false;
2573         goto CATCH;
2574     }
2575     if(identical != DRMTEST_IDENTICAL) {
2576         printf("...the decrypted file is not same with a original plaintext file .\n");
2577         res = false;
2578         goto CATCH;
2579     }
2580     printf("...drm_tizen_decrypt_package: succeeded : the decrypted file is with a original plaintext file.\n");
2581
2582 CATCH:
2583     if(purchase_response != NULL)
2584         free(purchase_response);
2585     if(req_id != NULL)
2586         free(req_id);
2587     if(ro_request_buff != NULL)
2588         free(ro_request_buff);
2589     if(ro_response_buff != NULL)
2590         free(ro_response_buff);
2591
2592     return res;
2593 }
2594
2595
2596 /*
2597 bool tc15_DrmTdcDecryptPackge_01(void)
2598 {
2599         int     nRet = TADC_SUCCESS;
2600
2601 }
2602 */
2603 #endif
2604
2605 int main(int argc, char* argv[])
2606 {
2607 //      return 0;
2608 #if 1
2609         printf(" ---------- Test Tizen DRM v2.0.1 APIs   ---  Start ....    \n");
2610
2611         int                             bRet = TADC_SUCCESS;
2612         
2613         char                    ReqBuf[1024*5] = {0, };
2614         unsigned int    ReqBufLen = 0;
2615         
2616         char                    RespBuf[1024*10] = {0, };       
2617         unsigned int    RespBufLen = 0;
2618         
2619 //      char                    DecLicenseBuf[1024*10] = {0, }; 
2620 //      unsigned int    DecLicenseBufLen = 0;
2621         
2622         char                    LicenseUrl[1024] = {0, };
2623         unsigned int    LicenseUrlLen = 0;
2624         
2625         //2011.03.08
2626         //DrmTdcFileHeader      TDCFileHeader;
2627 //      char    cid[1024] = {0, };
2628 //      char    riurl[1024] = {0, };
2629         
2630         char    testFileName[256] = {0, };
2631         char    tempBuf[256] = {0, };
2632
2633         bool    isOk = false;
2634
2635         //----------------------------------------------------------------------------------------------------
2636         // 0. Static TC running
2637         //----------------------------------------------------------------------------------------------------
2638
2639         printf("\n0. Static TC  Start  ----------------------------------------\n");
2640 /*
2641         isOk = tc01_VerifyRoSignature_Positive_01();
2642         if (isOk != true)
2643         {
2644                 printf("tc01_VerifyRoSignature_Positive_01 failed!\n");
2645         }
2646
2647         isOk = tc01_VerifyRoSignature_Positive_02();
2648         if (isOk != true)
2649         {
2650                 printf("tc01_VerifyRoSignature_Positive_02 failed!\n");
2651         }
2652
2653         isOk = tc01_VerifyRoSignature_Positive_03();
2654         if (isOk != true)
2655         {
2656                 printf("tc01_VerifyRoSignature_Positive_03 failed!\n");
2657         }
2658
2659         isOk = tc02_VerifyRoSignature_Negative_Cert_01();
2660         if (isOk != true)
2661         {
2662                 printf("tc02_VerifyRoSignature_Negative_Cert_01 failed!\n");
2663         }
2664
2665         isOk = tc02_VerifyRoSignature_Negative_Cert_02();
2666         if (isOk != true)
2667         {
2668                 printf("tc02_VerifyRoSignature_Negative_Cert_02 failed!\n");
2669         }
2670
2671         isOk = tc02_VerifyRoSignature_Negative_Cert_03();
2672         if (isOk != true)
2673         {
2674                 printf("tc02_VerifyRoSignature_Negative_Cert_03 failed!\n");
2675         }
2676
2677         isOk = tc03_VerifyRoSignature_Negative_Signature_01();
2678         if (isOk != true)
2679         {
2680                 printf("tc03_VerifyRoSignature_Negative_Signature_01 failed!\n");
2681         }
2682
2683         isOk = tc03_VerifyRoSignature_Negative_Signature_02();
2684         if (isOk != true)
2685         {
2686                 printf("tc03_VerifyRoSignature_Negative_Signature_02 failed!\n");
2687         }
2688
2689         isOk = tc03_VerifyRoSignature_Negative_Signature_03();
2690         if (isOk != true)
2691         {
2692                 printf("tc03_VerifyRoSignature_Negative_Signature_03 failed!\n");
2693         }
2694
2695         isOk = tc04_isDrmFile_Positive_01();
2696         if (isOk != true)
2697         {
2698                 printf("tc04_isDrmFile_Positive_01 failed!\n");
2699         }
2700
2701         isOk = tc04_isDrmFile_Positive_02();
2702         if (isOk != true)
2703         {
2704                 printf("tc04_isDrmFile_Positive_02 failed!\n");
2705         }
2706
2707         isOk = tc04_isDrmFile_Positive_03();
2708         if (isOk != true)
2709         {
2710                 printf("tc04_isDrmFile_Positive_03 failed!\n");
2711         }
2712
2713         isOk = tc05_isDrmFile_Negative_01();
2714         if (isOk != true)
2715         {
2716                 printf("tc05_isDrmFile_Negative_01 failed!\n");
2717         }
2718
2719         isOk = tc05_isDrmFile_Negative_02();
2720         if (isOk != true)
2721         {
2722                 printf("tc05_isDrmFile_Negative_02 failed!\n");
2723         }
2724
2725         isOk = tc05_isDrmFile_Negative_03();
2726         if (isOk != true)
2727         {
2728                 printf("tc05_isDrmFile_Negative_03 failed!\n");
2729         }
2730
2731         isOk = tc13_DTappsInstallLicense_01();
2732         if (isOk != true)
2733         {
2734                 printf("tc13_DTappsInstallLicense_01 failed!\n");
2735         }
2736
2737         isOk = tc13_DTappsInstallLicense_02();
2738         if (isOk != true)
2739         {
2740                 printf("tc13_DTappsInstallLicense_02 failed!\n");
2741         }
2742
2743         isOk = tc13_DTappsInstallLicense_03();
2744         if (isOk != true)
2745         {
2746                 printf("tc13_DTappsInstallLicense_03 failed!\n");
2747         }
2748
2749         isOk = tc06_DrmFileHandlerPositive_01();
2750         if (isOk != true)
2751         {
2752                 printf("tc06_DrmFileHandlerPositive_01 failed!\n");
2753         }
2754
2755         isOk = tc06_DrmFileHandlerPositive_02();
2756         if (isOk != true)
2757         {
2758                 printf("tc06_DrmFileHandlerPositive_02 failed!\n");
2759         }
2760
2761         isOk = tc06_DrmFileHandlerPositive_03();
2762         if (isOk != true)
2763         {
2764                 printf("tc06_DrmFileHandlerPositive_03 failed!\n");
2765         }
2766
2767         isOk = tc07_DrmFileMgrPositive_01();
2768         if (isOk != true)
2769         {
2770                 printf("tc07_DrmFileMgrPositive_01 failed!\b");
2771         }
2772
2773         isOk = tc07_DrmFileMgrPositive_02();
2774         if (isOk != true)
2775         {
2776                 printf("tc07_DrmFileMgrPositive_02 failed!\n");
2777         }
2778
2779         isOk = tc07_DrmFileMgrPositive_03();
2780         if (isOk != true)
2781         {
2782                 printf("tc07_DrmFileMgrPositive_03 failed!\n");
2783         }
2784
2785         isOk = tc08_DrmFileMgrPositive_GetFileHandler_01();
2786         if (isOk != true)
2787         {
2788                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed!\n");
2789         }
2790
2791         isOk = tc08_DrmFileMgrPositive_GetFileHandler_02();
2792         if (isOk != true)
2793         {
2794                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed!\n");
2795         }
2796
2797         isOk = tc08_DrmFileMgrPositive_GetFileHandler_03();
2798         if (isOk != true)
2799         {
2800                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed!\n");
2801         }
2802
2803         isOk = tc09_DrmFileMgrPositive_FileAPI_01();
2804         if (isOk != true)
2805         {
2806                 printf("tc09_DrmFileMgrPositive_FileAPI_01 failed!\n");
2807         }
2808
2809         isOk = tc09_DrmFileMgrPositive_FileAPI_02();
2810         if (isOk != true)
2811         {
2812                 printf("tc09_DrmFileMgrPositive_FileAPI_02 failed!\n");
2813         }
2814
2815         isOk = tc09_DrmFileMgrPositive_FileAPI_03();
2816         if (isOk != true)
2817         {
2818                 printf("tc09_DrmFileMgrPositive_FileAPI_03 failed!\n");
2819         }
2820
2821         isOk = tc10_DrmFileMgrPositive_CloseFileHandler_01();
2822         if (isOk != true)
2823         {
2824                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed!\n");
2825         }
2826
2827         isOk = tc10_DrmFileMgrPositive_CloseFileHandler_02();
2828         if (isOk != true)
2829         {
2830                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed!\n");
2831         }
2832
2833         isOk = tc10_DrmFileMgrPositive_CloseFileHandler_03();
2834         if (isOk != true)
2835         {
2836                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed!\n");
2837         }
2838
2839         isOk = tc11_GetDeviceId_01();
2840         if (isOk != true)
2841         {
2842                 printf("tc11_GetDeviceId_01 failed!\n");
2843         }
2844
2845         isOk = tc12_TADC_SetDeviceInfo_01();
2846         if (isOk != true)
2847         {
2848                 printf("tc12_TADC_SetDeviceInfo_01 failed!\n");
2849         }
2850
2851         isOk = tc11_GetDeviceId_01();
2852         if (isOk != true)
2853         {
2854                 printf("tc11_GetDeviceId_01 failed!\n");
2855         }
2856 */
2857     isOk = tc_local_01_drm_tizen_full_test_p();
2858     if (isOk != true)
2859     {
2860         printf("tc_local_01_drm_tizen_full_test_p failed!\n");
2861     }
2862
2863         //----------------------------------------------------------------------------------------------------
2864         // 1. Check is drm file
2865         //----------------------------------------------------------------------------------------------------
2866
2867         printf("===============================================================================\n");
2868         printf ("Enter test file name  -->  ");
2869
2870         isOk = scanf("%s", testFileName); 
2871         if (isOk < 1)
2872         {
2873                 printf ("Input value wrong! scanf() failed!!");
2874                 return 0;
2875         }
2876         printf("\n1. drm_tizen_is_drm_file  Start  ----------------------------------------\n");
2877
2878         bRet = drm_tizen_is_drm_file(testFileName, strlen(testFileName));
2879         if (bRet != TADC_SUCCESS)
2880         {
2881                 printf("drm_tizen_is_drm_file Error! ret = %d\n", bRet);
2882                 return 0;
2883         }
2884         printf("%s file is TADC file!\n", testFileName);
2885
2886         //----------------------------------------------------------------------------------------------------
2887         // 2. Make PurchaseRequest Data 
2888         //----------------------------------------------------------------------------------------------------
2889         printf("\n2. Make PurchaseRequest Data  Start  ----------------------------------------\n");
2890         
2891         memset(ReqBuf, 0x00, sizeof(ReqBuf));
2892         memset(LicenseUrl, 0x00, sizeof(LicenseUrl));
2893         ReqBufLen = sizeof(ReqBuf);
2894         LicenseUrlLen = sizeof(LicenseUrl);
2895         
2896         bRet = drm_tizen_generate_purchase_request(testFileName, ReqBuf, &ReqBufLen, LicenseUrl, &LicenseUrlLen);
2897         if (bRet == false)
2898         {
2899                 printf(" drm_tizen_generate_purchase_request Error!  \n");
2900                 return 0;
2901         }
2902
2903         printf("drm_tizen_generate_purchase_request - ReqBufLen : %d,  License Url : %s   \n", ReqBufLen, LicenseUrl);  
2904         if ((bRet = _write_logfile("Request_1.dat", ReqBuf, ReqBufLen-1)) == false)
2905         {
2906                 printf(" drm_tizen_generate_purchase_request _write_logfile Error!  \n");
2907                 return 0;
2908         }
2909
2910         //break.... HTTP Request & Reaponse Processing...
2911         printf ("Enter any key after create Response_1.dat file. -->  ");
2912         scanf ("%s", tempBuf); 
2913
2914         memset(RespBuf, 0x00, sizeof(RespBuf)); 
2915         RespBufLen = sizeof(RespBuf);
2916         if ((bRet = _read_logfile("Response_1.dat", RespBuf, &RespBufLen)) == false)
2917         {
2918                 printf(" drm_tizen_generate_purchase_request _read_logfile Error!  \n");
2919                 return 0;
2920         }
2921
2922         //----------------------------------------------------------------------------------------------------
2923         // 3. Make License Request Data  
2924         //----------------------------------------------------------------------------------------------------
2925         printf("\n3. Make License Request Data  Start  ----------------------------------------\n");
2926         
2927         memset(ReqBuf, 0x00, sizeof(ReqBuf));
2928         memset(LicenseUrl, 0x00, sizeof(LicenseUrl));
2929         ReqBufLen = sizeof(ReqBuf);
2930         LicenseUrlLen = sizeof(LicenseUrl);     
2931         
2932         bRet = drm_tizen_generate_license_request(RespBuf,  RespBufLen, ReqBuf, &ReqBufLen, LicenseUrl, &LicenseUrlLen);
2933         if (bRet != TADC_SUCCESS)
2934         {
2935                 printf(" drm_tizen_generate_license_request Error!  \n");
2936                 return 0;
2937         }
2938
2939         printf("drm_tizen_generate_license_request - ReqBufLen : %d,  RO Url : %s   \n", ReqBufLen, LicenseUrl);
2940         if ((bRet = _write_logfile("Request_2.dat", ReqBuf, ReqBufLen - 1)) == false)
2941         {
2942                 printf(" drm_tizen_generate_license_request _write_logfile Error!  \n");
2943                 return 0;
2944         }
2945
2946         //break.... HTTP Request & Reaponse Processing...
2947         printf ("Enter any key after create Response_2.dat file. -->  ");
2948         scanf ("%s", tempBuf); 
2949
2950         memset(RespBuf, 0x00, sizeof(RespBuf)); 
2951         RespBufLen = sizeof(RespBuf);
2952         if ((bRet = _read_logfile("Response_2.dat", RespBuf, &RespBufLen)) == false)
2953         {
2954                 printf(" drm_tizen_generate_license_request _read_logfile Error! \n");
2955                 return 0;
2956         }
2957
2958         //----------------------------------------------------------------------------------------------------
2959         // 4. Decrypt DRM License
2960         //----------------------------------------------------------------------------------------------------
2961         printf("\n4. Decrypt DRM License Start  --------------------------------------------\n");
2962
2963         bRet = drm_tizen_register_license(RespBuf, RespBufLen);
2964         if (bRet != TADC_SUCCESS)
2965         {
2966                 printf(" drm_tizen_register_license  Error!  \n");
2967                 return 0;
2968         }
2969
2970         //---------------------------------------------------------------------------------------------------
2971         // 5. Decrypt DRM File
2972         //----------------------------------------------------------------------------------------------------
2973         printf("\n5. Decrypt DRM File Start  -----------------------------------------\n");
2974
2975         sprintf(tempBuf, "%s.dec", testFileName);
2976         bRet = drm_tizen_decrypt_package(testFileName, strlen(testFileName), tempBuf, strlen(tempBuf));
2977
2978         if (bRet != TADC_SUCCESS)
2979         {
2980                 printf(" drm_tizen_decrypt_package  Error!  \n");
2981                 return 0;
2982         }
2983
2984         printf("\n --------------Test Tizen Apps DRM APIs   ---  End ---------------\n");
2985
2986 #endif
2987 }