From 175af1219a9a071b19b25e958aeec81aedacd7c3 Mon Sep 17 00:00:00 2001 From: anon Date: Sat, 14 Jun 2008 21:23:55 +0800 Subject: [PATCH] nagra-0101: INT map38 --- systems/nagra/nagra2-0101.c | 7 +++++++ systems/nagra/nagra2.c | 18 +++++++++++++----- systems/nagra/nagra2.h | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) 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); -- 2.39.5