| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2007-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_avkeyladder.h $ |
|---|
| 39 | * $brcm_Revision: 2 $ |
|---|
| 40 | * $brcm_Date: 5/25/11 11:40a $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/extensions/security/avkeyladder/7422/include/nexus_avkeyladder.h $ |
|---|
| 47 | * |
|---|
| 48 | * 2 5/25/11 11:40a atruong |
|---|
| 49 | * SW7342-341: Support for AV Command chain |
|---|
| 50 | * |
|---|
| 51 | * 1 1/28/11 5:47p atruong |
|---|
| 52 | * SW7422-235: Enable Nexus Security extension modules for 97422 |
|---|
| 53 | * |
|---|
| 54 | ******************************************************************************/ |
|---|
| 55 | |
|---|
| 56 | #ifndef NEXUS_AVKEYLADDER_H__ |
|---|
| 57 | #define NEXUS_AVKEYLADDER_H__ |
|---|
| 58 | |
|---|
| 59 | #include "nexus_security_datatypes.h" |
|---|
| 60 | #include "nexus_security.h" |
|---|
| 61 | #include "nexus_keyladder.h" |
|---|
| 62 | |
|---|
| 63 | #ifdef __cplusplus |
|---|
| 64 | extern "C" { |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | #define NEXUS_AVKEYLADDER_KEY_DATA_LEN 16 |
|---|
| 68 | #define NEXUS_AVKEYLADDER_SCD_DATA_LEN 8 |
|---|
| 69 | #define NEXUS_AVKEYLADDER_CMD_CHAIN_LEN 4 |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | /** |
|---|
| 73 | Summary: |
|---|
| 74 | This enum defines the sub commands for AVCMD |
|---|
| 75 | **/ |
|---|
| 76 | typedef enum NEXUS_AvKeyLadderSubCmdType |
|---|
| 77 | { |
|---|
| 78 | NEXUS_AvKeyLadderSubCmdType_eNoOp = 0, |
|---|
| 79 | NEXUS_AvKeyLadderSubCmdType_eDecryptEFK = 1, |
|---|
| 80 | NEXUS_AvKeyLadderSubCmdType_eDecryptEPK = 2, |
|---|
| 81 | NEXUS_AvKeyLadderSubCmdType_eDecryptECW = 3, |
|---|
| 82 | NEXUS_AvKeyLadderSubCmdType_eDecryptCID = 4, |
|---|
| 83 | NEXUS_AvKeyLadderSubCmdType_eReadSCN = 5, |
|---|
| 84 | NEXUS_AvKeyLadderSubCmdType_eLoadCW = 6, |
|---|
| 85 | |
|---|
| 86 | NEXUS_AvKeyLadderSubCmdType_eMax |
|---|
| 87 | |
|---|
| 88 | } NEXUS_AvKeyLadderSubCmdType; |
|---|
| 89 | |
|---|
| 90 | /** |
|---|
| 91 | Summary: |
|---|
| 92 | This structure provides the parameters for an AV Reset command |
|---|
| 93 | |
|---|
| 94 | Description: |
|---|
| 95 | See Also: |
|---|
| 96 | NEXUS_AvKeyLadder_AvResetCmd |
|---|
| 97 | |
|---|
| 98 | **/ |
|---|
| 99 | typedef struct NEXUS_AvKeyLadderAvResetCmdParm |
|---|
| 100 | { |
|---|
| 101 | NEXUS_SecurityOtpId otpIdSelect; |
|---|
| 102 | uint32_t caVendorId; |
|---|
| 103 | NEXUS_SecurityKey2Select key2Select; |
|---|
| 104 | NEXUS_SecurityRootKeySrc rootKeySrc; |
|---|
| 105 | bool bASKMMode; |
|---|
| 106 | |
|---|
| 107 | } NEXUS_AvKeyLadderAvResetCmdParm; |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | /** |
|---|
| 112 | Summary: |
|---|
| 113 | This function initializes the AV states and logics. |
|---|
| 114 | |
|---|
| 115 | Description: |
|---|
| 116 | This function is normally called once after bootup to reset the AV states and logics. |
|---|
| 117 | The chip will not function if this function is called too frequently. |
|---|
| 118 | |
|---|
| 119 | **/ |
|---|
| 120 | |
|---|
| 121 | NEXUS_Error NEXUS_AvKeyLadder_AvResetCmd( |
|---|
| 122 | const NEXUS_AvKeyLadderAvResetCmdParm *pResetCmdParm |
|---|
| 123 | ); |
|---|
| 124 | |
|---|
| 125 | /** |
|---|
| 126 | Summary: |
|---|
| 127 | This structure provides the parameters for an AV regular command |
|---|
| 128 | |
|---|
| 129 | Description: |
|---|
| 130 | See Also: |
|---|
| 131 | NEXUS_AvKeyLadder_AvCmd |
|---|
| 132 | |
|---|
| 133 | **/ |
|---|
| 134 | |
|---|
| 135 | typedef struct NEXUS_AvKeyLadderAvCmdParm |
|---|
| 136 | { |
|---|
| 137 | NEXUS_AvKeyLadderSubCmdType avSubCmd; |
|---|
| 138 | NEXUS_SecurityEngine cryptoEngine; |
|---|
| 139 | NEXUS_SecurityKeyType cryptoKeyType; |
|---|
| 140 | NEXUS_SecurityKeyIVType destIV; |
|---|
| 141 | NEXUS_SecuritySwizzleType swizzleType; |
|---|
| 142 | unsigned char swizzle1Index; |
|---|
| 143 | NEXUS_SecurityKeyMode keyMode; |
|---|
| 144 | /* AES key ladder - 128-bit CW key is used */ |
|---|
| 145 | /* DES-ECB CA - 64-bit key is used bit[64-127] */ |
|---|
| 146 | unsigned char encryptedKeyData[NEXUS_AVKEYLADDER_KEY_DATA_LEN]; |
|---|
| 147 | unsigned int keyDataLen; |
|---|
| 148 | |
|---|
| 149 | } NEXUS_AvKeyLadderAvCmdParm; |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | /** |
|---|
| 153 | Summary: |
|---|
| 154 | This structure defines the output for the AV subcommand NEXUS_AvKeyLadderSubCmdType_eReadSCN |
|---|
| 155 | |
|---|
| 156 | Description: |
|---|
| 157 | See Also: |
|---|
| 158 | NEXUS_AvKeyLadder_AvCmd |
|---|
| 159 | |
|---|
| 160 | **/ |
|---|
| 161 | |
|---|
| 162 | typedef struct NEXUS_AvKeyLadderAvCmdOutput |
|---|
| 163 | { |
|---|
| 164 | unsigned char scnData[NEXUS_AVKEYLADDER_SCD_DATA_LEN]; |
|---|
| 165 | unsigned int scnDataLen; |
|---|
| 166 | |
|---|
| 167 | } NEXUS_AvKeyLadderAvCmdOutput; |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | /** |
|---|
| 172 | Summary: |
|---|
| 173 | This function is used to communicate with the BSP AV module, as defined by DirecTV. |
|---|
| 174 | |
|---|
| 175 | Description: |
|---|
| 176 | This function is used to generate a key based on the DIRECTV AV module. The keys |
|---|
| 177 | generated by the AV module are used by both CA and M2M descramblers. |
|---|
| 178 | - CA commands : NEXUS_AvKeyLadderSubCmdType_eDecryptEPK. |
|---|
| 179 | NEXUS_AvKeyLadderSubCmdType_eDecryptECW. |
|---|
| 180 | - M2M commands : NEXUS_AvKeyLadderSubCmdType_eDecryptEFK. |
|---|
| 181 | NEXUS_AvKeyLadderSubCmdType_eDecryptCID. |
|---|
| 182 | The following command sequences should be used: |
|---|
| 183 | *** Generating CPCW (M2M) *** |
|---|
| 184 | NEXUS_AvKeyLadderSubCmdType_eReadSCN, |
|---|
| 185 | NEXUS_AvKeyLadderSubCmdType_eDecryptEFK, |
|---|
| 186 | NEXUS_AvKeyLadderSubCmdType_eDecryptCID. |
|---|
| 187 | |
|---|
| 188 | *** Generating CW (CA) *** |
|---|
| 189 | NEXUS_AvKeyLadderSubCmdType_eReadSCN, |
|---|
| 190 | NEXUS_AvKeyLadderSubCmdType_eDecryptEPK, |
|---|
| 191 | NEXUS_AvKeyLadderSubCmdType_eDecryptECW. |
|---|
| 192 | |
|---|
| 193 | *** Loading Clear Key *** |
|---|
| 194 | NEXUS_AvKeyLadderSubCmdType_eReadSCN, |
|---|
| 195 | NEXUS_AvKeyLadderSubCmdType_eLoadCW. |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | The following parameter settings are currently supported: |
|---|
| 199 | |
|---|
| 200 | NEXUS_SecurityEngine cryptoEngine |
|---|
| 201 | NEXUS_SecurityEngine_eCA or |
|---|
| 202 | NEXUS_SecurityEngine_eM2m |
|---|
| 203 | |
|---|
| 204 | NEXUS_SecurityKeyType cryptoKeyType |
|---|
| 205 | NEXUS_SecurityKeyType_eEven or |
|---|
| 206 | NEXUS_SecurityKeyType_eOdd |
|---|
| 207 | |
|---|
| 208 | NEXUS_SecuritySwizzleType swizzleType |
|---|
| 209 | NEXUS_SecuritySwizzleType_eNone |
|---|
| 210 | |
|---|
| 211 | unsigned char swizzle1Index |
|---|
| 212 | Not used |
|---|
| 213 | |
|---|
| 214 | NEXUS_SecurityKeySlotType caKeySlotType |
|---|
| 215 | Any type except NEXUS_SecurityKeySlotType_eType6 |
|---|
| 216 | |
|---|
| 217 | NEXUS_SecurityKeyMode keyMode |
|---|
| 218 | NEXUS_SecurityKeyMode_eRegular or |
|---|
| 219 | NEXUS_SecurityKeyMode_eDes56 or |
|---|
| 220 | NEXUS_SecurityKeyMode_eDvbConformance |
|---|
| 221 | |
|---|
| 222 | SCN Identifier (OTP A ID) is returned only for AVCMD subcommand |
|---|
| 223 | NEXUS_AvKeyLadderSubCmdType_eReadSCN |
|---|
| 224 | as pAvCmdDataOutput->scnData[]. |
|---|
| 225 | |
|---|
| 226 | **/ |
|---|
| 227 | NEXUS_Error NEXUS_AvKeyLadder_AvCmd( |
|---|
| 228 | NEXUS_KeySlotHandle keyHandle, |
|---|
| 229 | const NEXUS_AvKeyLadderAvCmdParm *pAvCmd, |
|---|
| 230 | NEXUS_AvKeyLadderAvCmdOutput *pAvCmdDataOutput /* [out] */ |
|---|
| 231 | ); |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | typedef struct NEXUS_AvKeyLadderAvCmdChain |
|---|
| 235 | { |
|---|
| 236 | int cmdCount; |
|---|
| 237 | NEXUS_KeySlotHandle keyHandle[NEXUS_AVKEYLADDER_CMD_CHAIN_LEN]; |
|---|
| 238 | NEXUS_AvKeyLadderAvCmdParm avCmdParm[NEXUS_AVKEYLADDER_CMD_CHAIN_LEN]; |
|---|
| 239 | |
|---|
| 240 | } NEXUS_AvKeyLadderAvCmdChain; |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | typedef struct NEXUS_AvKeyLadderAvCmdChainOutput |
|---|
| 244 | { |
|---|
| 245 | int respCount; |
|---|
| 246 | NEXUS_AvKeyLadderAvCmdOutput avCmdOutput[NEXUS_AVKEYLADDER_CMD_CHAIN_LEN]; |
|---|
| 247 | |
|---|
| 248 | } NEXUS_AvKeyLadderAvCmdChainOutput; |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | NEXUS_Error NEXUS_AvKeyLadder_AvCmdChain( |
|---|
| 253 | const NEXUS_AvKeyLadderAvCmdChain *pAvCmdChain, |
|---|
| 254 | NEXUS_AvKeyLadderAvCmdChainOutput *pAvCmdChainOutput /* [out] */ |
|---|
| 255 | ); |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | #ifdef __cplusplus |
|---|
| 259 | } |
|---|
| 260 | #endif |
|---|
| 261 | |
|---|
| 262 | #endif |
|---|