]> www.vanbest.org Git - sasc-ng.git/commitdiff
add TPS testing code
authorleslie <unknown>
Mon, 4 Feb 2008 15:16:52 +0000 (16:16 +0100)
committerleslie <unknown>
Mon, 4 Feb 2008 15:16:52 +0000 (16:16 +0100)
systems/viaccess/tps.c
testing/Makefile
testing/compat.c
testing/testTPS.c [new file with mode: 0644]

index 5ac0acaf7b6544cd41bf942418fac67e3547c2ec..2ea6f41d9b0b941242000d9a131a1d83ecfd4f7e 100644 (file)
@@ -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;
index 06d00ef5f3cd1f3164aaa5b6d4b60bf28a7a46c8..b79e2c60a9c6a11f16780517574bd4504e80ee72 100644 (file)
@@ -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:
index ed9e58d71d1c8fc024dd74da6e1b7009dc1e5cd1..320d647f9f231bb192e7b1caf9afd9b468441f59 100644 (file)
@@ -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 (file)
index 0000000..36e68cf
--- /dev/null
@@ -0,0 +1,91 @@
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#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 <plugin-dir> <decomp-bin>\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;
+}