Commit 06cf881a authored by Rich Salz's avatar Rich Salz
Browse files

Final (for me, for now) dead code cleanup



This is a final pass looking for '#if 0'/'#if 1' controls and
removing the appropriate pieces.

Reviewed-by: default avatarAndy Polyakov <appro@openssl.org>
parent 3ffbe008
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -222,28 +222,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
                break;
        }
    }
#if 0
    memcpy(rp, ap, sizeof(*rp) * (max - i));
#else
    if (rp != ap) {
        for (;;) {
            if (!dif--)
                break;
            rp[0] = ap[0];
            if (!dif--)
                break;
            rp[1] = ap[1];
            if (!dif--)
                break;
            rp[2] = ap[2];
            if (!dif--)
                break;
            rp[3] = ap[3];
            rp += 4;
            ap += 4;
        }
    }
#endif

    r->top = max;
    r->neg = 0;
+0 −23
Original line number Diff line number Diff line
@@ -384,29 +384,6 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
        b->dmax = words;
    }

/* None of this should be necessary because of what b->top means! */
#if 0
    /*
     * NB: bn_wexpand() calls this only if the BIGNUM really has to grow
     */
    if (b->top < b->dmax) {
        int i;
        BN_ULONG *A = &(b->d[b->top]);
        for (i = (b->dmax - b->top) >> 3; i > 0; i--, A += 8) {
            A[0] = 0;
            A[1] = 0;
            A[2] = 0;
            A[3] = 0;
            A[4] = 0;
            A[5] = 0;
            A[6] = 0;
            A[7] = 0;
        }
        for (i = (b->dmax - b->top) & 7; i > 0; i--, A++)
            A[0] = 0;
        assert(A == &(b->d[b->dmax]));
    }
#endif
    bn_check_top(b);
    return b;
}
+0 −8
Original line number Diff line number Diff line
@@ -116,14 +116,6 @@
#include "cryptlib.h"
#include "bn_lcl.h"

#if 0                           /* now just a #define */
int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
{
    return (BN_div(NULL, rem, m, d, ctx));
    /* note that  rem->neg == m->neg  (unless the remainder is zero) */
}
#endif

int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
{
    /*
+0 −4
Original line number Diff line number Diff line
@@ -149,7 +149,6 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
            goto err;
    }

#if 1
    if (pseudorand == 2) {
        /*
         * generate patterns that are more likely to trigger BN library bugs
@@ -167,7 +166,6 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
                buf[i] = 255;
        }
    }
#endif

    if (top != -1) {
        if (top) {
@@ -206,12 +204,10 @@ int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
    return bnrand(1, rnd, bits, top, bottom);
}

#if 1
int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
{
    return bnrand(2, rnd, bits, top, bottom);
}
#endif

/* random number r:  0 <= r < range */
static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
+0 −2
Original line number Diff line number Diff line
@@ -195,7 +195,6 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
        goto err;
    r->neg = 0;

#if 1
    j = 0;
    while (BN_ucmp(r, &(recp->N)) >= 0) {
        if (j++ > 2) {
@@ -207,7 +206,6 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
        if (!BN_add_word(d, 1))
            goto err;
    }
#endif

    r->neg = BN_is_zero(r) ? 0 : m->neg;
    d->neg = m->neg ^ recp->N.neg;
Loading