Changeset 3602
- Timestamp:
- 10/18/10 00:28:22 (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/reader-videoguard-common.c
r3430 r3602 19 19 13, 1992, 0, NDS1, "VideoGuard Sky New Zealand (0969)"}, 20 20 /* known NDS1+ atrs */ 21 {{ 0x3F, 0x7F, 0x13, 0x25, 0x04, 0x33, 0xB0, 0x02, 0x69, 0xFF, 0x4A, 0x50, 0xE0, 0x00, 0x00, 0x54, 22 0x42, 0x00, 0x00, 0x00 }, 23 20, 1997, 0, NDS12, "VideoGuard China (0988)"}, 21 24 {{ 0x3F, 0x78, 0x13, 0x25, 0x03, 0x40, 0xB0, 0x20, 0xFF, 0xFF, 0x4A, 0x50, 0x00 }, 22 25 13, 1997, 0, NDS12, "VideoGuard DirecTV"}, … … 58 61 0x80, 0x00, 0x46, 0x44, 0x03 }, 59 62 20, 2000, 0, NDS2, "VideoGuard Foxtel Australia (096C)"}, 60 {{ 0x3F, 0x7F, 0x13, 0x25, 0x04, 0x33, 0xB0, 0x02, 0x69, 0xFF, 0x4A, 0x50, 0xE0, 0x00, 0x00, 0x54,61 0x42, 0x00, 0x00, 0x00 },62 20, 1997, 0, NDS2, "VideoGuard China (0988)"},63 63 {{ 0x3F, 0xFF, 0x11, 0x25, 0x03, 0x10, 0x80, 0x41, 0xB0, 0x06, 0x69, 0xFF, 0x4A, 0x50, 0x70, 0x00, 64 64 0x00, 0x41, 0x5A, 0x01, 0x00, 0x11 }, -
trunk/reader-videoguard-common.h
r3327 r3602 43 43 extern int status_ok(const unsigned char *status); 44 44 extern void memorize_cmd_table (struct s_reader * reader, const unsigned char *mem, int size); 45 extern int cmd_table_get_info(struct s_reader * reader, const unsigned char *cmd, unsigned char *rlen, unsigned char *rmode); 45 46 extern int cmd_exists(struct s_reader * reader, const unsigned char *cmd); 46 47 extern int read_cmd_len(struct s_reader * reader, const unsigned char *cmd); -
trunk/reader-videoguard12.c
r3354 r3602 3 3 #include "reader-videoguard-common.h" 4 4 5 // Redefine logging funtion to include reader name 6 #define cs_log(x...) cs_log("[videoguard12-reader] "x) 7 #define cs_ri_log(x,y...) cs_ri_log(x,"[videoguard12-reader] "y) 8 #ifdef WITH_DEBUG 9 #define cs_debug(x...) cs_debug("[videoguard12-reader] "x) 10 #define cs_debug_mask(x,y...) cs_debug_mask(x,"[videoguard12-reader] "y) 11 #endif 12 13 static int vg12_do_cmd(struct s_reader * reader, const unsigned char *ins, const unsigned char *txbuff, unsigned char *rxbuff, 14 unsigned char * cta_res) 15 { 16 ushort cta_lr; 17 unsigned char ins2[5]; 18 memcpy(ins2,ins,5); 19 unsigned char len=0, mode=0; 20 21 if(cmd_table_get_info(reader,ins2,&len,&mode)) { 22 if(len==0xFF && mode==2) { 23 if(ins2[4]==0) ins2[4]=len=read_cmd_len(reader,ins2); 24 } 25 else if(mode!=0) ins2[4]=len; 26 } 27 28 len=ins2[4]; 29 30 unsigned char tmp[264]; 31 if(!rxbuff) rxbuff=tmp; 32 if(mode>1) { 33 if(!write_cmd_vg(ins2,NULL) || !status_ok(cta_res+len)) return -1; 34 memcpy(rxbuff,ins2,5); 35 memcpy(rxbuff+5,cta_res,len); 36 memcpy(rxbuff+5+len,cta_res+len,2); 37 } 38 else { 39 if(!write_cmd_vg(ins2,(uchar *)txbuff) || !status_ok(cta_res)) return -2; 40 memcpy(rxbuff,ins2,5); 41 memcpy(rxbuff+5,txbuff,len); 42 memcpy(rxbuff+5+len,cta_res,2); 43 } 44 45 return len; 46 } 47 5 48 static void read_tiers(struct s_reader * reader) 6 49 { … … 8 51 static const unsigned char ins2a[5] = { 0x48,0x2a,0x00,0x00,0x00 }; 9 52 int l; 10 l= do_cmd(reader,ins2a,NULL,NULL,cta_res);53 l=vg12_do_cmd(reader,ins2a,NULL,NULL,cta_res); 11 54 if(l<0 || !status_ok(cta_res+l)) return; 12 55 unsigned char ins76[5] = { 0x48,0x76,0x00,0x00,0x00 }; … … 19 62 for(i=0; i<num; i++) { 20 63 ins76[2]=i; 21 l= do_cmd(reader,ins76,NULL,NULL,cta_res);64 l=vg12_do_cmd(reader,ins76,NULL,NULL,cta_res); 22 65 if(l<0 || !status_ok(cta_res+l)) return; 23 66 if(cta_res[2]==0 && cta_res[3]==0) break; … … 26 69 unsigned short tier_id = (cta_res[2] << 8) | cta_res[3]; 27 70 char *tier_name = get_tiername(tier_id, reader->caid[0]); 28 cs_ri_log(reader, " [videoguard12-reader]tier: %04x, expiry date: %04d/%02d/%02d-%02d:%02d:%02d %s",tier_id,y,m,d,H,M,S,tier_name);71 cs_ri_log(reader, "tier: %04x, expiry date: %04d/%02d/%02d-%02d:%02d:%02d %s",tier_id,y,m,d,H,M,S,tier_name); 29 72 } 30 73 } … … 35 78 get_hist; 36 79 if ((hist_size < 7) || (hist[1] != 0xB0) || (hist[4] != 0xFF) || (hist[5] != 0x4A) || (hist[6] != 0x50)){ 37 return ERROR; 38 } 80 cs_debug("failed history check"); 81 return ERROR; 82 } 83 cs_debug("passed history check"); 39 84 40 85 get_atr; … … 52 97 } 53 98 54 cs_ ri_log(reader, "[videoguard12-reader]type: %s, baseyear: %i", reader->card_desc, reader->card_baseyear);99 cs_debug("type: %s, baseyear: %i", reader->card_desc, reader->card_baseyear); 55 100 if(reader->ndsversion == NDS12){ 56 cs_ log("[videoguard12-reader]forced to NDS1+");101 cs_debug("forced to NDS1+"); 57 102 } 58 103 … … 63 108 if(!write_cmd_vg(ins3601,NULL) || !status_ok(cta_res+l)) { 64 109 return ERROR; // not a possible NDS1+ card 65 110 } 66 111 67 112 static const unsigned char dummy_cmd_table[132] = { … … 104 149 unsigned char buff[256]; 105 150 106 /* Read card serial number to initialisethe card151 // Read card serial number to check the card 107 152 unsigned char ins52[5] = { 0x48,0x52,0x00,0x00,0x14 }; 108 153 109 if(!write_cmd_vg(ins52,NULL) || !status_ok(cta_res+l)) { 110 cs_log ("[videoguard12-reader] failed to read serial"); 111 return ERROR; 112 } 113 */ 154 if(!write_cmd_vg(ins52,NULL) || !status_ok(cta_res+0x14)) { 155 cs_log ("class48 ins52: failed to read serial"); 156 return ERROR; 157 } 114 158 115 159 static const unsigned char ins36[5] = { 0x48,0x36,0x00,0x00,0x00 }; … … 125 169 /* we can try to get the boxid from the card */ 126 170 int boxidOK=0; 127 l= do_cmd(reader,ins36,NULL,buff,cta_res);171 l=vg12_do_cmd(reader,ins36,NULL,buff,cta_res); 128 172 if(l<13) 129 cs_log(" [videoguard12-reader]ins36: too short answer");173 cs_log("class48 ins36: too short answer"); 130 174 else if (buff[7] > 0x0F) 131 cs_log(" [videoguard12-reader]ins36: encrypted - can't parse");175 cs_log("class48 ins36: encrypted - can't parse"); 132 176 else { 133 177 /* skipping the initial fixed fields: cmdecho (4) + length (1) + encr/rev++ (4) */ … … 175 219 break; 176 220 default: /* default to assume a length byte */ 177 cs_log(" [videoguard12-reader] ins36returned unknown type=0x%02X - parsing may fail", buff[i]);221 cs_log("class48 ins36: returned unknown type=0x%02X - parsing may fail", buff[i]); 178 222 i+=buff[i+1]+2; 179 223 } … … 182 226 183 227 if(!boxidOK) { 184 cs_log (" [videoguard12-reader]no boxID available");228 cs_log ("no boxID available"); 185 229 return ERROR; 186 230 } … … 191 235 memcpy(payload4C,boxID,4); 192 236 if(!write_cmd_vg(ins4C,payload4C) || !status_ok(cta_res+l)) { 193 cs_log("[videoguard12-reader] sending boxid failed"); 194 return ERROR; 195 } 196 197 //short int SWIRDstatus = cta_res[1]; 237 cs_log("class48 ins4C: failed - sending boxid failed"); 238 return ERROR; 239 } 240 198 241 static const unsigned char ins58[5] = { 0x48,0x58,0x00,0x00,0x00 }; 199 l= do_cmd(reader,ins58,NULL,buff,cta_res);242 l=vg12_do_cmd(reader,ins58,NULL,buff,cta_res); 200 243 if(l<0) { 201 cs_log(" [videoguard12-reader] cmd ins58failed");244 cs_log("class48 ins58: failed"); 202 245 return ERROR; 203 246 } … … 211 254 memset(reader->prid, 0x00, sizeof(reader->prid)); 212 255 213 /* 214 cs_log ("[videoguard12-reader] INS58 : Fuse byte=0x%02X, IRDStatus=0x%02X", cta_res[2],SWIRDstatus); 215 if (SWIRDstatus==4) { 216 // If swMarriage=4, not married then exchange for BC Key 217 cs_log ("[videoguard12-reader] Card not married, exchange for BC Keys"); 218 */ 219 220 cCamCryptVG_SetSeed(reader); 221 222 static const unsigned char insB4[5] = { 0x48,0xB4,0x00,0x00,0x40 }; 223 unsigned char tbuff[64]; 224 cCamCryptVG_GetCamKey(reader,tbuff); 225 l=do_cmd(reader,insB4,tbuff,NULL,cta_res); 226 if(l<0 || !status_ok(cta_res)) { 227 cs_log ("[videoguard12-reader] cmd D0B4 failed (%02X%02X)", cta_res[0], cta_res[1]); 228 return ERROR; 229 } 230 231 static const unsigned char insBC[5] = { 0x48,0xBC,0x00,0x00,0x00 }; 232 l=do_cmd(reader,insBC,NULL,NULL,cta_res); 256 static const unsigned char insBE[5] = { 0x4B,0xBE,0x00,0x00,0x00 }; 257 l=vg12_do_cmd(reader,insBE,NULL,NULL,cta_res); 233 258 if(l<0) { 234 cs_log("[videoguard12-reader] cmd D0BC failed"); 235 return ERROR; 236 } 237 238 static const unsigned char insBE[5] = { 0x48,0xBE,0x00,0x00,0x00 }; 239 l=do_cmd(reader,insBE,NULL,NULL,cta_res); 240 if(l<0) { 241 cs_log("[videoguard12-reader] cmd D3BE failed"); 242 return ERROR; 243 } 244 245 static const unsigned char ins58a[5] = { 0x49,0x58,0x00,0x00,0x00 }; 246 l=do_cmd(reader,ins58a,NULL,NULL,cta_res); 247 if(l<0) { 248 cs_log("[videoguard12-reader] cmd D158 failed"); 249 return ERROR; 250 } 251 252 static const unsigned char ins4Ca[5] = { 0x49,0x4C,0x00,0x00,0x00 }; 253 l=do_cmd(reader,ins4Ca,payload4C,NULL,cta_res); 254 if(l<0 || !status_ok(cta_res)) { 255 cs_log("[videoguard12-reader] cmd D14Ca failed"); 256 return ERROR; 257 } 258 259 cs_ri_log(reader, "[videoguard12-reader] type: VideoGuard, caid: %04X, serial: %02X%02X%02X%02X, BoxID: %02X%02X%02X%02X", 260 reader->caid[0], 259 cs_log("class4B insBE: failed"); 260 return ERROR; 261 } 262 263 cs_ri_log(reader, "type: %s, caid: %04X", 264 reader->card_desc, 265 reader->caid[0]); 266 cs_ri_log(reader, "serial: %02X%02X%02X%02X, BoxID: %02X%02X%02X%02X, baseyear: %i", 261 267 reader->hexserial[2],reader->hexserial[3],reader->hexserial[4],reader->hexserial[5], 262 boxID[0],boxID[1],boxID[2],boxID[3] );263 264 cs_log(" [videoguard12-reader]ready for requests");268 boxID[0],boxID[1],boxID[2],boxID[3], 269 reader->card_baseyear); 270 cs_log("ready for requests"); 265 271 266 272 return OK; … … 283 289 int l; 284 290 285 l = do_cmd(reader,ins40,tbuff,NULL,cta_res);291 l = vg12_do_cmd(reader,ins40,tbuff,NULL,cta_res); 286 292 if(l<0 || !status_ok(cta_res)) { 287 cs_log (" [videoguard12-reader]class49 ins40: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]);293 cs_log ("class49 ins40: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]); 288 294 return ERROR; 289 295 } else { 290 l = do_cmd(reader,ins54,NULL,rbuff,cta_res);296 l = vg12_do_cmd(reader,ins54,NULL,rbuff,cta_res); 291 297 if(l<0 || !status_ok(cta_res+l)) { 292 cs_log(" [reader-videoguard12]class4B ins54: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]);298 cs_log("class4B ins54: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]); 293 299 return ERROR; 294 300 } else { 295 // Log decrypted INS54296 // cs_dump (rbuff, 5, "Decrypted INS54:");297 // cs_dump (rbuff + 5, rbuff[4], "");298 301 299 302 if (!cw_is_valid(rbuff+5,0)){ //sky cards report 90 00 = ok but send cw = 00 when channel not subscribed 300 cs_log(" [reader-videoguard12]class4B ins54: status 90 00 = ok but cw=00 -> channel not subscribed " );303 cs_log("class4B ins54: status 90 00 = ok but cw=00 -> channel not subscribed " ); 301 304 return ERROR; 302 305 } … … 304 307 // copy cw1 in place 305 308 memcpy(er->cw+0,rbuff+5,8); 306 307 // process cw2308 int ind;309 for(ind=15; ind<l+5-10; ind++) { // +5 for 5 ins bytes, -10 to prevent memcpy ind+3,8 from reading past310 // rxbuffer we start searching at 15 because start at 13 goes wrong311 // with 090F 090b and 096a312 if(rbuff[ind]==0x25) {313 memcpy(er->cw+8,rbuff+ind+3,8); //don't care whether cw is 0 or not314 break;315 }316 }317 309 318 310 if(er->ecm[0]&1) { … … 349 341 case VG_EMMTYPE_G: 350 342 ep->type=GLOBAL; 351 cs_debug_mask(D_EMM, " VIDEOGUARD12EMM: GLOBAL");343 cs_debug_mask(D_EMM, "EMM: GLOBAL"); 352 344 return TRUE; 353 345 354 346 case VG_EMMTYPE_U: 355 cs_debug_mask(D_EMM, " VIDEOGUARD12EMM: UNIQUE");347 cs_debug_mask(D_EMM, "EMM: UNIQUE"); 356 348 ep->type=UNIQUE; 357 349 if (ep->emm[1] == 0) // detected UNIQUE EMM from cccam (there is no serial) … … 370 362 case VG_EMMTYPE_S: 371 363 ep->type=SHARED; 372 cs_debug_mask(D_EMM, " VIDEOGUARD12EMM: SHARED");364 cs_debug_mask(D_EMM, "EMM: SHARED"); 373 365 return TRUE; // FIXME: no check for SA 374 366 … … 441 433 while (payload) { 442 434 ins42[4]=*payload; 443 int l = do_cmd(reader,ins42,payload+1,NULL,cta_res);435 int l = vg12_do_cmd(reader,ins42,payload+1,NULL,cta_res); 444 436 if(l>0 && status_ok(cta_res)) { 445 437 rc=OK; 446 438 } 447 439 448 cs_debug_mask(D_EMM, " [videoguard12-reader]EMM request return code : %02X%02X", cta_res[0], cta_res[1]);440 cs_debug_mask(D_EMM, "EMM request return code : %02X%02X", cta_res[0], cta_res[1]); 449 441 //cs_dump(ep->emm, 64, "EMM:"); 450 442 if (status_ok (cta_res) && (cta_res[1] & 0x01)) { … … 470 462 { 471 463 /* info is displayed in init, or when processing info */ 472 cs_log(" [videoguard12-reader]card detected");473 cs_log(" [videoguard12-reader]type: %s", reader->card_desc);464 cs_log("card detected"); 465 cs_log("type: %s", reader->card_desc); 474 466 read_tiers (reader); 475 467 return OK; 476 468 } 477 469 478 void reader_videoguard12(struct s_cardsystem *ph) 470 void reader_videoguard12(struct s_cardsystem *ph) 479 471 { 480 472 ph->do_emm=videoguard12_do_emm;
Note:
See TracChangeset
for help on using the changeset viewer.