| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2002, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bhdmlib_hdcpkeys.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/5 $ |
|---|
| 12 | * $brcm_Date: 9/9/04 5:08p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/syslib/hdmlib/bhdmlib_hdcpkeys.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/5 9/9/04 5:08p rgreen |
|---|
| 21 | * PR 12116: Add HDCP Key Loading Support |
|---|
| 22 | * Fix compilation for testing binary keys read from file (user mode only) |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/4 9/9/04 4:45p erickson |
|---|
| 25 | * PR12116: removed #include stdio |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/3 9/1/04 11:49a rgreen |
|---|
| 28 | * PR 12116: Add HDCP Key Loading Support |
|---|
| 29 | * Add test to load keys from binary file |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/2 8/18/04 4:38p rgreen |
|---|
| 32 | * PR 12116: Add HDCP Key Loading Support |
|---|
| 33 | * Use new BHDM_EncryptedHdcpStructure for HDCP Key loading |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/1 4/5/04 5:41p rgreen |
|---|
| 36 | * PR 8896: HDMI Development/Test |
|---|
| 37 | * Add HDCP Support |
|---|
| 38 | * |
|---|
| 39 | ***************************************************************************/ |
|---|
| 40 | |
|---|
| 41 | /* #define READ_FROM_BINARY_FILE_TEST */ |
|---|
| 42 | /* BINARY_FILE_TEST CAN NOT be done in kernel mode! */ |
|---|
| 43 | |
|---|
| 44 | #ifdef READ_FROM_BINARY_FILE_TEST |
|---|
| 45 | #include <stdio.h> |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | #include "bhdmlib_hdcp_keyloader.h" |
|---|
| 49 | |
|---|
| 50 | BDBG_MODULE(BHDMLIB_HDCPKEYS) ; |
|---|
| 51 | |
|---|
| 52 | uint8_t HdcpTxAksv[BHDM_HDCP_KSV_LENGTH] = |
|---|
| 53 | {0x14, 0xF7, 0x61, 0x03, 0xB7} ; |
|---|
| 54 | |
|---|
| 55 | BHDM_EncryptedHdcpKeyStruct EncryptedHdcpTxKeys[BHDM_HDCP_NUM_KEYS] = |
|---|
| 56 | { |
|---|
| 57 | /* LSB.. MSB */ |
|---|
| 58 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x691e138f, 0x58a44d00}, |
|---|
| 59 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x0950e658, 0x35821f00}, |
|---|
| 60 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x0d98b9ab, 0x476a8a00}, |
|---|
| 61 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xcac5cb52, 0x1b18f300}, |
|---|
| 62 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xb4d89668, 0x7f14fb00}, |
|---|
| 63 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x818f4878, 0xc98be000}, |
|---|
| 64 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x412c11c8, 0x64d0a000}, |
|---|
| 65 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x44202428, 0x5a9db300}, |
|---|
| 66 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6b56adbd, 0xb228b900}, |
|---|
| 67 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf6e46c4a, 0x7ba49100}, |
|---|
| 68 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x589d5e20, 0xf8005600}, |
|---|
| 69 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xa03fee06, 0xb77f8c00}, |
|---|
| 70 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x28bc7c9d, 0x8c2dc000}, |
|---|
| 71 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x059f4be5, 0x61125600}, |
|---|
| 72 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xcbc1ca8c, 0xdef07400}, |
|---|
| 73 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6adbfc0e, 0xf6b83b00}, |
|---|
| 74 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xd72fb216, 0xbb2ba000}, |
|---|
| 75 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x98547846, 0x8e2f4800}, |
|---|
| 76 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x38472762, 0x25ae6600}, |
|---|
| 77 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf2dd23a3, 0x52493d00}, |
|---|
| 78 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x543a7b76, 0x31d2e200}, |
|---|
| 79 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x2561e6ed, 0x1a584d00}, |
|---|
| 80 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf7227bbf, 0x82603200}, |
|---|
| 81 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6bce3035, 0x461bf600}, |
|---|
| 82 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6b97d7f0, 0x09043600}, |
|---|
| 83 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf9498d61, 0x05e1a100}, |
|---|
| 84 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x063405d1, 0x9d8ec900}, |
|---|
| 85 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x90614294, 0x67c32000}, |
|---|
| 86 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xc34facce, 0x51449600}, |
|---|
| 87 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x8a8ce104, 0x45903e00}, |
|---|
| 88 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xfc2d9c57, 0x10002900}, |
|---|
| 89 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x80b1e569, 0x3b94d700}, |
|---|
| 90 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x437bdd5b, 0xeac75400}, |
|---|
| 91 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xba90c787, 0x58fb7400}, |
|---|
| 92 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xe01d4e36, 0xfa5c9300}, |
|---|
| 93 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xae119a15, 0x5e070300}, |
|---|
| 94 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x01fb788a, 0x40d30500}, |
|---|
| 95 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xb34da0d7, 0xa5590000}, |
|---|
| 96 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x409e2c4a, 0x633b3700}, |
|---|
| 97 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x412056b4, 0xbb732500} |
|---|
| 98 | } ; |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | BERR_Code BHDMlib_HDCP_GetKeySet(uint8_t *pTxAksv, uint8_t *pHdcpKeys) |
|---|
| 102 | { |
|---|
| 103 | |
|---|
| 104 | #ifdef READ_FROM_BINARY_FILE_TEST |
|---|
| 105 | FILE *fp ; |
|---|
| 106 | uint8_t pad[3] ; |
|---|
| 107 | |
|---|
| 108 | fp = fopen("keys.bin", "rb"); |
|---|
| 109 | if (!fp) |
|---|
| 110 | { |
|---|
| 111 | BDBG_MSG(("Error opening binary key file")) ; |
|---|
| 112 | return BERR_INVALID_PARAMETER ; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | BDBG_WRN(("Test Reading from Binary File")) ; |
|---|
| 116 | fread(pTxAksv, sizeof(uint8_t), BHDM_HDCP_KSV_LENGTH, fp) ; |
|---|
| 117 | |
|---|
| 118 | /* remember Bksv is padded with three 0x00 to round out to 8 bytes */ |
|---|
| 119 | /* skip over these bytes */ |
|---|
| 120 | fread(pad, sizeof(uint8_t), 3, fp) ; |
|---|
| 121 | |
|---|
| 122 | fread(pHdcpKeys, sizeof(BHDM_EncryptedHdcpKeyStruct), BHDM_HDCP_NUM_KEYS, fp) ; |
|---|
| 123 | |
|---|
| 124 | /* Verify bytes read into TxAksv and pHdcpKeys using SHA-1 algorithm */ |
|---|
| 125 | |
|---|
| 126 | #else |
|---|
| 127 | BKNI_Memcpy(pTxAksv, HdcpTxAksv, BHDM_HDCP_KSV_LENGTH) ; |
|---|
| 128 | |
|---|
| 129 | BKNI_Memcpy(pHdcpKeys, EncryptedHdcpTxKeys, |
|---|
| 130 | sizeof(BHDM_EncryptedHdcpKeyStruct) * BHDM_HDCP_NUM_KEYS) ; |
|---|
| 131 | #endif |
|---|
| 132 | |
|---|
| 133 | return BERR_SUCCESS ; |
|---|
| 134 | } |
|---|