SASC-NG
DVBSoftCAM

cCmd0cCrypt Class Reference

List of all members.

Public Member Functions

 cCmd0cCrypt (void)
void Reset (void)
void SetMode (int m)
void SetKey (const unsigned char *key, int l)
void Decrypt (const unsigned char *in, int len, unsigned char *out)

Detailed Description

Definition at line 174 of file cccam2.c.


Constructor & Destructor Documentation

cCmd0cCrypt::cCmd0cCrypt ( void  )

Definition at line 190 of file cccam2.c.

References Reset().

{
  Reset();
}

Member Function Documentation

void cCmd0cCrypt::Decrypt ( const unsigned char *  in,
int  len,
unsigned char *  out 
)

Definition at line 232 of file cccam2.c.

References CMD0C_MODE_AES, CMD0C_MODE_CC, CMD0C_MODE_IDEA, CMD0C_MODE_PLAIN, CMD0C_MODE_RC4, CMD0C_MODE_RC6, cAES::Decrypt(), cCCcamCrypt::Decrypt(), cRC6::Decrypt(), cIDEA::EcbEncrypt(), cCCcamCrypt::Encrypt(), i, and j.

{
  switch(mode) {
    case CMD0C_MODE_PLAIN:
      memcpy(out,in,len);
      break;
    case CMD0C_MODE_RC6:
      for(int i=0; i<(len&~15); i+=16) rc6.Decrypt(in+i,out+i);
      break;
    case CMD0C_MODE_RC4:
      cc.Encrypt(in,out,len);
      break;
    case CMD0C_MODE_CC:
      cc.Decrypt(in,out,len);
      break;
    case CMD0C_MODE_AES:
      aes.Decrypt(in,len,out);
      break;
    case CMD0C_MODE_IDEA:
      idea.EcbEncrypt(in,len,out,&ks);
      for(int i=8; i<len; i+=8)
        for(int j=0; j<8; j++)
          out[j+i]^=in[j+i-8];
      break;
    }
}
void cCmd0cCrypt::Reset ( void  )

Definition at line 195 of file cccam2.c.

References CMD0C_MODE_PLAIN, L_CC_CCCAM2EX, and PRINTF.

Referenced by cCmd0cCrypt(), and cCardClientCCcam2::Logout().

{
  mode=CMD0C_MODE_PLAIN;
  PRINTF(L_CC_CCCAM2EX,"cmd 0c crypt mode now %d",mode);
}
void cCmd0cCrypt::SetKey ( const unsigned char *  key,
int  l 
)

Definition at line 207 of file cccam2.c.

References CMD0C_MODE_AES, CMD0C_MODE_CC, CMD0C_MODE_IDEA, CMD0C_MODE_PLAIN, CMD0C_MODE_RC4, CMD0C_MODE_RC6, cCCcamCrypt::Init(), cIDEA::SetDecKey(), cAES::SetKey(), and cRC6::SetKey().

{
  unsigned char buff[32];
  memset(buff,0,sizeof(buff));
  if(l>32) l=32;
  memcpy(buff,key,l);
  switch(mode) {
    case CMD0C_MODE_PLAIN:
      break;
    case CMD0C_MODE_RC6:
      rc6.SetKey(buff,32);
      break;
    case CMD0C_MODE_RC4:
    case CMD0C_MODE_CC:
      cc.Init(buff,32,true);
      break;
    case CMD0C_MODE_AES:
      aes.SetKey(buff);
      break;
    case CMD0C_MODE_IDEA:
      idea.SetDecKey(buff,&ks);
      break;
    }
}
void cCmd0cCrypt::SetMode ( int  m)

Definition at line 201 of file cccam2.c.

References L_CC_CCCAM2EX, and PRINTF.

{
  mode=m;
  PRINTF(L_CC_CCCAM2EX,"cmd 0c crypt mode now %d",mode);
}

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