crypto/ec/ec2_mult.c:347: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `gf2m_Mxy`.
Showing all 13 steps of the trace


crypto/ec/ec2_mult.c:264:1: Parameter `ctx->stack.depth`
262.    * avoiding conditional branches.
263.    */
264. > static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group,
265.                                                EC_POINT *r,
266.                                                const BIGNUM *scalar,

crypto/ec/ec2_mult.c:292:5: Call
290.        * Since point_multiply is static we can guarantee that ctx != NULL.
291.        */
292.       BN_CTX_start(ctx);
           ^
293.       x1 = BN_CTX_get(ctx);
294.       z1 = BN_CTX_get(ctx);

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

crypto/ec/ec2_mult.c:347:9: Call
345.   
346.       /* convert out of "projective" coordinates */
347.       i = gf2m_Mxy(group, point->X, point->Y, x1, z1, x2, z2, ctx);
               ^
348.       if (i == 0)
349.           goto err;

crypto/ec/ec2_mult.c:174:1: Parameter `ctx->stack.depth`
  172.    *     2 otherwise
  173.    */
  174. > static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y,
  175.                       BIGNUM *x1, BIGNUM *z1, BIGNUM *x2, BIGNUM *z2,
  176.                       BN_CTX *ctx)

crypto/ec/ec2_mult.c:196:5: Call
  194.   
  195.       /* Since Mxy is static we can guarantee that ctx != NULL. */
  196.       BN_CTX_start(ctx);
             ^
  197.       t3 = BN_CTX_get(ctx);
  198.       t4 = BN_CTX_get(ctx);

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

crypto/ec/ec2_mult.c:250:5: Call
  248.   
  249.    err:
  250.       BN_CTX_end(ctx);
             ^
  251.       return ret;
  252.   }

crypto/bn/bn_ctx.c:267:1: Parameter `ctx->stack.depth`
    265.   }
    266.   
    267. > void BN_CTX_end(BN_CTX *ctx)
    268.   {
    269.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:273:27: Call
    271.           ctx->err_stack--;
    272.       else {
    273.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                     ^
    274.           /* Does this stack frame have anything to release? */
    275.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:351:1: <LHS trace>
349.   }
350.   
351. > static unsigned int BN_STACK_pop(BN_STACK *st)
352.   {
353.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:351:1: Parameter `st->depth`
      349.   }
      350.   
      351. > static unsigned int BN_STACK_pop(BN_STACK *st)
      352.   {
      353.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:353:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `gf2m_Mxy` 
      351.   static unsigned int BN_STACK_pop(BN_STACK *st)
      352.   {
      353.       return st->indexes[--(st->depth)];
                        ^
      354.   }
      355.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group,\n                                             EC_POINT *r,\n                                             const BIGNUM *scalar,\n                                             const EC_POINT *point,\n                                             BN_CTX *ctx)\n{\n    BIGNUM *x1, *x2, *z1, *z2;\n    int ret = 0, i;\n    BN_ULONG mask, word;\n    if (r == point) {\n        ECerr(EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY, EC_R_INVALID_ARGUMENT);\n        return 0;\n    }\n    if ((scalar == NULL) || BN_is_zero(scalar) || (point == NULL) ||\n        EC_POINT_is_at_infinity(group, point)) {\n        return EC_POINT_set_to_infinity(group, r);\n    }\n    if (!point->Z_is_one)\n        return 0;\n    BN_CTX_start(ctx);\n    x1 = BN_CTX_get(ctx);\n    z1 = BN_CTX_get(ctx);\n    if (z1 == NULL)\n        goto err;\n    x2 = r->X;\n    z2 = r->Y;\n    bn_wexpand(x1, bn_get_top(group->field));\n    bn_wexpand(z1, bn_get_top(group->field));\n    bn_wexpand(x2, bn_get_top(group->field));\n    bn_wexpand(z2, bn_get_top(group->field));\n    if (!BN_GF2m_mod_arr(x1, point->X, group->poly))\n        goto err;\n    if (!BN_one(z1))\n        goto err;\n    if (!group->meth->field_sqr(group, z2, x1, ctx))\n        goto err;\n    if (!group->meth->field_sqr(group, x2, z2, ctx))\n        goto err;\n    if (!BN_GF2m_add(x2, x2, group->b))\n        goto err;\n    i = bn_get_top(scalar) - 1;\n    mask = BN_TBIT;\n    word = bn_get_words(scalar)[i];\n    while (!(word & mask))\n        mask >>= 1;\n    mask >>= 1;\n    if (!mask) {\n        i--;\n        mask = BN_TBIT;\n    }\n    for (; i >= 0; i--) {\n        word = bn_get_words(scalar)[i];\n        while (mask) {\n            BN_consttime_swap(word & mask, x1, x2, bn_get_top(group->field));\n            BN_consttime_swap(word & mask, z1, z2, bn_get_top(group->field));\n            if (!gf2m_Madd(group, point->X, x2, z2, x1, z1, ctx))\n                goto err;\n            if (!gf2m_Mdouble(group, x1, z1, ctx))\n                goto err;\n            BN_consttime_swap(word & mask, x1, x2, bn_get_top(group->field));\n            BN_consttime_swap(word & mask, z1, z2, bn_get_top(group->field));\n            mask >>= 1;\n        }\n        mask = BN_TBIT;\n    }\n    i = gf2m_Mxy(group, point->X, point->Y, x1, z1, x2, z2, ctx);\n    if (i == 0)\n        goto err;\n    else if (i == 1) {\n        if (!EC_POINT_set_to_infinity(group, r))\n            goto err;\n    } else {\n        if (!BN_one(r->Z))\n            goto err;\n        r->Z_is_one = 1;\n    }\n    BN_set_negative(r->X, 0);\n    BN_set_negative(r->Y, 0);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\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}', 'static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y,\n                    BIGNUM *x1, BIGNUM *z1, BIGNUM *x2, BIGNUM *z2,\n                    BN_CTX *ctx)\n{\n    BIGNUM *t3, *t4, *t5;\n    int ret = 0;\n    if (BN_is_zero(z1)) {\n        BN_zero(x2);\n        BN_zero(z2);\n        return 1;\n    }\n    if (BN_is_zero(z2)) {\n        if (!BN_copy(x2, x))\n            return 0;\n        if (!BN_GF2m_add(z2, x, y))\n            return 0;\n        return 2;\n    }\n    BN_CTX_start(ctx);\n    t3 = BN_CTX_get(ctx);\n    t4 = BN_CTX_get(ctx);\n    t5 = BN_CTX_get(ctx);\n    if (t5 == NULL)\n        goto err;\n    if (!BN_one(t5))\n        goto err;\n    if (!group->meth->field_mul(group, t3, z1, z2, ctx))\n        goto err;\n    if (!group->meth->field_mul(group, z1, z1, x, ctx))\n        goto err;\n    if (!BN_GF2m_add(z1, z1, x1))\n        goto err;\n    if (!group->meth->field_mul(group, z2, z2, x, ctx))\n        goto err;\n    if (!group->meth->field_mul(group, x1, z2, x1, ctx))\n        goto err;\n    if (!BN_GF2m_add(z2, z2, x2))\n        goto err;\n    if (!group->meth->field_mul(group, z2, z2, z1, ctx))\n        goto err;\n    if (!group->meth->field_sqr(group, t4, x, ctx))\n        goto err;\n    if (!BN_GF2m_add(t4, t4, y))\n        goto err;\n    if (!group->meth->field_mul(group, t4, t4, t3, ctx))\n        goto err;\n    if (!BN_GF2m_add(t4, t4, z2))\n        goto err;\n    if (!group->meth->field_mul(group, t3, t3, x, ctx))\n        goto err;\n    if (!group->meth->field_div(group, t3, t5, t3, ctx))\n        goto err;\n    if (!group->meth->field_mul(group, t4, t3, t4, ctx))\n        goto err;\n    if (!group->meth->field_mul(group, x2, x1, t3, ctx))\n        goto err;\n    if (!BN_GF2m_add(z2, x2, x))\n        goto err;\n    if (!group->meth->field_mul(group, z2, z2, t4, ctx))\n        goto err;\n    if (!BN_GF2m_add(z2, z2, y))\n        goto err;\n    ret = 2;\n err:\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}']