Changeset 8488 for trunk/reader-irdeto.c
- Timestamp:
- 03/06/13 01:32:21 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/reader-irdeto.c
r8458 r8488 85 85 uint32_t base; 86 86 } CHID_BASE_DATE; 87 88 struct irdeto_data { 89 int32_t acs57; // A flag for the ACS57 ITA DVB-T 90 uint16_t acs; 91 char country_code[3]; // irdeto country code. 92 }; 87 93 88 94 static void XRotateLeft8Byte(uchar *buf) … … 181 187 // now check for specific providers base date 182 188 int32_t i=0; 189 struct irdeto_data *csystem_data = reader->csystem_data; 183 190 while(table[i].caid) { 184 if(reader->caid==table[i].caid && reader->acs==table[i].acs && !memcmp(reader->country_code,table[i].c_code,3) ) {191 if(reader->caid==table[i].caid && csystem_data->acs==table[i].acs && !memcmp(csystem_data->country_code,table[i].c_code,3) ) { 185 192 date_base = table[i].base; 186 193 break; … … 218 225 int32_t i, p; 219 226 uchar buf[256] = {0}; 227 struct irdeto_data *csystem_data = reader->csystem_data; 220 228 221 229 uchar sc_GetProvider[] = { 0x02, 0x03, 0x03, 0x00, 0x00 }; … … 229 237 { 230 238 int32_t acspadd = 0; 231 if( reader->acs57==1){239 if(csystem_data->acs57==1){ 232 240 acspadd=8; 233 241 sc_Acs57Prov[3]=i; … … 243 251 } 244 252 //if ((cta_lr==26) && (cta_res[0]!=0xf)) 245 if (((cta_lr == 26) && ((!(i&1)) || (cta_res[0] != 0xf))) || ( reader->acs57==1))253 if (((cta_lr == 26) && ((!(i&1)) || (cta_res[0] != 0xf))) || (csystem_data->acs57==1)) 246 254 { 247 255 reader->prid[i][4] = p++; … … 300 308 301 309 int32_t acspadd = 0; 310 int32_t acs57 = 0; 302 311 if (!memcmp(atr+4, "IRDETO", 6)) 303 reader->acs57=0;312 acs57=0; 304 313 else { 305 314 if ((!memcmp(atr+5, "IRDETO", 6)) || ((atr[6]==0xC4 && atr[9]==0x8F && atr[10]==0xF1) && reader->force_irdeto)) { 306 reader->acs57=1;315 acs57=1; 307 316 acspadd=8; 308 317 rdr_log(reader, "Hist. Bytes: %s",atr+5); … … 311 320 } 312 321 } 322 323 if (!cs_malloc(&reader->csystem_data, sizeof(struct irdeto_data))) 324 return ERROR; 325 struct irdeto_data *csystem_data = reader->csystem_data; 326 csystem_data->acs57 = acs57; 327 313 328 rdr_log(reader, "detect irdeto card"); 314 if(check_filled(reader->rsa_mod, 64) > 0 && (!reader->force_irdeto || reader->acs57)) // we use rsa from config as camkey329 if(check_filled(reader->rsa_mod, 64) > 0 && (!reader->force_irdeto || csystem_data->acs57)) // we use rsa from config as camkey 315 330 { 316 331 char tmp_dbg[65]; 317 332 rdr_debug_mask(reader, D_READER, "using camkey data from config"); 318 333 rdr_debug_mask(reader, D_READER, " camkey: %s", cs_hexdump(0, reader->boxkey, sizeof(reader->boxkey), tmp_dbg, sizeof(tmp_dbg))); 319 if ( reader->acs57==1) {334 if (csystem_data->acs57==1) { 320 335 memcpy(&sc_Acs57CamKey[5], reader->rsa_mod, 0x40); 321 336 rdr_debug_mask(reader, D_READER, "camkey-data: %s", cs_hexdump(0, &sc_Acs57CamKey[5], 32, tmp_dbg, sizeof(tmp_dbg))); … … 327 342 } 328 343 } else { 329 if( reader->acs57==1) {344 if(csystem_data->acs57==1) { 330 345 rdr_log(reader, "WARNING: ACS57 card can require the CamKey from config"); 331 346 } else { … … 336 351 * Get Irdeto Smartcard Details - version - patch level etc 337 352 */ 338 if( reader->acs57==0) {353 if(csystem_data->acs57==0) { 339 354 if(!irdeto_do_cmd(reader,sc_GetSCDetails,0,cta_res, &cta_lr)) 340 355 rdr_log(reader,"Irdeto SC %0x version %0x revision %0x, patch level %0x",cta_res[0+acspadd], … … 344 359 * CountryCode 345 360 */ 346 if( reader->acs57==1) {361 if(csystem_data->acs57==1) { 347 362 irdeto_do_cmd(reader, sc_Acs57Country, 0x9019, cta_res, &cta_lr); 348 363 int32_t acslength=cta_res[cta_lr-1]; … … 352 367 reader_chk_cmd(sc_GetCountryCode, 18); 353 368 } 354 reader->acs = (cta_res[0+acspadd] << 8) | cta_res[1+acspadd];369 csystem_data->acs = (cta_res[0+acspadd] << 8) | cta_res[1+acspadd]; 355 370 reader->caid = (cta_res[5+acspadd] << 8) | cta_res[6+acspadd]; 356 memcpy( reader->country_code,cta_res + 13 + acspadd, 3);371 memcpy(csystem_data->country_code,cta_res + 13 + acspadd, 3); 357 372 rdr_log(reader, "caid: %04X, acs: %x.%02x, country code: %c%c%c", 358 373 reader->caid, cta_res[0+acspadd], cta_res[1+acspadd], cta_res[13+acspadd], cta_res[14+acspadd], cta_res[15+acspadd]); … … 361 376 * Ascii/Hex-Serial 362 377 */ 363 if( reader->acs57==1) {378 if(csystem_data->acs57==1) { 364 379 irdeto_do_cmd(reader, sc_Acs57Ascii, 0x901D, cta_res, &cta_lr); 365 380 int32_t acslength=cta_res[cta_lr-1]; … … 371 386 memcpy(buf, cta_res+acspadd, 10); 372 387 buf[10] = 0; 373 if( reader->acs57==1) {388 if(csystem_data->acs57==1) { 374 389 irdeto_do_cmd(reader, sc_Acs57Hex, 0x903E, cta_res, &cta_lr); 375 390 int32_t acslength=cta_res[cta_lr-1]; … … 388 403 * CardFile 389 404 */ 390 if( reader->acs57==1) {405 if(csystem_data->acs57==1) { 391 406 irdeto_do_cmd(reader, sc_Acs57CFile, 0x9049, cta_res, &cta_lr); 392 407 int32_t acslength=cta_res[cta_lr-1]; … … 460 475 break; 461 476 default: 462 if( reader->acs57==1) {477 if(csystem_data->acs57==1) { 463 478 int32_t i, crc=0x76; 464 479 for(i=6;i<(int)sizeof(sc_Acs57CamKey)-1;i++) … … 487 502 uchar sc_Acs57_Cmd[]={ ACS57ECM, 0xFE, 0x00, 0x00, 0x00 }; 488 503 uchar cta_cmd[272]; 504 struct irdeto_data *csystem_data = reader->csystem_data; 489 505 490 506 int32_t i=0, acspadd=0; 491 if( reader->acs57==1) {507 if(csystem_data->acs57==1) { 492 508 int32_t crc=63; 493 509 sc_Acs57Ecm[4]=er->ecm[2]-2; … … 740 756 static uchar sc_Acs57Emm[] = { 0xD1,0x00,0x00,0x00,0x00 }; 741 757 uchar sc_Acs57_Cmd[]={ ACS57EMM, 0xFE, 0x00, 0x00, 0x00 }; 758 struct irdeto_data *csystem_data = reader->csystem_data; 742 759 743 760 uchar cta_cmd[272]; … … 767 784 l++; 768 785 if (l <= ADDRLEN) { 769 if( reader->acs57==1) {786 if(csystem_data->acs57==1) { 770 787 int32_t dataLen=0; 771 788 if(ep->type==UNIQUE){ … … 833 850 def_resp; 834 851 int32_t i, p; 852 struct irdeto_data *csystem_data = reader->csystem_data; 835 853 836 854 cs_clear_entitlement(reader); // reset the entitlements … … 845 863 */ 846 864 int32_t acspadd=0; 847 if( reader->acs57==1){865 if(csystem_data->acs57==1){ 848 866 acspadd=8; 849 867 reader_chk_cmd(sc_Acs57Code,0); … … 855 873 } 856 874 857 if (((cta_lr>9) && !(cta_res[cta_lr-2]|cta_res[cta_lr-1])) || ( reader->acs57==1))875 if (((cta_lr>9) && !(cta_res[cta_lr-2]|cta_res[cta_lr-1])) || (csystem_data->acs57==1)) 858 876 { 859 877 rdr_debug_mask(reader, D_READER, "max chids: %d, %d, %d, %d", cta_res[6+acspadd], cta_res[7+acspadd], cta_res[8+acspadd], cta_res[9+acspadd]); … … 876 894 while(1) // will exit if cta_lr < 61 .. which is the correct break condition. 877 895 { 878 if( reader->acs57==1) {896 if(csystem_data->acs57==1) { 879 897 int32_t crc=63; 880 898 sc_Acs57Prid[5]=j;
Note:
See TracChangeset
for help on using the changeset viewer.