|
SASC-NG
DVBSoftCAM
|
#include <nagra2.h>
Inheritance diagram for cN2Prov:Public Member Functions | |
| cN2Prov (int Id, int Flags) | |
| virtual | ~cN2Prov () |
| bool | MECM (unsigned char in15, int algo, const unsigned char *ed, unsigned char *cw) |
| void | SwapCW (unsigned char *cw) |
| virtual int | ProcessBx (unsigned char *data, int len, int pos) |
| virtual int | ProcessEx (unsigned char *data, int len, int pos) |
| virtual bool | PostProcAU (int id, unsigned char *data) |
| virtual int | RunEmu (unsigned char *data, int len, unsigned short load, unsigned short run, unsigned short stop, unsigned short fetch, int fetch_len) |
| virtual void | PostDecrypt (bool ecm) |
| bool | CanHandle (int Id) |
| bool | HasFlags (int Flags) |
| void | PrintCaps (int c) |
Protected Member Functions | |
| virtual bool | Algo (int algo, const unsigned char *hd, unsigned char *hw) |
| virtual void | DynamicHD (unsigned char *hd, const unsigned char *ed) |
| virtual bool | NeedsCwSwap (void) |
| void | ExpandInput (unsigned char *hw) |
Protected Attributes | |
| int | id |
| int | flags |
| int | seedSize |
| cIDEA | idea |
| cN2Prov::cN2Prov | ( | int | Id, |
| int | Flags | ||
| ) |
| virtual bool cN2Prov::Algo | ( | int | algo, |
| const unsigned char * | hd, | ||
| unsigned char * | hw | ||
| ) | [inline, protected, virtual] |
Reimplemented in cN2Prov0101, and cN2Prov0501.
Definition at line 297 of file nagra2.h.
Referenced by MECM().
{ return false; }
| bool cN2Prov::CanHandle | ( | int | Id | ) | [inline] |
Definition at line 311 of file nagra2.h.
References MATCH_ID.
Referenced by Emm(), cSystemNagra2::ProcessECM(), and cSystemNagra2::ProcessEMM().
{ return MATCH_ID(Id,id); }
| virtual void cN2Prov::DynamicHD | ( | unsigned char * | hd, |
| const unsigned char * | ed | ||
| ) | [inline, protected, virtual] |
| void cN2Prov::ExpandInput | ( | unsigned char * | hw | ) | [protected] |
Definition at line 1035 of file nagra2.c.
References cIDEA::Encrypt(), i, idea, cIDEA::SetEncKey(), and xxor.
Referenced by cN2Prov0501::Algo(), and cN2Prov0101::Algo().
{
hw[0]^=(0xDE +(0xDE<<1)) & 0xFF;
hw[1]^=(hw[0]+(0xDE<<1)) & 0xFF;
for(int i=2; i<128; i++) hw[i]^=hw[i-2]+hw[i-1];
IdeaKS ks;
idea.SetEncKey((unsigned char *)"NagraVision S.A.",&ks);
unsigned char buf[8];
memset(buf,0,8);
for(int i=0; i<128; i+=8) {
xxor(buf,8,buf,&hw[i]);
idea.Encrypt(buf,8,buf,&ks,0);
xxor(buf,8,buf,&hw[i]);
memcpy(&hw[i],buf,8);
}
}
| bool cN2Prov::HasFlags | ( | int | Flags | ) | [inline] |
Definition at line 312 of file nagra2.h.
References flags.
Referenced by Ecm(), Emm(), PrintCaps(), cSystemNagra2::ProcessECM(), and cSystemNagra2::ProcessEMM().
{ return (flags&Flags)==Flags; }
| bool cN2Prov::MECM | ( | unsigned char | in15, |
| int | algo, | ||
| const unsigned char * | ed, | ||
| unsigned char * | cw | ||
| ) |
Definition at line 1052 of file nagra2.c.
References Algo(), DynamicHD(), cIDEA::Encrypt(), i, idea, RotateBytes(), seedSize, and cIDEA::SetEncKey().
Referenced by Ecm(), and cSystemNagra2::ProcessECM().
{
unsigned char hd[32], hw[128+64], buf[20];
hd[0]=in15&0x7F;
hd[1]=cw[14];
hd[2]=cw[15];
hd[3]=cw[6];
hd[4]=cw[7];
DynamicHD(hd,ed);
if(keyValid && !memcmp(seed,hd,seedSize)) { // key cached
memcpy(buf,cwkey,8);
}
else { // key not cached
memset(hw,0,sizeof(hw));
if(!Algo(algo,hd,hw)) return false;
memcpy(&hw[128],hw,64);
RotateBytes(&hw[64],128);
SHA1(&hw[64],128,buf);
RotateBytes(buf,20);
memcpy(seed,hd,seedSize);
memcpy(cwkey,buf,8);
keyValid=true;
}
memcpy(&buf[8],buf,8);
IdeaKS ks;
idea.SetEncKey(buf,&ks);
memcpy(&buf[0],&cw[8],6);
memcpy(&buf[6],&cw[0],6);
idea.Encrypt(&buf[4],8,&buf[4],&ks,0);
idea.Encrypt(buf,8,buf,&ks,0);
memcpy(&cw[ 0],&buf[6],3);
memcpy(&cw[ 4],&buf[9],3);
memcpy(&cw[ 8],&buf[0],3);
memcpy(&cw[12],&buf[3],3);
for(int i=0; i<16; i+=4) cw[i+3]=cw[i]+cw[i+1]+cw[i+2];
return true;
}
| virtual bool cN2Prov::NeedsCwSwap | ( | void | ) | [inline, protected, virtual] |
Reimplemented in cN2Prov0501.
Definition at line 299 of file nagra2.h.
Referenced by SwapCW().
{ return false; }
| virtual void cN2Prov::PostDecrypt | ( | bool | ecm | ) | [inline, virtual] |
Reimplemented in cN2Prov0101, and cN2Prov0501.
Definition at line 310 of file nagra2.h.
Referenced by Ecm(), Emm(), cSystemNagra2::ProcessECM(), and cSystemNagra2::ProcessEMM().
{}
| virtual bool cN2Prov::PostProcAU | ( | int | id, |
| unsigned char * | data | ||
| ) | [inline, virtual] |
Reimplemented in cN2Prov0101, and cN2Prov4101.
Definition at line 308 of file nagra2.h.
Referenced by Emm(), and cSystemNagra2::ProcessEMM().
{ return true; }
| void cN2Prov::PrintCaps | ( | int | c | ) |
Definition at line 1025 of file nagra2.c.
References HasFlags(), N2FLAG_Bx, N2FLAG_Ex, N2FLAG_INV, N2FLAG_MECM, N2FLAG_POSTAU, and PRINTF.
Referenced by Ecm(), Emm(), cSystemNagra2::ProcessECM(), and cSystemNagra2::ProcessEMM().
{
PRINTF(c,"provider %04x capabilities%s%s%s%s%s",id,
HasFlags(N2FLAG_MECM) ?" MECM":"",
HasFlags(N2FLAG_Bx) ?" Bx":"",
HasFlags(N2FLAG_Ex) ?" Ex":"",
HasFlags(N2FLAG_POSTAU) ?" POSTPROCAU":"",
HasFlags(N2FLAG_INV) ?" INVCW":"");
}
| virtual int cN2Prov::ProcessBx | ( | unsigned char * | data, |
| int | len, | ||
| int | pos | ||
| ) | [inline, virtual] |
Reimplemented in cN2Prov0101, cN2Prov0501, and cN2Prov4101.
Definition at line 306 of file nagra2.h.
Referenced by Emm(), and cSystemNagra2::ProcessEMM().
{ return -1; }
| virtual int cN2Prov::ProcessEx | ( | unsigned char * | data, |
| int | len, | ||
| int | pos | ||
| ) | [inline, virtual] |
Reimplemented in cN2Prov0101.
Definition at line 307 of file nagra2.h.
Referenced by Emm(), and cSystemNagra2::ProcessEMM().
{ return -1; }
| virtual int cN2Prov::RunEmu | ( | unsigned char * | data, |
| int | len, | ||
| unsigned short | load, | ||
| unsigned short | run, | ||
| unsigned short | stop, | ||
| unsigned short | fetch, | ||
| int | fetch_len | ||
| ) | [inline, virtual] |
Reimplemented in cN2Prov0101, and cN2Prov0501.
Definition at line 309 of file nagra2.h.
Referenced by main().
{ return -1; }
| void cN2Prov::SwapCW | ( | unsigned char * | cw | ) |
Definition at line 1094 of file nagra2.c.
References NeedsCwSwap().
Referenced by Ecm(), and cSystemNagra2::ProcessECM().
{
if(NeedsCwSwap()) {
unsigned char tt[8];
memcpy(&tt[0],&cw[0],8);
memcpy(&cw[0],&cw[8],8);
memcpy(&cw[8],&tt[0],8);
}
}
int cN2Prov::flags [protected] |
Definition at line 294 of file nagra2.h.
Referenced by cN2Prov(), and HasFlags().
int cN2Prov::id [protected] |
cIDEA cN2Prov::idea [protected] |
Definition at line 295 of file nagra2.h.
Referenced by cN2Prov0101::Algo(), ExpandInput(), and MECM().
int cN2Prov::seedSize [protected] |
Definition at line 294 of file nagra2.h.
Referenced by cN2Prov0101::Algo(), cN2Prov(), cN2Prov0101::cN2Prov0101(), and MECM().