From: anon Date: Sat, 14 Jun 2008 13:23:55 +0000 (+0800) Subject: nagra-0101: INT map38 X-Git-Tag: 0.9.1~62 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=175af1219a9a071b19b25e958aeec81aedacd7c3;p=sasc-ng.git nagra-0101: INT map38 --- diff --git a/systems/nagra/nagra2-0101.c b/systems/nagra/nagra2-0101.c index 670b593..0ae84ce 100644 --- a/systems/nagra/nagra2-0101.c +++ b/systems/nagra/nagra2-0101.c @@ -222,6 +222,12 @@ bool cMap0101::Map(int f, unsigned char *data, int l) } BN_zero(J); break; + case 0x38: + AddMapCycles(232); + MonMul0(B,B,B,C,D,J,wordsize); + AddMapCycles(90); + MonFin(B,D); + break; case 0x3b: MonInit(wordsize*60+4*l); I.GetLE(data,l<<3); @@ -607,6 +613,7 @@ bool cN2Prov0101::ProcessMap(int f) case 0x21: case 0x30: case 0x31: + case 0x38: case 0x3a: case 0x43: DoMap(f); diff --git a/systems/nagra/nagra2.c b/systems/nagra/nagra2.c index e68e6d0..ba4f79e 100644 --- a/systems/nagra/nagra2.c +++ b/systems/nagra/nagra2.c @@ -422,6 +422,12 @@ void cMapMath::MonMul(BIGNUM *o, BIGNUM *a, BIGNUM *b, int w) } void cMapMath::MonMul(BIGNUM *o, BIGNUM *a, BIGNUM *b, BIGNUM *c, BIGNUM *d, BIGNUM *j, int w) +{ + MonMul0(o,a,b,c,d,j,w); + MonFin(o,d); +} + +void cMapMath::MonMul0(BIGNUM *o, BIGNUM *a, BIGNUM *b, BIGNUM *c, BIGNUM *d, BIGNUM *j, int w) { if(!w) w=wordsize; MonStart(w); @@ -472,14 +478,16 @@ void cMapMath::MonLoop(BIGNUM *o, BIGNUM *a, BIGNUM *b, BIGNUM *c, BIGNUM *d, BI } BN_rshift(s,s,64); - if(BN_cmp(s,d)==1) { - BN_copy(x,s); - BN_sub(s,x,d); - } - + if(words) MonFin(s,d); if(!words) BN_copy(o,s); } +void cMapMath::MonFin(BIGNUM *s, BIGNUM *d) +{ + if(BN_cmp(s,d)>=0) + BN_sub(s,s,d); +} + // -- cMapCore ----------------------------------------------------------------- cMapCore::cMapCore(void) diff --git a/systems/nagra/nagra2.h b/systems/nagra/nagra2.h index 673605d..e58db97 100644 --- a/systems/nagra/nagra2.h +++ b/systems/nagra/nagra2.h @@ -99,8 +99,10 @@ protected: 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 MonMul0(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); + void MonFin(BIGNUM *s, BIGNUM *d); // statefull void MonMul(BIGNUM *o, BIGNUM *a, BIGNUM *b); void MonMul(BIGNUM *o, BIGNUM *a, BIGNUM *b, int w);