From: leslie Date: Mon, 4 Feb 2008 15:16:52 +0000 (+0100) Subject: add TPS testing code X-Git-Tag: 0.9.0~11 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=53920e7b02b14ec028769632664d06c36a90f80a;p=sasc-ng.git add TPS testing code --- diff --git a/systems/viaccess/tps.c b/systems/viaccess/tps.c index 5ac0aca..2ea6f41 100644 --- a/systems/viaccess/tps.c +++ b/systems/viaccess/tps.c @@ -176,6 +176,8 @@ time_t cTransponderTime::Now(void) // -- cSatTimeHook ------------------------------------------------------------- +#ifndef TESTER + class cSatTimeHook : public cLogHook { private: cTransponderTime *ttime; @@ -214,6 +216,8 @@ void cSatTimeHook::Process(int pid, unsigned char *data) } } +#endif //TESTER + // -- cSatTime ----------------------------------------------------------------- class cSatTime { @@ -282,6 +286,7 @@ private: void Dump(void); public: cOpenTVModule(const unsigned char *data); + cOpenTVModule(int Id, const unsigned char *data, int len); ~cOpenTVModule(); int AddPart(const unsigned char *data, int len); const info_header_t *InfoHdr(void) const { return &info; } @@ -300,6 +305,14 @@ cOpenTVModule::cOpenTVModule(const unsigned char *data) mem=MALLOC(unsigned char,modlen); } +cOpenTVModule::cOpenTVModule(int Id, const unsigned char *data, int len) +{ + id=Id; modlen=received=len; + mem=MALLOC(unsigned char,modlen); + memcpy(mem,data,len); + ParseSections(); +} + cOpenTVModule::~cOpenTVModule() { free(mem); @@ -556,6 +569,8 @@ cString cTpsKey::ToString(bool hide) // -- cTpsAuHook --------------------------------------------------------------- +#ifndef TESTER + #define BUFF_SIZE 20000 class cTpsAuHook : public cLogHook { @@ -568,6 +583,8 @@ public: virtual void Process(int pid, unsigned char *data); }; +#endif //TESTER + // -- cTpsKeys ----------------------------------------------------------------- cTpsKeys tpskeys; @@ -972,6 +989,8 @@ void cTpsKeys::PostSave(FILE *f) // -- cTpsAuHook --------------------------------------------------------------- +#ifndef TESTER + #define AUSID 0x12C0 cTpsAuHook::cTpsAuHook(void) @@ -1048,6 +1067,8 @@ void cTpsAuHook::Process(int pid, unsigned char *data) } } +#endif //TESTER + // -- cTPSDecrypt -------------------------------------------------------------- unsigned char *cTPSDecrypt::mem=0; diff --git a/testing/Makefile b/testing/Makefile index 06d00ef..b79e2c6 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -64,6 +64,10 @@ testN2RunEmu: testN2RunEmu.o $(SHAREDOBJS) $(NOBJS) $(CXX) $(CXXFLAGS) $^ $(LIBS) -L../systems/nagra -lsc-nagra -o $@ @echo "don't forget: export LD_LIBRARY_PATH=../systems/nagra" +testTPS.o: testTPS.c ../systems/viaccess/tps.c ../systems/viaccess/st20.c ../systems/viaccess/viaccess.c +testTPS: testTPS.o $(SHAREDOBJS) $(NOBJS) + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ + filterhelper: filterhelper.o $(CXX) $(CXXFLAGS) $^ -o $@ clean: diff --git a/testing/compat.c b/testing/compat.c index ed9e58d..320d647 100644 --- a/testing/compat.c +++ b/testing/compat.c @@ -163,6 +163,8 @@ bool cScSetup::Ignore(unsigned short caid) { return false; } // void cSoftCAM::SetLogStatus(int CardNum, const cEcmInfo *ecm, bool on) {} +void cSoftCAM::AddHook(int CardNum, cLogHook *hook) {} +bool cSoftCAM::TriggerHook(int CardNum, int id) { return true; } // // diff --git a/testing/testTPS.c b/testing/testTPS.c new file mode 100644 index 0000000..36e68cf --- /dev/null +++ b/testing/testTPS.c @@ -0,0 +1,91 @@ + +#include +#include + +#define TESTER +#include "crypto.h" +#include "data.h" +#include "system-common.h" +#include "compat.h" + +#include "systems/viaccess/viaccess.h" +#include "systems/viaccess/viaccess.c" + +// ---------------------------------------------------------------- + +class cTransponderTime; + +class cSatTimeHook : public cLogHook { +private: +public: + cSatTimeHook(cTransponderTime *Ttime); + ~cSatTimeHook(); + virtual void Process(int pid, unsigned char *data); + }; + +cSatTimeHook::cSatTimeHook(cTransponderTime *Ttime) +:cLogHook(HOOK_SATTIME,"sattime") +{} + +cSatTimeHook::~cSatTimeHook() +{} + +void cSatTimeHook::Process(int pid, unsigned char *data) +{} + +// ---------------------------------------------------------------- + +class cTpsAuHook : public cLogHook { +public: + cTpsAuHook(void); + virtual ~cTpsAuHook(); + virtual void Process(int pid, unsigned char *data); + void DummyProcess(unsigned char *data, int size); + }; + +#include "systems/viaccess/tps.c" +#include "systems/viaccess/st20.c" + +cTpsAuHook::cTpsAuHook(void) +:cLogHook(HOOK_TPSAU,"tpsau") +{} + +cTpsAuHook::~cTpsAuHook() +{} + +void cTpsAuHook::Process(int pid, unsigned char *data) +{ +} + +void cTpsAuHook::DummyProcess(unsigned char *data, int size) +{ + cOpenTVModule mod(2,data,size); + tpskeys.ProcessAu(&mod); +} + +// ---------------------------------------------------------------- + +int main(int argc, char *argv[]) +{ + if(argc<3) { + printf("usage: %s \n",argv[0]); + return 1; + } + + InitAll(argv[1]); + LogAll(); + FILE *f=fopen(argv[2],"r"); + if(f) { + fseek(f,0,SEEK_END); + int size=ftell(f); + fseek(f,0,SEEK_SET); + unsigned char *data=(unsigned char *)malloc(size); + fread(data,1,size,f); + fclose(f); + printf("read %d bytes from %s\n",size,argv[2]); + + cTpsAuHook hook; + hook.DummyProcess(data,size); + } + return 0; +}