SASC-NG
DVBSoftCAM

cIrdeto2 Class Reference

Inheritance diagram for cIrdeto2:

List of all members.

Protected Member Functions

void Encrypt (unsigned char *data, const unsigned char *seed, const unsigned char *key, int len)
void Decrypt (unsigned char *data, const unsigned char *seed, const unsigned char *key, int len)
bool CalculateHash (const unsigned char *key, const unsigned char *iv, const unsigned char *data, int len)

Detailed Description

Definition at line 37 of file irdeto2.c.


Member Function Documentation

bool cIrdeto2::CalculateHash ( const unsigned char *  key,
const unsigned char *  iv,
const unsigned char *  data,
int  len 
) [protected]

Definition at line 90 of file irdeto2.c.

References L_SYS_VERBOSE, LDUMP, and xxor.

Referenced by cSystemIrd2::ProcessECM(), and cSystemIrd2::ProcessEMM().

{
  ScheduleKey(key);
  unsigned char cbuff[8];
  memset(cbuff,0,sizeof(cbuff));
  len-=8;
  for(int y=0; y<len; y+=8) {
    if(y<len-8) {
      xxor(cbuff,8,cbuff,&data[y]);
      LDUMP(L_SYS_VERBOSE,cbuff,8,"3DES XOR in:");
      }
    else {
      int l=len-y;
      xxor(cbuff,l,cbuff,&data[y]);
      xxor(cbuff+l,8-l,cbuff+l,iv+8);
      LDUMP(L_SYS_VERBOSE,cbuff,8,"3DES XOR(%d) in:",8-l);
      }
    DES3(cbuff,0);
    LDUMP(L_SYS_VERBOSE,cbuff,8,"3DES out:");
    }
  LDUMP(L_SYS_VERBOSE,cbuff,8,"CryptBuffer:");
  LDUMP(L_SYS_VERBOSE,&data[len],8,"MACBuffer:");
  return memcmp(cbuff,&data[len],8)==0;
}
void cIrdeto2::Decrypt ( unsigned char *  data,
const unsigned char *  seed,
const unsigned char *  key,
int  len 
) [protected]

Definition at line 76 of file irdeto2.c.

References i, and xxor.

Referenced by cSystemIrd2::ProcessECM(), and cSystemIrd2::ProcessEMM().

{
  ScheduleKey(key);
  len&=~7;
  unsigned char buf[2][8];
  int n=0;
  memcpy(buf[n],seed,8);
  for(int i=0; i<len; i+=8,data+=8,n^=1) {
    memcpy(buf[1-n],data,8);
    DES3(data,1);
    xxor(data,8,data,buf[n]);
    }
}
void cIrdeto2::Encrypt ( unsigned char *  data,
const unsigned char *  seed,
const unsigned char *  key,
int  len 
) [protected]

Definition at line 65 of file irdeto2.c.

References i, and xxor.

{
  ScheduleKey(key);
  len&=~7;
  const unsigned char *tmp=seed;
  for(int i=0; i<len; i+=8) {
    xxor(&data[i],8,&data[i],tmp); tmp=&data[i];
    DES3(&data[i],0);
    }
}

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