Changeset 495
- Timestamp:
- 11/05/09 08:49:32 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/reader-videoguard2.c
r479 r495 35 35 36 36 ////// ==================================================================================== 37 38 // SIFTEAM funzione per cambio endianness 39 static void swap_lb (unsigned char *buff, int len) 40 { 41 42 #if __BYTE_ORDER != __BIG_ENDIAN 43 return; 44 45 #endif /* */ 46 int i; 47 unsigned short *tmp; 48 for (i = 0; i < len / 2; i++) { 49 tmp = (unsigned short *) buff + i; 50 *tmp = ((*tmp << 8) & 0xff00) | ((*tmp >> 8) & 0x00ff); 51 } 52 } 37 53 38 54 static inline void __xxor(unsigned char *data, int len, const unsigned char *v1, const unsigned char *v2) … … 67 83 static void cCamCryptVG2_Decrypt_D3(unsigned char *ins, unsigned char *data, const unsigned char *status); 68 84 static void cCamCryptVG2_PostProcess_Decrypt(unsigned char *buff, int len, unsigned char *cw1, unsigned char *cw2); 69 static void cCamCryptVG2_SetSeed( const unsigned char *Key1, constunsigned char *Key2);85 static void cCamCryptVG2_SetSeed(unsigned char *Key1, unsigned char *Key2); 70 86 static void cCamCryptVG2_GetCamKey(unsigned char *buff); 71 87 72 static void cCamCryptVG2_SetSeed(const unsigned char *Key1, const unsigned char *Key2) 73 { 88 static void cCamCryptVG2_SetSeed(unsigned char *Key1, unsigned char *Key2) 89 { 90 swap_lb (Key1, 64); 91 swap_lb (Key2, 64); 74 92 memcpy(cardkeys[1],Key1,sizeof(cardkeys[1])); 75 93 memcpy(cardkeys[2],Key2,sizeof(cardkeys[2])); 94 swap_lb (Key1, 64); 95 swap_lb (Key2, 64); 76 96 } 77 97 … … 83 103 int i; 84 104 for(i=0; i<32; i++) cCamCryptVG2_LongMult(tb2,&c,cardkeys[1][i],0); 105 swap_lb (buff, 64); 85 106 } 86 107 … … 116 137 switch(ins[1]) { 117 138 case 0xb4: 139 swap_lb (data, 64); 118 140 memcpy(cardkeys[0],data,sizeof(cardkeys[0])); 119 141 break; 120 142 case 0xbc: 121 143 { 144 swap_lb (data, 64); 122 145 unsigned short *idata=(unsigned short *)data; 123 146 const unsigned short *key1=(const unsigned short *)cardkeys[1]; … … 143 166 int i; 144 167 for(i=31; i>=0; i--) cCamCryptVG2_LongMult(idata,&idatacount,key1[i],key2[i]); 168 swap_lb (data, 64); 145 169 unsigned char stateD1[16]; 146 170 cCamCryptVG2_Reorder16A(stateD1,data); … … 411 435 cCamCryptVG2_PostProcess_Decrypt(rxbuff,len,CW1,CW2); 412 436 437 // Log decrypted INS54 438 if (rxbuff[1] == 0x54) { 439 cs_dump (rxbuff, 5, "Decrypted INS54:"); 440 cs_dump (rxbuff + 5, rxbuff[4], ""); 441 } 442 413 443 return len; 414 444 } … … 595 625 } 596 626 627 short int SWIRDstatus = cta_res[1]; 597 628 unsigned char ins58[5] = { 0xD0,0x58,0x00,0x00,0x00 }; 598 629 l=do_cmd(ins58, NULL, buff); … … 609 640 memset(reader[ridx].prid, 0x00, sizeof(reader[ridx].prid)); 610 641 611 612 const unsigned char seed1[] = { 642 /* 643 cs_log ("INS58 : Fuse byte=0x%02X, IRDStatus=0x%02X", cta_res[2],SWIRDstatus); 644 if (SWIRDstatus==4) { 645 // If swMarriage=4, not married then exchange for BC Key 646 cs_log ("Card not married, exchange for BC Keys"); 647 */ 648 649 unsigned char seed1[] = { 613 650 0xb9, 0xd5, 0xef, 0xd5, 0xf5, 0xd5, 0xfb, 0xd5, 0x31, 0xd6, 0x43, 0xd6, 0x55, 0xd6, 0x61, 0xd6, 614 651 0x85, 0xd6, 0x9d, 0xd6, 0xaf, 0xd6, 0xc7, 0xd6, 0xd9, 0xd6, 0x09, 0xd7, 0x15, 0xd7, 0x21, 0xd7, … … 616 653 0x29, 0xd8, 0x2f, 0xd8, 0x4d, 0xd8, 0x8f, 0xd8, 0xa1, 0xd8, 0xad, 0xd8, 0xbf, 0xd8, 0xd7, 0xd8 617 654 }; 618 constunsigned char seed2[] = {655 unsigned char seed2[] = { 619 656 0x01, 0x00, 0xcf, 0x13, 0xe0, 0x60, 0x54, 0xac, 0xab, 0x99, 0xe6, 0x0c, 0x9f, 0x5b, 0x91, 0xb9, 620 657 0x72, 0x72, 0x4d, 0x5b, 0x5f, 0xd3, 0xb7, 0x5b, 0x01, 0x4d, 0xef, 0x9e, 0x6b, 0x8a, 0xb9, 0xd1, … … 675 712 int videoguard_do_ecm(ECM_REQUEST *er) 676 713 { 677 static unsigned char ins40[5] = { 0xD1,0x40,0x 40,0x80,0xFF };714 static unsigned char ins40[5] = { 0xD1,0x40,0x00,0x80,0xFF }; 678 715 static const unsigned char ins54[5] = { 0xD3,0x54,0x00,0x00,0x00}; 679 716 int posECMpart2=er->ecm[6]+7;
Note:
See TracChangeset
for help on using the changeset viewer.