M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file drm_decoder.h
*
* provide service to decode base64 data.
*
* <!-- #interface list begin -->
* \section drm decoder interface
* - drm_decodeBase64()
* <!-- #interface list end -->
*/
#ifndef __DRM_DECODER_H__
#define __DRM_DECODER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/**
* Decode base64
* \param dest dest buffer to save decode base64 data
* \param destLen dest buffer length
* \param src source data to be decoded
* \param srcLen source buffer length, and when return, give out how many bytes has been decoded
* \return
* -when success, return a positive integer of dest buffer length,
* if input dest buffer is NULL or destLen is 0,
* return dest buffer length that user should allocate to save decoding data
* -when failed, return -1
*/
int32_t drm_decodeBase64(uint8_t * dest, int32_t destLen, uint8_t * src, int32_t * srcLen);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_DECODER_H__ */

View File

@@ -0,0 +1,296 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* File Porting Layer.
*/
#ifndef __DRM_FILE_H__
#define __DRM_FILE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/** Type value of a regular file or file name. */
#define DRM_FILE_ISREG 1
/** Type value of a directory or directory name. */
#define DRM_FILE_ISDIR 2
/** Type value of a filter name */
#define DRM_FILE_ISFILTER 3
/** Return code that indicates successful completion of an operation. */
#define DRM_FILE_SUCCESS 0
/** Indicates that an operation failed. */
#define DRM_FILE_FAILURE -1
/** Indicates that the a DRM_file_read() call reached the end of the file. */
#define DRM_FILE_EOF -2
/** Open for read access. */
#define DRM_FILE_MODE_READ 1
/** Open for write access. */
#define DRM_FILE_MODE_WRITE 2
#ifndef MAX_FILENAME_LEN
/** Maximum number of characters that a filename may have. By default assumes
* that the entry results of DRM_file_listNextEntry() are returned in the async state
* buffer, after the #DRM_file_result_s, and calculates the maximum name
* from that.
*/
#define MAX_FILENAME_LEN 1024
#endif
/**
* Performs one-time initialization of the File System (FS).
* This function is called once during the lifetime of an application,
* and before any call to <code>DRM_file_*</code> functions by this application.
* When several applications are using the file interface, this function may be called
* several times, once per application.
*
* @return #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_startup(void);
/**
* Returns the length of a file (by name, opened or unopened).
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number characters encoded in name.
* asynchronous operation returns #DRM_FILE_WOULDBLOCK.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_FAILURE or the file length.
*/
int32_t DRM_file_getFileLength(const uint16_t* name,
int32_t nameChars);
/**
* Initializes a list iteration session.
*
* @param prefix Prefix that must be matched, UCS-2 encoded. *
* @param prefixChars Number characters encoded in prefix.
* @param session List session identifier.
* @param iteration List iteration identifier.
*
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_listOpen(const uint16_t* prefix,
int32_t prefixChars,
int32_t* session,
int32_t* iteration);
/**
* Used to fetch a list of file names that match a given name prefix.
*
* @param prefix See DRM_file_listOpen(). This does not change during the
* iteration session.
* @param prefixChars See DRM_file_listOpen(). This does not change during
* the iteration session.
* @param entry Buffer parameter to return the next file name that matches the
* #prefix parameter, if any, when the function returns a positive number of
* characters.
* @param entryBytes Size of entry in bytes.
* @param session See DRM_file_listOpen().
* @param iteration See DRM_file_listOpen().
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_FAILURE or the number of
* characters encoded in entry. Returns 0 when the end of the list is reached.
*/
int32_t DRM_file_listNextEntry(const uint16_t* prefix,
int32_t prefixChars,
uint16_t* entry,
int32_t entryBytes,
int32_t* session,
int32_t* iteration);
/**
* Ends a list iteration session. Notifies the implementation
* that the list session is over and that any session resources
* can be released.
*
* @param session See DRM_file_listOpen().
* @param iteration See DRM_file_listOpen().
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_listClose(int32_t session, int32_t iteration);
/**
* Renames a file, given its old name. The file or directory is renamed
* immediately on the actual file system upon invocation of this method.
* Any open handles on the file specified by oldName become invalid after
* this method has been called.
*
* @param oldName Current file name (unopened), UCS-2 encoded.
* @param oldNameChars Number of characters encoded on oldName.
* @param newName New name for the file (unopened), UCS-2 encoded.
* @param newNameChars Number of characters encoded on newName.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE. In particular,
* #DRM_FILE_FAILURE if a file or directory already exists with the new name.
*/
int32_t DRM_file_rename(const uint16_t* oldName,
int32_t oldNameChars,
const uint16_t* newName,
int32_t newNameChars);
/**
* Tests if a file exists given its name.
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_ISREG, #DRM_FILE_ISDIR, #DRM_FILE_FAILURE. If name
* exists, returns #DRM_FILE_ISREG if it is a regular file and #DRM_FILE_ISDIR if it is a directory.
* Returns #DRM_FILE_FAILURE in all other cases, including those where name exists but is neither
* a regular file nor a directory. Platforms that do not support directories MUST NOT return
* #DRM_FILE_ISDIR.
*/
int32_t DRM_file_exists(const uint16_t* name,
int32_t nameChars);
/**
* Opens a file with the given name and returns its file handle.
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @param mode Any combination of the #DRM_FILE_MODE_READ and
* #DRM_FILE_MODE_WRITE flags. If the file does not exist and mode contains the
* #DRM_FILE_MODE_WRITE flag, then the file is automatically created. If the
* file exists and the mode contains the #DRM_FILE_MODE_WRITE flag, the file is
* opened so it can be modified, but the data is not modified by the open call.
* In all cases the current position is set to the start of the file.
* The following table shows how to map the mode semantics above to UNIX
* fopen-style modes. For brevity in the table, R=#DRM_FILE_MODE_READ,
* W=#DRM_FILE_MODE_WRITE, E=File exists:
* <table>
* <tr><td>RW</td><td>E</td><td>Maps-to</td></tr>
* <tr><td>00</td><td>0</td><td>Return #DRM_FILE_FAILURE</td></tr>
* <tr><td>00</td><td>1</td><td>Return #DRM_FILE_FAILURE</td></tr>
* <tr><td>01</td><td>0</td><td>Use fopen mode "w"</td></tr>
* <tr><td>01</td><td>1</td><td>Use fopen mode "a" and fseek to the start</td></tr>
* <tr><td>10</td><td>0</td><td>Return #DRM_FILE_FAILURE</td></tr>
* <tr><td>10</td><td>1</td><td>Use fopen mode "r"</td></tr>
* <tr><td>11</td><td>0</td><td>Use fopen mode "w+"</td></tr>
* <tr><td>11</td><td>1</td><td>Use fopen mode "r+"</td></tr>
* </table>
* @param handle Pointer where the result handle value is placed when the function
* is called synchronously.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_open(const uint16_t* name,
int32_t nameChars,
int32_t mode,
int32_t* handle);
/**
* Deletes a file given its name, UCS-2 encoded. The file or directory is
* deleted immediately on the actual file system upon invocation of this
* method. Any open handles on the file specified by name become invalid
* after this method has been called.
*
* If the port needs to ensure that a specific application does not exceed a given storage
* space quota, then the bytes freed by the deletion must be added to the available space for
* that application.
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_delete(const uint16_t* name,
int32_t nameChars);
/**
* Read bytes from a file at the current position to a buffer. Afterwards the
* new file position is the byte after the last byte read.
* DRM_FILE_FAILURE is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete, DRM_file_rename, or DRM_file_close).
*
* @param handle File handle as returned by DRM_file_open().
* @param dst Buffer where the data is to be copied.
* @param length Number of bytes to be copied.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE, #DRM_FILE_EOF
* or the number of bytes that were read, i.e. in the range 0..length.
*/
int32_t DRM_file_read(int32_t handle,
uint8_t* dst,
int32_t length);
/**
* Write bytes from a buffer to the file at the current position. If the
* current position + number of bytes written > current size of the file,
* then the file is grown. Afterwards the new file position is the byte
* after the last byte written.
* DRM_FILE_FAILURE is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete, DRM_file_rename, or DRM_file_close).
*
* @param handle File handle as returned by DRM_file_open().
* @param src Buffer that contains the bytes to be written.
* @param length Number of bytes to be written.
* If the port needs to ensure that a specific application does not exceed a given storage
* space quota, the implementation must make sure the call does not violate that invariant.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_FAILURE or the number of bytes
* that were written. This number must be in the range 0..length.
* Returns #DRM_FILE_FAILURE when storage is full or exceeds quota.
*/
int32_t DRM_file_write(int32_t handle,
const uint8_t* src,
int32_t length);
/**
* Closes a file.
* DRM_FILE_SUCCESS is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete or DRM_file_rename).
*
* @param handle File handle as returned by DRM_file_open().
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_close(int32_t handle);
/**
* Sets the current position in an opened file.
* DRM_FILE_FAILURE is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete, DRM_file_rename, or DRM_file_close).
*
* @param handle File handle as returned by DRM_file_open().
* @param value The new current position of the file. If value is greater
* than the length of the file then the file should be extended. The contents
* of the newly extended portion of the file is undefined.
* If the port needs to ensure that a specific application does not exceed a given storage
* space quota, the implementation must make sure the call does not violate that invariant.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
* Returns #DRM_FILE_FAILURE when storage is full or exceeds quota.
*/
int32_t DRM_file_setPosition(int32_t handle, int32_t value);
/**
* Creates a directory with the assigned name and full file permissions on
* the file system. The full path to the new directory must already exist.
* The directory is created immediately on the actual file system upon
* invocation of this method.
*
* @param name Name of the directory, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_mkdir(const uint16_t* name,
int32_t nameChars);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_FILE_H__ */

View File

@@ -0,0 +1,107 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM_I18N_H__
#define __DRM_I18N_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/**
* @name Charset value defines
* @ingroup i18n
*
* Charset value defines
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_81rn.asp
*/
typedef enum {
DRM_CHARSET_GBK = 936, /** Simplified Chinese GBK (CP936) */
DRM_CHARSET_GB2312 = 20936, /** Simplified Chinese GB2312 (CP936) */
DRM_CHARSET_BIG5 = 950, /** BIG5 (CP950) */
DRM_CHARSET_LATIN1 = 28591, /** ISO 8859-1, Latin 1 */
DRM_CHARSET_LATIN2 = 28592, /** ISO 8859-2, Latin 2 */
DRM_CHARSET_LATIN3 = 28593, /** ISO 8859-3, Latin 3 */
DRM_CHARSET_LATIN4 = 28594, /** ISO 8859-4, Latin 4 */
DRM_CHARSET_CYRILLIC = 28595, /** ISO 8859-5, Cyrillic */
DRM_CHARSET_ARABIC = 28596, /** ISO 8859-6, Arabic */
DRM_CHARSET_GREEK = 28597, /** ISO 8859-7, Greek */
DRM_CHARSET_HEBREW = 28598, /** ISO 8859-8, Hebrew */
DRM_CHARSET_LATIN5 = 28599, /** ISO 8859-9, Latin 5 */
DRM_CHARSET_LATIN6 = 865, /** ISO 8859-10, Latin 6 (not sure here) */
DRM_CHARSET_THAI = 874, /** ISO 8859-11, Thai */
DRM_CHARSET_LATIN7 = 1257, /** ISO 8859-13, Latin 7 (not sure here) */
DRM_CHARSET_LATIN8 = 38598, /** ISO 8859-14, Latin 8 (not sure here) */
DRM_CHARSET_LATIN9 = 28605, /** ISO 8859-15, Latin 9 */
DRM_CHARSET_LATIN10 = 28606, /** ISO 8859-16, Latin 10 */
DRM_CHARSET_UTF8 = 65001, /** UTF-8 */
DRM_CHARSET_UTF16LE = 1200, /** UTF-16 LE */
DRM_CHARSET_UTF16BE = 1201, /** UTF-16 BE */
DRM_CHARSET_HINDI = 57002, /** Hindi/Mac Devanagari */
DRM_CHARSET_UNSUPPORTED = -1
} DRM_Charset_t;
/**
* Convert multibyte string of specified charset to unicode string.
* Note NO terminating '\0' will be appended to the output unicode string.
*
* @param charset Charset of the multibyte string.
* @param mbs Multibyte string to be converted.
* @param mbsLen Number of the bytes (in mbs) to be converted.
* @param wcsBuf Buffer for the converted unicode characters.
* If wcsBuf is NULL, the function returns the number of unicode
* characters required for the buffer.
* @param bufSizeInWideChar The size (in wide char) of wcsBuf
* @param bytesConsumed The number of bytes in mbs that have been successfully
* converted. The value of *bytesConsumed is undefined
* if wcsBuf is NULL.
*
* @return Number of the successfully converted unicode characters if wcsBuf
* is not NULL. If wcsBuf is NULL, returns required unicode buffer
* size. -1 for unrecoverable errors.
*/
int32_t DRM_i18n_mbsToWcs(DRM_Charset_t charset,
const uint8_t *mbs, int32_t mbsLen,
uint16_t *wcsBuf, int32_t bufSizeInWideChar,
int32_t *bytesConsumed);
/**
* Convert unicode string to multibyte string with specified charset.
* Note NO terminating '\0' will be appended to the output multibyte string.
*
* @param charset Charset of the multibyte string to be converted to.
* @param wcs Unicode string to be converted.
* @param wcsLen Number of the unicode characters (in wcs) to be converted.
* @param mbsBuf Buffer for converted multibyte characters.
* If mbsBuf is NULL, the function returns the number of bytes
* required for the buffer.
* @param bufSizeInByte The size (in byte) of mbsBuf.
*
* @return Number of the successfully converted bytes.
*/
int32_t DRM_i18n_wcsToMbs(DRM_Charset_t charset,
const uint16_t *wcs, int32_t wcsLen,
uint8_t *mbsBuf, int32_t bufSizeInByte);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM_INNER_H__
#define __DRM_INNER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define INT_2_YMD_HMS(year, mon, day, date, hour, min, sec, time) do{\
year = date / 10000;\
mon = date % 10000 / 100;\
day = date %100;\
hour = time / 10000;\
min = time % 10000 / 100;\
sec = time % 100;\
}while(0)
/**
* Define the max malloc length for a DRM.
*/
#define DRM_MAX_MALLOC_LEN (50 * 1024) /* 50K */
#define DRM_ONE_AES_BLOCK_LEN 16
#define DRM_TWO_AES_BLOCK_LEN 32
typedef struct _T_DRM_DM_Binary_Node {
uint8_t boundary[256];
} T_DRM_DM_Binary_Node;
typedef struct _T_DRM_DM_Base64_Node {
uint8_t boundary[256];
uint8_t b64DecodeData[4];
int32_t b64DecodeDataLen;
} T_DRM_DM_Base64_Node;
typedef struct _T_DRM_Dcf_Node {
uint8_t rightsIssuer[256];
int32_t encContentLength;
uint8_t aesDecData[16];
int32_t aesDecDataLen;
int32_t aesDecDataOff;
uint8_t aesBackupBuf[16];
int32_t bAesBackupBuf;
} T_DRM_Dcf_Node;
typedef struct _T_DRM_Session_Node {
int32_t sessionId;
int32_t inputHandle;
int32_t mimeType;
int32_t (*getInputDataLengthFunc)(int32_t inputHandle);
int32_t (*readInputDataFunc)(int32_t inputHandle, uint8_t* buf, int32_t bufLen);
int32_t (*seekInputDataFunc)(int32_t inputHandle, int32_t offset);
int32_t deliveryMethod;
int32_t transferEncoding;
uint8_t contentType[64];
int32_t contentLength;
int32_t contentOffset;
uint8_t contentID[256];
uint8_t* rawContent;
int32_t rawContentLen;
int32_t bEndData;
uint8_t* readBuf;
int32_t readBufLen;
int32_t readBufOff;
void* infoStruct;
struct _T_DRM_Session_Node* next;
} T_DRM_Session_Node;
#ifdef __cplusplus
}
#endif
#endif /* __DRM_INNER_H__ */

View File

@@ -0,0 +1,183 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM_RIGHTS_MANAGER_H__
#define __DRM_RIGHTS_MANAGER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <openssl/aes.h>
#include <drm_common_types.h>
#include <parser_rel.h>
#ifdef DRM_DEVICE_ARCH_ARM
#define ANDROID_DRM_CORE_PATH "/data/drm/rights/"
#define DRM_UID_FILE_PATH "/data/drm/rights/uid.txt"
#else
#define ANDROID_DRM_CORE_PATH "/home/user/golf/esmertec/device/out/debug/host/linux-x86/product/sim/data/data/com.android.drm.mobile1/"
#define DRM_UID_FILE_PATH "/home/user/golf/esmertec/device/out/debug/host/linux-x86/product/sim/data/data/com.android.drm.mobile1/uid.txt"
#endif
#define EXTENSION_NAME_INFO ".info"
#define GET_ID 1
#define GET_UID 2
#define GET_ROAMOUNT 1
#define GET_ALL_RO 2
#define SAVE_ALL_RO 3
#define GET_A_RO 4
#define SAVE_A_RO 5
/**
* Get the id or uid from the "uid.txt" file.
*
* \param Uid The content id for a specially DRM object.
* \param id The id number managed by DRM engine for a specially DRM object.
* \param option The option to get id or uid, the value includes: GET_ID, GET_UID.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_readFromUidTxt(uint8_t* Uid, int32_t* id, int32_t option);
/**
* Save or read the rights information on the "id.info" file.
*
* \param id The id number managed by DRM engine for a specially DRM object.
* \param Ro The rights structure to save the rights information.
* \param RoAmount The number of rights for this DRM object.
* \param option The option include: GET_ROAMOUNT, GET_ALL_RO, SAVE_ALL_RO, GET_A_RO, SAVE_A_RO.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_writeOrReadInfo(int32_t id, T_DRM_Rights* Ro, int32_t* RoAmount, int32_t option);
/**
* Append a rights information to DRM engine storage.
*
* \param Ro The rights structure to save the rights information.
*
* return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_appendRightsInfo(T_DRM_Rights* rights);
/**
* Get the mex id number from the "uid.txt" file.
*
* \return
* -an integer to indicate the max id number.
* -(-1), if the operation failed.
*/
int32_t drm_getMaxIdFromUidTxt();
/**
* Remove the "id.info" file if all the rights for this DRM object has been deleted.
*
* \param id The id number managed by DRM engine for a specially DRM object.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_removeIdInfoFile(int32_t id);
/**
* Update the "uid.txt" file when delete the rights object.
*
* \param id The id number managed by DRM engine for a specially DRM object.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_updateUidTxtWhenDelete(int32_t id);
/**
* Get the CEK according the given content id.
*
* \param uid The content id for a specially DRM object.
* \param KeyValue The buffer to save the CEK.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_getKey(uint8_t* uid, uint8_t* KeyValue);
/**
* Discard the padding bytes in DCF decrypted data.
*
* \param decryptedBuf The aes decrypted data buffer to be scanned.
* \param decryptedBufLen The length of the buffer. And save the output result.
*
* \return
* -0
*/
void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen);
/**
* Decrypt the media data according the CEK.
*
* \param Buffer The buffer to decrypted and also used to save the output data.
* \param BufferLen The length of the buffer data and also save the output data length.
* \param key The structure of the CEK.
*
* \return
* -0
*/
int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, AES_KEY *key);
/**
* Update the DCF data length according the CEK.
*
* \param pDcfLastData The last several byte for the DCF.
* \param keyValue The CEK of the DRM content.
* \param moreBytes Output the more bytes for discarded.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_updateDcfDataLen(uint8_t* pDcfLastData, uint8_t* keyValue, int32_t* moreBytes);
/**
* Check and update the rights for a specially DRM content.
*
* \param id The id number managed by DRM engine for a specially DRM object.
* \param permission The permission to be check and updated.
*
* \return
* -DRM_SUCCESS, if there is a valid rights and update it successfully.
* -DRM_NO_RIGHTS, if there is no rights for this content.
* -DRM_RIGHTS_PENDING, if the rights is pending.
* -DRM_RIGHTS_EXPIRED, if the rights has expired.
* -DRM_RIGHTS_FAILURE, if there is some other error occur.
*/
int32_t drm_checkRoAndUpdate(int32_t id, int32_t permission);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_RIGHTS_MANAGER_H__ */

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* Time Porting Layer
*
* Basic support functions that are needed by time.
*
* <!-- #interface list begin -->
* \section drm_time Interface
* - DRM_time_getElapsedSecondsFrom1970()
* - DRM_time_sleep()
* - DRM_time_getSysTime()
* <!-- #interface list end -->
*/
#ifndef __DRM_TIME_H__
#define __DRM_TIME_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <drm_common_types.h>
/** the time format */
typedef struct __db_system_time_
{
uint16_t year;
uint16_t month;
uint16_t day;
uint16_t hour;
uint16_t min;
uint16_t sec;
} T_DB_TIME_SysTime;
/**
* Get the system time.it's up to UTC
* \return Return the time in elapsed seconds.
*/
uint32_t DRM_time_getElapsedSecondsFrom1970(void);
/**
* Suspend the execution of the current thread for a specified interval
* \param ms suspended time by millisecond
*/
void DRM_time_sleep(uint32_t ms);
/**
* function: get current system time
* \param time_ptr[OUT] the system time got
* \attention
* time_ptr must not be NULL
*/
void DRM_time_getSysTime(T_DB_TIME_SysTime *time_ptr);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_TIME_H__ */

View File

@@ -0,0 +1,376 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SVC_DRM_NEW_H__
#define __SVC_DRM_NEW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/**
* Define the mime type of DRM data.
*/
#define TYPE_DRM_MESSAGE 0x48 /**< The mime type is "application/vnd.oma.drm.message" */
#define TYPE_DRM_CONTENT 0x49 /**< The mime type is "application/vnd.oma.drm.content" */
#define TYPE_DRM_RIGHTS_XML 0x4a /**< The mime type is "application/vnd.oma.drm.rights+xml" */
#define TYPE_DRM_RIGHTS_WBXML 0x4b /**< The mime type is "application/vnd.oma.drm.rights+wbxml" */
#define TYPE_DRM_UNKNOWN 0xff /**< The mime type is unknown */
/**
* Define the delivery methods.
*/
#define FORWARD_LOCK 1 /**< Forward_lock */
#define COMBINED_DELIVERY 2 /**< Combined delivery */
#define SEPARATE_DELIVERY 3 /**< Separate delivery */
#define SEPARATE_DELIVERY_FL 4 /**< Separate delivery but DCF is forward-lock */
/**
* Define the permissions.
*/
#define DRM_PERMISSION_PLAY 0x01 /**< Play */
#define DRM_PERMISSION_DISPLAY 0x02 /**< Display */
#define DRM_PERMISSION_EXECUTE 0x04 /**< Execute */
#define DRM_PERMISSION_PRINT 0x08 /**< Print */
#define DRM_PERMISSION_FORWARD 0x10 /**< Forward */
/**
* Define the constraints.
*/
#define DRM_NO_CONSTRAINT 0x80 /**< Indicate have no constraint, it can use freely */
#define DRM_END_TIME_CONSTRAINT 0x08 /**< Indicate have end time constraint */
#define DRM_INTERVAL_CONSTRAINT 0x04 /**< Indicate have interval constraint */
#define DRM_COUNT_CONSTRAINT 0x02 /**< Indicate have count constraint */
#define DRM_START_TIME_CONSTRAINT 0x01 /**< Indicate have start time constraint */
#define DRM_NO_PERMISSION 0x00 /**< Indicate no rights */
/**
* Define the return values for those interface.
*/
#define DRM_SUCCESS 0
#define DRM_FAILURE -1
#define DRM_MEDIA_EOF -2
#define DRM_RIGHTS_DATA_INVALID -3
#define DRM_MEDIA_DATA_INVALID -4
#define DRM_SESSION_NOT_OPENED -5
#define DRM_NO_RIGHTS -6
#define DRM_NOT_SD_METHOD -7
#define DRM_RIGHTS_PENDING -8
#define DRM_RIGHTS_EXPIRED -9
#define DRM_UNKNOWN_DATA_LEN -10
/**
* The input DRM data structure, include DM, DCF, DR, DRC.
*/
typedef struct _T_DRM_Input_Data {
/**
* The handle of the input DRM data.
*/
int32_t inputHandle;
/**
* The mime type of the DRM data, if the mime type set to unknown, DRM engine
* will try to scan the input data to confirm the mime type, but we must say that
* the scan and check of mime type is not strictly precise.
*/
int32_t mimeType;
/**
* The function to get input data length, this function should be implement by out module,
* and DRM engine will call-back it.
*
* \param inputHandle The handle of the DRM data.
*
* \return
* -A positive integer indicate the length of input data.
* -0, if some error occurred.
*/
int32_t (*getInputDataLength)(int32_t inputHandle);
/**
* The function to read the input data, this function should be implement by out module,
* and DRM engine will call-back it.
*
* \param inputHandle The handle of the DRM data.
* \param buf The buffer mallocced by DRM engine to save the data.
* \param bufLen The length of the buffer.
*
* \return
* -A positive integer indicate the actually length of byte has been read.
* -0, if some error occurred.
* -(-1), if reach to the end of the data.
*/
int32_t (*readInputData)(int32_t inputHandle, uint8_t* buf, int32_t bufLen);
/**
* The function to seek the current file pointer, this function should be implement by out module,
* and DRM engine will call-back it.
*
* \param inputHandle The handle of the DRM data.
* \param offset The offset from the start position to be seek.
*
* \return
* -0, if seek operation success.
* -(-1), if seek operation fail.
*/
int32_t (*seekInputData)(int32_t inputHandle, int32_t offset);
} T_DRM_Input_Data;
/**
* The constraint structure.
*/
typedef struct _T_DRM_Constraint_Info {
uint8_t indicator; /**< Whether there is a right */
uint8_t unUsed[3];
int32_t count; /**< The constraint of count */
int32_t startDate; /**< The constraint of start date */
int32_t startTime; /**< The constraint of start time */
int32_t endDate; /**< The constraint of end date */
int32_t endTime; /**< The constraint of end time */
int32_t intervalDate; /**< The constraint of interval date */
int32_t intervalTime; /**< The constraint of interval time */
} T_DRM_Constraint_Info;
/**
* The rights permission and constraint information structure.
*/
typedef struct _T_DRM_Rights_Info {
uint8_t roId[256]; /**< The unique id for a specially rights object */
T_DRM_Constraint_Info playRights; /**< Constraint of play */
T_DRM_Constraint_Info displayRights; /**< Constraint of display */
T_DRM_Constraint_Info executeRights; /**< Constraint of execute */
T_DRM_Constraint_Info printRights; /**< Constraint of print */
} T_DRM_Rights_Info;
/**
* The list node of the Rights information structure.
*/
typedef struct _T_DRM_Rights_Info_Node {
T_DRM_Rights_Info roInfo;
struct _T_DRM_Rights_Info_Node *next;
} T_DRM_Rights_Info_Node;
/**
* Install a rights object to DRM engine, include the rights in Combined Delivery cases.
* Because all the rights object is managed by DRM engine, so every incoming rights object
* must be install to the engine first, or the DRM engine will not recognize it.
*
* \param data The rights object data or Combined Delivery case data.
* \param pRightsInfo The structure to save this rights information.
*
* \return
* -DRM_SUCCESS, when install successfully.
* -DRM_RIGHTS_DATA_INVALID, when the input rights data is invalid.
* -DRM_FAILURE, when some other error occur.
*/
int32_t SVC_drm_installRights(T_DRM_Input_Data data, T_DRM_Rights_Info* pRightsInfo);
/**
* Open a session for a special DRM object, it will parse the input DRM data, and then user
* can try to get information for this DRM object, or try to use it if the rights is valid.
*
* \param data The DRM object data, DM or DCF.
*
* \return
* -A handle for this opened DRM object session.
* -DRM_MEDIA_DATA_INVALID, when the input DRM object data is invalid.
* -DRM_FAILURE, when some other error occurred.
*/
int32_t SVC_drm_openSession(T_DRM_Input_Data data);
/**
* Get the delivery method of the DRM object.
*
* \param session The handle for this DRM object session.
*
* \return
* -The delivery method of this DRM object, include: FORWARD_LOCK, COMBINED_DELIVERY, SEPARATE_DELIVERY, SEPARATE_DELIVERY_FL.
* -DRM_FAILURE, when some other error occurred.
*/
int32_t SVC_drm_getDeliveryMethod(int32_t session);
/**
* Get DRM object media object content type.
*
* \param session The handle for this DRM object session.
* \param mediaType The buffer to save the media type string, 64 bytes is enough.
*
* \return
* -DRM_SUCCESS, when get the media object content type successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getContentType(int32_t session, uint8_t* mediaType);
/**
* Check whether a specific DRM object has the specific permission rights or not.
*
* \param session The handle for this DRM object session.
* \param permission Specify the permission to be checked.
*
* \return
* -DRM_SUCCESS, when it has the rights for the permission.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when it has no rights.
* -DRM_RIGHTS_PENDING, when it has the rights, but currently it is pending.
* -DRM_RIGHTS_EXPIRED, when the rights has expired.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_checkRights(int32_t session, int32_t permission);
/**
* Consume the rights when try to use the DRM object.
*
* \param session The handle for this DRM object session.
* \param permission Specify the permission to be checked.
*
* \return
* -DRM_SUCCESS, when consume rights successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when it has no rights.
* -DRM_RIGHTS_PENDING, when it has the rights, but currently it is pending.
* -DRM_RIGHTS_EXPIRED, when the rights has expired.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_consumeRights(int32_t session, int32_t permission);
/**
* Get DRM media object content data length.
*
* \param session The handle for this DRM object session.
*
* \return
* -A positive integer indicate the length of the media object content data.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when the rights object is not existed.
* -DRM_UNKNOWN_DATA_LEN, when DRM object media data length is unknown in case of DCF has no rights.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getContentLength(int32_t session);
/**
* Get DRM media object content data. Support get the data piece by piece if the content is too large.
*
* \param session The handle for this DRM object session.
* \param offset The offset to start to get content.
* \param mediaBuf The buffer to save media object data.
* \param mediaBufLen The length of the buffer.
*
* \return
* -A positive integer indicate the actually length of the data has been got.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when the rights object is not existed.
* -DRM_MEDIA_EOF, when reach to the end of the media data.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getContent(int32_t session, int32_t offset, uint8_t* mediaBuf, int32_t mediaBufLen);
/**
* Get the rights issuer address, this interface is specially for Separate Delivery method.
*
* \param session The handle for this DRM object session.
* \param rightsIssuer The buffer to save rights issuer, 256 bytes are enough.
*
* \return
* -DRM_SUCCESS, when get the rights issuer successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NOT_SD_METHOD, when it is not a Separate Delivery DRM object.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getRightsIssuer(int32_t session, uint8_t* rightsIssuer);
/**
* Get DRM object constraint informations.
*
* \param session The handle for this DRM object session.
* \param rights The structue to save the rights object information.
*
* \return
* -DRM_SUCCESS, when get the rights information successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when this DRM object has not rights.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getRightsInfo(int32_t session, T_DRM_Rights_Info* rights);
/**
* Close the opened session, after closed, the handle become invalid.
*
* \param session The handle for this DRM object session.
*
* \return
* -DRM_SUCCESS, when close operation success.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_closeSession(int32_t session);
/**
* Check and update the given rights according the given permission.
*
* \param contentID The unique id of the rights object.
* \param permission The permission to be updated.
*
* \return
* -DRM_SUCCESS, when update operation success.
* -DRM_NO_RIGHTS, when it has no rights.
* -DRM_RIGHTS_PENDING, when it has the rights, but currently it is pending.
* -DRM_RIGHTS_EXPIRED, when the rights has expired.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_updateRights(uint8_t* contentID, int32_t permission);
/**
* Scan all the rights object in current DRM engine, and get all their information.
*
* \param ppRightsInfo The pointer to the list structure to save rights info.
*
* \return
* -DRM_SUCCESS, when get information successfully.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_viewAllRights(T_DRM_Rights_Info_Node **ppRightsInfo);
/**
* Free the allocated memory when call "SVC_drm_viewAllRights".
*
* \param pRightsHeader The header pointer of the list to be free.
*
* \return
* -DRM_SUCCESS, when free operation successfully.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_freeRightsInfoList(T_DRM_Rights_Info_Node *pRightsHeader);
/**
* Delete a specify rights.
*
* \param roId The unique id of the rights.
*
* \return
* -DRM_SUCCESS, when free operation successfully.
* -DRM_NO_RIGHTS, when there is not this rights object.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_deleteRights(uint8_t* roId);
#ifdef __cplusplus
}
#endif
#endif /* __SVC_DRM_NEW_H__ */