123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- #ifndef KEYUPDATE_H_INCLUDED
- #define KEYUPDATE_H_INCLUDED
- #include "types.h"
- #undef KEYUPDATE_DEBUG
- #if 0
- #define KEYUPDATE_DEBUG(fmt, args...) do {fprintf(stderr, "[KEYUPDATE] " fmt, ##args);}while(0);
- #else
- #define KEYUPDATE_DEBUG(fmt, args...)
- #endif
- #define FILENAME_SIZE 32
- #ifdef CONFIG_DISABLE_CIKEY_HDCPKEY_SPI_ENCRYPT
- extern void do_spi_decrypt(char *, unsigned int, unsigned int);
- #endif
- /*******************************************************************************
- * enumeration
- ******************************************************************************/
- typedef enum {
- e_MID_STATUS_NO_UPDATE,
- e_MID_STATUS_OPEN_FILE_FAILED,
- e_MID_STATUS_FORMAT_ERROR,
- e_MID_STATUS_UPDATE_SUCCESS,
- }e_MID_KEYUPDATE_STATUS;
- /*******************************************************************************
- * HDCP UPDATE - Constant
- ******************************************************************************/
- #define DIR_HDCPKEY "s2_hdcp"
- #define FILE_EXTENSION_HDCPKEY ".bin"
- /*******************************************************************************
- * HDCP UPDATE - APIs
- ******************************************************************************/
- /*******************************************************************************************/
- /**
- * \fn e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP_Update.
- *
- * \param pBuffer : The storage that carrys the data which will be updated to flash.
- * size_buffer : The size of Buffer.
- *
- * \return e_MID_STATUS_UPDATE_SUCCESS if update flash successful, warning or error code if function failed
- *
- * \note Description : Update HDCP KEY to flash, and the keys should be encrypt to 588 bytes format.
- *
- ********************************************************************************************/
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP_Update(UINT8 *pBuffer, UINT32 size_buffer);
- /*******************************************************************************************/
- /**
- * \fn e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP_Update_ByFile.
- *
- * \param pFileName : The file that carrys the data which will be updated to flash.
- *
- * \return e_MID_STATUS_UPDATE_SUCCESS if update flash successful, warning or error code if function failed
- *
- * \note Description : Update HDCP KEY to flash, and the keys should be encrypt to 588 bytes format.
- *
- ********************************************************************************************/
- #ifndef CONFIG_EXTIC_STORAGE_DEVICE
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP_Update_ByFile(char *pFileName);
- #else
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP_Update_ToFlash_ByFile(char *pFileName, char **pBuffer1, int* size_file);
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP_Update_NoticeHDMI_RemoveFile(char *pFileName);
- #endif
- /*******************************************************************************************/
- /**
- * \fn UINT32 MID_KEYUPDATE_HDCP_Get_Flash_Checksum.
- *
- * \param None.
- *
- * \return The 4-bytes checksum. If data error will be return 0.
- *
- * \note Description : The HDCP key checksum which is encrypted to 588-bytes format.
- *
- ********************************************************************************************/
- UINT32 MID_KEYUPDATE_HDCP_Get_Flash_Checksum(void);
- /*******************************************************************************
- * CI+ UPDATE - Constant
- ******************************************************************************/
- #define DIR_CIPLUS "s2_ciplus"
- #define FILE_EXTENSION_CIPLUS ".bin"
- /*******************************************************************************
- * CI+ UPDATE - APIs
- ******************************************************************************/
- /*******************************************************************************************/
- /**
- * \fn e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_CIPlus_Update.
- *
- * \param pBuffer : The storage that carrys the data which will be updated to flash.
- * size_buffer : The size of Buffer.
- *
- * \return e_MID_STATUS_UPDATE_SUCCESS if update flash successful, warning or error code if function failed
- *
- * \note Description : Update CI+ KEY to flash, and the keys should be encrypt to 10K bytes format.
- *
- ********************************************************************************************/
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_CIPlus_Update(UINT8 *pBuffer, UINT32 size_buffer);
- /*******************************************************************************************/
- /**
- * \fn e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_CIPLUS_Update_ByFile.
- *
- * \param pFileName : The file that carrys the data which will be updated to flash.
- *
- * \return e_MID_STATUS_UPDATE_SUCCESS if update flash successful, warning or error code if function failed
- *
- * \note Description : Update CI+ KEY to flash, and the keys should be encrypt to 10K bytes format.
- *
- ********************************************************************************************/
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_CIPLUS_Update_ByFile(char *pFileName);
- UINT8 *MID_CIKEYUPDATE_Get_File_byOrder(char *pdirpath, char*pfile_extension);
- UINT8 *MID_HDCPKEYUPDATE_Get_File_byOrder(char *pdirpath, char*pfile_extension);
- /*******************************************************************************************/
- /**
- * \fn UINT32 MID_KEYUPDATE_CIPlus_Get_Flash_Checksum.
- *
- * \param None.
- *
- * \return The 4-bytes checksum. If data error will be return 0.
- *
- * \note Description : The CI+ key checksum which is encrypted to 10K-bytes format.
- *
- ********************************************************************************************/
- UINT32 MID_KEYUPDATE_CIPlus_Get_Flash_Checksum(void);
- /*******************************************************************************
- * Common - APIs
- ******************************************************************************/
- /*******************************************************************************************/
- /**
- * \fn UINT8 *MID_KEYUPDATE_Get_File.
- *
- * \param pdirpath : the specific directory path.
- * pfile_extension : the specific file extension.
- *
- * \return The file which name is end by the specific file extension. If not match, return NULL.
- *
- * \note Description : Search the file on specific dir. path.
- * And return the first file which name must be end by specific file extension.
- ********************************************************************************************/
- UINT8 *MID_KEYUPDATE_Get_File(char *pdirpath, char*pfile_extension);
- UINT8 *MID_KEYUPDATE_Get_File_byOrder(char *pdirpath, char*pfile_extension);
- /*******************************************************************************************/
- /**
- * \fn UINT8 MID_KEYUPATE_Remove_File.
- *
- * \param pFileName : The file name.
- *
- * \return Return 0, if remove failed. Others, remove success.
- *
- * \note Description : Remove specific file.
- *
- ********************************************************************************************/
- UINT8 MID_KEYUPATE_Remove_File(char *pFileName);
- /*******************************************************************************************/
- /**
- * \fn UINT8 MID_KEYUPDATE_HDCP_IsKeyValid
- *
- * \param None.
- *
- * \return The 1-bytes . If key error will be return false
- *
- ********************************************************************************************/
- UINT8 MID_KEYUPDATE_HDCP_IsKeyValid(void);
- /*******************************************************************************************/
- /**
- * \fn UINT32 MID_KEYUPDATE_CIPlus_Get_KeyFileName.
- *
- * \param :.Get file name
- *
- * \return \return The 1-bytes . If error will be return false.
- *
- * \note Description : The pKEYFileName which is get file name of key.
- *
- ********************************************************************************************/
- UINT8 MID_KEYUPDATE_CIPlus_Get_KeyFileName(char *pKEYFileName);
- /*******************************************************************************************/
- /**
- * \fn UINT32 MID_KEYUPDATE_HDCP_Get_KeyFileName.
- *
- * \param :.Get file name
- *
- * \return \return The 1-bytes . If error will be return false.
- *
- * \note Description : The pKEYFileName which is get file name of key.
- *
- ********************************************************************************************/
- UINT8 MID_KEYUPDATE_HDCP_Get_KeyFileName(char *pKEYFileName);
- #ifdef CONFIG_SUPPORT_STORE_HDCP2X_TO_FLASH
- UINT8 *MID_HDCP2XKEYUPDATE_Get_File_byOrder(char *pdirpath, char*pfile_extension);
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP2X_Update(UINT8 *pBuffer, UINT32 size_buffer);
- e_MID_KEYUPDATE_STATUS MID_KEYUPDATE_HDCP2X_Update_ByFile(char *pFileName);
- UINT32 MID_KEYUPDATE_HDCP2X_Get_Flash_Checksum(void);
- UINT8 MID_KEYUPDATE_HDCP2X_IsKeyValid(void);
- #ifdef CONFIG_APPEND_NAME_TO_CIKEY_HDCPKEY
- UINT8 MID_KEYUPDATE_HDCP2X_Get_KeyFileName(char *pKEYFileName);
- #endif
- #endif
- #endif // KEYUPDATE_H_INCLUDED
|