Commit ceac1975 authored by Richard Levitte's avatar Richard Levitte
Browse files

bntest: make sure file_rshift tests BN_rshift1 as well when appropriate

parent 26141bab
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -1155,21 +1155,28 @@ static int file_rshift(STANZA *s)
    BIGNUM *rshift = getBN(s, "RShift");
    BIGNUM *ret = BN_new();
    int n = 0;
    int st = 0;
    int errcnt = 1;

    if (a == NULL || rshift == NULL || ret == NULL || !getint(s, &n, "N"))
        goto err;

    errcnt = 0;
    if (!BN_rshift(ret, a, n)
            || !equalBN("A >> N", rshift, ret))
        goto err;
        errcnt++;

    /* If N == 1, try with rshift1 as well */
    if (n == 1) {
        if (!BN_rshift1(ret, a)
                || !equalBN("A >> 1 (rshift1)", rshift, ret))
            errcnt++;
    }

    st = 1;
err:
    BN_free(a);
    BN_free(rshift);
    BN_free(ret);
    return st;
    return errcnt == 0;
}

static int file_square(STANZA *s)