- Timestamp:
- 07/20/11 00:38:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/1.10/reader-viaccess.c
r5619 r5684 81 81 cls=(l-(j+1))*8+i; 82 82 if (p) 83 cs_log("%sclass: %02X, expiry date: %04d/%02d/%02d - %04d/%02d/%02d", p, cls, 83 cs_log("%sclass: %02X, expiry date: %04d/%02d/%02d - %04d/%02d/%02d", p, cls, 84 84 vd.year_s+1980, vd.month_s, vd.day_s, 85 85 vd.year_e+1980, vd.month_e, vd.day_e); 86 86 else 87 cs_ri_log(reader, "class: %02X, expiry date: %04d/%02d/%02d - %04d/%02d/%02d", cls, 87 cs_ri_log(reader, "class: %02X, expiry date: %04d/%02d/%02d - %04d/%02d/%02d", cls, 88 88 vd.year_s+1980, vd.month_s, vd.day_s, 89 89 vd.year_e+1980, vd.month_e, vd.day_e); … … 92 92 93 93 static void show_subs(struct s_reader * reader, const uchar *emm) 94 { 94 { 95 95 // emm -> A9, A6, B6 96 96 … … 119 119 cls=(byts-(j+1))*8+i; 120 120 cs_log("%sclass %02X: expiry date: %02d/%02d/%04d - %02d/%02d/%04d", 121 fnano?"nano A9: ":"", cls, 122 vd.day_s, vd.month_s, vd.year_s+1980, 121 fnano?"nano A9: ":"", cls, 122 vd.day_s, vd.month_s, vd.year_s+1980, 123 123 vd.day_e, vd.month_e, vd.year_e+1980); 124 124 } … … 142 142 m=emm[emm[1]+1]; 143 143 parse_via_date(emm+2, &vd, 0); 144 cs_log("[viaccess-reader] nano B6: modexp %d%d%d%d%d%d: %02d/%02d/%04d", (m&0x20)?1:0, 144 cs_log("[viaccess-reader] nano B6: modexp %d%d%d%d%d%d: %02d/%02d/%04d", (m&0x20)?1:0, 145 145 (m&0x10)?1:0,(m&0x08)?1:0,(m&0x04)?1:0,(m&0x02)?1:0,(m&0x01)?1:0, 146 146 vd.day_s, vd.month_s, vd.year_s+1980); … … 210 210 211 211 212 if ((atr[1]!=0x77) || ((atr[2]!=0x18) && (atr[2]!=0x11) && (atr[2]!=0x19)) || ( atr[9]!=0x68))212 if ((atr[1]!=0x77) || ((atr[2]!=0x18) && (atr[2]!=0x11) && (atr[2]!=0x19)) || ((atr[9]!=0x68) && (atr[9]!=0x6C))) 213 213 return ERROR; 214 214 … … 299 299 static const unsigned char insa4[] = { 0xca,0xa4,0x04,0x00,0x03 }; // set provider id 300 300 unsigned char ins88[] = { 0xca,0x88,0x00,0x00,0x00 }; // set ecm 301 unsigned char insf8[] = { 0xca,0xf8,0x00,0x00,0x00 }; // set geographic info 301 unsigned char insf8[] = { 0xca,0xf8,0x00,0x00,0x00 }; // set geographic info 302 302 static const unsigned char insc0[] = { 0xca,0xc0,0x00,0x00,0x12 }; // read dcw 303 303 … … 400 400 401 401 // 40 07 03 0b 00 -> nano 40, len =7 ident 030B00 (tntsat), key #0 <== we're pointing here 402 // 09 -> use key #9 402 // 09 -> use key #9 403 403 // 05 67 00 404 404 if ((ecm88Data[0]==0x90 || ecm88Data[0]==0x40) && (ecm88Data[1]==0x03 || ecm88Data[1]==0x07 ) ) … … 409 409 410 410 nanoLen=ecm88Data[1] + 2; 411 keynr=ecm88Data[4]&0x0F; 411 keynr=ecm88Data[4]&0x0F; 412 412 413 413 // 40 07 03 0b 00 -> nano 40, len =7 ident 030B00 (tntsat), key #0 <== we're pointing here 414 // 09 -> use key #9 414 // 09 -> use key #9 415 415 if(nanoLen>5) { 416 416 curnumber_ecm =(ecm88Data[6]<<8) | (ecm88Data[7]); … … 420 420 // as some card don't support this 421 421 //force use ecm 00 provider 030B00 & 032920 & 032940 422 if( reader->last_geo.number_ecm > 0 ) 423 { 422 if( reader->last_geo.number_ecm > 0 ) 423 { 424 424 if(ecm88Data[2] == 0x03 && ((ecm88Data[3] == 0x0B && ecm88Data[4] == 0x00)|| 425 425 (ecm88Data[3] == 0x29 && ecm88Data[4] == 0x20)|| … … 430 430 keynr=ecm88Data[5]; 431 431 cs_debug_mask(D_READER, "keyToUse = %02x, ECM ending with %02x",ecm88Data[5], ecm88Data[nanoLen-1]); 432 } 433 else 432 } 433 else 434 434 { 435 435 // ecm 01 … … 482 482 // 483 483 484 if( reader->last_geo.provid != provid ) 484 if( reader->last_geo.provid != provid ) 485 485 { 486 486 reader->last_geo.provid = provid; … … 490 490 } 491 491 492 //Nano D2 0x0b Pre AES decrypt CW 493 if ( hasD2 && nanoD2 == 1) 492 //Nano D2 0x0b Pre AES decrypt CW 493 if ( hasD2 && nanoD2 == 1) 494 494 { 495 495 uchar *ecm88DataCW = ecm88Data; … … 506 506 } 507 507 cwStart++; 508 } 508 } 509 509 // use AES from list to decrypt CW 510 510 cs_debug_mask(D_READER, "Decoding CW : using AES key id %d for provider %06x",D2KeyID, (provid & 0xFFFFF0)); … … 525 525 if(ecmf8Len) 526 526 { 527 if( reader->last_geo.geo_len!=ecmf8Len || 527 if( reader->last_geo.geo_len!=ecmf8Len || 528 528 memcmp(reader->last_geo.geo, ecmf8Data, reader->last_geo.geo_len)) 529 529 { … … 538 538 ins88[3]=keynr; 539 539 ins88[4]= curEcm88len; 540 // 540 // 541 541 // we should check the nano to make sure the ecm is valid 542 542 // we should look for at least 1 E3 nano, 1 EA nano and the F0 signature nano … … 638 638 cs_debug_mask(D_EMM, "VIACCESS EMM: UNKNOWN"); 639 639 return TRUE; 640 } 640 } 641 641 } 642 642 … … 749 749 // check if the provider changes. If yes, set the new one. If not, don't .. card will return an error if we do. 750 750 if( reader->last_geo.provid != emm_provid ) { 751 write_cmd(insa4, ident); 751 write_cmd(insa4, ident); 752 752 if( cta_res[cta_lr-2]!=0x90 || cta_res[cta_lr-1]!=0x00 ) { 753 753 cs_dump(insa4, 5, "set provider cmd:"); … … 762 762 reader->last_geo.geo[0] = 0; 763 763 764 } 764 } 765 765 else if (emmParsed[0]==0x9e && emmParsed[1]==0x20) { 766 766 /* adf */ … … 818 818 insf0[3] = keynr; // key 819 819 insf0[4] = nano9EData[1] + 2; 820 write_cmd(insf0, nano9EData); 820 write_cmd(insf0, nano9EData); 821 821 if( cta_res[cta_lr-2]!=0x90 || cta_res[cta_lr-1]!=0x00 ) { 822 822 cs_dump(insf0, 5, "set adf cmd:"); … … 831 831 memcpy (insData, nano91Data, nano91Data[1] + 2); 832 832 memcpy (insData + nano91Data[1] + 2, nano9EData, nano9EData[1] + 2); 833 write_cmd(insf4, insData); 833 write_cmd(insf4, insData); 834 834 if(( cta_res[cta_lr-2]!=0x90 && cta_res[cta_lr-2]!=0x91) || cta_res[cta_lr-1]!=0x00 ) { 835 835 cs_dump(insf4, 5, "set adf encrypted cmd:"); … … 842 842 843 843 if (!nano92Data) { 844 // send subscription 844 // send subscription 845 845 ins18[2] = nano9EData ? 0x01: 0x00; // found 9E nano ? 846 846 ins18[3] = keynr; // key … … 873 873 memcpy (insData + nano92Data[1] + 2, nano81Data, nano81Data[1] + 2); 874 874 memcpy (insData + nano92Data[1] + 2 + nano81Data[1] + 2, nanoF0Data, nanoF0Data[1] + 2); 875 write_cmd(ins1c, insData); 875 write_cmd(ins1c, insData); 876 876 877 877 if( (cta_res[cta_lr-2]==0x90 && cta_res[cta_lr-1]==0x00) ) { 878 878 cs_log("[viaccess-reader] update successfully written"); 879 879 rc=1; // written 880 } 880 } 881 881 else { 882 882 if( cta_res[cta_lr-2]&0x1 ) … … 888 888 cs_log("[viaccess-reader] extended status %02X %02X", cta_res[0], cta_res[1]); 889 889 } 890 //} 890 //} 891 891 return ERROR; 892 892 } … … 938 938 reader->last_geo.geo[0] = 0; 939 939 940 cs_log("[viaccess-reader] card detected"); 941 940 cs_log("[viaccess-reader] card detected"); 941 942 942 cs_clear_entitlement(reader); //reset the entitlements 943 943 … … 997 997 fshow=(scls<show_cls); 998 998 insb8[4]=l; write_cmd(insb8, NULL); // read class subs 999 if( (cta_res[cta_lr-2]==0x90) && (fshow) && 999 if( (cta_res[cta_lr-2]==0x90) && (fshow) && 1000 1000 (cta_res[cta_lr-1]==0x00 || cta_res[cta_lr-1]==0x08) ) 1001 1001 { … … 1011 1011 1012 1012 insac[4]=0; 1013 insa4[2]=0x02; 1013 insa4[2]=0x02; 1014 1014 write_cmd(insa4, NULL); // select next provider 1015 1015 } … … 1059 1059 } 1060 1060 1061 if (buffer[2]==0x2c) { 1061 if (buffer[2]==0x2c) { 1062 1062 //add 9E 20 nano + first 32 bytes of emm content 1063 1063 memcpy(emmbuf+pos, "\x9E\x20", 2); … … 1096 1096 #endif 1097 1097 1098 void reader_viaccess(struct s_cardsystem *ph) 1098 void reader_viaccess(struct s_cardsystem *ph) 1099 1099 { 1100 1100 ph->do_emm=viaccess_do_emm;
Note:
See TracChangeset
for help on using the changeset viewer.