2 * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
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
8 * http://floralicense.org/license/
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.
24 #include "CPointerArray.h"
25 #include "CXMLAttribute.h"
26 #include "CXMLElement.h"
29 #define STACKTRACE(pszFunction) // RETAILMSG(1, pszFunction);
32 #define IF_ERROR_RETURN(error , errcode) \
34 DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); \
37 #define IF_TRUE_RETURN(error , errcode) \
39 DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); \
44 #define IF_TRUE_RETURN2(error , do1, do2, do3, errcode) \
49 DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); \
54 #define TADC_SWAP32(x) \
55 ((((TADC_U32)(x) & 0x000000ffL) << 24) | \
56 (((TADC_U32)(x) & 0x0000ff00L) << 8) | \
57 (((TADC_U32)(x) & 0x00ff0000L) >> 8) | \
58 (((TADC_U32)(x) & 0xff000000L) >> 24))
61 #define TADC_U8 unsigned char
62 #define TADC_U16 unsigned short
63 #define TADC_U32 unsigned long
64 #define DWORD unsigned long
65 #define LPBYTE unsigned char *
66 #define TCHAR unsigned char
68 #define BYTE unsigned char
69 #define UINT unsigned int
70 #define ULONG unsigned long
72 #define INT64 long long
77 #define REQU_MAXSIZE 1024 * 5 // HTTP Request Buffer Max Size
78 #define RESP_MAXSIZE 1024 * 10 // HTTP Response Buffer Max Size
80 #define ROXML_MAXSIZE 4096 * 2
81 #define CERT_MAXSIZE 4096
84 #define CID_SIZE 1024 // 32 -> 1024
85 #define CEK_SIZE 32 // multiplication of 8
88 // Core Value Size define
90 #define DEVICEKEY_SIZE 16
92 #define DHKey_SIZE 128 // bit
94 // DRM Type : Tizen DRM DRM - 1
103 typedef struct t_file_header {
104 unsigned char Version[2];
105 unsigned char DRMType;
106 unsigned char ContentsType[128];
118 typedef struct t_drm_header {
120 unsigned char Version[2];
123 unsigned char ContentsType[128];
124 long EncryptionMethod;
125 long EncryptionLevel;
126 long long EncryptionRange;
127 unsigned char *RIURL;
128 long long PlaintextSize;
129 unsigned char *Packdate;
133 typedef struct t_decice_info {
134 unsigned char DUID[DUID_SIZE + 1];
137 typedef struct t_dh_info {
138 unsigned char p[DHKey_SIZE + 1]; // DH prime binary
140 long g; // DH primitive root. ( 2 or 5 )
141 unsigned char a[DHKey_SIZE + 1]; // DH Client private binary
143 unsigned char A[DHKey_SIZE + 1]; // DH Client public binary (ga mod p)
145 unsigned char B[DHKey_SIZE + 1]; // DH Server public binary (gb mod p)
147 unsigned char K[32 + 1]; // DH Session Key
150 typedef struct t_ro_content {
155 typedef struct t_roacq_info {
156 unsigned char *ROAcqURL;
157 unsigned char *ReqID;
159 unsigned char sTimeStamp[21];
162 typedef struct t_individual {
163 unsigned char BindingType;
167 typedef struct t_ro_permission {
168 T_INDIVIDUAL t_Individual;
172 typedef struct t_ro {
174 T_RO_CONTENT t_Content;
175 T_RO_PERMISSION t_Permission;
178 int TADC_SetDeviceInfo(T_DEVICE_INFO *t_DeviceInfo);
179 int TADC_GetFileHeader(unsigned char *inBuffer, T_FILE_HEADER *t_FileHeader);
180 int TADC_GetDRMHeader(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader);
181 int TADC_GetDRMHeaderInfo(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader);
182 int TADC_GetDRMHeaderFromFile(const char *pTADCFilepath,
183 T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader);
184 int TADC_MakeRequestLicense(T_DEVICE_INFO *t_DeviceInfo,
185 T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader,
186 unsigned char *outBuffer, size_t outBufferSize);
187 int TADC_GetROAcqInfo(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo);
188 int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char *outBuffer,
189 size_t outBufferSize, unsigned char *ROVer = NULL);
190 int TADC_GetResponseRO(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo,
191 T_RO *t_RO, unsigned char *outBuffer);
192 int TADC_GetResponseROInfo(LPBYTE pszXML, T_RO *t_RO);
193 int TADC_GetHashReqID(unsigned char *inBuffer, unsigned char *hashReqID);
194 int TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB,
195 T_DRM_HEADER *t_DRMHeader);
196 int TADC_DecryptBlock(char *pbBuffer, int nSize,
197 const T_DRM_HEADER *t_DRMHeader);
198 int TADC_VerifyROSignature(LPBYTE pszXML);
199 DWORD TADC_GetLastError(void);
200 int TADC_MEMFree_RO(T_RO *t_ro);
201 int TADC_MEMFree_FileHeader(T_FILE_HEADER *t_FileHeader);
202 int TADC_MEMFree_DRMHeader(T_DRM_HEADER *t_DrmHeader);
203 int TADC_MEMFree_ROAcqInfo(T_ROACQ_INFO *t_ROAcqInfo);
205 #endif //__TADCCORE_H_