crypto/bn/bn_recp.c:76: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BN_div_recp`.
Showing all 14 steps of the trace


crypto/bn/bn_recp.c:54:1: Parameter `*x->d`
52.   }
53.   
54. > int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
55.                             BN_RECP_CTX *recp, BN_CTX *ctx)
56.   {

crypto/bn/bn_recp.c:76:11: Call
74.           ca = x;                 /* Just do the mod */
75.   
76.       ret = BN_div_recp(NULL, r, ca, recp, ctx);
                ^
77.    err:
78.       BN_CTX_end(ctx);

crypto/bn/bn_recp.c:83:1: Parameter `*m->d`
  81.   }
  82.   
  83. > int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
  84.                   BN_RECP_CTX *recp, BN_CTX *ctx)
  85.   {

crypto/bn/bn_recp.c:103:9: Call
  101.           goto err;
  102.   
  103.       if (BN_ucmp(m, &(recp->N)) < 0) {
                 ^
  104.           BN_zero(d);
  105.           if (!BN_copy(r, m)) {

crypto/bn/bn_lib.c:623:1: Parameter `*a->d`
    621.   }
    622.   
    623. > int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
    624.   {
    625.       int i;

crypto/bn/bn_recp.c:119:9: Call
  117.   
  118.       /* i := max(BN_num_bits(m), 2*BN_num_bits(N)) */
  119.       i = BN_num_bits(m);
                 ^
  120.       j = recp->num_bits << 1;
  121.       if (j > i)

crypto/bn/bn_lib.c:161:1: Parameter `*a->d`
    159.   }
    160.   
    161. > int BN_num_bits(const BIGNUM *a)
    162.   {
    163.       int i = a->top - 1;

crypto/bn/bn_recp.c:137:10: Call
  135.        *    = |m/N|
  136.        */
  137.       if (!BN_rshift(a, m, recp->num_bits))
                  ^
  138.           goto err;
  139.       if (!BN_mul(b, a, &(recp->Nr), ctx))

crypto/bn/bn_shift.c:120:1: Parameter `*a->d`
    118.   }
    119.   
    120. > int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
    121.   {
    122.       int i, j, nw, lb, rb;

crypto/bn/bn_recp.c:147:10: Call
  145.       if (!BN_mul(b, &(recp->N), d, ctx))
  146.           goto err;
  147.       if (!BN_usub(r, m, b))
                  ^
  148.           goto err;
  149.       r->neg = 0;

crypto/bn/bn_add.c:117:1: <LHS trace>
115.   
116.   /* unsigned subtraction of b from a, a must be larger than b. */
117. > int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
118.   {
119.       int max, min, dif;

crypto/bn/bn_add.c:117:1: Parameter `*a->d`
    115.   
    116.   /* unsigned subtraction of b from a, a must be larger than b. */
    117. > int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
    118.   {
    119.       int max, min, dif;

crypto/bn/bn_add.c:169:13: Assignment
    167.           while (dif) {
    168.               dif--;
    169.               t1 = *(ap++);
                       ^
    170.               t2 = (t1 - 1) & BN_MASK2;
    171.               *(rp++) = t2;

crypto/bn/bn_add.c:170:13: Binary operation: ([0, +oo] - 1):unsigned64 by call to `BN_div_recp` 
    168.               dif--;
    169.               t1 = *(ap++);
    170.               t2 = (t1 - 1) & BN_MASK2;
                       ^
    171.               *(rp++) = t2;
    172.               if (t1)

int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
    int max, min, dif;
    register BN_ULONG t1, t2, *rp;
    register const BN_ULONG *ap, *bp;
    int i, carry;
    bn_check_top(a);
    bn_check_top(b);
    max = a->top;
    min = b->top;
    dif = max - min;
    if (dif < 0) {
        BNerr(BN_F_BN_USUB, BN_R_ARG2_LT_ARG3);
        return (0);
    }
    if (bn_wexpand(r, max) == NULL)
        return (0);
    ap = a->d;
    bp = b->d;
    rp = r->d;
#if 1
    carry = 0;
    for (i = min; i != 0; i--) {
        t1 = *(ap++);
        t2 = *(bp++);
        if (carry) {
            carry = (t1 <= t2);
            t1 = (t1 - t2 - 1) & BN_MASK2;
        } else {
            carry = (t1 < t2);
            t1 = (t1 - t2) & BN_MASK2;
        }
        *(rp++) = t1 & BN_MASK2;
    }
#else
    carry = bn_sub_words(rp, ap, bp, min);
    ap += min;
    bp += min;
    rp += min;
#endif
    if (carry) {
        if (!dif)
            return 0;
        while (dif) {
            dif--;
            t1 = *(ap++);
            t2 = (t1 - 1) & BN_MASK2;
            *(rp++) = t2;
            if (t1)
                break;
        }
    }
    if (dif && ap != rp)
        memcpy(rp, ap, sizeof(*rp) * dif);
    r->top = max;
    r->neg = 0;
    bn_correct_top(r);
    return (1);
}
['int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *a;\n    const BIGNUM *ca;\n    BN_CTX_start(ctx);\n    if ((a = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (y != NULL) {\n        if (x == y) {\n            if (!BN_sqr(a, x, ctx))\n                goto err;\n        } else {\n            if (!BN_mul(a, x, y, ctx))\n                goto err;\n        }\n        ca = a;\n    } else\n        ca = x;\n    ret = BN_div_recp(NULL, r, ca, recp, ctx);\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return (ret);\n}', 'int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx)\n{\n    int i, j, ret = 0;\n    BIGNUM *a, *b, *d, *r;\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    if (dv != NULL)\n        d = dv;\n    else\n        d = BN_CTX_get(ctx);\n    if (rem != NULL)\n        r = rem;\n    else\n        r = BN_CTX_get(ctx);\n    if (a == NULL || b == NULL || d == NULL || r == NULL)\n        goto err;\n    if (BN_ucmp(m, &(recp->N)) < 0) {\n        BN_zero(d);\n        if (!BN_copy(r, m)) {\n            BN_CTX_end(ctx);\n            return 0;\n        }\n        BN_CTX_end(ctx);\n        return (1);\n    }\n    i = BN_num_bits(m);\n    j = recp->num_bits << 1;\n    if (j > i)\n        i = j;\n    if (i != recp->shift)\n        recp->shift = BN_reciprocal(&(recp->Nr), &(recp->N), i, ctx);\n    if (recp->shift == -1)\n        goto err;\n    if (!BN_rshift(a, m, recp->num_bits))\n        goto err;\n    if (!BN_mul(b, a, &(recp->Nr), ctx))\n        goto err;\n    if (!BN_rshift(d, b, i - recp->num_bits))\n        goto err;\n    d->neg = 0;\n    if (!BN_mul(b, &(recp->N), d, ctx))\n        goto err;\n    if (!BN_usub(r, m, b))\n        goto err;\n    r->neg = 0;\n    j = 0;\n    while (BN_ucmp(r, &(recp->N)) >= 0) {\n        if (j++ > 2) {\n            BNerr(BN_F_BN_DIV_RECP, BN_R_BAD_RECIPROCAL);\n            goto err;\n        }\n        if (!BN_usub(r, r, &(recp->N)))\n            goto err;\n        if (!BN_add_word(d, 1))\n            goto err;\n    }\n    r->neg = BN_is_zero(r) ? 0 : m->neg;\n    d->neg = m->neg ^ recp->N.neg;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(dv);\n    bn_check_top(rem);\n    return (ret);\n}', 'int BN_ucmp(const BIGNUM *a, const BIGNUM *b)\n{\n    int i;\n    BN_ULONG t1, t2, *ap, *bp;\n    bn_check_top(a);\n    bn_check_top(b);\n    i = a->top - b->top;\n    if (i != 0)\n        return (i);\n    ap = a->d;\n    bp = b->d;\n    for (i = a->top - 1; i >= 0; i--) {\n        t1 = ap[i];\n        t2 = bp[i];\n        if (t1 != t2)\n            return ((t1 > t2) ? 1 : -1);\n    }\n    return (0);\n}', 'int BN_num_bits(const BIGNUM *a)\n{\n    int i = a->top - 1;\n    bn_check_top(a);\n    if (BN_is_zero(a))\n        return 0;\n    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));\n}', 'int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, j, nw, lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l, tmp;\n    bn_check_top(r);\n    bn_check_top(a);\n    if (n < 0) {\n        BNerr(BN_F_BN_RSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n    nw = n / BN_BITS2;\n    rb = n % BN_BITS2;\n    lb = BN_BITS2 - rb;\n    if (nw >= a->top || a->top == 0) {\n        BN_zero(r);\n        return (1);\n    }\n    i = (BN_num_bits(a) - n + (BN_BITS2 - 1)) / BN_BITS2;\n    if (r != a) {\n        r->neg = a->neg;\n        if (bn_wexpand(r, i) == NULL)\n            return (0);\n    } else {\n        if (n == 0)\n            return 1;\n    }\n    f = &(a->d[nw]);\n    t = r->d;\n    j = a->top - nw;\n    r->top = i;\n    if (rb == 0) {\n        for (i = j; i != 0; i--)\n            *(t++) = *(f++);\n    } else {\n        l = *(f++);\n        for (i = j - 1; i != 0; i--) {\n            tmp = (l >> rb) & BN_MASK2;\n            l = *(f++);\n            *(t++) = (tmp | (l << lb)) & BN_MASK2;\n        }\n        if ((l = (l >> rb) & BN_MASK2))\n            *(t) = l;\n    }\n    bn_check_top(r);\n    return (1);\n}', 'int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int max, min, dif;\n    register BN_ULONG t1, t2, *rp;\n    register const BN_ULONG *ap, *bp;\n    int i, carry;\n    bn_check_top(a);\n    bn_check_top(b);\n    max = a->top;\n    min = b->top;\n    dif = max - min;\n    if (dif < 0) {\n        BNerr(BN_F_BN_USUB, BN_R_ARG2_LT_ARG3);\n        return (0);\n    }\n    if (bn_wexpand(r, max) == NULL)\n        return (0);\n    ap = a->d;\n    bp = b->d;\n    rp = r->d;\n#if 1\n    carry = 0;\n    for (i = min; i != 0; i--) {\n        t1 = *(ap++);\n        t2 = *(bp++);\n        if (carry) {\n            carry = (t1 <= t2);\n            t1 = (t1 - t2 - 1) & BN_MASK2;\n        } else {\n            carry = (t1 < t2);\n            t1 = (t1 - t2) & BN_MASK2;\n        }\n        *(rp++) = t1 & BN_MASK2;\n    }\n#else\n    carry = bn_sub_words(rp, ap, bp, min);\n    ap += min;\n    bp += min;\n    rp += min;\n#endif\n    if (carry) {\n        if (!dif)\n            return 0;\n        while (dif) {\n            dif--;\n            t1 = *(ap++);\n            t2 = (t1 - 1) & BN_MASK2;\n            *(rp++) = t2;\n            if (t1)\n                break;\n        }\n    }\n    if (dif && ap != rp)\n        memcpy(rp, ap, sizeof(*rp) * dif);\n    r->top = max;\n    r->neg = 0;\n    bn_correct_top(r);\n    return (1);\n}']