summaryrefslogtreecommitdiff
authorSam Wu <yihui.wu@amlogic.com>2018-10-12 17:22:28 (GMT)
committer xiaoliang.wang <xiaoliang.wang@amlogic.com>2018-12-25 01:26:37 (GMT)
commit665b17c208795f71077ec2d4c3d9fdaa51e5d927 (patch)
tree810d6607668c00648a02392f271aca17c9b9103f
parent9d7e3b304f1032ef278f1c7432d8a0ea468af5b6 (diff)
downloaduboot-p-tv-atom.zip
uboot-p-tv-atom.tar.gz
uboot-p-tv-atom.tar.bz2
factoryBurn:hdcp22rxKey: support hdcp rx and rx repeater [5/10]
PD#SWPL-323: support burn new format hdcp rx repeater key 1, hdcp_key2.2.bin format update to be composed by unifykeys "hdcp22_rx_fw_private + hdcp22_rx_fw (+hdcp2_rx) (+hdcp22_rprx_fw)", in which hdcp2_rx for miracast and hdcp22_rprx_fw for repeater is optional; 2, burn this binary key by PC command burn rx [update hdcp_key2.2.bin mwrite key aml_hdcp_key2.2 normal]; burn rxrp [update hdcp_key2.2.bin mwrite key aml_hdcp_key2.2rp normal]; Change-Id: Iad6c5d5ea8c24794ab9ab14e18bd790dc83250aa Signed-off-by: Sam Wu <yihui.wu@amlogic.com>
Diffstat
-rw-r--r--drivers/usb/gadget/v2_burning/v2_common/optimus_download_key.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/drivers/usb/gadget/v2_burning/v2_common/optimus_download_key.c b/drivers/usb/gadget/v2_burning/v2_common/optimus_download_key.c
index 12179e0..ec1078b 100644
--- a/drivers/usb/gadget/v2_burning/v2_common/optimus_download_key.c
+++ b/drivers/usb/gadget/v2_burning/v2_common/optimus_download_key.c
@@ -77,15 +77,27 @@ typedef struct {
#endif//#ifndef __HDCP22_HEY_H__
#define _AML_HDCP22_RX_KEY_NAME "aml_hdcp_key2.2"
-static struct {
+#define _AML_HDCP22_RP_KEY_NAME "aml_hdcp_key2.2rp"
+static struct AmlHdcp22RxKey{
const char* keyName;
+ const char* itemName;
int isEncrypt;
}
-_amlHdcp22RxKeys[] = {
- [0] = {.keyName = "hdcp22_rx_private", .isEncrypt = 1},
- [1] = {.keyName = "hdcp22_rx_fw", .isEncrypt = 0},
- [2] = {.keyName = "hdcp2_rx", .isEncrypt = 0},
+_amlHdcp22RxKeys[2][4] = {
+ {
+ [0] = {.keyName = "hdcp22_rx_private", .itemName = "hdcp22_rx_private", .isEncrypt = 1},
+ [1] = {.keyName = "hdcp22_rx_fw", .itemName = "extractedKey", .isEncrypt = 0},
+ [2] = {.keyName = "hdcp2_rx", .itemName = "hdcp2_rx", .isEncrypt = 0},
+ [3] = {.keyName = "hdcp22_rprx_fw", .itemName = "extractedKey_rxrp", .isEncrypt = 0},
+ },
+ {
+ [0] = {.keyName = "hdcp22_rp_private", .itemName = "hdcp22_rx_private", .isEncrypt = 1},
+ [1] = {.keyName = "hdcp22_rprx_fw", .itemName = "extractedKey", .isEncrypt = 0},
+ [2] = {.keyName = "hdcp2_rx", .itemName = "hdcp2_rx", .isEncrypt = 0},
+ [3] = {.keyName = "hdcp22_rprp_fw", .itemName = "extractedKey_rxrp", .isEncrypt = 0},
+ },
};
+#define _HDCP22_MAX_KEY_NUM 4
static char generalDataChange(const char input)
{
@@ -124,10 +136,12 @@ unsigned v2_key_burn(const char* keyName, const u8* keyVal, const unsigned keyVa
unsigned writtenLen = 0;
DWN_DBG("to write key[%s] in len=%d\n", keyName, keyValLen);
- if (!strcmp(keyName, _AML_HDCP22_RX_KEY_NAME))
+ if (!strcmp(keyName, _AML_HDCP22_RX_KEY_NAME) || !strcmp(keyName, _AML_HDCP22_RP_KEY_NAME))
{
const AmlResImgHead_t* packedImgHead = (AmlResImgHead_t*)keyVal;
const AmlResItemHead_t* packedImgItem = (AmlResItemHead_t*)(packedImgHead + 1);
+ const int isRepeater = !strcmp(keyName, _AML_HDCP22_RP_KEY_NAME);
+ const struct AmlHdcp22RxKey* _amlHdcp22RxKey = _amlHdcp22RxKeys[isRepeater];
int i = 0;
const unsigned gensum = add_sum(keyVal + 4, keyValLen - 4);
@@ -139,18 +153,29 @@ unsigned v2_key_burn(const char* keyName, const u8* keyVal, const unsigned keyVa
for (i = 0; i < packedImgHead->imgItemNum; ++i)
{
const AmlResItemHead_t* pItem = packedImgItem + i;
- const char* itemN = _amlHdcp22RxKeys[i].keyName;
+ const char* itemN = pItem->name;
u8* itembuf = (u8*)keyVal + pItem->dataOffset;
int itemSz = pItem->dataSz;
+ int k = 0;
- if (_amlHdcp22RxKeys[i].isEncrypt) {
+ for (; k < _HDCP22_MAX_KEY_NUM;++k) {
+ ret = strcmp(_amlHdcp22RxKey[k].itemName, itemN);
+ if (ret) continue;
+ break;
+ }
+ if ( _HDCP22_MAX_KEY_NUM == k ) {
+ DWN_ERR("Err, cannot find keyname for item[%d] %s\n", i, itemN);
+ return 0;
+ }
+ if (_amlHdcp22RxKey[k].isEncrypt) {
DWN_MSG("key[%s] at[%d] isEncrypted\n", itemN, i);
hdcp2DataDecryption(itemSz, (char*)itembuf, (char*)itembuf);
}
- DWN_MSG("burnkey[%s] at sz[%d]\n", itemN, itemSz);
- ret = key_manage_write(itemN, itembuf, itemSz);
+ const char* keyN = _amlHdcp22RxKey[k].keyName;
+ DWN_MSG("burnkey[%s] at sz[%d]\n", keyN, itemSz);
+ ret = key_manage_write(keyN, itembuf, itemSz);
if (ret) {
- DWN_ERR("Fail to write key[%s] in len=%d\n", itemN, itemSz);
+ DWN_ERR("Fail to write key[[%s] in len=%d\n", keyN, itemSz);
return 0;
}
}
@@ -235,7 +260,8 @@ int v2_key_command(const int argc, char * const argv[], char *info)
const char* queryKey = subCmd_argv[1];
int keyIsBurned = 0;
- if (!strcmp(_AML_HDCP22_RX_KEY_NAME, queryKey)) queryKey = _amlHdcp22RxKeys[0].keyName;
+ if (!strcmp(_AML_HDCP22_RX_KEY_NAME, queryKey)) queryKey = _amlHdcp22RxKeys[0][0].keyName;
+ if (!strcmp(_AML_HDCP22_RP_KEY_NAME, queryKey)) queryKey = _amlHdcp22RxKeys[1][0].keyName;
rcode = key_manage_query_exist(queryKey, &keyIsBurned);
if (rcode) {
@@ -258,7 +284,8 @@ int v2_key_command(const int argc, char * const argv[], char *info)
int exist = 0;
int canOverWrite = 0;
- if (!strcmp(_AML_HDCP22_RX_KEY_NAME, queryKey)) queryKey = _amlHdcp22RxKeys[0].keyName;
+ if (!strcmp(_AML_HDCP22_RX_KEY_NAME, queryKey)) queryKey = _amlHdcp22RxKeys[0][0].keyName;
+ if (!strcmp(_AML_HDCP22_RP_KEY_NAME, queryKey)) queryKey = _amlHdcp22RxKeys[1][0].keyName;
rcode = key_manage_query_canOverWrite(queryKey, &canOverWrite);
if (rcode) {