crypto/bn/bn_rsa_fips186_4.c:215: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `bn_rsa_fips186_4_derive_prime`.
Showing all 16 steps of the trace


crypto/bn/bn_rsa_fips186_4.c:208:17: Call
206.       /* (Steps 4.2/5.2) - find first auxiliary probable primes */
207.       if (!bn_rsa_fips186_4_find_aux_prob_prime(Xp1i, p1i, ctx, cb)
208.               || !bn_rsa_fips186_4_find_aux_prob_prime(Xp2i, p2i, ctx, cb))
                       ^
209.           goto err;
210.       /* (Table B.1) auxiliary prime Max length check */

crypto/bn/bn_rsa_fips186_4.c:120:1: Parameter `ctx->stack.depth`
  118.    * Returns: 1 on success otherwise it returns 0.
  119.    */
  120. > static int bn_rsa_fips186_4_find_aux_prob_prime(const BIGNUM *Xp1,
  121.                                                   BIGNUM *p1, BN_CTX *ctx,
  122.                                                   BN_GENCB *cb)

crypto/bn/bn_rsa_fips186_4.c:215:10: Call
213.           goto err;
214.       /* (Steps 4.3/5.3) - generate prime */
215.       if (!bn_rsa_fips186_4_derive_prime(p, Xpout, Xp, p1i, p2i, nlen, e, ctx, cb))
                ^
216.           goto err;
217.       ret = 1;

crypto/bn/bn_rsa_fips186_4.c:253:1: Parameter `ctx->stack.depth`
  251.    *     Y, X, r1, r2, e are not NULL.
  252.    */
  253. > int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
  254.                                     const BIGNUM *r1, const BIGNUM *r2, int nlen,
  255.                                     const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb)

crypto/bn/bn_rsa_fips186_4.c:265:5: Call
  263.       if (checks == 0)
  264.           return 0;
  265.       BN_CTX_start(ctx);
             ^
  266.   
  267.       R = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:171:1: Parameter `ctx->stack.depth`
    169.   }
    170.   
    171. > void BN_CTX_start(BN_CTX *ctx)
    172.   {
    173.       CTXDBG("ENTER BN_CTX_start()", ctx);

crypto/bn/bn_rsa_fips186_4.c:280:16: Call
  278.       if (!(BN_lshift1(r1x2, r1)
  279.               /* (Step 1) GCD(2r1, r2) = 1 */
  280.               && BN_gcd(tmp, r1x2, r2, ctx)
                        ^
  281.               && BN_is_one(tmp)
  282.               /* (Step 2) R = ((r2^-1 mod 2r1) * r2) - ((2r1^-1 mod r2)*2r1) */

crypto/bn/bn_gcd.c:15:1: Parameter `ctx->stack.depth`
    13.   static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
    14.   
    15. > int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)
    16.   {
    17.       BIGNUM *a, *b, *t;

crypto/bn/bn_gcd.c:23:5: Call
    21.       bn_check_top(in_b);
    22.   
    23.       BN_CTX_start(ctx);
              ^
    24.       a = BN_CTX_get(ctx);
    25.       b = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:171:1: Parameter `ctx->stack.depth`
      169.   }
      170.   
      171. > void BN_CTX_start(BN_CTX *ctx)
      172.   {
      173.       CTXDBG("ENTER BN_CTX_start()", ctx);

crypto/bn/bn_gcd.c:49:5: Call
    47.       ret = 1;
    48.    err:
    49.       BN_CTX_end(ctx);
              ^
    50.       bn_check_top(r);
    51.       return ret;

crypto/bn/bn_ctx.c:185:1: Parameter `ctx->stack.depth`
      183.   }
      184.   
      185. > void BN_CTX_end(BN_CTX *ctx)
      186.   {
      187.       if (ctx == NULL)

crypto/bn/bn_ctx.c:193:27: Call
      191.           ctx->err_stack--;
      192.       else {
      193.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                       ^
      194.           /* Does this stack frame have anything to release? */
      195.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:268:1: <LHS trace>
266.   }
267.   
268. > static unsigned int BN_STACK_pop(BN_STACK *st)
269.   {
270.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:268:1: Parameter `st->depth`
        266.   }
        267.   
        268. > static unsigned int BN_STACK_pop(BN_STACK *st)
        269.   {
        270.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:270:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `bn_rsa_fips186_4_derive_prime` 
        268.   static unsigned int BN_STACK_pop(BN_STACK *st)
        269.   {
        270.       return st->indexes[--(st->depth)];
                          ^
        271.   }
        272.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout,\n                                     BIGNUM *p1, BIGNUM *p2,\n                                     const BIGNUM *Xp, const BIGNUM *Xp1,\n                                     const BIGNUM *Xp2, int nlen,\n                                     const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb)\n{\n    int ret = 0;\n    BIGNUM *p1i = NULL, *p2i = NULL, *Xp1i = NULL, *Xp2i = NULL;\n    int bitlen;\n    if (p == NULL || Xpout == NULL)\n        return 0;\n    BN_CTX_start(ctx);\n    p1i = (p1 != NULL) ? p1 : BN_CTX_get(ctx);\n    p2i = (p2 != NULL) ? p2 : BN_CTX_get(ctx);\n    Xp1i = (Xp1 != NULL) ? (BIGNUM *)Xp1 : BN_CTX_get(ctx);\n    Xp2i = (Xp2 != NULL) ? (BIGNUM *)Xp2 : BN_CTX_get(ctx);\n    if (p1i == NULL || p2i == NULL || Xp1i == NULL || Xp2i == NULL)\n        goto err;\n    bitlen = bn_rsa_fips186_4_aux_prime_min_size(nlen);\n    if (bitlen == 0)\n        goto err;\n    if (Xp1 == NULL) {\n        if (!BN_priv_rand(Xp1i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))\n            goto err;\n    }\n    if (Xp2 == NULL) {\n        if (!BN_priv_rand(Xp2i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))\n            goto err;\n    }\n    if (!bn_rsa_fips186_4_find_aux_prob_prime(Xp1i, p1i, ctx, cb)\n            || !bn_rsa_fips186_4_find_aux_prob_prime(Xp2i, p2i, ctx, cb))\n        goto err;\n    if ((BN_num_bits(p1i) + BN_num_bits(p2i)) >=\n            bn_rsa_fips186_4_aux_prime_max_sum_size_for_prob_primes(nlen))\n        goto err;\n    if (!bn_rsa_fips186_4_derive_prime(p, Xpout, Xp, p1i, p2i, nlen, e, ctx, cb))\n        goto err;\n    ret = 1;\nerr:\n    if (p1 == NULL)\n        BN_clear(p1i);\n    if (p2 == NULL)\n        BN_clear(p2i);\n    if (Xp1 == NULL)\n        BN_clear(Xp1i);\n    if (Xp2 == NULL)\n        BN_clear(Xp2i);\n    BN_CTX_end(ctx);\n    return ret;\n}', 'static int bn_rsa_fips186_4_find_aux_prob_prime(const BIGNUM *Xp1,\n                                                BIGNUM *p1, BN_CTX *ctx,\n                                                BN_GENCB *cb)\n{\n    int ret = 0;\n    int i = 0;\n    int checks = bn_rsa_fips186_4_aux_prime_MR_min_checks(BN_num_bits(Xp1));\n    if (checks == 0 || BN_copy(p1, Xp1) == NULL)\n        return 0;\n    for(;;) {\n        i++;\n        BN_GENCB_call(cb, 0, i);\n        if (BN_is_prime_fasttest_ex(p1, checks, ctx, 1, cb))\n            break;\n        if (!BN_add_word(p1, 2))\n            goto err;\n    }\n    BN_GENCB_call(cb, 2, i);\n    ret = 1;\nerr:\n    return ret;\n}', 'int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,\n                                  const BIGNUM *r1, const BIGNUM *r2, int nlen,\n                                  const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb)\n{\n    int ret = 0;\n    int i, imax;\n    int bits = nlen >> 1;\n    int checks = bn_rsa_fips186_4_prime_MR_min_checks(nlen);\n    BIGNUM *tmp, *R, *r1r2x2, *y1, *r1x2;\n    if (checks == 0)\n        return 0;\n    BN_CTX_start(ctx);\n    R = BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    r1r2x2 = BN_CTX_get(ctx);\n    y1 = BN_CTX_get(ctx);\n    r1x2 = BN_CTX_get(ctx);\n    if (r1x2 == NULL)\n        goto err;\n    if (Xin != NULL && BN_copy(X, Xin) == NULL)\n        goto err;\n    if (!(BN_lshift1(r1x2, r1)\n            && BN_gcd(tmp, r1x2, r2, ctx)\n            && BN_is_one(tmp)\n            && BN_mod_inverse(R, r2, r1x2, ctx)\n            && BN_mul(R, R, r2, ctx)\n            && BN_mod_inverse(tmp, r1x2, r2, ctx)\n            && BN_mul(tmp, tmp, r1x2, ctx)\n            && BN_sub(R, R, tmp)\n            && BN_mul(r1r2x2, r1x2, r2, ctx)))\n        goto err;\n    if (BN_is_negative(R) && !BN_add(R, R, r1r2x2))\n        goto err;\n    imax = 5 * bits;\n    for (;;) {\n        if (Xin == NULL) {\n            if (!BN_priv_rand(X, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))\n                goto end;\n        }\n        if (!BN_mod_sub(Y, R, X, r1r2x2, ctx) || !BN_add(Y, Y, X))\n            goto err;\n        i = 0;\n        for (;;) {\n            if (BN_num_bits(Y) > bits) {\n                if (Xin == NULL)\n                    break;\n                else\n                    goto err;\n            }\n            BN_GENCB_call(cb, 0, 2);\n            if (BN_copy(y1, Y) == NULL\n                    || !BN_sub_word(y1, 1)\n                    || !BN_gcd(tmp, y1, e, ctx))\n                goto err;\n            if (BN_is_one(tmp)\n                    && BN_is_prime_fasttest_ex(Y, checks, ctx, 1, cb))\n                goto end;\n            if (++i >= imax || !BN_add(Y, Y, r1r2x2))\n                goto err;\n        }\n    }\nend:\n    ret = 1;\n    BN_GENCB_call(cb, 3, 0);\nerr:\n    BN_clear(y1);\n    BN_CTX_end(ctx);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER 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("LEAVE BN_CTX_start()", ctx);\n}', 'int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)\n{\n    BIGNUM *a, *b, *t;\n    int ret = 0;\n    bn_check_top(in_a);\n    bn_check_top(in_b);\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    if (b == NULL)\n        goto err;\n    if (BN_copy(a, in_a) == NULL)\n        goto err;\n    if (BN_copy(b, in_b) == NULL)\n        goto err;\n    a->neg = 0;\n    b->neg = 0;\n    if (BN_cmp(a, b) < 0) {\n        t = a;\n        a = b;\n        b = t;\n    }\n    t = euclid(a, b);\n    if (t == NULL)\n        goto err;\n    if (BN_copy(r, t) == NULL)\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return ret;\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    CTXDBG("ENTER 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("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']