Change DH_up() -> DH_up_ref()
[openssl.git] / crypto / bn / bn_shift.c
index e4da833ea67f33aa68b22a7dde588ca182034358..70f785ea185b8841e415d33b385bf96de95535be 100644 (file)
@@ -128,8 +128,8 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
        BN_ULONG l;
 
        r->neg=a->neg;
-       if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0);
        nw=n/BN_BITS2;
+       if (bn_wexpand(r,a->top+nw+1) == NULL) return(0);
        lb=n%BN_BITS2;
        rb=BN_BITS2-lb;
        f=a->d;
@@ -172,6 +172,11 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
                r->neg=a->neg;
                if (bn_wexpand(r,a->top-nw+1) == NULL) return(0);
                }
+       else
+               {
+               if (n == 0)
+                       return 1; /* or the copying loop will go berserk */
+               }
 
        f= &(a->d[nw]);
        t=r->d;