Some provisional bignum debugging has begun to detect inconsistent BIGNUM
authorGeoff Thorpe <geoff@openssl.org>
Wed, 29 Oct 2003 20:47:49 +0000 (20:47 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Wed, 29 Oct 2003 20:47:49 +0000 (20:47 +0000)
structures being passed in to or out of API functions, and this corrects a
couple of cases found so far.

Also, lop off a couple of bytes of white-space.

crypto/bn/bn_lib.c
crypto/bn/bn_nist.c
crypto/bn/bn_recp.c

index 8207bce23061fe395a0800ffe9d536e905b39424..783881d3a6977964c8993a25a8673d4128c462d1 100644 (file)
@@ -462,7 +462,6 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
                        A[0]=0;
                assert(A == &(b->d[b->dmax]));
                }
-               
        return b;
        }
 
index 19bd5407254c873d8e38814bbb50e490880948ff..2ababfbed1ae81f106ad7a91e5a8cb5aadc13b85 100644 (file)
@@ -823,6 +823,7 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
        if (tmp->top == BN_NIST_521_TOP)
                tmp->d[BN_NIST_521_TOP-1]  &= BN_NIST_521_TOP_MASK;
 
+       bn_fix_top(tmp);
        if (!BN_uadd(r, tmp, r))
                return 0;
        top = r->top;
@@ -838,6 +839,6 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
        ret = 1;
 err:
        BN_CTX_end(ctx);
-       
+
        return ret;
        }
index ef5fdd470808c96f02fba4ec12327267d6131961..22cbcfc49b7885f5f1a0647c2281b71ccc23a0a6 100644 (file)
@@ -203,6 +203,8 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
        ret=1;
 err:
        BN_CTX_end(ctx);
+       if(dv) bn_fix_top(dv);
+       if(rem) bn_fix_top(rem);
        return(ret);
        }