07c219414b3f15b41a8509279e0d2f37c9482aad
[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 <vector>
18 #include <fstream>
19 #include <iostream>
20
21 #include "drm-tizen-apps.h"
22 #include "drm-tizen-error.h"
23 #include "TADC_Core.h"
24 #include "TADC_IF.h"
25 #include "DrmFileMgr.h"
26
27 #include "DTapps2Rights.h"
28 #include "drm_testutil.h"
29 #include "drm_testcore.h"
30
31 #if 1
32 static int first_key = 0;
33 static int second_key = 0;
34 static int third_key = 0;
35
36 bool _write_logfile(const char *filename, char *buf, unsigned int len)
37 {
38         FILE *fd = NULL;
39
40         if ((fd = fopen(filename,"w+b")) == NULL)
41         {
42                 return false;
43         }
44
45         fwrite(buf, 1, len,fd);
46         fclose(fd);
47
48         return true;
49 }
50
51 bool _read_logfile(const char *filename, char *buf, unsigned int *pLen)
52 {
53         FILE *fd = NULL;
54         int  nReadLen = 0;
55
56         if ((fd = fopen(filename,"r+b")) == NULL)
57         {
58                 return false;
59         }
60
61         nReadLen = fread(buf, 1, *pLen,fd);
62         *pLen = nReadLen;
63
64         fclose(fd);
65
66         return true;
67 }
68
69 bool tc01_VerifyRoSignature_Positive_01(void)
70 {
71         printf("tc01_VerifyRoSignature_Positive_01() -------- Started! \n");
72
73         const char *pRo = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.ro";
74
75         auto buf = _read_ro_file(pRo);
76
77         int nRet = TADC_VerifyROSignature(buf.data());
78         if (nRet != 0) {
79                 printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
80                 return false;
81         }
82
83         printf("tc01_VerifyRoSignature_Positive_01() finished! -------- success \n");
84
85         return true;
86 }
87
88 bool tc01_VerifyRoSignature_Positive_02(void)
89 {
90         printf("tc01_VerifyRoSignature_Positive_02() -------- Started! \n");
91         const char *pRo = TEST_DATA_DIR "/RO/8SPXfqc6iL-1.0.0.ro";
92
93         auto buf = _read_ro_file(pRo);
94
95         int nRet = TADC_VerifyROSignature(buf.data());
96         if (nRet != 0) {
97                 printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
98                 return false;
99         }
100
101         printf("tc01_VerifyRoSignature_Positive_02() finished! -------- success \n");
102         return true;
103 }
104
105 bool tc01_VerifyRoSignature_Positive_03(void)
106 {
107         printf("tc01_VerifyRoSignature_Positive_03() -------- Started! \n");
108
109         const char *pRo = TEST_DATA_DIR "/RO/FightGuiIF-1.0.0.ro";
110
111         auto buf = _read_ro_file(pRo);
112
113         int nRet = TADC_VerifyROSignature(buf.data());
114         if (nRet != 0)
115         {
116                 printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
117                 return false;
118         }
119
120         printf("tc01_VerifyRoSignature_Positive_03() finished! -------- success \n");
121         return true;
122 }
123
124 bool tc02_VerifyRoSignature_Negative_Cert_01(void)
125 {
126         printf("tc02_VerifyRoSignature_Negative_Cert_01() -------- Started! \n");
127
128         const char *pRo  = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.cert_only_selfsigned.ro";
129
130         auto buf = _read_ro_file(pRo);
131
132         int nRet = TADC_VerifyROSignature(buf.data());
133         if (nRet >= 0) {
134                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
135                 return false;
136         }
137
138         printf("tc02_VerifyRoSignature_Negative_Cert_01 finished! -------- success \n");
139         return true;
140 }
141
142 bool tc02_VerifyRoSignature_Negative_Cert_02(void)
143 {
144         printf("tc02_VerifyRoSignature_Negative_Cert_02() -------- Started! \n");
145
146         const char *pRo = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.cert_chain_invalid.ro";
147
148         auto buf = _read_ro_file(pRo);
149
150         int nRet = TADC_VerifyROSignature(buf.data());
151         if (nRet >= 0) {
152                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
153                 return false;
154         }
155
156         printf("tc02_VerifyRoSignature_Negative_Cert_02 finished! -------- success \n");
157         return true;
158 }
159
160 bool tc02_VerifyRoSignature_Negative_Cert_03(void)
161 {
162         printf("tc02_VerifyRoSignature_Negative_Cert_03() -------- Started! \n");
163
164         const char *pRo  = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.cert_invalid.ro";
165
166         auto buf = _read_ro_file(pRo);
167
168         int nRet = TADC_VerifyROSignature(buf.data());
169         if (nRet >= 0) {
170                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
171                 return false;
172         }
173
174         printf("tc02_VerifyRoSignature_Negative_Cert_03 finished! -------- success \n");
175         return true;
176 }
177
178 bool tc03_VerifyRoSignature_Negative_Signature_01(void)
179 {
180         printf("tc03_VerifyRoSignature_Negative_Signature_01() -------- Started! \n");
181
182         const char *pRo   = TEST_DATA_DIR "/RO/FightGuiIF-1.0.0.signature_invalid.ro";
183
184         auto buf = _read_ro_file(pRo);
185
186         int nRet = TADC_VerifyROSignature(buf.data());
187         if (nRet >= 0) {
188                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
189                 return false;
190         }
191
192         printf("tc03_VerifyRoSignature_Negative_Signature_01() finished! -------- success \n");
193
194         return true;
195 }
196
197 bool tc03_VerifyRoSignature_Negative_Signature_02(void)
198 {
199         printf("tc03_VerifyRoSignature_Negative_Signature_02() -------- Started! \n");
200
201         const char *pRo = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.signature_invalid.ro";
202
203         auto buf = _read_ro_file(pRo);
204
205         int nRet = TADC_VerifyROSignature(buf.data());
206         if (nRet >= 0) {
207                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
208                 return false;
209         }
210
211         printf("tc03_VerifyRoSignature_Negative_Signature_01() finished! -------- success \n");
212
213         return true;
214 }
215
216 bool tc03_VerifyRoSignature_Negative_Signature_03(void)
217 {
218         printf("tc03_VerifyRoSignature_Negative_Signature_03() -------- Started! \n");
219
220         const char *pRo  = TEST_DATA_DIR "/RO/8SPXfqc6iL-1.0.0.signature_invalid.ro";
221
222         auto buf = _read_ro_file(pRo);
223
224         int nRet = TADC_VerifyROSignature(buf.data());
225         if (nRet >= 0) {
226                 printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
227                 return false;
228         }
229
230         printf("tc03_VerifyRoSignature_Negative_Signature_03() finished! -------- success \n");
231
232         return true;
233 }
234
235 bool tc04_isDrmFile_Positive_01(void)
236 {
237         const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
238
239         printf("tc04_isDrmFile_Positive_01() -------- Started!\n");
240
241         int nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
242         if (nRet != TADC_SUCCESS) {
243                 printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
244                 printf("%s file is not TADC file!\n", pDCF);
245                 return false;
246         }
247
248         printf("tc04_isDrmFile_Positive_01() finished! -------- success \n");
249
250         return true;
251 }
252
253 bool tc04_isDrmFile_Positive_02(void)
254 {
255         const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
256
257         printf("tc04_isDrmFile_Positive_02() -------- Started!\n");
258
259         int nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
260         if (nRet != TADC_SUCCESS) {
261                 printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
262                 printf("%s file is not TADC file!\n", pDCF);
263                 return false;
264         }
265
266         printf("tc04_isDrmFile_Positive_02() finished! -------- success \n");
267
268         return true;
269 }
270
271 bool tc04_isDrmFile_Positive_03(void)
272 {
273         const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
274
275         printf("tc04_isDrmFile_Positive_03() -------- Started!\n");
276
277         int nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
278         if (nRet != TADC_SUCCESS) {
279                 printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
280                 printf("%s file is not TADC file!\n", pDCF);
281                 return false;
282         }
283
284         printf("tc04_isDrmFile_Positive_03() finished! -------- success \n");
285
286         return true;
287 }
288
289 bool tc05_isDrmFile_Negative_01(void)
290 {
291         const char *pApp = TEST_DATA_DIR "/DecryptedApp/38EIfBurLJ_dec.tpk";
292
293         printf("tc05_isDrmFile_Negative_01() -------- Started! \n");
294
295         int nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
296         if(nRet == TADC_SUCCESS) {
297                 printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
298                 return false;
299         }
300
301         printf("tc05_isDrmFile_Negative_01 finished! -------- success \n");
302
303         return true;
304 }
305
306 bool tc05_isDrmFile_Negative_02(void)
307 {
308         const char *pApp = TEST_DATA_DIR "/DecryptedApp/8SPXfqc6iL_dec.tpk";
309
310         printf("tc05_isDrmFile_Negative_02() -------- Started! \n");
311
312         int nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
313         if(nRet == TADC_SUCCESS) {
314                 printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
315                 return false;
316         }
317
318         printf("tc05_isDrmFile_Negative_02 finished! -------- success \n");
319
320         return true;
321 }
322
323 bool tc05_isDrmFile_Negative_03(void)
324 {
325         const char *pApp = TEST_DATA_DIR "/DecryptedApp/FightGuiIF_dec.tpk";
326
327         printf("tc05_isDrmFile_Negative_03() -------- Started! \n");
328
329         int nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
330         if(nRet == TADC_SUCCESS) {
331                 printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
332                 return false;
333         }
334
335         printf("tc05_isDrmFile_Negative_03 finished! -------- success \n");
336
337         return true;
338 }
339
340 bool
341 tc06_DrmFileHandlerPositive_01(void)
342 {
343         const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
344         DrmFileHandler* pDcfHandler = NULL;
345         unsigned char* pBufCEK = NULL;
346         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};
347         unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
348
349         long encryptionLevel = 17;
350         long long encryptionRange = 10;
351         long long plainTextSize = 1630724;
352         long long originalEndOffset = 1631570;
353         int nRet = 0;
354
355         printf("tc06_DrmFileHandlerPositive_01() -------- Started! \n");
356
357         pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
358         memset(pBufCEK, 0x00, CEK_SIZE + 1);
359
360         pDcfHandler = new DrmFileHandler();
361         if (pDcfHandler == NULL)
362         {
363                 goto CATCH;
364         }
365
366         nRet = pDcfHandler->Construct(pDCF);
367         if (nRet != 1)
368         {
369                 printf("tc06_DrmFileHandlerPositive_01 - Construct() failed : %s, %x\n", pDCF, nRet);
370                 goto CATCH;
371         }
372
373         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
374         {
375                 printf("tc06_DrmFileHandlerPositive_01 - CEK Comparison failed : %s\n", pDCF);
376                 goto CATCH;
377         }
378
379         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
380         {
381                 printf("tc06_DrmFileHandlerPositive_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
382                 goto CATCH;
383         }
384
385         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
386         {
387                 printf("tc06_DrmFileHandlerPositive_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
388                 goto CATCH;
389         }
390
391         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
392         {
393                 printf("tc06_DrmFileHandlerPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
394                 goto CATCH;
395         }
396
397         if (pDcfHandler->m_encryptionRange != encryptionRange)
398         {
399                 printf("tc06_DrmFileHandlerPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
400                 goto CATCH;
401         }
402
403         if (pDcfHandler->m_plaintextSize != plainTextSize)
404         {
405                 printf("tc06_DrmFileHandlerPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
406                 goto CATCH;
407         }
408
409         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
410         {
411                 printf("tc06_DrmFileHandlerPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
412                 goto CATCH;
413         }
414
415         if (pDcfHandler != NULL)
416         {
417                 delete pDcfHandler;
418         }
419
420         if (pBufCEK != NULL)
421         {
422                 free(pBufCEK);
423         }
424
425         printf("tc06_DrmFileHandlerPositive_01 finished! -------- success \n");
426
427         return true;
428
429 CATCH:
430         if (pDcfHandler != NULL)
431         {
432                 delete pDcfHandler;
433         }
434
435         if (pBufCEK != NULL)
436         {
437                 free(pBufCEK);
438         }
439
440         return false;
441 }
442
443 bool
444 tc06_DrmFileHandlerPositive_02(void)
445 {
446         const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
447         unsigned char* pBufCEK = NULL;
448         DrmFileHandler* pDcfHandler = NULL;
449         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};
450         unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
451
452         long encryptionLevel = 17;
453         long long encryptionRange = 10;
454         long long plainTextSize = 705072;
455         long long originalEndOffset = 705914;
456         int nRet = 0;
457
458         printf("tc06_DrmFileHandlerPositive_02() -------- Started! \n");
459
460         pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
461         memset(pBufCEK, 0x00, CEK_SIZE + 1);
462
463         pDcfHandler = new DrmFileHandler();
464         if (pDcfHandler == NULL)
465         {
466                 goto CATCH;
467         }
468
469         nRet = pDcfHandler->Construct(pDCF);
470         if (nRet != 1)
471         {
472                 printf("tc06_DrmFileHandlerPositive_02 - Construct() failed : %s, %x\n", pDCF, nRet);
473                 goto CATCH;
474         }
475
476         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
477         {
478                 printf("tc06_DrmFileHandlerPositive_02 - CEK Comparison failed : %s\n", pDCF);
479                 goto CATCH;
480         }
481
482         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
483         {
484                 printf("tc06_DrmFileHandlerPositive_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
485                 goto CATCH;
486         }
487
488         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
489         {
490                 printf("tc06_DrmFileHandlerPositive_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
491                 goto CATCH;
492         }
493
494         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
495         {
496                 printf("tc06_DrmFileHandlerPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
497                 goto CATCH;
498         }
499
500         if (pDcfHandler->m_encryptionRange != encryptionRange)
501         {
502                 printf("tc06_DrmFileHandlerPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
503                 goto CATCH;
504         }
505
506         if (pDcfHandler->m_plaintextSize != plainTextSize)
507         {
508                 printf("tc06_DrmFileHandlerPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
509                 goto CATCH;
510         }
511
512         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
513         {
514                 printf("tc06_DrmFileHandlerPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
515                 goto CATCH;
516         }
517
518         if (pDcfHandler != NULL)
519         {
520                 delete pDcfHandler;
521         }
522
523         if (pBufCEK != NULL)
524         {
525                 free(pBufCEK);
526         }
527
528         printf("tc06_DrmFileHandlerPositive_02 finished! -------- success \n");
529
530         return true;
531
532 CATCH:
533         if (pDcfHandler != NULL)
534         {
535                 delete pDcfHandler;
536         }
537
538         if (pBufCEK != NULL)
539         {
540                 free(pBufCEK);
541         }
542
543         return false;
544 }
545
546 bool
547 tc06_DrmFileHandlerPositive_03(void)
548 {
549         const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
550         unsigned char* pBufCEK = NULL;
551         DrmFileHandler* pDcfHandler = NULL;
552         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};
553         unsigned char pCID[32] = "FightGuiIF-1.0.0";
554
555         long encryptionLevel = 17;
556         long long encryptionRange = 10;
557         long long plainTextSize = 45193789;
558         long long originalEndOffset = 45194636;
559         int nRet = 0;
560
561         printf("tc06_DrmFileHandlerPositive_03() -------- Started! \n");
562
563         pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
564         memset(pBufCEK, 0x00, CEK_SIZE + 1);
565
566         pDcfHandler = new DrmFileHandler();
567         if (pDcfHandler == NULL)
568         {
569                 goto CATCH;
570         }
571
572         nRet = pDcfHandler->Construct(pDCF);
573         if (nRet != 1)
574         {
575                 printf("tc06_DrmFileHandlerPositive_03 - Construct() failed : %s, %x\n", pDCF, nRet);
576                 goto CATCH;
577         }
578
579         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
580         {
581                 printf("tc06_DrmFileHandlerPositive_03 - CEK Comparison failed : %s\n", pDCF);
582                 goto CATCH;
583         }
584
585         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
586         {
587                 printf("tc06_DrmFileHandlerPositive_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
588                 goto CATCH;
589         }
590
591         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
592         {
593                 printf("tc06_DrmFileHandlerPositive_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
594                 goto CATCH;
595         }
596
597         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
598         {
599                 printf("tc06_DrmFileHandlerPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
600                 goto CATCH;
601         }
602
603         if (pDcfHandler->m_encryptionRange != encryptionRange)
604         {
605                 printf("tc06_DrmFileHandlerPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
606                 goto CATCH;
607         }
608
609         if (pDcfHandler->m_plaintextSize != plainTextSize)
610         {
611                 printf("tc06_DrmFileHandlerPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
612                 goto CATCH;
613         }
614
615         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
616         {
617                 printf("tc06_DrmFileHandlerPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
618                 goto CATCH;
619         }
620
621         if (pDcfHandler != NULL)
622         {
623                 delete pDcfHandler;
624         }
625
626         if (pBufCEK != NULL)
627         {
628                 free(pBufCEK);
629         }
630
631         printf("tc06_DrmFileHandlerPositive_03 finished! -------- success \n");
632
633         return true;
634
635 CATCH:
636         if (pDcfHandler != NULL)
637         {
638                 delete pDcfHandler;
639         }
640
641         if (pBufCEK != NULL)
642         {
643                 free(pBufCEK);
644         }
645
646         return false;
647 }
648
649 bool tc07_DrmFileMgrPositive_01(void)
650 {
651         const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
652         int nRet = TADC_SUCCESS;
653
654         DrmFileMgr* pDrmFileMgr = NULL;
655         DrmFileHandler *pDcfHandler = NULL;
656
657         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};
658
659         unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
660         long encryptionLevel = 17;
661         long long encryptionRange = 10;
662         long long plainTextSize = 1630724;
663         long long originalEndOffset = 1631570;
664
665         printf("tc07_DrmFileMgrPositive_01() -------- Started! \n");
666
667         pDrmFileMgr = DrmFileMgr::GetInstance();
668
669         nRet = pDrmFileMgr->OpenFileHandler(pDCF, &first_key);
670         if (nRet != TADC_SUCCESS)
671         {
672                 printf("tc07_DrmFileMgrPositive_01 - OpenFileHandler() failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
673                 goto CATCH;
674         }
675
676         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
677         if (nRet != TADC_SUCCESS)
678         {
679                 printf("tc07_DrmFileMgrPositive_01 - GetFileHandler() failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
680                 goto CATCH;
681         }
682
683         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
684         {
685                 printf("tc07_DrmFileMgrPositive_01 - CEK Comparison failed : %s\n", pDCF);
686                 goto CATCH;
687         }
688
689         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
690         {
691                 printf("tc07_DrmFileMgrPositive_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
692                 goto CATCH;
693         }
694
695         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
696         {
697                 printf("tc07_DrmFileMgrPositive_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
698                 goto CATCH;
699         }
700
701         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
702         {
703                 printf("tc07_DrmFileMgrPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
704                 goto CATCH;
705         }
706
707         if (pDcfHandler->m_encryptionRange != encryptionRange)
708         {
709                 printf("tc07_DrmFileMgrPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
710                 goto CATCH;
711         }
712
713         if (pDcfHandler->m_plaintextSize != plainTextSize)
714         {
715                 printf("tc07_DrmFileMgrPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
716                 goto CATCH;
717         }
718
719         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
720         {
721                 printf("tc07_DrmFileMgrPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
722                 goto CATCH;
723         }
724
725         printf("tc07_DrmFileMgrPositive_01 finished! -------- success \n");
726
727         return true;
728
729 CATCH:
730
731         return false;
732 }
733
734 bool tc07_DrmFileMgrPositive_02(void)
735 {
736         const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
737         int nRet = TADC_SUCCESS;
738
739         DrmFileMgr* pDrmFileMgr = NULL;
740         DrmFileHandler *pDcfHandler = NULL;
741
742         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};
743         unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
744
745         long encryptionLevel = 17;
746         long long encryptionRange = 10;
747         long long plainTextSize = 705072;
748         long long originalEndOffset = 705914;
749
750         printf("tc07_DrmFileMgrPositive_02() -------- Started! \n");
751
752         pDrmFileMgr = DrmFileMgr::GetInstance();
753
754         nRet = pDrmFileMgr->OpenFileHandler(pDCF, &second_key);
755         if (nRet != TADC_SUCCESS)
756         {
757                 printf("tc07_DrmFileMgrPositive_02 - OpenFileHandler() failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
758                 goto CATCH;
759         }
760
761         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
762         if (nRet != TADC_SUCCESS)
763         {
764                 printf("tc07_DrmFileMgrPositive_02 - GetFileHandler() failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
765                 goto CATCH;
766         }
767
768         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
769         {
770                 printf("tc07_DrmFileMgrPositive_02 - CEK Comparison failed : %s\n", pDCF);
771                 goto CATCH;
772         }
773
774         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
775         {
776                 printf("tc07_DrmFileMgrPositive_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
777                 goto CATCH;
778         }
779
780         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
781         {
782                 printf("tc07_DrmFileMgrPositive_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
783                 goto CATCH;
784         }
785
786         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
787         {
788                 printf("tc07_DrmFileMgrPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
789                 goto CATCH;
790         }
791
792         if (pDcfHandler->m_encryptionRange != encryptionRange)
793         {
794                 printf("tc07_DrmFileMgrPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
795                 goto CATCH;
796         }
797
798         if (pDcfHandler->m_plaintextSize != plainTextSize)
799         {
800                 printf("tc07_DrmFileMgrPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
801                 goto CATCH;
802         }
803
804         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
805         {
806                 printf("tc07_DrmFileMgrPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
807                 goto CATCH;
808         }
809
810         printf("tc07_DrmFileMgrPositive_02 finished! -------- success \n");
811
812         return true;
813
814 CATCH:
815
816         return false;
817 }
818
819 bool tc07_DrmFileMgrPositive_03(void)
820 {
821         const char *pDCF  = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
822         int nRet = TADC_SUCCESS;
823
824         DrmFileMgr* pDrmFileMgr = NULL;
825         DrmFileHandler *pDcfHandler = NULL;
826
827         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};
828
829         unsigned char pCID[32] = "FightGuiIF-1.0.0";
830
831         long encryptionLevel = 17;
832         long long encryptionRange = 10;
833         long long plainTextSize = 45193789;
834         long long originalEndOffset = 45194636;
835
836         printf("tc07_DrmFileMgrPositive_03() -------- Started! \n");
837
838         pDrmFileMgr = DrmFileMgr::GetInstance();
839
840         nRet = pDrmFileMgr->OpenFileHandler(pDCF, &third_key);
841         if (nRet != TADC_SUCCESS)
842         {
843                 printf("tc07_DrmFileMgrPositive_03 - OpenFileHandler() failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
844                 goto CATCH;
845         }
846
847         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
848         if (nRet != TADC_SUCCESS)
849         {
850                 printf("tc07_DrmFileMgrPositive_03 - GetFileHandler() failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
851                 goto CATCH;
852         }
853
854         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
855         {
856                 printf("tc07_DrmFileMgrPositive_03 - CEK Comparison failed : %s\n", pDCF);
857                 goto CATCH;
858         }
859
860         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
861         {
862                 printf("tc07_DrmFileMgrPositive_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
863                 goto CATCH;
864         }
865
866         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
867         {
868                 printf("tc07_DrmFileMgrPositive_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
869                 goto CATCH;
870         }
871
872         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
873         {
874                 printf("tc07_DrmFileMgrPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
875                 goto CATCH;
876         }
877
878         if (pDcfHandler->m_encryptionRange != encryptionRange)
879         {
880                 printf("tc07_DrmFileMgrPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
881                 goto CATCH;
882         }
883
884         if (pDcfHandler->m_plaintextSize != plainTextSize)
885         {
886                 printf("tc07_DrmFileMgrPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
887                 goto CATCH;
888         }
889
890         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
891         {
892                 printf("tc07_DrmFileMgrPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
893                 goto CATCH;
894         }
895
896         printf("tc07_DrmFileMgrPositive_03 finished! -------- success \n");
897
898         return true;
899
900 CATCH:
901
902         return false;
903 }
904
905 bool tc08_DrmFileMgrPositive_GetFileHandler_01(void)
906 {
907         const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
908         int nRet = TADC_SUCCESS;
909
910         DrmFileMgr* pDrmFileMgr = NULL;
911         DrmFileHandler *pDcfHandler = NULL;
912
913         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};
914
915         unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
916
917         long encryptionLevel = 17;
918         long long encryptionRange = 10;
919         long long plainTextSize = 1630724;
920         long long originalEndOffset = 1631570;
921
922         printf("tc08_DrmFileMgrPositive_GetFileHandler_01() -------- Started! \n");
923
924         pDrmFileMgr = DrmFileMgr::GetInstance();
925
926         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
927         if (nRet != TADC_SUCCESS)
928         {
929                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
930                 goto CATCH;
931         }
932
933         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
934         {
935                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CEK Comparison failed : %s\n", pDCF);
936                 goto CATCH;
937         }
938
939         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
940         {
941                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
942                 goto CATCH;
943         }
944
945         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
946         {
947                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
948                 goto CATCH;
949         }
950
951         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
952         {
953                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
954                 goto CATCH;
955         }
956
957         if (pDcfHandler->m_encryptionRange != encryptionRange)
958         {
959                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
960                 goto CATCH;
961         }
962
963         if (pDcfHandler->m_plaintextSize != plainTextSize)
964         {
965                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
966                 goto CATCH;
967         }
968
969         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
970         {
971                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
972                 goto CATCH;
973         }
974
975         printf("tc08_DrmFileMgrPositive_GetFileHandler_01 finished! -------- success \n");
976
977         return true;
978
979 CATCH:
980
981         return false;
982 }
983
984 bool tc08_DrmFileMgrPositive_GetFileHandler_02(void)
985 {
986         const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
987         int nRet = TADC_SUCCESS;
988
989         DrmFileMgr* pDrmFileMgr = NULL;
990         DrmFileHandler *pDcfHandler = NULL;
991
992         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};
993
994         unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
995
996         long encryptionLevel = 17;
997         long long encryptionRange = 10;
998         long long plainTextSize = 705072;
999         long long originalEndOffset = 705914;
1000
1001         printf("tc08_DrmFileMgrPositive_GetFileHandler_02() -------- Started! \n");
1002
1003         pDrmFileMgr = DrmFileMgr::GetInstance();
1004
1005         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1006         if (nRet != TADC_SUCCESS)
1007         {
1008                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
1009                 goto CATCH;
1010         }
1011
1012         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1013         {
1014                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CEK Comparison failed : %s\n", pDCF);
1015                 goto CATCH;
1016         }
1017
1018         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1019         {
1020                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1021                 goto CATCH;
1022         }
1023
1024         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1025         {
1026                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1027                 goto CATCH;
1028         }
1029
1030         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1031         {
1032                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1033                 goto CATCH;
1034         }
1035
1036         if (pDcfHandler->m_encryptionRange != encryptionRange)
1037         {
1038                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1039                 goto CATCH;
1040         }
1041
1042         if (pDcfHandler->m_plaintextSize != plainTextSize)
1043         {
1044                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1045                 goto CATCH;
1046         }
1047
1048         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1049         {
1050                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1051                 goto CATCH;
1052         }
1053
1054         printf("tc08_DrmFileMgrPositive_GetFileHandler_02 finished! -------- success \n");
1055
1056         return true;
1057
1058 CATCH:
1059
1060         return false;
1061 }
1062
1063 bool tc08_DrmFileMgrPositive_GetFileHandler_03(void)
1064 {
1065         const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
1066         int nRet = TADC_SUCCESS;
1067
1068         DrmFileMgr* pDrmFileMgr = NULL;
1069         DrmFileHandler *pDcfHandler = NULL;
1070
1071         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};
1072
1073         unsigned char pCID[32] = "FightGuiIF-1.0.0";
1074
1075         long encryptionLevel = 17;
1076         long long encryptionRange = 10;
1077         long long plainTextSize = 45193789;
1078         long long originalEndOffset = 45194636;
1079
1080         printf("tc08_DrmFileMgrPositive_GetFileHandler_03() -------- Started! \n");
1081
1082         pDrmFileMgr = DrmFileMgr::GetInstance();
1083
1084         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1085         if (nRet != TADC_SUCCESS)
1086         {
1087                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
1088                 goto CATCH;
1089         }
1090
1091         if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
1092         {
1093                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CEK Comparison failed : %s\n", pDCF);
1094                 goto CATCH;
1095         }
1096
1097         if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
1098         {
1099                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
1100                 goto CATCH;
1101         }
1102
1103         if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
1104         {
1105                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
1106                 goto CATCH;
1107         }
1108
1109         if (pDcfHandler->m_encryptionLevel != encryptionLevel)
1110         {
1111                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
1112                 goto CATCH;
1113         }
1114
1115         if (pDcfHandler->m_encryptionRange != encryptionRange)
1116         {
1117                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
1118                 goto CATCH;
1119         }
1120
1121         if (pDcfHandler->m_plaintextSize != plainTextSize)
1122         {
1123                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
1124                 goto CATCH;
1125         }
1126
1127         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1128         {
1129                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1130                 goto CATCH;
1131         }
1132
1133         printf("tc08_DrmFileMgrPositive_GetFileHandler_03 finished! -------- success \n");
1134
1135         return true;
1136
1137 CATCH:
1138
1139         return false;
1140 }
1141
1142 bool tc09_DrmFileMgrPositive_FileAPI_01(void)
1143 {
1144         const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
1145         int nRet = TADC_SUCCESS;
1146
1147         DrmFileMgr* pDrmFileMgr = NULL;
1148         DrmFileHandler *pDcfHandler = NULL;
1149
1150         long long originalEndOffset = 1631570;
1151         long long DrmCurOffset = 0;
1152         long long OriginCurOffset = 846;
1153         long long i = 0;
1154
1155         printf("tc09_DrmFileMgrPositive_FileAPI_01() -------- Started! \n");
1156
1157         pDrmFileMgr = DrmFileMgr::GetInstance();
1158
1159         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
1160         if (nRet != TADC_SUCCESS)
1161         {
1162                 printf("tc09_DrmFileMgrPositive_FileAPI_01 failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
1163                 goto CATCH;
1164         }
1165
1166         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1167         {
1168                 printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1169                 goto CATCH;
1170         }
1171
1172         if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
1173         {
1174                 printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
1175                 goto CATCH;
1176         }
1177
1178         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1179         {
1180                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1181                 if (nRet != TADC_SUCCESS)
1182                 {
1183                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", first_key, pDCF, i, nRet);
1184                         goto CATCH;
1185                 }
1186
1187                 DrmCurOffset = pDcfHandler->DrmTell();
1188                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1189                 {
1190                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1191                         goto CATCH;
1192                 }
1193         }
1194         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1195         {
1196                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1197                 goto CATCH;
1198         }
1199
1200         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1201         {
1202                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1203                 if (nRet != TADC_SUCCESS)
1204                 {
1205                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1206                         goto CATCH;
1207                 }
1208
1209                 DrmCurOffset = pDcfHandler->DrmTell();
1210                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1211                 {
1212                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1213                         goto CATCH;
1214                 }
1215         }
1216         if (DrmCurOffset != 0)
1217         {
1218                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1219                 goto CATCH;
1220         }
1221
1222         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1223         {
1224                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1225                 if (nRet != TADC_SUCCESS)
1226                 {
1227                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1228                         goto CATCH;
1229                 }
1230
1231                 DrmCurOffset = pDcfHandler->DrmTell();
1232                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1233                 {
1234                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1235                         goto CATCH;
1236                 }
1237         }
1238         if (DrmCurOffset != 0)
1239         {
1240                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1241                 goto CATCH;
1242         }
1243
1244         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1245         {
1246                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1247                 if (nRet != TADC_SUCCESS)
1248                 {
1249                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1250                         goto CATCH;
1251                 }
1252
1253                 DrmCurOffset = pDcfHandler->DrmTell();
1254                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1255                 {
1256                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1257                         goto CATCH;
1258                 }
1259         }
1260         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1261         {
1262                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1263                 goto CATCH;
1264         }
1265
1266         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1267         {
1268                 nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
1269                 if (nRet != TADC_SUCCESS)
1270                 {
1271                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1272                         goto CATCH;
1273                 }
1274
1275                 DrmCurOffset = pDcfHandler->DrmTell();
1276                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1277                 {
1278                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
1279                         goto CATCH;
1280                 }
1281         }
1282         if (DrmCurOffset != 0)
1283         {
1284                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1285                 goto CATCH;
1286         }
1287
1288         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1289         {
1290                 nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
1291                 if (nRet != TADC_SUCCESS)
1292                 {
1293                         printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
1294                         goto CATCH;
1295                 }
1296
1297                 DrmCurOffset = pDcfHandler->DrmTell();
1298                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1299                 {
1300                         printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1301                         goto CATCH;
1302                 }
1303         }
1304         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1305         {
1306                 printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1307                 goto CATCH;
1308         }
1309
1310         printf("tc09_DrmFileMgrPositive_FileAPI_01 finished! -------- success \n");
1311
1312         return true;
1313
1314 CATCH:
1315         return false;
1316 }
1317
1318 bool tc09_DrmFileMgrPositive_FileAPI_02(void)
1319 {
1320         const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
1321         int nRet = TADC_SUCCESS;
1322
1323         DrmFileMgr* pDrmFileMgr = NULL;
1324         DrmFileHandler *pDcfHandler = NULL;
1325
1326         long long originalEndOffset = 705914;
1327         long long DrmCurOffset = 0;
1328         long long OriginCurOffset = 842;
1329         long long i = 0;
1330
1331         printf("tc09_DrmFileMgrPositive_FileAPI_02() -------- Started! \n");
1332
1333         pDrmFileMgr = DrmFileMgr::GetInstance();
1334
1335         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1336         if (nRet != TADC_SUCCESS)
1337         {
1338                 printf("tc09_DrmFileMgrPositive_FileAPI_02 failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
1339                 goto CATCH;
1340         }
1341
1342         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1343         {
1344                 printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1345                 goto CATCH;
1346         }
1347
1348         if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
1349         {
1350                 printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
1351                 goto CATCH;
1352         }
1353
1354         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1355         {
1356                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1357                 if (nRet != TADC_SUCCESS)
1358                 {
1359                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", second_key, pDCF, i, nRet);
1360                         goto CATCH;
1361                 }
1362
1363                 DrmCurOffset = pDcfHandler->DrmTell();
1364                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1365                 {
1366                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, forward : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1367                         goto CATCH;
1368                 }
1369         }
1370         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1371         {
1372                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1373                 goto CATCH;
1374         }
1375
1376         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1377         {
1378                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1379                 if (nRet != TADC_SUCCESS)
1380                 {
1381                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1382                         goto CATCH;
1383                 }
1384
1385                 DrmCurOffset = pDcfHandler->DrmTell();
1386                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1387                 {
1388                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1389                         goto CATCH;
1390                 }
1391         }
1392         if (DrmCurOffset != 0)
1393         {
1394                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1395                 goto CATCH;
1396         }
1397
1398         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1399         {
1400                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1401                 if (nRet != TADC_SUCCESS)
1402                 {
1403                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1404                         goto CATCH;
1405                 }
1406
1407                 DrmCurOffset = pDcfHandler->DrmTell();
1408                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1409                 {
1410                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1411                         goto CATCH;
1412                 }
1413         }
1414         if (DrmCurOffset != 0)
1415         {
1416                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1417                 goto CATCH;
1418         }
1419
1420         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1421         {
1422                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1423                 if (nRet != TADC_SUCCESS)
1424                 {
1425                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1426                         goto CATCH;
1427                 }
1428
1429                 DrmCurOffset = pDcfHandler->DrmTell();
1430                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1431                 {
1432                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1433                         goto CATCH;
1434                 }
1435         }
1436         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1437         {
1438                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1439                 goto CATCH;
1440         }
1441
1442         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1443         {
1444                 nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
1445                 if (nRet != TADC_SUCCESS)
1446                 {
1447                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1448                         goto CATCH;
1449                 }
1450
1451                 DrmCurOffset = pDcfHandler->DrmTell();
1452                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1453                 {
1454                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
1455                         goto CATCH;
1456                 }
1457         }
1458         if (DrmCurOffset != 0)
1459         {
1460                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1461                 goto CATCH;
1462         }
1463
1464         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1465         {
1466                 nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
1467                 if (nRet != TADC_SUCCESS)
1468                 {
1469                         printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
1470                         goto CATCH;
1471                 }
1472
1473                 DrmCurOffset = pDcfHandler->DrmTell();
1474                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1475                 {
1476                         printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1477                         goto CATCH;
1478                 }
1479         }
1480         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1481         {
1482                 printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1483                 goto CATCH;
1484         }
1485
1486         printf("tc09_DrmFileMgrPositive_FileAPI_02 finished! -------- success \n");
1487
1488         return true;
1489
1490 CATCH:
1491         return false;
1492 }
1493
1494 bool tc09_DrmFileMgrPositive_FileAPI_03(void)
1495 {
1496         const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
1497         int nRet = TADC_SUCCESS;
1498
1499         DrmFileMgr* pDrmFileMgr = NULL;
1500         DrmFileHandler *pDcfHandler = NULL;
1501
1502         long long originalEndOffset = 45194636;
1503         long long DrmCurOffset = 0;
1504         long long OriginCurOffset = 847;
1505         long long i = 0;
1506
1507         printf("tc09_DrmFileMgrPositive_FileAPI_03() -------- Started! \n");
1508
1509         pDrmFileMgr = DrmFileMgr::GetInstance();
1510
1511         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1512         if (nRet != TADC_SUCCESS)
1513         {
1514                 printf("tc09_DrmFileMgrPositive_FileAPI_03 failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
1515                 goto CATCH;
1516         }
1517
1518         if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
1519         {
1520                 printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
1521                 goto CATCH;
1522         }
1523
1524         if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
1525         {
1526                 printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
1527                 goto CATCH;
1528         }
1529
1530         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1531         {
1532                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1533                 if (nRet != TADC_SUCCESS)
1534                 {
1535                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", third_key, pDCF, i, nRet);
1536                         goto CATCH;
1537                 }
1538
1539                 DrmCurOffset = pDcfHandler->DrmTell();
1540                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1541                 {
1542                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1543                         goto CATCH;
1544                 }
1545         }
1546         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1547         {
1548                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1549                 goto CATCH;
1550         }
1551
1552         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1553         {
1554                 nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
1555                 if (nRet != TADC_SUCCESS)
1556                 {
1557                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1558                         goto CATCH;
1559                 }
1560
1561                 DrmCurOffset = pDcfHandler->DrmTell();
1562                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1563                 {
1564                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1565                         goto CATCH;
1566                 }
1567         }
1568         if (DrmCurOffset != 0)
1569         {
1570                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1571                 goto CATCH;
1572         }
1573
1574         for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
1575         {
1576                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1577                 if (nRet != TADC_SUCCESS)
1578                 {
1579                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1580                         goto CATCH;
1581                 }
1582
1583                 DrmCurOffset = pDcfHandler->DrmTell();
1584                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1585                 {
1586                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1587                         goto CATCH;
1588                 }
1589         }
1590         if (DrmCurOffset != 0)
1591         {
1592                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1593                 goto CATCH;
1594         }
1595
1596         for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
1597         {
1598                 nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
1599                 if (nRet != TADC_SUCCESS)
1600                 {
1601                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1602                         goto CATCH;
1603                 }
1604
1605                 DrmCurOffset = pDcfHandler->DrmTell();
1606                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1607                 {
1608                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1609                         goto CATCH;
1610                 }
1611         }
1612         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1613         {
1614                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
1615                 goto CATCH;
1616         }
1617
1618         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1619         {
1620                 nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
1621                 if (nRet != TADC_SUCCESS)
1622                 {
1623                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1624                         goto CATCH;
1625                 }
1626
1627                 DrmCurOffset = pDcfHandler->DrmTell();
1628                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1629                 {
1630                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
1631                         goto CATCH;
1632                 }
1633         }
1634         if (DrmCurOffset != 0)
1635         {
1636                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1637                 goto CATCH;
1638         }
1639
1640         for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
1641         {
1642                 nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
1643                 if (nRet != TADC_SUCCESS)
1644                 {
1645                         printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
1646                         goto CATCH;
1647                 }
1648
1649                 DrmCurOffset = pDcfHandler->DrmTell();
1650                 if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
1651                 {
1652                         printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
1653                         goto CATCH;
1654                 }
1655         }
1656         if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
1657         {
1658                 printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
1659                 goto CATCH;
1660         }
1661
1662         printf("tc09_DrmFileMgrPositive_FileAPI_03 finished! -------- success \n");
1663
1664         return true;
1665
1666 CATCH:
1667         return false;
1668 }
1669
1670 bool tc10_DrmFileMgrPositive_CloseFileHandler_01(void)
1671 {
1672         int nRet = TADC_SUCCESS;
1673
1674         DrmFileMgr* pDrmFileMgr = NULL;
1675         DrmFileHandler *pDcfHandler = NULL;
1676
1677         printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 -------- Started! \n");
1678
1679         pDrmFileMgr = DrmFileMgr::GetInstance();
1680
1681         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
1682         if (nRet != TADC_SUCCESS)
1683         {
1684                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n", first_key, nRet);
1685                 goto CATCH;
1686         }
1687
1688         nRet = pDrmFileMgr->CloseFileHandler(first_key);
1689         if (nRet != TADC_SUCCESS)
1690         {
1691                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n", first_key, nRet);
1692                 goto CATCH;
1693         }
1694
1695         nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
1696         if (nRet == TADC_SUCCESS)
1697         {
1698                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d\n", first_key);
1699                 goto CATCH;
1700         }
1701
1702         printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 finished! -------- success \n");
1703
1704         return true;
1705
1706 CATCH:
1707         return false;
1708 }
1709
1710 bool tc10_DrmFileMgrPositive_CloseFileHandler_02(void)
1711 {
1712         int nRet = TADC_SUCCESS;
1713
1714         DrmFileMgr* pDrmFileMgr = NULL;
1715         DrmFileHandler *pDcfHandler = NULL;
1716
1717         printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 -------- Started! \n");
1718
1719         pDrmFileMgr = DrmFileMgr::GetInstance();
1720
1721         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1722         if (nRet != TADC_SUCCESS)
1723         {
1724                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n", second_key, nRet);
1725                 goto CATCH;
1726         }
1727
1728         nRet = pDrmFileMgr->CloseFileHandler(second_key);
1729         if (nRet != TADC_SUCCESS)
1730         {
1731                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n", second_key, nRet);
1732                 goto CATCH;
1733         }
1734
1735         nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
1736         if (nRet == TADC_SUCCESS)
1737         {
1738                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d\n", second_key);
1739                 goto CATCH;
1740         }
1741
1742         printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 finished! -------- success \n");
1743
1744         return true;
1745
1746 CATCH:
1747         return false;
1748 }
1749
1750 bool tc10_DrmFileMgrPositive_CloseFileHandler_03(void)
1751 {
1752         int nRet = TADC_SUCCESS;
1753
1754         DrmFileMgr* pDrmFileMgr = NULL;
1755         DrmFileHandler *pDcfHandler = NULL;
1756
1757         printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 -------- Started! \n");
1758
1759         pDrmFileMgr = DrmFileMgr::GetInstance();
1760
1761         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1762         if (nRet != TADC_SUCCESS)
1763         {
1764                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n", third_key, nRet);
1765                 goto CATCH;
1766         }
1767
1768         nRet = pDrmFileMgr->CloseFileHandler(third_key);
1769         if (nRet != TADC_SUCCESS)
1770         {
1771                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n", third_key, nRet);
1772                 goto CATCH;
1773         }
1774
1775         nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
1776         if (nRet == TADC_SUCCESS)
1777         {
1778                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d\n", third_key);
1779                 goto CATCH;
1780         }
1781
1782         printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 finished! -------- success \n");
1783
1784         return true;
1785
1786 CATCH:
1787         return false;
1788 }
1789
1790 bool tc11_GetDeviceId_01(void)
1791 {
1792         unsigned char DUID[33] = {0,};
1793         int nRet = 0;
1794
1795         printf("tc11_GetDeviceID_01() -------- Started! \n");
1796
1797         nRet = TADC_IF_GetDUID((char*)DUID);
1798         if (nRet !=TADC_SUCCESS)
1799         {
1800                 printf("tc11_GetDeviceID_01() failed.");
1801                 return false;
1802         }
1803
1804         printf("DUID=%s\n", (char*)DUID);
1805         printf("tc11_GetDeviceID_01() finished! -------- success \n");
1806
1807         return true;
1808 }
1809
1810 bool tc12_TADC_SetDeviceInfo_01(void)
1811 {
1812         int     nRet = TADC_SUCCESS;
1813         T_DEVICE_INFO   t_DeviceInfo;
1814
1815         printf("tc12_TADC_SetDeviceInfo_01() -------- Started! \n");
1816
1817         nRet = TADC_SetDeviceInfo(&t_DeviceInfo);
1818         if (nRet != TADC_SUCCESS)
1819         {
1820                 printf("tc12_TADC_SetDeviceInfo_01() failed.\n");
1821                 return false;
1822         }
1823         printf("DUID=%s\n", (char*)t_DeviceInfo.DUID);
1824         printf("tc12_TADC_SetDeviceInfo_01() finished! -------- success \n");
1825
1826         return true;
1827 }
1828
1829 bool tc13_DTappsInstallLicense_01(void)
1830 {
1831         printf("tc13_DTappsInstallLicense_01() -------- Started! \n");
1832
1833         const char *pFirstRo = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.ro";
1834
1835         auto buf = _read_ro_file(pFirstRo);
1836
1837         int nRet = DTappsInstallLicense(reinterpret_cast<char *>(buf.data()));
1838         if (nRet != TADC_SUCCESS) {
1839                 printf("tc13_DTappsInstallLicense_01() failed. nRet=%d\n", nRet);
1840                 return false;
1841         }
1842
1843         printf("tc13_DTappsInstallLicense_01() finished! -------- success \n");
1844         return true;
1845 }
1846
1847 bool tc13_DTappsInstallLicense_02(void)
1848 {
1849         printf("tc13_DTappsInstallLicense_02() -------- Started! \n");
1850
1851         const char *pFirstRo = TEST_DATA_DIR "/RO/8SPXfqc6iL-1.0.0.ro";
1852
1853         auto buf = _read_ro_file(pFirstRo);
1854
1855         int nRet = DTappsInstallLicense(reinterpret_cast<char *>(buf.data()));
1856         if (nRet != TADC_SUCCESS) {
1857                 printf("tc13_DTappsInstallLicense_02() failed. nRet=%d\n", nRet);
1858                 return false;
1859         }
1860
1861         printf("tc13_DTappsInstallLicense_02() finished! -------- success \n");
1862         return true;
1863 }
1864
1865 bool tc13_DTappsInstallLicense_03(void)
1866 {
1867         printf("tc13_DTappsInstallLicense_03() -------- Started! \n");
1868
1869         const char *pFirstRo = TEST_DATA_DIR "/RO/FightGuiIF-1.0.0.ro";
1870
1871         auto buf = _read_ro_file(pFirstRo);
1872
1873         int nRet = DTappsInstallLicense(reinterpret_cast<char *>(buf.data()));
1874         if (nRet != TADC_SUCCESS) {
1875                 printf("tc13_DTappsInstallLicense_03() failed. nRet=%d\n", nRet);
1876                 return false;
1877         }
1878
1879         printf("tc13_DTappsInstallLicense_03() finished! -------- success \n");
1880         return true;
1881 }
1882
1883 bool
1884 tc_local_01_drm_tizen_generate_license_request_p(void)
1885 {
1886     bool res = true;
1887     int ret_value = DRMTEST_SUCCESS;
1888
1889     char *purchase_response = NULL;
1890     char *req_id = NULL;
1891     unsigned int  req_buff_len = 1024*5;
1892     char req_buff[req_buff_len] = {0, };
1893     unsigned int  url_buff_len = 1024;
1894     char url_buff[url_buff_len] = {0, };
1895
1896     printf("[%s] test started\n", __func__);
1897     ret_value = generate_purchase_response(&purchase_response, &req_id);
1898     if(ret_value != DRMTEST_SUCCESS) {
1899         res = false;
1900         goto CATCH;
1901     }
1902     printf("...purchase_response:\n%s\n", purchase_response);
1903
1904     ret_value = drm_tizen_generate_license_request(purchase_response, strlen(purchase_response),
1905                                              req_buff, &req_buff_len, url_buff, &url_buff_len);
1906     if(ret_value != TADC_SUCCESS) {
1907         printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
1908         res = false;
1909         goto CATCH;
1910     }
1911     printf("...license_request_url:%s\n", url_buff);
1912     printf("...license_request:\n%s\n", req_buff);
1913
1914     printf("[%s] test ended: result=%d\n", __func__, ret_value);
1915
1916 CATCH:
1917     if(purchase_response != NULL)
1918         free(purchase_response);
1919     if(req_id != NULL)
1920         free(req_id);
1921
1922     return res;
1923 }
1924
1925 bool
1926 tc_local_01_drm_tizen_full_test_p(void)
1927 {
1928     bool res = true;
1929     int ret_value = DRMTEST_SUCCESS;
1930
1931     char *purchase_response = NULL;
1932     char *req_id = NULL;
1933     unsigned int  req_buff_len = 1024*5;
1934     char req_buff[req_buff_len] = {0, };
1935     unsigned int  url_buff_len = 1024;
1936     char url_buff[url_buff_len] = {0, };
1937
1938     char* ro_request_buff = NULL;
1939     char* ro_response_buff = NULL;
1940     char* dh_key_p = NULL;
1941     char* dh_key_g = NULL;
1942     char* dh_key_a = NULL;
1943
1944     unsigned char duid[33] = {0,};
1945     const char* cid = "38EIfBurLJ-1.0.2";
1946     const char* ro_template_path = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.ro_template";
1947
1948     const char* encrypted_file_path = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
1949     const char* plaintext_file_path = TEST_DATA_DIR "/DecryptedApp/38EIfBurLJ_dec.tpk";
1950     const char* decrypted_file_path = "/tmp/38EIfBurLJ.tpk";
1951
1952     int identical = DRMTEST_NOTIDENTICAL;
1953
1954     printf("[%s] test started\n", __func__);
1955
1956     if(ret_value != DRMTEST_SUCCESS) {
1957         res = false;
1958         goto CATCH;
1959     }
1960
1961     ret_value = generate_purchase_response(&purchase_response, &req_id);
1962     if(ret_value != DRMTEST_SUCCESS) {
1963         res = false;
1964         goto CATCH;
1965     }
1966     //printf("...purchase_response:\n%s\n", purchase_response);
1967
1968     ret_value = drm_tizen_generate_license_request(purchase_response, strlen(purchase_response),
1969                                              req_buff, &req_buff_len, url_buff, &url_buff_len);
1970     if(ret_value != TADC_SUCCESS) {
1971         printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
1972         res = false;
1973         goto CATCH;
1974     }
1975     printf("...license_request_url:%s\n", url_buff);
1976     printf("...license_request:\n%s\n", req_buff);
1977
1978     ret_value = get_dh_key_from_ro_request(req_buff, &dh_key_p, &dh_key_g, &dh_key_a);
1979     if(ret_value != DRMTEST_SUCCESS) {
1980         res = false;
1981         goto CATCH;
1982     }
1983     //printf("...DH key: p=%s, g=%s, a=%s\n", dh_key_p, dh_key_g, dh_key_a);
1984
1985     ret_value = TADC_IF_GetDUID((char*)duid);
1986     if (ret_value != TADC_SUCCESS) {
1987         return false;
1988     }
1989     printf("duid=%s\n", (char*)duid);
1990
1991     ret_value = generate_right_object_response(dh_key_p, dh_key_g, dh_key_a, req_id,
1992                                                cid, ro_template_path, (const char*)duid, &ro_response_buff);
1993     if(ret_value != DRMTEST_SUCCESS) {
1994         res = false;
1995         goto CATCH;
1996     }
1997     printf("...right_object_response:\n%s\n", ro_response_buff);
1998
1999     ret_value = drm_tizen_register_license(ro_response_buff, strlen(ro_response_buff));
2000     if(ret_value != TADC_SUCCESS) {
2001         printf("...drm_tizen_register_license failed. ret=%d\n", ret_value);
2002         res = false;
2003         goto CATCH;
2004     }
2005     printf("...drm_tizen_register_license: succeeded\n");
2006
2007     ret_value = drm_tizen_decrypt_package(encrypted_file_path, strlen(encrypted_file_path),
2008                                           decrypted_file_path, strlen(decrypted_file_path));
2009     if(ret_value != TADC_SUCCESS) {
2010         printf("...drm_tizen_decrypt_package failed. ret=%d\n", ret_value);
2011         res = false;
2012         goto CATCH;
2013     }
2014     printf("...drm_tizen_decrypt_package: succeeded\n");
2015
2016     ret_value = is_identical_files(plaintext_file_path, decrypted_file_path, &identical);
2017     if(ret_value != DRMTEST_SUCCESS) {
2018         printf("...is_identical_files failed. ret=%d\n", ret_value);
2019         res = false;
2020         goto CATCH;
2021     }
2022     if(identical != DRMTEST_IDENTICAL) {
2023         printf("...the decrypted file is not same with a original plaintext file .\n");
2024         res = false;
2025         goto CATCH;
2026     }
2027     printf("...drm_tizen_decrypt_package: succeeded : the decrypted file is with a original plaintext file.\n");
2028
2029 CATCH:
2030     if(purchase_response != NULL)
2031         free(purchase_response);
2032     if(req_id != NULL)
2033         free(req_id);
2034     if(ro_request_buff != NULL)
2035         free(ro_request_buff);
2036     if(ro_response_buff != NULL)
2037         free(ro_response_buff);
2038
2039     return res;
2040 }
2041
2042
2043 /*
2044 bool tc15_DrmTdcDecryptPackge_01(void)
2045 {
2046         int     nRet = TADC_SUCCESS;
2047
2048 }
2049 */
2050 #endif
2051
2052 int main(int, char *[])
2053 {
2054         printf(" ---------- Test Tizen DRM core --- Start ....\n");
2055         test_drm_core();
2056         printf(" ---------- Test Tizen DRM core ---  End  ....\n");
2057
2058 #if 1
2059         printf(" ---------- Test Tizen DRM v2.0.1 APIs   ---  Start ....    \n");
2060
2061         int bRet = TADC_SUCCESS;
2062
2063         char ReqBuf[1024*5] = {0, };
2064         unsigned int ReqBufLen = 0;
2065
2066         char RespBuf[1024*10] = {0, };
2067         unsigned int RespBufLen = 0;
2068
2069 //      char DecLicenseBuf[1024*10] = {0, };
2070 //      unsigned int DecLicenseBufLen = 0;
2071
2072         char LicenseUrl[1024] = {0, };
2073         unsigned int LicenseUrlLen = 0;
2074
2075         //2011.03.08
2076         //DrmTdcFileHeader TDCFileHeader;
2077 //      char cid[1024] = {0, };
2078 //      char riurl[1024] = {0, };
2079
2080         char testFileName[256] = {0, };
2081         char tempBuf[256] = {0, };
2082
2083         bool isOk = false;
2084
2085         //----------------------------------------------------------------------------------------------------
2086         // 0. Static TC running
2087         //----------------------------------------------------------------------------------------------------
2088
2089         printf("\n0. Static TC  Start  ----------------------------------------\n");
2090 /*
2091         isOk = tc01_VerifyRoSignature_Positive_01();
2092         if (isOk != true)
2093         {
2094                 printf("tc01_VerifyRoSignature_Positive_01 failed!\n");
2095         }
2096
2097         isOk = tc01_VerifyRoSignature_Positive_02();
2098         if (isOk != true)
2099         {
2100                 printf("tc01_VerifyRoSignature_Positive_02 failed!\n");
2101         }
2102
2103         isOk = tc01_VerifyRoSignature_Positive_03();
2104         if (isOk != true)
2105         {
2106                 printf("tc01_VerifyRoSignature_Positive_03 failed!\n");
2107         }
2108
2109         isOk = tc02_VerifyRoSignature_Negative_Cert_01();
2110         if (isOk != true)
2111         {
2112                 printf("tc02_VerifyRoSignature_Negative_Cert_01 failed!\n");
2113         }
2114
2115         isOk = tc02_VerifyRoSignature_Negative_Cert_02();
2116         if (isOk != true)
2117         {
2118                 printf("tc02_VerifyRoSignature_Negative_Cert_02 failed!\n");
2119         }
2120
2121         isOk = tc02_VerifyRoSignature_Negative_Cert_03();
2122         if (isOk != true)
2123         {
2124                 printf("tc02_VerifyRoSignature_Negative_Cert_03 failed!\n");
2125         }
2126
2127         isOk = tc03_VerifyRoSignature_Negative_Signature_01();
2128         if (isOk != true)
2129         {
2130                 printf("tc03_VerifyRoSignature_Negative_Signature_01 failed!\n");
2131         }
2132
2133         isOk = tc03_VerifyRoSignature_Negative_Signature_02();
2134         if (isOk != true)
2135         {
2136                 printf("tc03_VerifyRoSignature_Negative_Signature_02 failed!\n");
2137         }
2138
2139         isOk = tc03_VerifyRoSignature_Negative_Signature_03();
2140         if (isOk != true)
2141         {
2142                 printf("tc03_VerifyRoSignature_Negative_Signature_03 failed!\n");
2143         }
2144
2145         isOk = tc04_isDrmFile_Positive_01();
2146         if (isOk != true)
2147         {
2148                 printf("tc04_isDrmFile_Positive_01 failed!\n");
2149         }
2150
2151         isOk = tc04_isDrmFile_Positive_02();
2152         if (isOk != true)
2153         {
2154                 printf("tc04_isDrmFile_Positive_02 failed!\n");
2155         }
2156
2157         isOk = tc04_isDrmFile_Positive_03();
2158         if (isOk != true)
2159         {
2160                 printf("tc04_isDrmFile_Positive_03 failed!\n");
2161         }
2162
2163         isOk = tc05_isDrmFile_Negative_01();
2164         if (isOk != true)
2165         {
2166                 printf("tc05_isDrmFile_Negative_01 failed!\n");
2167         }
2168
2169         isOk = tc05_isDrmFile_Negative_02();
2170         if (isOk != true)
2171         {
2172                 printf("tc05_isDrmFile_Negative_02 failed!\n");
2173         }
2174
2175         isOk = tc05_isDrmFile_Negative_03();
2176         if (isOk != true)
2177         {
2178                 printf("tc05_isDrmFile_Negative_03 failed!\n");
2179         }
2180
2181         isOk = tc13_DTappsInstallLicense_01();
2182         if (isOk != true)
2183         {
2184                 printf("tc13_DTappsInstallLicense_01 failed!\n");
2185         }
2186
2187         isOk = tc13_DTappsInstallLicense_02();
2188         if (isOk != true)
2189         {
2190                 printf("tc13_DTappsInstallLicense_02 failed!\n");
2191         }
2192
2193         isOk = tc13_DTappsInstallLicense_03();
2194         if (isOk != true)
2195         {
2196                 printf("tc13_DTappsInstallLicense_03 failed!\n");
2197         }
2198
2199         isOk = tc06_DrmFileHandlerPositive_01();
2200         if (isOk != true)
2201         {
2202                 printf("tc06_DrmFileHandlerPositive_01 failed!\n");
2203         }
2204
2205         isOk = tc06_DrmFileHandlerPositive_02();
2206         if (isOk != true)
2207         {
2208                 printf("tc06_DrmFileHandlerPositive_02 failed!\n");
2209         }
2210
2211         isOk = tc06_DrmFileHandlerPositive_03();
2212         if (isOk != true)
2213         {
2214                 printf("tc06_DrmFileHandlerPositive_03 failed!\n");
2215         }
2216
2217         isOk = tc07_DrmFileMgrPositive_01();
2218         if (isOk != true)
2219         {
2220                 printf("tc07_DrmFileMgrPositive_01 failed!\b");
2221         }
2222
2223         isOk = tc07_DrmFileMgrPositive_02();
2224         if (isOk != true)
2225         {
2226                 printf("tc07_DrmFileMgrPositive_02 failed!\n");
2227         }
2228
2229         isOk = tc07_DrmFileMgrPositive_03();
2230         if (isOk != true)
2231         {
2232                 printf("tc07_DrmFileMgrPositive_03 failed!\n");
2233         }
2234
2235         isOk = tc08_DrmFileMgrPositive_GetFileHandler_01();
2236         if (isOk != true)
2237         {
2238                 printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed!\n");
2239         }
2240
2241         isOk = tc08_DrmFileMgrPositive_GetFileHandler_02();
2242         if (isOk != true)
2243         {
2244                 printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed!\n");
2245         }
2246
2247         isOk = tc08_DrmFileMgrPositive_GetFileHandler_03();
2248         if (isOk != true)
2249         {
2250                 printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed!\n");
2251         }
2252
2253         isOk = tc09_DrmFileMgrPositive_FileAPI_01();
2254         if (isOk != true)
2255         {
2256                 printf("tc09_DrmFileMgrPositive_FileAPI_01 failed!\n");
2257         }
2258
2259         isOk = tc09_DrmFileMgrPositive_FileAPI_02();
2260         if (isOk != true)
2261         {
2262                 printf("tc09_DrmFileMgrPositive_FileAPI_02 failed!\n");
2263         }
2264
2265         isOk = tc09_DrmFileMgrPositive_FileAPI_03();
2266         if (isOk != true)
2267         {
2268                 printf("tc09_DrmFileMgrPositive_FileAPI_03 failed!\n");
2269         }
2270
2271         isOk = tc10_DrmFileMgrPositive_CloseFileHandler_01();
2272         if (isOk != true)
2273         {
2274                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed!\n");
2275         }
2276
2277         isOk = tc10_DrmFileMgrPositive_CloseFileHandler_02();
2278         if (isOk != true)
2279         {
2280                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed!\n");
2281         }
2282
2283         isOk = tc10_DrmFileMgrPositive_CloseFileHandler_03();
2284         if (isOk != true)
2285         {
2286                 printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed!\n");
2287         }
2288
2289         isOk = tc11_GetDeviceId_01();
2290         if (isOk != true)
2291         {
2292                 printf("tc11_GetDeviceId_01 failed!\n");
2293         }
2294
2295         isOk = tc12_TADC_SetDeviceInfo_01();
2296         if (isOk != true)
2297         {
2298                 printf("tc12_TADC_SetDeviceInfo_01 failed!\n");
2299         }
2300
2301         isOk = tc11_GetDeviceId_01();
2302         if (isOk != true)
2303         {
2304                 printf("tc11_GetDeviceId_01 failed!\n");
2305         }
2306 */
2307     isOk = tc_local_01_drm_tizen_full_test_p();
2308     if (isOk != true)
2309     {
2310         printf("tc_local_01_drm_tizen_full_test_p failed!\n");
2311     }
2312
2313         //----------------------------------------------------------------------------------------------------
2314         // 1. Check is drm file
2315         //----------------------------------------------------------------------------------------------------
2316
2317         printf("===============================================================================\n");
2318         printf ("Enter test file name  -->  ");
2319
2320         isOk = scanf("%s", testFileName);
2321         if (isOk < 1)
2322         {
2323                 printf ("Input value wrong! scanf() failed!!");
2324                 return 0;
2325         }
2326         printf("\n1. drm_tizen_is_drm_file  Start  ----------------------------------------\n");
2327
2328         bRet = drm_tizen_is_drm_file(testFileName, strlen(testFileName));
2329         if (bRet != TADC_SUCCESS)
2330         {
2331                 printf("drm_tizen_is_drm_file Error! ret = %d\n", bRet);
2332                 return 0;
2333         }
2334         printf("%s file is TADC file!\n", testFileName);
2335
2336         //----------------------------------------------------------------------------------------------------
2337         // 2. Make PurchaseRequest Data
2338         //----------------------------------------------------------------------------------------------------
2339         printf("\n2. Make PurchaseRequest Data  Start  ----------------------------------------\n");
2340
2341         memset(ReqBuf, 0x00, sizeof(ReqBuf));
2342         memset(LicenseUrl, 0x00, sizeof(LicenseUrl));
2343         ReqBufLen = sizeof(ReqBuf);
2344         LicenseUrlLen = sizeof(LicenseUrl);
2345
2346         bRet = drm_tizen_generate_purchase_request(testFileName, ReqBuf, &ReqBufLen, LicenseUrl, &LicenseUrlLen);
2347         if (bRet == false)
2348         {
2349                 printf(" drm_tizen_generate_purchase_request Error!  \n");
2350                 return 0;
2351         }
2352
2353         printf("drm_tizen_generate_purchase_request - ReqBufLen : %d,  License Url : %s   \n", ReqBufLen, LicenseUrl);
2354         if ((bRet = _write_logfile("Request_1.dat", ReqBuf, ReqBufLen-1)) == false)
2355         {
2356                 printf(" drm_tizen_generate_purchase_request _write_logfile Error!  \n");
2357                 return 0;
2358         }
2359
2360         //break.... HTTP Request & Reaponse Processing...
2361         printf ("Enter any key after create Response_1.dat file. -->  ");
2362         std::cin >> tempBuf;
2363
2364         memset(RespBuf, 0x00, sizeof(RespBuf));
2365         RespBufLen = sizeof(RespBuf);
2366         if ((bRet = _read_logfile("Response_1.dat", RespBuf, &RespBufLen)) == false)
2367         {
2368                 printf(" drm_tizen_generate_purchase_request _read_logfile Error!  \n");
2369                 return 0;
2370         }
2371
2372         //----------------------------------------------------------------------------------------------------
2373         // 3. Make License Request Data
2374         //----------------------------------------------------------------------------------------------------
2375         printf("\n3. Make License Request Data  Start  ----------------------------------------\n");
2376
2377         memset(ReqBuf, 0x00, sizeof(ReqBuf));
2378         memset(LicenseUrl, 0x00, sizeof(LicenseUrl));
2379         ReqBufLen = sizeof(ReqBuf);
2380         LicenseUrlLen = sizeof(LicenseUrl);
2381
2382         bRet = drm_tizen_generate_license_request(RespBuf,  RespBufLen, ReqBuf, &ReqBufLen, LicenseUrl, &LicenseUrlLen);
2383         if (bRet != TADC_SUCCESS)
2384         {
2385                 printf(" drm_tizen_generate_license_request Error!  \n");
2386                 return 0;
2387         }
2388
2389         printf("drm_tizen_generate_license_request - ReqBufLen : %d,  RO Url : %s   \n", ReqBufLen, LicenseUrl);
2390         if ((bRet = _write_logfile("Request_2.dat", ReqBuf, ReqBufLen - 1)) == false)
2391         {
2392                 printf(" drm_tizen_generate_license_request _write_logfile Error!  \n");
2393                 return 0;
2394         }
2395
2396         //break.... HTTP Request & Reaponse Processing...
2397         printf ("Enter any key after create Response_2.dat file. -->  ");
2398         std::cin >> tempBuf;
2399
2400         memset(RespBuf, 0x00, sizeof(RespBuf));
2401         RespBufLen = sizeof(RespBuf);
2402         if ((bRet = _read_logfile("Response_2.dat", RespBuf, &RespBufLen)) == false)
2403         {
2404                 printf(" drm_tizen_generate_license_request _read_logfile Error! \n");
2405                 return 0;
2406         }
2407
2408         //----------------------------------------------------------------------------------------------------
2409         // 4. Decrypt DRM License
2410         //----------------------------------------------------------------------------------------------------
2411         printf("\n4. Decrypt DRM License Start  --------------------------------------------\n");
2412
2413         bRet = drm_tizen_register_license(RespBuf, RespBufLen);
2414         if (bRet != TADC_SUCCESS)
2415         {
2416                 printf(" drm_tizen_register_license  Error!  \n");
2417                 return 0;
2418         }
2419
2420         //---------------------------------------------------------------------------------------------------
2421         // 5. Decrypt DRM File
2422         //----------------------------------------------------------------------------------------------------
2423         printf("\n5. Decrypt DRM File Start  -----------------------------------------\n");
2424
2425         sprintf(tempBuf, "%s.dec", testFileName);
2426         bRet = drm_tizen_decrypt_package(testFileName, strlen(testFileName), tempBuf, strlen(tempBuf));
2427
2428         if (bRet != TADC_SUCCESS)
2429         {
2430                 printf(" drm_tizen_decrypt_package  Error!  \n");
2431                 return 0;
2432         }
2433
2434         printf("\n --------------Test Tizen Apps DRM APIs   ---  End ---------------\n");
2435
2436 #endif
2437 }