Totally remove the supposedly 'faster' variant in
[openssl.git] / crypto / bn / bn_mont.c
index e5fbcd619f7b05ce078565c7cdb67027916af7de..8cf1febaccad8579bcc13d91caf55d520d1c25e1 100644 (file)
@@ -85,16 +85,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
 
        if (a == b)
                {
-#if 1 
-               bn_wexpand(tmp,a->top*2);
-               bn_wexpand(tmp2,a->top*4);
-               bn_sqr_recursive(tmp->d,a->d,a->top,tmp2->d);
-               tmp->top=a->top*2;
-               if (tmp->d[tmp->top-1] == 0)
-                       tmp->top--;
-#else
                if (!BN_sqr(tmp,a,ctx)) goto err;
-#endif
                }
        else
                {
@@ -157,7 +148,22 @@ int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
 #endif
        for (i=0; i<nl; i++)
                {
+#ifdef __TANDEM
+                {
+                   long long t1;
+                   long long t2;
+                   long long t3;
+                   t1 = rp[0] * (n0 & 0177777);
+                   t2 = 037777600000l;
+                   t2 = n0 & t2;
+                   t3 = rp[0] & 0177777;
+                   t2 = (t3 * t2) & BN_MASK2;
+                   t1 = t1 + t2;
+                   v=bn_mul_add_words(rp,np,nl,(BN_ULONG) t1);
+                }
+#else
                v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
+#endif
                nrp++;
                rp++;
                if (((nrp[-1]+=v)&BN_MASK2) >= v)
@@ -175,6 +181,7 @@ int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
 #if 0
        BN_rshift(ret,r,mont->ri);
 #else
+       ret->neg = r->neg;
        x=ri;
        rp=ret->d;
        ap= &(r->d[x]);
@@ -284,7 +291,7 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
                buf[1]=0;
                tmod.d=buf;
                tmod.top=1;
-               tmod.max=2;
+               tmod.dmax=2;
                tmod.neg=mod->neg;
                                                        /* Ri = R^-1 mod N*/
                if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)