Changeset 495


Ignore:
Timestamp:
Nov 5, 2009, 8:49:32 AM (10 years ago)
Author:
dingo35
Message:

Sky Italia fix, many thanks to Sifteam and Pynkyz

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/reader-videoguard2.c

    r479 r495  
    3535
    3636//////  ====================================================================================
     37
     38// SIFTEAM funzione per cambio endianness
     39static 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}
    3753
    3854static inline void __xxor(unsigned char *data, int len, const unsigned char *v1, const unsigned char *v2)
     
    6783static void cCamCryptVG2_Decrypt_D3(unsigned char *ins, unsigned char *data, const unsigned char *status);
    6884static void cCamCryptVG2_PostProcess_Decrypt(unsigned char *buff, int len, unsigned char *cw1, unsigned char *cw2);
    69 static void cCamCryptVG2_SetSeed(const unsigned char *Key1, const unsigned char *Key2);
     85static void cCamCryptVG2_SetSeed(unsigned char *Key1, unsigned char *Key2);
    7086static void cCamCryptVG2_GetCamKey(unsigned char *buff);
    7187
    72 static void cCamCryptVG2_SetSeed(const unsigned char *Key1, const unsigned char *Key2)
    73 {
     88static void cCamCryptVG2_SetSeed(unsigned char *Key1, unsigned char *Key2)
     89{
     90  swap_lb (Key1, 64);
     91  swap_lb (Key2, 64);
    7492  memcpy(cardkeys[1],Key1,sizeof(cardkeys[1]));
    7593  memcpy(cardkeys[2],Key2,sizeof(cardkeys[2]));
     94  swap_lb (Key1, 64);
     95  swap_lb (Key2, 64);
    7696}
    7797
     
    83103  int i;
    84104  for(i=0; i<32; i++) cCamCryptVG2_LongMult(tb2,&c,cardkeys[1][i],0);
     105  swap_lb (buff, 64);
    85106}
    86107
     
    116137  switch(ins[1]) {
    117138    case 0xb4:
     139      swap_lb (data, 64);
    118140      memcpy(cardkeys[0],data,sizeof(cardkeys[0]));
    119141      break;
    120142    case 0xbc:
    121143      {
     144      swap_lb (data, 64);
    122145      unsigned short *idata=(unsigned short *)data;
    123146      const unsigned short *key1=(const unsigned short *)cardkeys[1];
     
    143166      int i;
    144167      for(i=31; i>=0; i--) cCamCryptVG2_LongMult(idata,&idatacount,key1[i],key2[i]);
     168      swap_lb (data, 64);
    145169      unsigned char stateD1[16];
    146170      cCamCryptVG2_Reorder16A(stateD1,data);
     
    411435  cCamCryptVG2_PostProcess_Decrypt(rxbuff,len,CW1,CW2);
    412436
     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
    413443  return len;
    414444}
     
    595625    }
    596626
     627  short int SWIRDstatus = cta_res[1];
    597628  unsigned char ins58[5] = { 0xD0,0x58,0x00,0x00,0x00 };
    598629  l=do_cmd(ins58, NULL, buff);
     
    609640  memset(reader[ridx].prid, 0x00, sizeof(reader[ridx].prid));
    610641
    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[] = {
    613650    0xb9, 0xd5, 0xef, 0xd5, 0xf5, 0xd5, 0xfb, 0xd5, 0x31, 0xd6, 0x43, 0xd6, 0x55, 0xd6, 0x61, 0xd6,
    614651    0x85, 0xd6, 0x9d, 0xd6, 0xaf, 0xd6, 0xc7, 0xd6, 0xd9, 0xd6, 0x09, 0xd7, 0x15, 0xd7, 0x21, 0xd7,
     
    616653    0x29, 0xd8, 0x2f, 0xd8, 0x4d, 0xd8, 0x8f, 0xd8, 0xa1, 0xd8, 0xad, 0xd8, 0xbf, 0xd8, 0xd7, 0xd8
    617654    };
    618   const unsigned char seed2[] = {
     655  unsigned char seed2[] = {
    619656    0x01, 0x00, 0xcf, 0x13, 0xe0, 0x60, 0x54, 0xac, 0xab, 0x99, 0xe6, 0x0c, 0x9f, 0x5b, 0x91, 0xb9,
    620657    0x72, 0x72, 0x4d, 0x5b, 0x5f, 0xd3, 0xb7, 0x5b, 0x01, 0x4d, 0xef, 0x9e, 0x6b, 0x8a, 0xb9, 0xd1,
     
    675712int videoguard_do_ecm(ECM_REQUEST *er)
    676713{
    677   static unsigned char ins40[5] = { 0xD1,0x40,0x40,0x80,0xFF };
     714  static unsigned char ins40[5] = { 0xD1,0x40,0x00,0x80,0xFF };
    678715  static const unsigned char ins54[5] = { 0xD3,0x54,0x00,0x00,0x00};
    679716  int posECMpart2=er->ecm[6]+7;
Note: See TracChangeset for help on using the changeset viewer.