1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0 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#ifndef __PARSER_DCF_H__ 18#define __PARSER_DCF_H__ 19 20#ifdef __cplusplus 21extern "C" { 22#endif 23 24#include <drm_common_types.h> 25 26#define MAX_ENCRYPTION_METHOD_LEN 64 27#define MAX_RIGHTS_ISSUER_LEN 256 28#define MAX_CONTENT_NAME_LEN 64 29#define MAX_CONTENT_DESCRIPTION_LEN 256 30#define MAX_CONTENT_VENDOR_LEN 256 31#define MAX_ICON_URI_LEN 256 32#define MAX_CONTENT_TYPE_LEN 64 33#define MAX_CONTENT_URI_LEN 256 34 35#define HEADER_ENCRYPTION_METHOD "Encryption-Method: " 36#define HEADER_RIGHTS_ISSUER "Rights-Issuer: " 37#define HEADER_CONTENT_NAME "Content-Name: " 38#define HEADER_CONTENT_DESCRIPTION "Content-Description: " 39#define HEADER_CONTENT_VENDOR "Content-Vendor: " 40#define HEADER_ICON_URI "Icon-Uri: " 41 42#define HEADER_ENCRYPTION_METHOD_LEN 19 43#define HEADER_RIGHTS_ISSUER_LEN 15 44#define HEADER_CONTENT_NAME_LEN 14 45#define HEADER_CONTENT_DESCRIPTION_LEN 21 46#define HEADER_CONTENT_VENDOR_LEN 16 47#define HEADER_ICON_URI_LEN 10 48 49#define UINT_VAR_FLAG 0x80 50#define UINT_VAR_DATA 0x7F 51#define MAX_UINT_VAR_BYTE 5 52#define DRM_UINT_VAR_ERR -1 53 54typedef struct _T_DRM_DCF_Info { 55 uint8_t Version; 56 uint8_t ContentTypeLen; /**< Length of the ContentType field */ 57 uint8_t ContentURILen; /**< Length of the ContentURI field */ 58 uint8_t unUsed; 59 uint8_t ContentType[MAX_CONTENT_TYPE_LEN]; /**< The MIME media type of the plaintext data */ 60 uint8_t ContentURI[MAX_CONTENT_URI_LEN]; /**< The unique identifier of this content object */ 61 int32_t HeadersLen; /**< Length of the Headers field */ 62 int32_t EncryptedDataLen; /**< Length of the encrypted data field */ 63 int32_t DecryptedDataLen; /**< Length of the decrypted data field */ 64 uint8_t Encryption_Method[MAX_ENCRYPTION_METHOD_LEN]; /**< Encryption method */ 65 uint8_t Rights_Issuer[MAX_RIGHTS_ISSUER_LEN]; /**< Rights issuer */ 66 uint8_t Content_Name[MAX_CONTENT_NAME_LEN]; /**< Content name */ 67 uint8_t ContentDescription[MAX_CONTENT_DESCRIPTION_LEN]; /**< Content description */ 68 uint8_t ContentVendor[MAX_CONTENT_VENDOR_LEN]; /**< Content vendor */ 69 uint8_t Icon_URI[MAX_ICON_URI_LEN]; /**< Icon URI */ 70} T_DRM_DCF_Info; 71 72/** 73 * Parse the DRM content format data 74 * 75 * \param buffer (in)Input the DCF format data 76 * \param bufferLen (in)The input buffer length 77 * \param pDcfInfo (out)A structure pointer which contain information of DCF headers 78 * \param ppEncryptedData (out)The location of encrypted data 79 * 80 * \return 81 * -TRUE, when success 82 * -FALSE, when failed 83 */ 84int32_t drm_dcfParser(uint8_t *buffer, int32_t bufferLen, T_DRM_DCF_Info *pDcfInfo, 85 uint8_t **ppEncryptedData); 86 87#ifdef __cplusplus 88} 89#endif 90 91#endif /* __PARSER_DCF_H__ */ 92