From: anon Date: Thu, 14 Aug 2008 13:35:22 +0000 (+0800) Subject: viaccess: loading TPS ST20 algo from tps.bin X-Git-Tag: 0.9.1~34 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=9223273293514dfef485661da286786a8c5c06d1;p=sasc-ng.git viaccess: loading TPS ST20 algo from tps.bin --- diff --git a/systems/viaccess/tps.c b/systems/viaccess/tps.c index 5e812b6..2f47747 100644 --- a/systems/viaccess/tps.c +++ b/systems/viaccess/tps.c @@ -877,16 +877,24 @@ bool cTpsKeys::LoadBin(void) PRINTF(L_SYS_TPS,"mapping failed for "TPSBIN); return false; } - else if(tpsbin->Size()<65536 || memcmp(mark,tpsbin->Addr()+32,sizeof(mark)) || memcmp(mark,tpsbin->Addr()+48,sizeof(mark))) { + const unsigned char *a=tpsbin->Addr(); + int len=tpsbin->Size(); + if(len<(68+56) || memcmp(mark,a+32,sizeof(mark)) || memcmp(mark,a+48,sizeof(mark))) { PRINTF(L_SYS_TPS,TPSBIN" format not recognised"); tpsbin->Unmap(); return false; } - int size=tpsbin->Size()-56; + int size=*((const unsigned int *)(a+64)); + a+=68; len-=68; + if(lenUnmap(); + return false; + } + cSimpleList *nlist=new cSimpleList; - for(int i=68; iAddr()+i; + for(int i=0; iSet(tmp); nlist->Add(k); } } - tpsbin->Unmap(); PRINTF(L_SYS_TPSAU,"loaded %d keys from "TPSBIN" file",nlist->Count()); Join(nlist); + + static const unsigned char alg_mark[] = { 'A','L','G','3' }; + while(len>64) { + if(!memcmp(alg_mark,a,sizeof(alg_mark)) && *(a+11)==0x02) { + size=*((const unsigned short *)(a+6)); + if(lenAddr()+64; + int cb1=*((const unsigned short *)(a+18))-off; + int cb2=*((const unsigned short *)(a+30))-off; + int cb3=*((const unsigned short *)(a+42))-off; + PRINTF(L_SYS_TPSAU,"algo pointers in "TPSBIN" off=%04x cb1=%04x cb2=%04x cb3=%04x size=%04x",off,cb1,cb2,cb3,size); + RegisterAlgo3(a+64,cb1,cb2,cb3,size); + break; + } + a+=4; len-=4; + } + + tpsbin->Unmap(); return true; } @@ -1234,8 +1262,8 @@ int cTPS::Decrypt(int cardNum, int Source, int Transponder, unsigned char *data, break; case 0xEA: if(doPre) TpsDecrypt(&data[i+2],k->Mode(0),k->Key(0)); - if(doTPS) TpsDecrypt(&data[i+2],(hasDF)?k->Mode(2):1,k->Key(2)); - if(doPost) { postMode=k->Mode(1); memcpy(postKey,k->Key(1),sizeof(postKey)); } + if(doTPS) TpsDecrypt(&data[i+2],(hasDF)?k->Mode(1):1,k->Key(1)); + if(doPost) { postMode=k->Mode(2); memcpy(postKey,k->Key(2),sizeof(postKey)); } break; } }