engines/ccgost/gost_sign.c:204: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul`.
Showing all 22 steps of the trace


engines/ccgost/gost_sign.c:177:5: Call
175.       }
176.   
177.       BN_CTX_start(ctx);
           ^
178.       if (BN_cmp(sig->s, dsa->q) >= 1 || BN_cmp(sig->r, dsa->q) >= 1) {
179.           GOSTerr(GOST_F_GOST_DO_VERIFY, GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q);

crypto/bn/bn_ctx.c:227:1: Parameter `ctx->stack.depth`
  225.   }
  226.   
  227. > void BN_CTX_start(BN_CTX *ctx)
  228.   {
  229.       CTXDBG_ENTRY("BN_CTX_start", ctx);

engines/ccgost/gost_sign.c:197:5: Call
195.       }
196.   
197.       BN_mod(tmp, md, dsa->q, ctx);
           ^
198.       if (BN_is_zero(tmp)) {
199.           BN_one(md);

crypto/bn/bn_div.c:189:1: Parameter `ctx->stack.depth`
  187.    * If 'dv' or 'rm' is NULL, the respective value is not returned.
  188.    */
  189. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
  190.              BN_CTX *ctx)
  191.   {

engines/ccgost/gost_sign.c:203:5: Call
201.       BN_copy(q2, dsa->q);
202.       BN_sub_word(q2, 2);
203.       BN_mod_exp(v, md, q2, dsa->q, ctx);
           ^
204.       BN_mod_mul(z1, sig->s, v, dsa->q, ctx);
205.       BN_sub(tmp, dsa->q, sig->r);

crypto/bn/bn_exp.c:197:1: Parameter `ctx->stack.depth`
  195.   }
  196.   
  197. > int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
  198.                  BN_CTX *ctx)
  199.   {

crypto/bn/bn_exp.c:254:19: Call
  252.               && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0)) {
  253.               BN_ULONG A = a->d[0];
  254.               ret = BN_mod_exp_mont_word(r, A, p, m, ctx, NULL);
                           ^
  255.           } else
  256.   # endif

crypto/bn/bn_exp.c:1142:1: Parameter `ctx->stack.depth`
    1140.   }
    1141.   
    1142. > int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,
    1143.                            const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
    1144.   {

engines/ccgost/gost_sign.c:204:5: Call
202.       BN_sub_word(q2, 2);
203.       BN_mod_exp(v, md, q2, dsa->q, ctx);
204.       BN_mod_mul(z1, sig->s, v, dsa->q, ctx);
           ^
205.       BN_sub(tmp, dsa->q, sig->r);
206.       BN_mod_mul(z2, tmp, v, dsa->p, ctx);

crypto/bn/bn_mod.c:179:1: Parameter `ctx->stack.depth`
  177.   
  178.   /* slow but works */
  179. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  180.                  BN_CTX *ctx)
  181.   {

crypto/bn/bn_mod.c:189:5: Call
  187.       bn_check_top(m);
  188.   
  189.       BN_CTX_start(ctx);
             ^
  190.       if ((t = BN_CTX_get(ctx)) == NULL)
  191.           goto err;

crypto/bn/bn_ctx.c:227:1: Parameter `ctx->stack.depth`
    225.   }
    226.   
    227. > void BN_CTX_start(BN_CTX *ctx)
    228.   {
    229.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_mod.c:196:14: Call
  194.               goto err;
  195.       } else {
  196.           if (!BN_mul(t, a, b, ctx))
                      ^
  197.               goto err;
  198.       }

crypto/bn/bn_mul.c:883:1: Parameter `ctx->stack.depth`
    881.   #endif                          /* BN_RECURSION */
    882.   
    883. > int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
    884.   {
    885.       int ret = 0;

crypto/bn/bn_mul.c:909:5: Call
    907.       top = al + bl;
    908.   
    909.       BN_CTX_start(ctx);
               ^
    910.       if ((r == a) || (r == b)) {
    911.           if ((rr = BN_CTX_get(ctx)) == NULL)

crypto/bn/bn_ctx.c:227:1: Parameter `ctx->stack.depth`
      225.   }
      226.   
      227. > void BN_CTX_start(BN_CTX *ctx)
      228.   {
      229.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_mul.c:1033:5: Call
    1031.    err:
    1032.       bn_check_top(r);
    1033.       BN_CTX_end(ctx);
                ^
    1034.       return (ret);
    1035.   }

crypto/bn/bn_ctx.c:241:1: Parameter `ctx->stack.depth`
      239.   }
      240.   
      241. > void BN_CTX_end(BN_CTX *ctx)
      242.   {
      243.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:247:27: Call
      245.           ctx->err_stack--;
      246.       else {
      247.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                       ^
      248.           /* Does this stack frame have anything to release? */
      249.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:319:1: <LHS trace>
317.   }
318.   
319. > static unsigned int BN_STACK_pop(BN_STACK *st)
320.   {
321.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:319:1: Parameter `st->depth`
        317.   }
        318.   
        319. > static unsigned int BN_STACK_pop(BN_STACK *st)
        320.   {
        321.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:321:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul` 
        319.   static unsigned int BN_STACK_pop(BN_STACK *st)
        320.   {
        321.       return st->indexes[--(st->depth)];
                          ^
        322.   }
        323.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int gost_do_verify(const unsigned char *dgst, int dgst_len,\n                   DSA_SIG *sig, DSA *dsa)\n{\n    BIGNUM *md = NULL, *tmp = NULL;\n    BIGNUM *q2 = NULL;\n    BIGNUM *u = NULL, *v = NULL, *z1 = NULL, *z2 = NULL;\n    BIGNUM *tmp2 = NULL, *tmp3 = NULL;\n    int ok;\n    BN_CTX *ctx = BN_CTX_new();\n    if(!ctx) {\n        GOSTerr(GOST_F_GOST_DO_VERIFY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    BN_CTX_start(ctx);\n    if (BN_cmp(sig->s, dsa->q) >= 1 || BN_cmp(sig->r, dsa->q) >= 1) {\n        GOSTerr(GOST_F_GOST_DO_VERIFY, GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q);\n        goto err;\n    }\n    md = hashsum2bn(dgst);\n    tmp = BN_CTX_get(ctx);\n    v = BN_CTX_get(ctx);\n    q2 = BN_CTX_get(ctx);\n    z1 = BN_CTX_get(ctx);\n    z2 = BN_CTX_get(ctx);\n    tmp2 = BN_CTX_get(ctx);\n    tmp3 = BN_CTX_get(ctx);\n    u = BN_CTX_get(ctx);\n    if(!tmp || !v || !q2 || !z1 || !z2 || !tmp2 || !tmp3 || !u) {\n        GOSTerr(GOST_F_GOST_DO_VERIFY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    BN_mod(tmp, md, dsa->q, ctx);\n    if (BN_is_zero(tmp)) {\n        BN_one(md);\n    }\n    BN_copy(q2, dsa->q);\n    BN_sub_word(q2, 2);\n    BN_mod_exp(v, md, q2, dsa->q, ctx);\n    BN_mod_mul(z1, sig->s, v, dsa->q, ctx);\n    BN_sub(tmp, dsa->q, sig->r);\n    BN_mod_mul(z2, tmp, v, dsa->p, ctx);\n    BN_mod_exp(tmp, dsa->g, z1, dsa->p, ctx);\n    BN_mod_exp(tmp2, dsa->pub_key, z2, dsa->p, ctx);\n    BN_mod_mul(tmp3, tmp, tmp2, dsa->p, ctx);\n    BN_mod(u, tmp3, dsa->q, ctx);\n    ok = BN_cmp(u, sig->r);\n    if (ok != 0) {\n        GOSTerr(GOST_F_GOST_DO_VERIFY, GOST_R_SIGNATURE_MISMATCH);\n    }\nerr:\n    if(md) BN_free(md);\n    if(ctx) {\n        BN_CTX_end(ctx);\n        BN_CTX_free(ctx);\n    }\n    return (ok == 0);\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("BN_CTX_start", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG_EXIT(ctx);\n}', 'int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,\n           BN_CTX *ctx)\n{\n    int norm_shift, i, loop;\n    BIGNUM *tmp, wnum, *snum, *sdiv, *res;\n    BN_ULONG *resp, *wnump;\n    BN_ULONG d0, d1;\n    int num_n, div_n;\n    int no_branch = 0;\n    if ((num->top > 0 && num->d[num->top - 1] == 0) ||\n        (divisor->top > 0 && divisor->d[divisor->top - 1] == 0)) {\n        BNerr(BN_F_BN_DIV, BN_R_NOT_INITIALIZED);\n        return 0;\n    }\n    bn_check_top(num);\n    bn_check_top(divisor);\n    if ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0)\n        || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0)) {\n        no_branch = 1;\n    }\n    bn_check_top(dv);\n    bn_check_top(rm);\n    if (BN_is_zero(divisor)) {\n        BNerr(BN_F_BN_DIV, BN_R_DIV_BY_ZERO);\n        return (0);\n    }\n    if (!no_branch && BN_ucmp(num, divisor) < 0) {\n        if (rm != NULL) {\n            if (BN_copy(rm, num) == NULL)\n                return (0);\n        }\n        if (dv != NULL)\n            BN_zero(dv);\n        return (1);\n    }\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    snum = BN_CTX_get(ctx);\n    sdiv = BN_CTX_get(ctx);\n    if (dv == NULL)\n        res = BN_CTX_get(ctx);\n    else\n        res = dv;\n    if (sdiv == NULL || res == NULL || tmp == NULL || snum == NULL)\n        goto err;\n    norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2);\n    if (!(BN_lshift(sdiv, divisor, norm_shift)))\n        goto err;\n    sdiv->neg = 0;\n    norm_shift += BN_BITS2;\n    if (!(BN_lshift(snum, num, norm_shift)))\n        goto err;\n    snum->neg = 0;\n    if (no_branch) {\n        if (snum->top <= sdiv->top + 1) {\n            if (bn_wexpand(snum, sdiv->top + 2) == NULL)\n                goto err;\n            for (i = snum->top; i < sdiv->top + 2; i++)\n                snum->d[i] = 0;\n            snum->top = sdiv->top + 2;\n        } else {\n            if (bn_wexpand(snum, snum->top + 1) == NULL)\n                goto err;\n            snum->d[snum->top] = 0;\n            snum->top++;\n        }\n    }\n    div_n = sdiv->top;\n    num_n = snum->top;\n    loop = num_n - div_n;\n    wnum.neg = 0;\n    wnum.d = &(snum->d[loop]);\n    wnum.top = div_n;\n    wnum.dmax = snum->dmax - loop;\n    d0 = sdiv->d[div_n - 1];\n    d1 = (div_n == 1) ? 0 : sdiv->d[div_n - 2];\n    wnump = &(snum->d[num_n - 1]);\n    res->neg = (num->neg ^ divisor->neg);\n    if (!bn_wexpand(res, (loop + 1)))\n        goto err;\n    res->top = loop - no_branch;\n    resp = &(res->d[loop - 1]);\n    if (!bn_wexpand(tmp, (div_n + 1)))\n        goto err;\n    if (!no_branch) {\n        if (BN_ucmp(&wnum, sdiv) >= 0) {\n            bn_clear_top2max(&wnum);\n            bn_sub_words(wnum.d, wnum.d, sdiv->d, div_n);\n            *resp = 1;\n        } else\n            res->top--;\n    }\n    if (res->top == 0)\n        res->neg = 0;\n    else\n        resp--;\n    for (i = 0; i < loop - 1; i++, wnump--, resp--) {\n        BN_ULONG q, l0;\n# if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)\n        BN_ULONG bn_div_3_words(BN_ULONG *, BN_ULONG, BN_ULONG);\n        q = bn_div_3_words(wnump, d1, d0);\n# else\n        BN_ULONG n0, n1, rem = 0;\n        n0 = wnump[0];\n        n1 = wnump[-1];\n        if (n0 == d0)\n            q = BN_MASK2;\n        else {\n#  ifdef BN_LLONG\n            BN_ULLONG t2;\n#   if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)\n            q = (BN_ULONG)(((((BN_ULLONG) n0) << BN_BITS2) | n1) / d0);\n#   else\n            q = bn_div_words(n0, n1, d0);\n#    ifdef BN_DEBUG_LEVITTE\n            fprintf(stderr, "DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\\\nX) -> 0x%08X\\n", n0, n1, d0, q);\n#    endif\n#   endif\n#   ifndef REMAINDER_IS_ALREADY_CALCULATED\n            rem = (n1 - q * d0) & BN_MASK2;\n#   endif\n            t2 = (BN_ULLONG) d1 *q;\n            for (;;) {\n                if (t2 <= ((((BN_ULLONG) rem) << BN_BITS2) | wnump[-2]))\n                    break;\n                q--;\n                rem += d0;\n                if (rem < d0)\n                    break;\n                t2 -= d1;\n            }\n#  else\n            BN_ULONG t2l, t2h;\n            q = bn_div_words(n0, n1, d0);\n#   ifdef BN_DEBUG_LEVITTE\n            fprintf(stderr, "DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\\\nX) -> 0x%08X\\n", n0, n1, d0, q);\n#   endif\n#   ifndef REMAINDER_IS_ALREADY_CALCULATED\n            rem = (n1 - q * d0) & BN_MASK2;\n#   endif\n#   if defined(BN_UMULT_LOHI)\n            BN_UMULT_LOHI(t2l, t2h, d1, q);\n#   elif defined(BN_UMULT_HIGH)\n            t2l = d1 * q;\n            t2h = BN_UMULT_HIGH(d1, q);\n#   else\n            {\n                BN_ULONG ql, qh;\n                t2l = LBITS(d1);\n                t2h = HBITS(d1);\n                ql = LBITS(q);\n                qh = HBITS(q);\n                mul64(t2l, t2h, ql, qh);\n            }\n#   endif\n            for (;;) {\n                if ((t2h < rem) || ((t2h == rem) && (t2l <= wnump[-2])))\n                    break;\n                q--;\n                rem += d0;\n                if (rem < d0)\n                    break;\n                if (t2l < d1)\n                    t2h--;\n                t2l -= d1;\n            }\n#  endif\n        }\n# endif\n        l0 = bn_mul_words(tmp->d, sdiv->d, div_n, q);\n        tmp->d[div_n] = l0;\n        wnum.d--;\n        if (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n + 1)) {\n            q--;\n            if (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n))\n                (*wnump)++;\n        }\n        *resp = q;\n    }\n    bn_correct_top(snum);\n    if (rm != NULL) {\n        int neg = num->neg;\n        BN_rshift(rm, snum, norm_shift);\n        if (!BN_is_zero(rm))\n            rm->neg = neg;\n        bn_check_top(rm);\n    }\n    if (no_branch)\n        bn_correct_top(res);\n    BN_CTX_end(ctx);\n    return (1);\n err:\n    bn_check_top(rm);\n    BN_CTX_end(ctx);\n    return (0);\n}', 'int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    int ret;\n    bn_check_top(a);\n    bn_check_top(p);\n    bn_check_top(m);\n#define MONT_MUL_MOD\n#define MONT_EXP_WORD\n#define RECP_MUL_MOD\n#ifdef MONT_MUL_MOD\n    if (BN_is_odd(m)) {\n# ifdef MONT_EXP_WORD\n        if (a->top == 1 && !a->neg\n            && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0)) {\n            BN_ULONG A = a->d[0];\n            ret = BN_mod_exp_mont_word(r, A, p, m, ctx, NULL);\n        } else\n# endif\n            ret = BN_mod_exp_mont(r, a, p, m, ctx, NULL);\n    } else\n#endif\n#ifdef RECP_MUL_MOD\n    {\n        ret = BN_mod_exp_recp(r, a, p, m, ctx);\n    }\n#else\n    {\n        ret = BN_mod_exp_simple(r, a, p, m, ctx);\n    }\n#endif\n    bn_check_top(r);\n    return (ret);\n}', 'int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)\n{\n    BN_MONT_CTX *mont = NULL;\n    int b, bits, ret = 0;\n    int r_is_one;\n    BN_ULONG w, next_w;\n    BIGNUM *d, *r, *t;\n    BIGNUM *swap_tmp;\n#define BN_MOD_MUL_WORD(r, w, m) \\\n                (BN_mul_word(r, (w)) && \\\n                (   \\\n                        (BN_mod(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1))))\n#define BN_TO_MONTGOMERY_WORD(r, w, mont) \\\n                (BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx))\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) {\n        BNerr(BN_F_BN_MOD_EXP_MONT_WORD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return -1;\n    }\n    bn_check_top(p);\n    bn_check_top(m);\n    if (!BN_is_odd(m)) {\n        BNerr(BN_F_BN_MOD_EXP_MONT_WORD, BN_R_CALLED_WITH_EVEN_MODULUS);\n        return (0);\n    }\n    if (m->top == 1)\n        a %= m->d[0];\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        if (BN_is_one(m)) {\n            ret = 1;\n            BN_zero(rr);\n        } else\n            ret = BN_one(rr);\n        return ret;\n    }\n    if (a == 0) {\n        BN_zero(rr);\n        ret = 1;\n        return ret;\n    }\n    BN_CTX_start(ctx);\n    d = BN_CTX_get(ctx);\n    r = BN_CTX_get(ctx);\n    t = BN_CTX_get(ctx);\n    if (d == NULL || r == NULL || t == NULL)\n        goto err;\n    if (in_mont != NULL)\n        mont = in_mont;\n    else {\n        if ((mont = BN_MONT_CTX_new()) == NULL)\n            goto err;\n        if (!BN_MONT_CTX_set(mont, m, ctx))\n            goto err;\n    }\n    r_is_one = 1;\n    w = a;\n    for (b = bits - 2; b >= 0; b--) {\n        next_w = w * w;\n        if ((next_w / w) != w) {\n            if (r_is_one) {\n                if (!BN_TO_MONTGOMERY_WORD(r, w, mont))\n                    goto err;\n                r_is_one = 0;\n            } else {\n                if (!BN_MOD_MUL_WORD(r, w, m))\n                    goto err;\n            }\n            next_w = 1;\n        }\n        w = next_w;\n        if (!r_is_one) {\n            if (!BN_mod_mul_montgomery(r, r, r, mont, ctx))\n                goto err;\n        }\n        if (BN_is_bit_set(p, b)) {\n            next_w = w * a;\n            if ((next_w / a) != w) {\n                if (r_is_one) {\n                    if (!BN_TO_MONTGOMERY_WORD(r, w, mont))\n                        goto err;\n                    r_is_one = 0;\n                } else {\n                    if (!BN_MOD_MUL_WORD(r, w, m))\n                        goto err;\n                }\n                next_w = a;\n            }\n            w = next_w;\n        }\n    }\n    if (w != 1) {\n        if (r_is_one) {\n            if (!BN_TO_MONTGOMERY_WORD(r, w, mont))\n                goto err;\n            r_is_one = 0;\n        } else {\n            if (!BN_MOD_MUL_WORD(r, w, m))\n                goto err;\n        }\n    }\n    if (r_is_one) {\n        if (!BN_one(rr))\n            goto err;\n    } else {\n        if (!BN_from_montgomery(rr, r, mont, ctx))\n            goto err;\n    }\n    ret = 1;\n err:\n    if ((in_mont == NULL) && (mont != NULL))\n        BN_MONT_CTX_free(mont);\n    BN_CTX_end(ctx);\n    bn_check_top(rr);\n    return (ret);\n}', 'int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int ret = 0;\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(m);\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (a == b) {\n        if (!BN_sqr(t, a, ctx))\n            goto err;\n    } else {\n        if (!BN_mul(t, a, b, ctx))\n            goto err;\n    }\n    if (!BN_nnmod(r, t, m, ctx))\n        goto err;\n    bn_check_top(r);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return (ret);\n}', 'int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    int top, al, bl;\n    BIGNUM *rr;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    int i;\n#endif\n#ifdef BN_RECURSION\n    BIGNUM *t = NULL;\n    int j = 0, k;\n#endif\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(r);\n    al = a->top;\n    bl = b->top;\n    if ((al == 0) || (bl == 0)) {\n        BN_zero(r);\n        return (1);\n    }\n    top = al + bl;\n    BN_CTX_start(ctx);\n    if ((r == a) || (r == b)) {\n        if ((rr = BN_CTX_get(ctx)) == NULL)\n            goto err;\n    } else\n        rr = r;\n    rr->neg = a->neg ^ b->neg;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    i = al - bl;\n#endif\n#ifdef BN_MUL_COMBA\n    if (i == 0) {\n# if 0\n        if (al == 4) {\n            if (bn_wexpand(rr, 8) == NULL)\n                goto err;\n            rr->top = 8;\n            bn_mul_comba4(rr->d, a->d, b->d);\n            goto end;\n        }\n# endif\n        if (al == 8) {\n            if (bn_wexpand(rr, 16) == NULL)\n                goto err;\n            rr->top = 16;\n            bn_mul_comba8(rr->d, a->d, b->d);\n            goto end;\n        }\n    }\n#endif\n#ifdef BN_RECURSION\n    if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {\n        if (i >= -1 && i <= 1) {\n            if (i >= 0) {\n                j = BN_num_bits_word((BN_ULONG)al);\n            }\n            if (i == -1) {\n                j = BN_num_bits_word((BN_ULONG)bl);\n            }\n            j = 1 << (j - 1);\n            assert(j <= al || j <= bl);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (t == NULL)\n                goto err;\n            if (al > j || bl > j) {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d,\n                                      j, al - j, bl - j, t->d);\n            } else {\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n# if 0\n        if (i == 1 && !BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n            BIGNUM *tmp_bn = (BIGNUM *)b;\n            if (bn_wexpand(tmp_bn, al) == NULL)\n                goto err;\n            tmp_bn->d[bl] = 0;\n            bl++;\n            i--;\n        } else if (i == -1 && !BN_get_flags(a, BN_FLG_STATIC_DATA)) {\n            BIGNUM *tmp_bn = (BIGNUM *)a;\n            if (bn_wexpand(tmp_bn, bl) == NULL)\n                goto err;\n            tmp_bn->d[al] = 0;\n            al++;\n            i++;\n        }\n        if (i == 0) {\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (al == j) {\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, al, t->d);\n            } else {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d, al - j, j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n# endif\n    }\n#endif\n    if (bn_wexpand(rr, top) == NULL)\n        goto err;\n    rr->top = top;\n    bn_mul_normal(rr->d, a->d, al, b->d, bl);\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n end:\n#endif\n    bn_correct_top(rr);\n    if (r != rr)\n        BN_copy(r, rr);\n    ret = 1;\n err:\n    bn_check_top(r);\n    BN_CTX_end(ctx);\n    return (ret);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("BN_CTX_end", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG_EXIT(ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']