SASC
DVBSoftCAM

cTPS Class Reference

#include <tps.h>

Inheritance diagram for cTPS:

List of all members.

Public Member Functions

 cTPS (void)
 ~cTPS ()
int Decrypt (cSystem *sys, int Source, int Transponder, unsigned char *data, int len)
void PostProc (unsigned char *cw)
 cTPS (void)
 ~cTPS ()
int Decrypt (cSystem *sys, int Source, int Transponder, unsigned char *data, int len)
void PostProc (unsigned char *cw)

Detailed Description

Definition at line 56 of file tps.h.


Constructor & Destructor Documentation

cTPS::cTPS ( void  )

Definition at line 1147 of file tps.c.

{
  sattime=0;
}
cTPS::~cTPS ( )

Definition at line 1152 of file tps.c.

{
  delete sattime;
}
cTPS::cTPS ( void  )
cTPS::~cTPS ( )

Member Function Documentation

int cTPS::Decrypt ( cSystem *  sys,
int  Source,
int  Transponder,
unsigned char *  data,
int  len 
)

Definition at line 1157 of file tps.c.

References cTpsKeys::Check(), cTpsKeys::GetKey(), cTpsKeys::GetV2Key(), cTpsKey::Key(), L_SYS_TPS, cTpsKey::Mode(), cSatTime::Now(), cTpsKey::Opmode(), PRINTF, and cTPSDecrypt::TpsDecrypt().

Referenced by cSystemViaccess::ProcessECM().

{
  if(!sattime) {
    sattime=new cSatTime(Source,Transponder);
    if(!sattime) {
      PRINTF(L_SYS_TPS,"failed to create time class");
      return -1;
      }
    }
  time_t now=sattime->Now(sys);
  tpskeys.Check(now,sys);
  if(now<0) return -1;

  const cTpsKey *k=tpskeys.GetKey(now);
  doPost=0;
  int opmode=k?k->Opmode():4, doTPS=0, doPre=0, hasDF=0, ret=0;
  if((opmode&4) && data[0]==0xD2 && data[1]==0x01 && data[2]==0x01) {
    data+=3; len-=3; ret=3;
    if(data[0]==0x90) PRINTF(L_SYS_TPS,"TPS v1 is no longer supported");
    if(data[0]==0x40) data[0]=0x90;
    doTPS=1;
    if(!k) k=tpskeys.GetV2Key(0x7c00);
    }
  for(int i=0; i<len; i+=data[i+1]+2) {
    if(!k && (doTPS || doPre || doPost)) {
      PRINTF(L_SYS_TPS,"no TPS key available for current time of day");
      return -1;
      }
    switch(data[i]) {
      case 0xDF:
        if(!(opmode&4)) doTPS =(0x6996>>((data[i+2]&0xF)^(data[i+2]>>4)))&1;
        if(opmode&8)    doPre =(0x6996>>((data[i+3]&0xF)^(data[i+3]>>4)))&1;
        if(opmode&16)   doPost=(0x6996>>((data[i+4]&0xF)^(data[i+4]>>4)))&1;
        hasDF=1;
        break;
      case 0xEA:
        if(doPre) TpsDecrypt(&data[i+2],k->Mode(0),k->Key(0));
        if(doTPS) TpsDecrypt(&data[i+2],(hasDF)?k->Mode(1):1,k->Key(1));
        if(doPost) { postMode=k->Mode(2); memcpy(postKey,k->Key(2),sizeof(postKey)); }
        break;
      }
    }
  return ret;
}
int cTPS::Decrypt ( cSystem *  sys,
int  Source,
int  Transponder,
unsigned char *  data,
int  len 
)
void cTPS::PostProc ( unsigned char *  cw)
void cTPS::PostProc ( unsigned char *  cw)

Definition at line 1202 of file tps.c.

References cTPSDecrypt::TpsDecrypt().

Referenced by cSystemViaccess::ProcessECM().

{
  if(doPost) TpsDecrypt(cw,postMode,postKey);
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines