|
SASC-NG
DVBSoftCAM
|
Inheritance diagram for cSeca2Prov:Public Member Functions | |
| cSeca2Prov (unsigned short Id) | |
| virtual | ~cSeca2Prov () |
| virtual void | PreSSE (unsigned char *data, int pos) |
| virtual void | PostSSE (unsigned char *data, int pos) |
| virtual void | SignatureMod (unsigned char *MD, const unsigned char *PK) |
| virtual void | PreCW (unsigned char *data) |
| virtual void | PostCW (unsigned char *data) |
| virtual void | ChainTableXor (unsigned char *data, unsigned short index)=0 |
| virtual bool | DoSigCheck (void) |
| virtual bool | Init (void) |
| void | CalcSHASignature (const unsigned char *data, int n, unsigned char *signature, bool PadMode=true) |
| bool | DecryptSE (unsigned char *data, const unsigned char *key, int n, int start, const unsigned char *T1, const unsigned char *T2) |
| bool | Matches (unsigned short Id) const |
| const unsigned char * | T1 (int index) const |
| const unsigned char * | T2 (int index) const |
| struct Perm * | P (int index) const |
| const unsigned char * | MT (void) const |
| int | MTSize (void) const |
| const unsigned char * | FP (void) const |
Protected Member Functions | |
| cFileMap * | GetMap (const char *type, int size, bool generic) const |
Protected Attributes | |
| struct ProvData * | pData |
| struct Perm * | perm |
| cSeca2Prov::cSeca2Prov | ( | unsigned short | Id | ) |
| cSeca2Prov::~cSeca2Prov | ( | ) | [virtual] |
| void cSeca2Prov::CalcSHASignature | ( | const unsigned char * | data, |
| int | n, | ||
| unsigned char * | signature, | ||
| bool | PadMode = true |
||
| ) |
Definition at line 550 of file seca.c.
References pData, ProvData::SHA1End, and ProvData::SHA1Pad.
Referenced by cSeca2ProvSSE::PostSSE(), cSystemSeca::ProcessECM(), and cSystemSeca::ProcessEMM().
{
SHA_CTX ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx,data,n);
unsigned char Pad=0;
if(PadMode) {
unsigned char End=pData->SHA1End;
SHA1_Update(&ctx,&End,1);
int l=(n&63)+1;
Pad=pData->SHA1Pad;
if(l>62) {
for(; l<64; l++) SHA1_Update(&ctx,&Pad,1);
l=0;
}
for(; l<62; l++) SHA1_Update(&ctx,&Pad,1);
unsigned short s=bswap_16(n);
SHA1_Update(&ctx,&s,2);
}
else for(; n&63; n++) SHA1_Update(&ctx,&Pad,1);
*((unsigned int *)(signature ))=bswap_32(ctx.h0);
*((unsigned int *)(signature+ 4))=bswap_32(ctx.h1);
*((unsigned int *)(signature+ 8))=bswap_32(ctx.h2);
*((unsigned int *)(signature+12))=bswap_32(ctx.h3);
*((unsigned int *)(signature+16))=bswap_32(ctx.h4);
}
| virtual void cSeca2Prov::ChainTableXor | ( | unsigned char * | data, |
| unsigned short | index | ||
| ) | [pure virtual] |
Implemented in cSeca2ProvFR, cSeca2ProvNL, cSeca2ProvPL, and cSeca2ProvSPA.
Referenced by DecryptSE().
| bool cSeca2Prov::DecryptSE | ( | unsigned char * | data, |
| const unsigned char * | key, | ||
| int | n, | ||
| int | start, | ||
| const unsigned char * | T1, | ||
| const unsigned char * | T2 | ||
| ) |
Definition at line 516 of file seca.c.
References ChainTableXor(), cSeca::Decrypt(), and i.
Referenced by cSystemSeca::ProcessECM(), and cSystemSeca::ProcessEMM().
{
const int sigStart=n-data[n-1]-9; // 82 <8 bytes> P5(sigStart)
const int encrLen=sigStart-16;
#ifdef DEBUG_SECA_EXTRA
if(encrLen>=n || encrLen<0) printf("encrLen error in SE\n");
if(sigStart<16) printf("sigStart error in SE\n");
#endif
if(encrLen>=n || encrLen<0 || sigStart<16) return false;
Decrypt(data+sigStart-8,key,T1,T2);
ChainTableXor(data+sigStart-8,Sum(data+start,sigStart-8-start));
int i;
for(i=start; i<encrLen; i+=8) {
Decrypt(data+i,key,T1,T2);
ChainTableXor(data+i,Sum(&data[i+8],8));
}
int restBytes=sigStart&0x07;
if(!restBytes) restBytes=8;
// Last Block
unsigned char lastBlock[8];
memset(lastBlock,0,sizeof(lastBlock));
memcpy(lastBlock,data+sigStart-restBytes,restBytes);
Decrypt(lastBlock,key,T1,T2);
Decrypt(data+i,key,T1,T2);
ChainTableXor(data+i,Sum(lastBlock,sizeof(lastBlock)));
return true;
}
| virtual bool cSeca2Prov::DoSigCheck | ( | void | ) | [inline, virtual] |
Reimplemented in cSeca2ProvNL.
Definition at line 417 of file seca.c.
Referenced by cSystemSeca::ProcessECM().
{ return true; }
| const unsigned char* cSeca2Prov::FP | ( | void | ) | const [inline] |
| cFileMap * cSeca2Prov::GetMap | ( | const char * | type, |
| int | size, | ||
| bool | generic | ||
| ) | const [protected] |
Definition at line 452 of file seca.c.
References FILEMAP_DOMAIN, filemaps, cFileMaps::GetFileMap(), L_SYS_CRYPTO, ProvData::LoadId, cFileMap::Map(), pData, PRINTF, cFileMap::Size(), and cFileMap::Unmap().
Referenced by Init(), cSeca2ProvNL::InitSSE(), and cSeca2ProvFR::InitSSE().
{
char name[32];
snprintf(name,sizeof(name),generic ? "s2_%s.bin" : "s2_%s_%04x.bin",type,pData->LoadId);
cFileMap *map=filemaps.GetFileMap(name,FILEMAP_DOMAIN,false);
if(!map)
PRINTF(L_SYS_CRYPTO,"no filemap for %s",name);
else if(!map->Map()) {
PRINTF(L_SYS_CRYPTO,"mapping failed for %s",name);
map=0;
}
else if(map->Size()<size) {
PRINTF(L_SYS_CRYPTO,"%s file %s has wrong size (has=%d wanted=%d)",type,name,map->Size(),size);
map->Unmap();
map=0;
}
return map;
}
| bool cSeca2Prov::Init | ( | void | ) | [virtual] |
Reimplemented in cSeca2ProvSSE.
Definition at line 444 of file seca.c.
References GetMap(), hash, ProvData::MTLoadSize, and pData.
Referenced by cSeca2Providers::GetProv().
| bool cSeca2Prov::Matches | ( | unsigned short | Id | ) | const [inline] |
| const unsigned char* cSeca2Prov::MT | ( | void | ) | const [inline] |
Definition at line 427 of file seca.c.
References cFileMap::Addr().
Referenced by cSeca2ProvSPA::ChainTableXor(), cSeca2ProvPL::ChainTableXor(), cSeca2ProvNL::ChainTableXor(), and cSeca2ProvFR::ChainTableXor().
{ return mask->Addr(); }
| int cSeca2Prov::MTSize | ( | void | ) | const [inline] |
| struct Perm * cSeca2Prov::P | ( | int | index | ) | const [read] |
| virtual void cSeca2Prov::PostCW | ( | unsigned char * | data | ) | [inline, virtual] |
Reimplemented in cSeca2ProvFR, and cSeca2ProvNL.
Definition at line 415 of file seca.c.
Referenced by cSystemSeca::ProcessECM().
{}
| virtual void cSeca2Prov::PostSSE | ( | unsigned char * | data, |
| int | pos | ||
| ) | [inline, virtual] |
Reimplemented in cSeca2ProvSSE.
Definition at line 412 of file seca.c.
Referenced by cSystemSeca::ProcessECM().
{}
| virtual void cSeca2Prov::PreCW | ( | unsigned char * | data | ) | [inline, virtual] |
Reimplemented in cSeca2ProvPL.
Definition at line 414 of file seca.c.
Referenced by cSystemSeca::ProcessECM().
{}
| virtual void cSeca2Prov::PreSSE | ( | unsigned char * | data, |
| int | pos | ||
| ) | [inline, virtual] |
Reimplemented in cSeca2ProvSSE.
Definition at line 411 of file seca.c.
Referenced by cSystemSeca::ProcessECM().
{}
| virtual void cSeca2Prov::SignatureMod | ( | unsigned char * | MD, |
| const unsigned char * | PK | ||
| ) | [inline, virtual] |
Reimplemented in cSeca2ProvFR.
Definition at line 413 of file seca.c.
Referenced by cSystemSeca::ProcessECM().
{}
| const unsigned char * cSeca2Prov::T1 | ( | int | index | ) | const |
Definition at line 479 of file seca.c.
References hash, L_SYS_CRYPTO, and PRINTF.
Referenced by cSystemSeca::ProcessECM(), and cSystemSeca::ProcessEMM().
{
static int idxTrans[] = { 0,1,2,2 };
if(index>=0 && index<=3) {
return hash->Addr()+(idxTrans[index]*256);
}
PRINTF(L_SYS_CRYPTO,"bad T1 table index %d",index);
return 0;
}
| const unsigned char * cSeca2Prov::T2 | ( | int | index | ) | const |
Definition at line 489 of file seca.c.
References hash, L_SYS_CRYPTO, and PRINTF.
Referenced by cSystemSeca::ProcessECM(), and cSystemSeca::ProcessEMM().
{
static int idxTrans[] = { 0,1,2,2 };
if(index>=0 && index<=3) {
return hash->Addr()+(idxTrans[index]*256)+768;
}
PRINTF(L_SYS_CRYPTO,"bad T2 table index %d",index);
return 0;
}
struct ProvData* cSeca2Prov::pData [protected] |
Definition at line 403 of file seca.c.
Referenced by CalcSHASignature(), cSeca2Prov(), cSeca2ProvFR::cSeca2ProvFR(), cSeca2ProvNL::cSeca2ProvNL(), cSeca2ProvPL::cSeca2ProvPL(), cSeca2ProvSPA::cSeca2ProvSPA(), FP(), GetMap(), Init(), and MTSize().
struct Perm* cSeca2Prov::perm [protected] |
Definition at line 404 of file seca.c.
Referenced by cSeca2Prov(), cSeca2ProvPL::cSeca2ProvPL(), cSeca2ProvSPA::cSeca2ProvSPA(), and P().