crypto/ecdsa/ecs_ossl.c:428: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul`.
Showing all 27 steps of the trace


crypto/ecdsa/ecs_ossl.c:402:10: Call
400.       }
401.       /* calculate tmp1 = inv(S) mod order */
402.       if (!BN_mod_inverse(u2, sig->s, order, ctx)) {
                ^
403.           ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);
404.           goto err;

crypto/bn/bn_gcd.c:231:10: Call
  229.       BIGNUM *rv;
  230.       int noinv;
  231.       rv = int_bn_mod_inverse(in, a, n, ctx, &noinv);
                  ^
  232.       if (noinv)
  233.           BNerr(BN_F_BN_MOD_INVERSE, BN_R_NO_INVERSE);

crypto/bn/bn_gcd.c:237:1: Parameter `ctx->stack.depth`
    235.   }
    236.   
    237. > BIGNUM *int_bn_mod_inverse(BIGNUM *in,
    238.                              const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,
    239.                              int *pnoinv)

crypto/bn/bn_gcd.c:256:5: Call
    254.       bn_check_top(n);
    255.   
    256.       BN_CTX_start(ctx);
               ^
    257.       A = BN_CTX_get(ctx);
    258.       B = BN_CTX_get(ctx);

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

crypto/bn/bn_gcd.c:548:5: Call
    546.       if ((ret == NULL) && (in == NULL))
    547.           BN_free(R);
    548.       BN_CTX_end(ctx);
               ^
    549.       bn_check_top(ret);
    550.       return (ret);

crypto/bn/bn_ctx.c:254:1: Parameter `ctx->stack.depth`
      252.   }
      253.   
      254. > void BN_CTX_end(BN_CTX *ctx)
      255.   {
      256.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/ecdsa/ecs_ossl.c:423:10: Call
421.       }
422.       /* u1 = m * tmp mod order */
423.       if (!BN_mod_mul(u1, m, u2, order, ctx)) {
                ^
424.           ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);
425.           goto err;

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:240:1: Parameter `ctx->stack.depth`
    238.   }
    239.   
    240. > void BN_CTX_start(BN_CTX *ctx)
    241.   {
    242.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_mod.c:204:5: Call
  202.       ret = 1;
  203.    err:
  204.       BN_CTX_end(ctx);
             ^
  205.       return (ret);
  206.   }

crypto/bn/bn_ctx.c:254:1: Parameter `ctx->stack.depth`
    252.   }
    253.   
    254. > void BN_CTX_end(BN_CTX *ctx)
    255.   {
    256.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/ecdsa/ecs_ossl.c:428:10: Call
426.       }
427.       /* u2 = r * w mod q */
428.       if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) {
                ^
429.           ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);
430.           goto err;

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:240:1: Parameter `ctx->stack.depth`
    238.   }
    239.   
    240. > void BN_CTX_start(BN_CTX *ctx)
    241.   {
    242.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_mod.c:193:14: Call
  191.           goto err;
  192.       if (a == b) {
  193.           if (!BN_sqr(t, a, ctx))
                      ^
  194.               goto err;
  195.       } else {

crypto/bn/bn_sqr.c:66:1: Parameter `ctx->stack.depth`
    64.    * I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96
    65.    */
    66. > int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    67.   {
    68.       int max, al;

crypto/bn/bn_sqr.c:81:5: Call
    79.       }
    80.   
    81.       BN_CTX_start(ctx);
              ^
    82.       rr = (a != r) ? r : BN_CTX_get(ctx);
    83.       tmp = BN_CTX_get(ctx);

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

crypto/bn/bn_sqr.c:148:5: Call
    146.       bn_check_top(rr);
    147.       bn_check_top(tmp);
    148.       BN_CTX_end(ctx);
               ^
    149.       return (ret);
    150.   }

crypto/bn/bn_ctx.c:254:1: Parameter `ctx->stack.depth`
      252.   }
      253.   
      254. > void BN_CTX_end(BN_CTX *ctx)
      255.   {
      256.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:260:27: Call
      258.           ctx->err_stack--;
      259.       else {
      260.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                       ^
      261.           /* Does this stack frame have anything to release? */
      262.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:330:1: <LHS trace>
328.   }
329.   
330. > static unsigned int BN_STACK_pop(BN_STACK *st)
331.   {
332.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:330:1: Parameter `st->depth`
        328.   }
        329.   
        330. > static unsigned int BN_STACK_pop(BN_STACK *st)
        331.   {
        332.       return st->indexes[--(st->depth)];

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

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len,\n                           const ECDSA_SIG *sig, EC_KEY *eckey)\n{\n    int ret = -1, i;\n    BN_CTX *ctx;\n    BIGNUM *order, *u1, *u2, *m, *X;\n    EC_POINT *point = NULL;\n    const EC_GROUP *group;\n    const EC_POINT *pub_key;\n    if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL ||\n        (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ECDSA_R_MISSING_PARAMETERS);\n        return -1;\n    }\n    ctx = BN_CTX_new();\n    if (!ctx) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_MALLOC_FAILURE);\n        return -1;\n    }\n    BN_CTX_start(ctx);\n    order = BN_CTX_get(ctx);\n    u1 = BN_CTX_get(ctx);\n    u2 = BN_CTX_get(ctx);\n    m = BN_CTX_get(ctx);\n    X = BN_CTX_get(ctx);\n    if (!X) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (!EC_GROUP_get_order(group, order, ctx)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (BN_is_zero(sig->r) || BN_is_negative(sig->r) ||\n        BN_ucmp(sig->r, order) >= 0 || BN_is_zero(sig->s) ||\n        BN_is_negative(sig->s) || BN_ucmp(sig->s, order) >= 0) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ECDSA_R_BAD_SIGNATURE);\n        ret = 0;\n        goto err;\n    }\n    if (!BN_mod_inverse(u2, sig->s, order, ctx)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    i = BN_num_bits(order);\n    if (8 * dgst_len > i)\n        dgst_len = (i + 7) / 8;\n    if (!BN_bin2bn(dgst, dgst_len, m)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (!BN_mod_mul(u1, m, u2, order, ctx)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((point = EC_POINT_new(group)) == NULL) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!EC_POINT_mul(group, point, u1, pub_key, u2, ctx)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==\n        NID_X9_62_prime_field) {\n        if (!EC_POINT_get_affine_coordinates_GFp(group, point, X, NULL, ctx)) {\n            ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB);\n            goto err;\n        }\n    }\n#ifndef OPENSSL_NO_EC2M\n    else {\n        if (!EC_POINT_get_affine_coordinates_GF2m(group, point, X, NULL, ctx)) {\n            ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB);\n            goto err;\n        }\n    }\n#endif\n    if (!BN_nnmod(u1, X, order, ctx)) {\n        ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);\n        goto err;\n    }\n    ret = (BN_ucmp(u1, sig->r) == 0);\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    EC_POINT_free(point);\n    return ret;\n}', 'BIGNUM *BN_mod_inverse(BIGNUM *in,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)\n{\n    BIGNUM *rv;\n    int noinv;\n    rv = int_bn_mod_inverse(in, a, n, ctx, &noinv);\n    if (noinv)\n        BNerr(BN_F_BN_MOD_INVERSE, BN_R_NO_INVERSE);\n    return rv;\n}', 'BIGNUM *int_bn_mod_inverse(BIGNUM *in,\n                           const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,\n                           int *pnoinv)\n{\n    BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL;\n    BIGNUM *ret = NULL;\n    int sign;\n    if (pnoinv)\n        *pnoinv = 0;\n    if ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0)\n        || (BN_get_flags(n, BN_FLG_CONSTTIME) != 0)) {\n        return BN_mod_inverse_no_branch(in, a, n, ctx);\n    }\n    bn_check_top(a);\n    bn_check_top(n);\n    BN_CTX_start(ctx);\n    A = BN_CTX_get(ctx);\n    B = BN_CTX_get(ctx);\n    X = BN_CTX_get(ctx);\n    D = BN_CTX_get(ctx);\n    M = BN_CTX_get(ctx);\n    Y = BN_CTX_get(ctx);\n    T = BN_CTX_get(ctx);\n    if (T == NULL)\n        goto err;\n    if (in == NULL)\n        R = BN_new();\n    else\n        R = in;\n    if (R == NULL)\n        goto err;\n    BN_one(X);\n    BN_zero(Y);\n    if (BN_copy(B, a) == NULL)\n        goto err;\n    if (BN_copy(A, n) == NULL)\n        goto err;\n    A->neg = 0;\n    if (B->neg || (BN_ucmp(B, A) >= 0)) {\n        if (!BN_nnmod(B, B, A, ctx))\n            goto err;\n    }\n    sign = -1;\n    if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048))) {\n        int shift;\n        while (!BN_is_zero(B)) {\n            shift = 0;\n            while (!BN_is_bit_set(B, shift)) {\n                shift++;\n                if (BN_is_odd(X)) {\n                    if (!BN_uadd(X, X, n))\n                        goto err;\n                }\n                if (!BN_rshift1(X, X))\n                    goto err;\n            }\n            if (shift > 0) {\n                if (!BN_rshift(B, B, shift))\n                    goto err;\n            }\n            shift = 0;\n            while (!BN_is_bit_set(A, shift)) {\n                shift++;\n                if (BN_is_odd(Y)) {\n                    if (!BN_uadd(Y, Y, n))\n                        goto err;\n                }\n                if (!BN_rshift1(Y, Y))\n                    goto err;\n            }\n            if (shift > 0) {\n                if (!BN_rshift(A, A, shift))\n                    goto err;\n            }\n            if (BN_ucmp(B, A) >= 0) {\n                if (!BN_uadd(X, X, Y))\n                    goto err;\n                if (!BN_usub(B, B, A))\n                    goto err;\n            } else {\n                if (!BN_uadd(Y, Y, X))\n                    goto err;\n                if (!BN_usub(A, A, B))\n                    goto err;\n            }\n        }\n    } else {\n        while (!BN_is_zero(B)) {\n            BIGNUM *tmp;\n            if (BN_num_bits(A) == BN_num_bits(B)) {\n                if (!BN_one(D))\n                    goto err;\n                if (!BN_sub(M, A, B))\n                    goto err;\n            } else if (BN_num_bits(A) == BN_num_bits(B) + 1) {\n                if (!BN_lshift1(T, B))\n                    goto err;\n                if (BN_ucmp(A, T) < 0) {\n                    if (!BN_one(D))\n                        goto err;\n                    if (!BN_sub(M, A, B))\n                        goto err;\n                } else {\n                    if (!BN_sub(M, A, T))\n                        goto err;\n                    if (!BN_add(D, T, B))\n                        goto err;\n                    if (BN_ucmp(A, D) < 0) {\n                        if (!BN_set_word(D, 2))\n                            goto err;\n                    } else {\n                        if (!BN_set_word(D, 3))\n                            goto err;\n                        if (!BN_sub(M, M, B))\n                            goto err;\n                    }\n                }\n            } else {\n                if (!BN_div(D, M, A, B, ctx))\n                    goto err;\n            }\n            tmp = A;\n            A = B;\n            B = M;\n            if (BN_is_one(D)) {\n                if (!BN_add(tmp, X, Y))\n                    goto err;\n            } else {\n                if (BN_is_word(D, 2)) {\n                    if (!BN_lshift1(tmp, X))\n                        goto err;\n                } else if (BN_is_word(D, 4)) {\n                    if (!BN_lshift(tmp, X, 2))\n                        goto err;\n                } else if (D->top == 1) {\n                    if (!BN_copy(tmp, X))\n                        goto err;\n                    if (!BN_mul_word(tmp, D->d[0]))\n                        goto err;\n                } else {\n                    if (!BN_mul(tmp, D, X, ctx))\n                        goto err;\n                }\n                if (!BN_add(tmp, tmp, Y))\n                    goto err;\n            }\n            M = Y;\n            Y = X;\n            X = tmp;\n            sign = -sign;\n        }\n    }\n    if (sign < 0) {\n        if (!BN_sub(Y, n, Y))\n            goto err;\n    }\n    if (BN_is_one(A)) {\n        if (!Y->neg && BN_ucmp(Y, n) < 0) {\n            if (!BN_copy(R, Y))\n                goto err;\n        } else {\n            if (!BN_nnmod(R, Y, n, ctx))\n                goto err;\n        }\n    } else {\n        if (pnoinv)\n            *pnoinv = 1;\n        goto err;\n    }\n    ret = R;\n err:\n    if ((ret == NULL) && (in == NULL))\n        BN_free(R);\n    BN_CTX_end(ctx);\n    bn_check_top(ret);\n    return (ret);\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}', '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}', '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_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int max, al;\n    int ret = 0;\n    BIGNUM *tmp, *rr;\n    bn_check_top(a);\n    al = a->top;\n    if (al <= 0) {\n        r->top = 0;\n        r->neg = 0;\n        return 1;\n    }\n    BN_CTX_start(ctx);\n    rr = (a != r) ? r : BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (!rr || !tmp)\n        goto err;\n    max = 2 * al;\n    if (bn_wexpand(rr, max) == NULL)\n        goto err;\n    if (al == 4) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[8];\n        bn_sqr_normal(rr->d, a->d, 4, t);\n#else\n        bn_sqr_comba4(rr->d, a->d);\n#endif\n    } else if (al == 8) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[16];\n        bn_sqr_normal(rr->d, a->d, 8, t);\n#else\n        bn_sqr_comba8(rr->d, a->d);\n#endif\n    } else {\n#if defined(BN_RECURSION)\n        if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) {\n            BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL * 2];\n            bn_sqr_normal(rr->d, a->d, al, t);\n        } else {\n            int j, k;\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            if (al == j) {\n                if (bn_wexpand(tmp, k * 2) == NULL)\n                    goto err;\n                bn_sqr_recursive(rr->d, a->d, al, tmp->d);\n            } else {\n                if (bn_wexpand(tmp, max) == NULL)\n                    goto err;\n                bn_sqr_normal(rr->d, a->d, al, tmp->d);\n            }\n        }\n#else\n        if (bn_wexpand(tmp, max) == NULL)\n            goto err;\n        bn_sqr_normal(rr->d, a->d, al, tmp->d);\n#endif\n    }\n    rr->neg = 0;\n    if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n        rr->top = max - 1;\n    else\n        rr->top = max;\n    if (rr != r)\n        BN_copy(r, rr);\n    ret = 1;\n err:\n    bn_check_top(rr);\n    bn_check_top(tmp);\n    BN_CTX_end(ctx);\n    return (ret);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']