|
SASC
DVBSoftCAM
|
#include <nagra2.h>
Inheritance diagram for cMapMath:Public Member Functions | |
| cMapMath (void) | |
| cMapMath (void) | |
Protected Member Functions | |
| 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) |
| 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) |
| void | MonMul (BIGNUM *o, BIGNUM *a, BIGNUM *b) |
| void | MonMul (BIGNUM *o, BIGNUM *a, BIGNUM *b, int w) |
| 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) |
| 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) |
| void | MonMul (BIGNUM *o, BIGNUM *a, BIGNUM *b) |
| void | MonMul (BIGNUM *o, BIGNUM *a, BIGNUM *b, int w) |
Protected Attributes | |
| int | wordsize |
| int | regpos |
| cMapReg | A |
| cMapReg | B |
| cMapReg | C |
| cMapReg | D |
| cMapReg | J |
| cMapReg | I |
| cBN | H |
| cBN | scalar |
| cBNctx | ctx |
| SHA_CTX | sctx |
| cMapMath::cMapMath | ( | void | ) |
| cMapMath::cMapMath | ( | void | ) |
| void cMapMath::MakeJ0 | ( | BIGNUM * | j, |
| BIGNUM * | d, | ||
| BIGNUM * | c = 0, |
||
| int | bits = 64 |
||
| ) | [protected] |
Definition at line 499 of file nagra2.c.
References ctx.
Referenced by cMapCore::IMakeJ(), cMap0101::Map(), and cMapCore::MonInit().
{
#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); 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::MakeJ0 | ( | BIGNUM * | j, |
| BIGNUM * | d, | ||
| BIGNUM * | c = 0, |
||
| int | bits = 64 |
||
| ) | [protected] |
| bool cMapMath::ModAdd | ( | BIGNUM * | r, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | d | ||
| ) | [protected] |
Definition at line 477 of file nagra2.c.
References wordsize.
Referenced by cMapCore::AddP(), and cMapCore::DoubleP().
| bool cMapMath::ModAdd | ( | BIGNUM * | r, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | d | ||
| ) | [protected] |
| bool cMapMath::ModSub | ( | BIGNUM * | r, |
| BIGNUM * | d, | ||
| BIGNUM * | b | ||
| ) | [protected] |
Definition at line 489 of file nagra2.c.
Referenced by cMapCore::AddP(), cMapCore::DoubleP(), and cMap0101::Map().
| bool cMapMath::ModSub | ( | BIGNUM * | r, |
| BIGNUM * | d, | ||
| BIGNUM * | b | ||
| ) | [protected] |
| void cMapMath::MonFin | ( | BIGNUM * | s, |
| BIGNUM * | d | ||
| ) | [protected] |
Definition at line 589 of file nagra2.c.
Referenced by cMapCore::IMonInit0(), cMap0101::Map(), MonLoop(), and MonMul().
{
if(BN_cmp(s,d)>=0)
BN_sub(s,s,d);
}
| void cMapMath::MonFin | ( | BIGNUM * | s, |
| BIGNUM * | d | ||
| ) | [protected] |
| void cMapMath::MonLoop | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | c, | ||
| BIGNUM * | d, | ||
| BIGNUM * | j | ||
| ) | [protected] |
| void cMapMath::MonLoop | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | c, | ||
| BIGNUM * | d, | ||
| BIGNUM * | j | ||
| ) | [protected] |
Definition at line 554 of file nagra2.c.
References ctx, MonFin(), and wordsize.
Referenced by MonMul0().
{
words--;
BN_mask_bits(a,64);
BN_mul(a,a,b,ctx);
BN_add(s,s,a);
BN_copy(x,s);
BN_mask_bits(x,64);
BN_mul(x,x,j,ctx);
if(!words) {
BN_lshift(y,x,64);
BN_add(y,y,x);
// Low
BN_rshift(c,y,2);
BN_add(c,c,s);
BN_rshift(c,c,52);
BN_mask_bits(c,12);
}
BN_mask_bits(x,64);
BN_mul(x,x,d,ctx);
BN_add(s,s,x);
if(!words) {
// High
BN_lshift(y,s,12);
BN_add(c,c,y);
BN_mask_bits(c,wordsize<<6);
}
BN_rshift(s,s,64);
if(words) MonFin(s,d);
if(!words) BN_copy(o,s);
}
| void cMapMath::MonMul | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| int | w | ||
| ) | [protected] |
| void cMapMath::MonMul | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b | ||
| ) | [protected] |
| void cMapMath::MonMul | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b | ||
| ) | [protected] |
| void cMapMath::MonMul | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| int | w | ||
| ) | [protected] |
| void cMapMath::MonMul | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | c, | ||
| BIGNUM * | d, | ||
| BIGNUM * | j, | ||
| int | w | ||
| ) | [protected] |
| void cMapMath::MonMul | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | c, | ||
| BIGNUM * | d, | ||
| BIGNUM * | j, | ||
| int | w | ||
| ) | [protected] |
Definition at line 528 of file nagra2.c.
References MonFin(), and MonMul0().
Referenced by cMapCore::AddP(), cMapCore::CurveInit(), cMapCore::DoubleP(), cMap0501::Map(), cMap0101::Map(), cMapCore::MonExp(), cMapCore::MonExpNeg(), cMapCore::MonInit(), MonMul(), cMapCore::ToAffine(), and cMapCore::ToProjective().
| void cMapMath::MonMul0 | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | c, | ||
| BIGNUM * | d, | ||
| BIGNUM * | j, | ||
| int | w | ||
| ) | [protected] |
| void cMapMath::MonMul0 | ( | BIGNUM * | o, |
| BIGNUM * | a, | ||
| BIGNUM * | b, | ||
| BIGNUM * | c, | ||
| BIGNUM * | d, | ||
| BIGNUM * | j, | ||
| int | w | ||
| ) | [protected] |
Definition at line 534 of file nagra2.c.
References i, MonLoop(), MonStart(), and wordsize.
Referenced by cMapCore::IMonInit0(), cMap0101::Map(), and MonMul().
| void cMapMath::MonStart | ( | int | w | ) | [protected] |
| void cMapMath::MonStart | ( | int | w | ) | [protected] |
cMapReg cMapMath::A [protected] |
Definition at line 95 of file nagra2.h.
Referenced by cMapCore::AddP(), cMapCore::cMapCore(), cMapCore::CurveInit(), cMapCore::DoubleP(), cMap0101::Map(), cMapCore::MonExp(), cMapCore::MonExpNeg(), and cMapCore::ToAffine().
cMapReg cMapMath::B [protected] |
Definition at line 95 of file nagra2.h.
Referenced by cMapCore::AddP(), cMapCore::cMapCore(), cMapCore::CurveInit(), cMapCore::DoubleP(), cMapCore::IMonInit0(), cMap0501::Map(), cMap0101::Map(), cMapCore::MonExp(), cMapCore::MonExpNeg(), cMapCore::MonInit(), cMapCore::ToAffine(), and cMapCore::ToProjective().
cMapReg cMapMath::C [protected] |
Definition at line 95 of file nagra2.h.
Referenced by cMapCore::cMapCore(), cMapCore::DoubleP(), cMapCore::IMakeJ(), cMapCore::IMonInit0(), cMap0101::Map(), cMapCore::MonInit(), and MonMul().
cBNctx cMapMath::ctx [protected] |
Definition at line 97 of file nagra2.h.
Referenced by cMapCore::IMonInit0(), MakeJ0(), cMap0101::Map(), ModSub(), cMapCore::MonInit(), and MonLoop().
cMapReg cMapMath::D [protected] |
Definition at line 95 of file nagra2.h.
Referenced by cMapCore::AddP(), cMapCore::cMapCore(), cMapCore::CurveInit(), cMapCore::DoubleP(), cMapCore::IMakeJ(), cMapCore::IMonInit0(), cMap4101::Map(), cMap0101::Map(), cMapCore::MonExp(), cMapCore::MonExpNeg(), cMapCore::MonInit(), and MonMul().
cBN cMapMath::H [protected] |
cMapReg cMapMath::I [protected] |
Definition at line 95 of file nagra2.h.
Referenced by cMapCore::AddP(), cMapCore::CurveInit(), cMapCore::IMonInit0(), cMap0501::Map(), cMapCore::MonInit(), cMapCore::ToAffine(), and cMapCore::ToProjective().
cMapReg cMapMath::J [protected] |
Definition at line 95 of file nagra2.h.
Referenced by cMapCore::cMapCore(), cMapCore::IMakeJ(), cMapCore::IMonInit0(), cMap0101::Map(), cMapCore::MonInit(), and MonMul().
int cMapMath::regpos [protected] |
Definition at line 94 of file nagra2.h.
Referenced by cMapMath().
cBN cMapMath::scalar [protected] |
Definition at line 96 of file nagra2.h.
Referenced by cMap4101::Map(), and cMap0101::Map().
SHA_CTX cMapMath::sctx [protected] |
Definition at line 98 of file nagra2.h.
Referenced by cMap4101::Map().
int cMapMath::wordsize [protected] |
Definition at line 94 of file nagra2.h.
Referenced by cMapMath(), cMapCore::CurveInit(), cMapCore::GetOpSize(), cMapCore::IMonInit0(), cMap0101::Map(), ModAdd(), ModSub(), cMapCore::MonInit(), MonLoop(), MonMul0(), and cMapCore::PostDecryptSetup().