}
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);
case 0x21:
case 0x30:
case 0x31:
+ case 0x38:
case 0x3a:
case 0x43:
DoMap(f);
}
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);
}
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)
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);