| 1 | /**************************************************************************** |
|---|
| 2 | *_Copyright (c) 2004 Digital Stream Technologies Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: dsthalca.c |
|---|
| 5 | * Author: Jun-ku Park, hwatk@dstreamtech.com |
|---|
| 6 | * Description: DST HAL [Conditional Access] Platform Indepedent Sources |
|---|
| 7 | * |
|---|
| 8 | ************************************************************************^^*/ |
|---|
| 9 | |
|---|
| 10 | #include <stdio.h> |
|---|
| 11 | #include <stdlib.h> |
|---|
| 12 | #include <errno.h> |
|---|
| 13 | #include <sys/stat.h> |
|---|
| 14 | |
|---|
| 15 | #include "dsthalcommon.h" |
|---|
| 16 | #include "dsthalca.h" |
|---|
| 17 | //#include "dstddca.h" |
|---|
| 18 | |
|---|
| 19 | #ifdef DMALLOC |
|---|
| 20 | #include <dmalloc.h> |
|---|
| 21 | #endif |
|---|
| 22 | |
|---|
| 23 | /****************************************************************************** |
|---|
| 24 | * Global variable declaration |
|---|
| 25 | ******************************************************************************/ |
|---|
| 26 | int gCADbgLvl = 1; |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | /****************************************************************************** |
|---|
| 30 | * Imported variable declaration |
|---|
| 31 | ******************************************************************************/ |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | /****************************************************************************** |
|---|
| 35 | * Imported function declaration |
|---|
| 36 | ******************************************************************************/ |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | /****************************************************************************** |
|---|
| 40 | * Local definitions / typedefs |
|---|
| 41 | ******************************************************************************/ |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | /****************************************************************************** |
|---|
| 45 | * Local variables |
|---|
| 46 | ******************************************************************************/ |
|---|
| 47 | static DST_CA sDSTCA; |
|---|
| 48 | |
|---|
| 49 | /****************************************************************************** |
|---|
| 50 | * Local function prototypes |
|---|
| 51 | ******************************************************************************/ |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | typedef struct tag_CA_START_PARAMs |
|---|
| 55 | { |
|---|
| 56 | CaDescrMode_t Mode; |
|---|
| 57 | CaDescrType_t Type; |
|---|
| 58 | DS_U8 bParityEnable; |
|---|
| 59 | DS_U32 Pid1; |
|---|
| 60 | DS_U32 Pid2; |
|---|
| 61 | DS_U32 EvenKeyHigh; |
|---|
| 62 | DS_U32 EvenKeyLow; |
|---|
| 63 | DS_U32 OddKeyHigh; |
|---|
| 64 | DS_U32 OddKeyLow; |
|---|
| 65 | } CA_START_PARAMs, *P_CA_START_PARAMs; |
|---|
| 66 | |
|---|
| 67 | static CA_START_PARAMs s_CaParams; |
|---|
| 68 | DS_U8 gdbghalca = 0; |
|---|
| 69 | |
|---|
| 70 | /**************************************************************************** |
|---|
| 71 | * |
|---|
| 72 | * DHL_RESULT DHL_CA_Init |
|---|
| 73 | * - Summary : Initialize the CA. |
|---|
| 74 | * - Argument : None. |
|---|
| 75 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 76 | * |
|---|
| 77 | ***************************************************************************/ |
|---|
| 78 | DHL_RESULT DHL_CA_Init( void ) |
|---|
| 79 | { |
|---|
| 80 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 81 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 82 | |
|---|
| 83 | /* Initialize the CA data structure. */ |
|---|
| 84 | pDSTCA->ScrMode = CaScrMode_DEFAULT; |
|---|
| 85 | pDSTCA->ScrType = CaScrType_PASSTHROUGH; |
|---|
| 86 | pDSTCA->ScrParityEnable = _FALSE_; |
|---|
| 87 | |
|---|
| 88 | pDSTCA->DescrMode = CaScrMode_DEFAULT; |
|---|
| 89 | pDSTCA->DescrType = CaScrType_PASSTHROUGH; |
|---|
| 90 | pDSTCA->ScrParityEnable = _FALSE_; |
|---|
| 91 | |
|---|
| 92 | pDSTCA->Pid1 = 0xFFFFFFFF; |
|---|
| 93 | pDSTCA->Pid2 = 0xFFFFFFFF; |
|---|
| 94 | |
|---|
| 95 | pDSTCA->dwEvenKeyHigh = 0L; |
|---|
| 96 | pDSTCA->dwEvenKeyLow = 0L; |
|---|
| 97 | pDSTCA->dwOddKeyHigh = 0L; |
|---|
| 98 | pDSTCA->dwOddKeyLow = 0L; |
|---|
| 99 | |
|---|
| 100 | pDSTCA->bStarted = _FALSE_; |
|---|
| 101 | |
|---|
| 102 | /* Call lower device driver. */ |
|---|
| 103 | //dhlResult = DD_CA_Init( pDSTCA ); |
|---|
| 104 | |
|---|
| 105 | /* Initialize MUTEX */ |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | pDSTCA->bCurState = CaState_INIT; |
|---|
| 110 | |
|---|
| 111 | return dhlResult; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | /**************************************************************************** |
|---|
| 115 | * |
|---|
| 116 | * DHL_RESULT DHL_CA_SetScramblingAlgorithm |
|---|
| 117 | * - Summary : Set the CA Scrambler Algorithm. |
|---|
| 118 | * - Argument |
|---|
| 119 | * Mode { CaScrMode_DEFAULT, CaScrMode_ECB, CaScrMode_CBC } |
|---|
| 120 | * Type { CaScrType_PASSTHROUGH, CaScrType_DVB_CSA, CaScrType_3DES, |
|---|
| 121 | * CaScrType_DES, CaScrType_CSS, CaScrType_M2 } |
|---|
| 122 | * bParityEnable : (1) Using even/odd or (0) Using odd only. |
|---|
| 123 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 124 | * |
|---|
| 125 | ***************************************************************************/ |
|---|
| 126 | DHL_RESULT DHL_CA_SetScramblingAlgorithm( CaScrMode_t Mode, CaScrType_t Type, DS_BOOL bParityEnable ) |
|---|
| 127 | { |
|---|
| 128 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 129 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 130 | |
|---|
| 131 | /* State should be INIT or STOP. */ |
|---|
| 132 | if ( (pDSTCA->bCurState == CaState_UNKNOWN) || (pDSTCA->bCurState == CaState_START) ) { |
|---|
| 133 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: CA State must INIT or STOP. State = 0x%x\n", pDSTCA->bCurState ); |
|---|
| 134 | return DHL_FAIL; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | /* Argument checks. */ |
|---|
| 138 | if ( (Mode >= CaScrMode_MAX) || (Type >= CaScrType_MAX) ) { |
|---|
| 139 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, |
|---|
| 140 | " Error: Invalid Arguments. Mode = %d, Type = %d\n", Mode, Type ); |
|---|
| 141 | return DHL_FAIL_INVALID_PARAM; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | /* Take the MUTEX. */ |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | pDSTCA->ScrMode = Mode; |
|---|
| 149 | pDSTCA->ScrType = Type; |
|---|
| 150 | pDSTCA->ScrParityEnable = bParityEnable; |
|---|
| 151 | |
|---|
| 152 | /* Give the MUTEX. */ |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | return dhlResult; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | /**************************************************************************** |
|---|
| 159 | * |
|---|
| 160 | * DHL_RESULT DHL_CA_SetDescramblingAlgorithm |
|---|
| 161 | * - Summary : Set the CA Descrambler Algorithm. |
|---|
| 162 | * - Argument |
|---|
| 163 | * Mode { CaScrMode_DEFAULT, CaScrMode_ECB, CaScrMode_CBC } |
|---|
| 164 | * Type { CaScrType_PASSTHROUGH, CaScrType_DVB_CSA, CaScrType_3DES, |
|---|
| 165 | * CaScrType_DES, CaScrType_CSS, CaScrType_M2 } |
|---|
| 166 | * bParityEnable : (1) Using even/odd or (0) Using odd only. |
|---|
| 167 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 168 | * |
|---|
| 169 | ***************************************************************************/ |
|---|
| 170 | DHL_RESULT DHL_CA_SetDescramblingAlgorithm( CaDescrMode_t Mode, CaDescrType_t Type, DS_BOOL bParityEnable ) |
|---|
| 171 | { |
|---|
| 172 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 173 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 174 | CA_START_PARAMs *p_caparam = &s_CaParams; |
|---|
| 175 | |
|---|
| 176 | //jfet_20050813 | For debuging |
|---|
| 177 | //save the input parameters |
|---|
| 178 | p_caparam->Mode = Mode; |
|---|
| 179 | p_caparam->Type = Type; |
|---|
| 180 | p_caparam->bParityEnable = bParityEnable; |
|---|
| 181 | |
|---|
| 182 | /* State should be INIT or STOP. */ |
|---|
| 183 | if ( (pDSTCA->bCurState == CaState_UNKNOWN) || (pDSTCA->bCurState == CaState_START) ) { |
|---|
| 184 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: CA State must INIT or STOP. State = 0x%x\n", pDSTCA->bCurState ); |
|---|
| 185 | return DHL_FAIL; |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | /* Argument checks. */ |
|---|
| 189 | if ( (Mode >= CaDescrMode_MAX) || (Type >= CaDescrType_MAX) ) { |
|---|
| 190 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, |
|---|
| 191 | " Error: Invalid Arguments. Mode = %d, Type = %d\n", Mode, Type ); |
|---|
| 192 | return DHL_FAIL_INVALID_PARAM; |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | /* Take the MUTEX. */ |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | pDSTCA->DescrMode = Mode; |
|---|
| 200 | pDSTCA->DescrType = Type; |
|---|
| 201 | pDSTCA->DescrParityEnable = bParityEnable; |
|---|
| 202 | |
|---|
| 203 | /* Give the MUTEX. */ |
|---|
| 204 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " success change mode (%d)\n",Mode); |
|---|
| 205 | |
|---|
| 206 | return dhlResult; |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | /**************************************************************************** |
|---|
| 210 | * |
|---|
| 211 | * DHL_RESULT DHL_CA_Start |
|---|
| 212 | * - Summary : Start the CA with Even / Odd Key. |
|---|
| 213 | * - Argument |
|---|
| 214 | * Pid1/Pid2 : Pid for CA Pid Filter |
|---|
| 215 | * EvenKeyHigh,EvenKeyLow,OddKeyHigh,OddKeyLow : Key for CA |
|---|
| 216 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 217 | * |
|---|
| 218 | ***************************************************************************/ |
|---|
| 219 | DHL_RESULT DHL_CA_Start( DS_U32 Pid1, DS_U32 Pid2, DS_U32 EvenKeyHigh, DS_U32 EvenKeyLow, |
|---|
| 220 | DS_U32 OddKeyHigh, DS_U32 OddKeyLow ) |
|---|
| 221 | { |
|---|
| 222 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 223 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 224 | CA_START_PARAMs *p_caparam = &s_CaParams; |
|---|
| 225 | |
|---|
| 226 | //jfet_20050813 | For debuging |
|---|
| 227 | //save the input parameters |
|---|
| 228 | p_caparam->Pid1 = Pid1; |
|---|
| 229 | p_caparam->Pid2 = Pid2; |
|---|
| 230 | p_caparam->EvenKeyHigh = EvenKeyHigh; |
|---|
| 231 | p_caparam->EvenKeyLow = EvenKeyLow; |
|---|
| 232 | p_caparam->OddKeyHigh = OddKeyHigh; |
|---|
| 233 | p_caparam->OddKeyLow = OddKeyLow; |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | /* State should be INIT or STOP or START*/ |
|---|
| 237 | if ( (pDSTCA->bCurState != CaState_STOP) && (pDSTCA->bCurState != CaState_INIT) && (pDSTCA->bCurState != CaState_START) ) { |
|---|
| 238 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: CA State must INIT or STOP. State = 0x%x\n", pDSTCA->bCurState ); |
|---|
| 239 | return DHL_FAIL; |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | /* Arguments Checks. */ |
|---|
| 243 | if ( (Pid1 > 0x1FFF) || (Pid2 > 0x1FFF) ) { |
|---|
| 244 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: Invalid PID. Pid1 = 0x%x, Pid2 = 0x%x\n", Pid1, Pid2 ); |
|---|
| 245 | return DHL_FAIL_INVALID_PARAM; |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | /* Take the MUTEX. */ |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | pDSTCA->Pid1 = Pid1; |
|---|
| 253 | pDSTCA->Pid2 = Pid2; |
|---|
| 254 | pDSTCA->dwEvenKeyHigh = EvenKeyHigh; |
|---|
| 255 | pDSTCA->dwEvenKeyLow = EvenKeyLow; |
|---|
| 256 | pDSTCA->dwOddKeyHigh = OddKeyHigh; |
|---|
| 257 | pDSTCA->dwOddKeyLow = OddKeyLow; |
|---|
| 258 | |
|---|
| 259 | if ( pDSTCA->bStarted == _TRUE_ ) { |
|---|
| 260 | dhlResult = DHL_CA_Stop(); |
|---|
| 261 | if ( dhlResult != DHL_OK ) { |
|---|
| 262 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: DD_CA_Stop. dhlResult = 0x%x\n", dhlResult ); |
|---|
| 263 | goto done; |
|---|
| 264 | } |
|---|
| 265 | } |
|---|
| 266 | |
|---|
| 267 | //dhlResult = DD_CA_Start( pDSTCA ); |
|---|
| 268 | if ( dhlResult != DHL_OK ) { |
|---|
| 269 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: DD_CA_Start. dhlResult = 0x%x\n", dhlResult ); |
|---|
| 270 | goto done; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | pDSTCA->bCurState = CaState_START; |
|---|
| 274 | pDSTCA->bStarted = _TRUE_; |
|---|
| 275 | done: |
|---|
| 276 | /* Give the MUTEX. */ |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | return dhlResult; |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | /**************************************************************************** |
|---|
| 283 | * |
|---|
| 284 | * DHL_RESULT DHL_CA_Stop |
|---|
| 285 | * - Summary : Stop the CA. |
|---|
| 286 | * - Argument : None. |
|---|
| 287 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 288 | * |
|---|
| 289 | ***************************************************************************/ |
|---|
| 290 | DHL_RESULT DHL_CA_Stop(void) |
|---|
| 291 | { |
|---|
| 292 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 293 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 294 | |
|---|
| 295 | /* State should be INIT or STOP */ |
|---|
| 296 | if ( (pDSTCA->bCurState != CaState_INIT) && (pDSTCA->bCurState != CaState_START) ) { |
|---|
| 297 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: CA State must INIT or STOP. State = 0x%x\n", pDSTCA->bCurState ); |
|---|
| 298 | return DHL_FAIL; |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | /* Take the MUTEX. */ |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | /* Call lower device driver. */ |
|---|
| 306 | //dhlResult = DD_CA_Stop( pDSTCA ); |
|---|
| 307 | if ( dhlResult != DHL_OK ) { |
|---|
| 308 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: DD_CA_Start, dhlResult = 0x%x\n", dhlResult ); |
|---|
| 309 | goto done; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | pDSTCA->bCurState = CaState_STOP; |
|---|
| 313 | pDSTCA->bStarted = _FALSE_; |
|---|
| 314 | done: |
|---|
| 315 | /* Give the MUTEX. */ |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | return dhlResult; |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | /**************************************************************************** |
|---|
| 323 | * |
|---|
| 324 | * DHL_RESULT DHL_CA_Close |
|---|
| 325 | * - Summary : Close the CA. |
|---|
| 326 | * - Argument : None. |
|---|
| 327 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 328 | * |
|---|
| 329 | ***************************************************************************/ |
|---|
| 330 | DHL_RESULT DHL_CA_Close(void) |
|---|
| 331 | { |
|---|
| 332 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 333 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 334 | |
|---|
| 335 | if ( (pDSTCA->bCurState == CaState_UNKNOWN) || (pDSTCA->bCurState >= CaState_MAX) ) { |
|---|
| 336 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: Invalid state. state = 0x%x\n", pDSTCA->bCurState ); |
|---|
| 337 | return DHL_FAIL; |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | /* Take the MUTEX. */ |
|---|
| 341 | |
|---|
| 342 | |
|---|
| 343 | /* Call lower device driver. */ |
|---|
| 344 | //dhlResult = DD_CA_Close( pDSTCA ); |
|---|
| 345 | if ( dhlResult != DHL_OK ) { |
|---|
| 346 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " Error: DD_CA_Close, dhlResult = 0x%x\n", dhlResult ); |
|---|
| 347 | goto done; |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | pDSTCA->bCurState = CaState_UNKNOWN; |
|---|
| 351 | |
|---|
| 352 | done: |
|---|
| 353 | /* Give the MUTEX. */ |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | return dhlResult; |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | /**************************************************************************** |
|---|
| 360 | * |
|---|
| 361 | * DHL_RESULT DHL_CA_SetMode |
|---|
| 362 | * - Summary : SET the current CA Mode and Type |
|---|
| 363 | * - Argument |
|---|
| 364 | * mode : new mode |
|---|
| 365 | * - Returns : DHL_OK on success, DHL_FAIL on failure. |
|---|
| 366 | * |
|---|
| 367 | * //--------------+------------- |
|---|
| 368 | * // input MODE | TYPE |
|---|
| 369 | * //--------------+------------- |
|---|
| 370 | * // DEFAULT | PASSTHROUGH |
|---|
| 371 | * // ECB | DES |
|---|
| 372 | * //---------------------------- |
|---|
| 373 | ***************************************************************************/ |
|---|
| 374 | |
|---|
| 375 | DHL_RESULT DHL_CA_SetMode(CaDescrMode_t mode) |
|---|
| 376 | { |
|---|
| 377 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 378 | P_DST_CA pDSTCA = &sDSTCA; |
|---|
| 379 | CA_START_PARAMs *p_caparam = &s_CaParams; |
|---|
| 380 | |
|---|
| 381 | //check the CA started |
|---|
| 382 | if(!pDSTCA->bStarted) |
|---|
| 383 | { |
|---|
| 384 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA," |skip| CA is not started yet\n"); |
|---|
| 385 | return DHL_FAIL; |
|---|
| 386 | } |
|---|
| 387 | //check the request mode |
|---|
| 388 | if(p_caparam->Mode == mode) |
|---|
| 389 | { |
|---|
| 390 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA," |skip| Same mode requested %d \n",mode); |
|---|
| 391 | return DHL_FAIL; |
|---|
| 392 | } |
|---|
| 393 | else { |
|---|
| 394 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA," |info| Chnage mode to %s \n", mode == 0? "DEFAULT": |
|---|
| 395 | mode == CaDescrMode_ECB ? "ECB":"Unknown"); |
|---|
| 396 | } |
|---|
| 397 | //1. STOP CA |
|---|
| 398 | dhlResult |= DHL_CA_Stop(); |
|---|
| 399 | |
|---|
| 400 | //2 set new Mode and Type |
|---|
| 401 | // - There are just 2 mode for now. (Default and ECB) |
|---|
| 402 | if( mode == CaDescrMode_DEFAULT) { |
|---|
| 403 | p_caparam->Mode = CaDescrMode_DEFAULT; |
|---|
| 404 | p_caparam->Type = CaDescrType_PASSTHROUGH; |
|---|
| 405 | } |
|---|
| 406 | else { |
|---|
| 407 | p_caparam->Mode = CaDescrMode_ECB; |
|---|
| 408 | p_caparam->Type = CaDescrType_DES; |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | //3. CHANGE DESCRAMBLING MODE &.. |
|---|
| 412 | dhlResult |= DHL_CA_SetDescramblingAlgorithm(p_caparam->Mode,p_caparam->Type,p_caparam->bParityEnable); |
|---|
| 413 | //4. RESTART with new Mode and Type |
|---|
| 414 | dhlResult |= DHL_CA_Start( p_caparam->Pid1, |
|---|
| 415 | p_caparam->Pid1, |
|---|
| 416 | p_caparam->EvenKeyHigh, |
|---|
| 417 | p_caparam->EvenKeyLow, |
|---|
| 418 | p_caparam->OddKeyHigh, |
|---|
| 419 | p_caparam->OddKeyLow ); |
|---|
| 420 | |
|---|
| 421 | if(dhlResult) |
|---|
| 422 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA," |error| %d 0x%x\n",__LINE__,dhlResult); |
|---|
| 423 | else |
|---|
| 424 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA, " success\n"); |
|---|
| 425 | return dhlResult; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | //Get current Mode |
|---|
| 429 | CaDescrMode_t DHL_CA_GetMode(void) |
|---|
| 430 | { |
|---|
| 431 | |
|---|
| 432 | if(gdbghalca) |
|---|
| 433 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA," |info| current mode is %s \n",s_CaParams.Mode == 0? "DEFAULT": |
|---|
| 434 | s_CaParams.Mode == CaDescrMode_ECB ? "ECB":"Unknown"); |
|---|
| 435 | |
|---|
| 436 | return s_CaParams.Mode; |
|---|
| 437 | } |
|---|
| 438 | //Get current CA module's start state |
|---|
| 439 | DS_BOOL DHL_CA_IsStarted(void) |
|---|
| 440 | { |
|---|
| 441 | if(gdbghalca) |
|---|
| 442 | DHL_DbgPrintf( gCADbgLvl, DHLDBG_CA," |info| CA is %s\n",sDSTCA.bStarted == _TRUE_ ? "started" : "not started"); |
|---|
| 443 | return sDSTCA.bStarted; |
|---|
| 444 | } |
|---|