This probably fixes a BN_rshift bug.
[openssl.git] / crypto / bn / bn_shift.c
index 944bf1794bc1876de012fc82d82881631011334d..0883247384e97a4d8ac9c37f83c4c4a21cb49b96 100644 (file)
@@ -60,9 +60,7 @@
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
-int BN_lshift1(r, a)
-BIGNUM *r;
-BIGNUM *a;
+int BN_lshift1(BIGNUM *r, BIGNUM *a)
        {
        register BN_ULONG *ap,*rp,t,c;
        int i;
@@ -94,9 +92,7 @@ BIGNUM *a;
        return(1);
        }
 
-int BN_rshift1(r, a)
-BIGNUM *r;
-BIGNUM *a;
+int BN_rshift1(BIGNUM *r, BIGNUM *a)
        {
        BN_ULONG *ap,*rp,t,c;
        int i;
@@ -125,10 +121,7 @@ BIGNUM *a;
        return(1);
        }
 
-int BN_lshift(r, a, n)
-BIGNUM *r;
-BIGNUM *a;
-int n;
+int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
        {
        int i,nw,lb,rb;
        BN_ULONG *t,*f;
@@ -160,10 +153,7 @@ int n;
        return(1);
        }
 
-int BN_rshift(r, a, n)
-BIGNUM *r;
-BIGNUM *a;
-int n;
+int BN_rshift(BIGNUM *r, BIGNUM *a, int n)
        {
        int i,j,nw,lb,rb;
        BN_ULONG *t,*f;
@@ -172,7 +162,7 @@ int n;
        nw=n/BN_BITS2;
        rb=n%BN_BITS2;
        lb=BN_BITS2-rb;
-       if (nw > a->top)
+       if (nw > a->top || a->top == 0)
                {
                BN_zero(r);
                return(1);