]> www.vanbest.org Git - sasc-ng.git/commitdiff
nagra-0101: map2a
authoranon <unknown>
Sat, 5 Apr 2008 14:11:17 +0000 (16:11 +0200)
committeranon <unknown>
Sat, 5 Apr 2008 14:11:17 +0000 (16:11 +0200)
systems/nagra/nagra2-0101.c
systems/nagra/nagra2.c
systems/nagra/nagra2.h

index 12be0595864364836ee303a273ae8d120b66271a..f0f51d479d42d9298227335d482a1b548dda619b 100644 (file)
@@ -443,8 +443,15 @@ void cMap0101::DoMap(int f, unsigned char *data, int l)
       if(data) data[0]=b;
       if(b) BN_mask_bits(B,wordsize<<6);
       cycles=501+(8*wordsize+3)/5*5-6;
-      }
       break; 
+      }
+    case 0x2a:
+      {
+      bool b=ModSub(B,B,D);
+      if(data) data[0]=b;
+      BN_zero(C);
+      break;
+      }
     case 0x30:
       BN_sqr(D,B,ctx);
       BN_rshift(C,D,wordsize<<6);
@@ -814,7 +821,7 @@ bool cN2Prov0101::ProcessMap(int f)
       AddCycles(MapCycles());
       break;
     case 0x29:
-      GetMem(HILO(0x44),tmp,dl,0);
+    case 0x2a:
       DoMap(f,tmp);
       Set(0x4b,tmp[0]);
       AddCycles(MapCycles());
index 8edcf3bef6ae8d584a6c7cd5f3b040016cb86b77..38f0bcecc2669bc471fcad2bd7f9c42c7d350bfe 100644 (file)
@@ -255,19 +255,26 @@ cMapMath::cMapMath(void)
   wordsize=DEF_WORDSIZE;
 }
 
-void cMapMath::ModAdd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *d)
+bool cMapMath::ModAdd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *d)
 {
   BN_add(r,a,b);
-  if(BN_cmp(r,d)>=0) BN_sub(r,r,d);
+  bool ret=false;
+  if(BN_cmp(r,d)>=0) {
+    BN_sub(r,r,d);
+    ret=true;
+    }
   BN_mask_bits(r,wordsize<<6);
+  return ret;
 }
 
-void cMapMath::ModSub(BIGNUM *r, BIGNUM *d, BIGNUM *b)
+bool cMapMath::ModSub(BIGNUM *r, BIGNUM *d, BIGNUM *b)
 {
   cBN p;
+  bool ret=BN_cmp(d,b)<0;
   BN_set_bit(p,wordsize<<6);
   BN_mod_sub(r,d,b,p,ctx);
   BN_mask_bits(r,wordsize<<6);
+  return ret;
 }
 
 void cMapMath::MakeJ0(BIGNUM *j, BIGNUM *d, int bits)
index af00a3e0dfaf3198d77d46efdf23fdc95b2a4d03..f1003eac19198fa78f92f4b9597490ad017597c4 100644 (file)
@@ -66,8 +66,8 @@ protected:
   SHA_CTX sctx;
   // stateless
   void MakeJ0(BIGNUM *j, BIGNUM *d, int bits=64);
-  void ModAdd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *d);
-  void ModSub(BIGNUM *r, BIGNUM *d, BIGNUM *b);
+  bool ModAdd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *d);
+  bool ModSub(BIGNUM *r, BIGNUM *d, BIGNUM *b);
   void MonMul(BIGNUM *o, BIGNUM *a, BIGNUM *b, BIGNUM *c, BIGNUM *d, BIGNUM *j, int w);
   void MonStart(int w);
   void MonLoop(BIGNUM *o, BIGNUM *a, BIGNUM *b, BIGNUM *c, BIGNUM *d, BIGNUM *j);