From: anon Date: Fri, 13 Jun 2008 00:42:58 +0000 (+0800) Subject: nagra-0101: fix map21 MakeJ0 X-Git-Tag: 0.9.1~68 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=17189611a1c1266e41b2663f48d27940565626bd;p=sasc-ng.git nagra-0101: fix map21 MakeJ0 --- diff --git a/systems/nagra/nagra2-0101.c b/systems/nagra/nagra2-0101.c index b94f2df..a45b8a9 100644 --- a/systems/nagra/nagra2-0101.c +++ b/systems/nagra/nagra2-0101.c @@ -176,7 +176,7 @@ void cMap0101::DoMap(int f, unsigned char *data, int l) MAP_IRQ_BEGIN(); AddMapCycles(288); WS_START(1); - MakeJ0(J,D); + MakeJ0(J,D,C); AddMapCycles(282); BN_clear(C); WS_END(); diff --git a/systems/nagra/nagra2.c b/systems/nagra/nagra2.c index 5cb5f40..4ed23b9 100644 --- a/systems/nagra/nagra2.c +++ b/systems/nagra/nagra2.c @@ -392,16 +392,23 @@ bool cMapMath::ModSub(BIGNUM *r, BIGNUM *d, BIGNUM *b) return ret; } -void cMapMath::MakeJ0(BIGNUM *j, BIGNUM *d, int bits) +void cMapMath::MakeJ0(BIGNUM *j, BIGNUM *d, BIGNUM *c, int bits) { #if OPENSSL_VERSION_NUMBER < 0x0090700fL #error BN_mod_inverse is probably buggy in your openssl version #endif BN_zero(x); - BN_sub(j,x,d); + BN_sub(j,x,d); j->neg=1; BN_set_bit(j,0); BN_set_bit(x,bits); BN_mod_inverse(j,j,x,ctx); + if(c) { + BN_copy(c,d); + BN_mask_bits(c,bits); + BN_mul(c,j,c,ctx); + BN_rshift(c,c,bits); + BN_mask_bits(c,bits); + } } void cMapMath::MonMul(BIGNUM *o, BIGNUM *a, BIGNUM *b) diff --git a/systems/nagra/nagra2.h b/systems/nagra/nagra2.h index 84fc002..1d8db71 100644 --- a/systems/nagra/nagra2.h +++ b/systems/nagra/nagra2.h @@ -95,7 +95,7 @@ protected: cBNctx ctx; SHA_CTX sctx; // stateless - void MakeJ0(BIGNUM *j, BIGNUM *d, int bits=64); + void MakeJ0(BIGNUM *j, BIGNUM *d, BIGNUM *c=0, int bits=64); 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);