]> www.vanbest.org Git - sasc-ng.git/commitdiff
cryptoworks: bunghole's min ECM time patch
authorleslie <unknown>
Sat, 5 May 2012 14:45:28 +0000 (16:45 +0200)
committerleslie <unknown>
Sat, 5 May 2012 14:45:28 +0000 (16:45 +0200)
systems/cryptoworks/cryptoworks.c

index c8a2b0ca343f1c993ebd6dc4225602017c8a9da2..1cbdba8cc8adac1a74bc0f221950ee1bf4e48478 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "system-common.h"
 #include "data.h"
+#include "opts.h"
 #include "helper.h"
 #include "crypto.h"
 #include "misc.h"
@@ -63,6 +64,8 @@ ADD_MODULE(L_SYS,lm_sys)
     } \
   LBEND();
 
+int minEcmTime=150; // ms
+
 // -- cCwDes -------------------------------------------------------------------
 
 static const unsigned char cryptoPC1[] = {
@@ -422,6 +425,7 @@ cSystemCryptoworks::cSystemCryptoworks(void)
 
 bool cSystemCryptoworks::ProcessECM(const cEcmInfo *ecmInfo, unsigned char *data)
 {
+  cTimeMs minTime;
   int len=SCT_LEN(data);
   if(data[ECM_NANO_LEN]!=len-ECM_NANO_START) {
     PRINTF(L_SYS_ECM,"invalid ECM structure");
@@ -521,6 +525,8 @@ bool cSystemCryptoworks::ProcessECM(const cEcmInfo *ecmInfo, unsigned char *data
           memcpy(cw,&data[i+2],16);
           LDUMP(L_SYS_VERBOSE,cw,16,"cw:");
           ks.OK(pk);
+          int i=minEcmTime-minTime.Elapsed();
+          if(i>0) cCondWait::SleepMs(i);
           return true;
           }
         break;
@@ -550,6 +556,8 @@ static cSystemLinkCryptoworks staticInit;
 cSystemLinkCryptoworks::cSystemLinkCryptoworks(void)
 :cSystemLink(SYSTEM_NAME,SYSTEM_PRI)
 {
+  opts=new cOpts(SYSTEM_NAME,1);
+  opts->Add(new cOptInt("MinEcmTime",trNOOP("Cryptoworks: min. ECM processing time"),&minEcmTime,0,5000));
   Feature.NeedsKeyFile();
 }