crypto/rsa/rsa_ossl.c:450: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `rsa_blinding_invert`.
Showing all 20 steps of the trace


crypto/rsa/rsa_ossl.c:358:5: Call
356.       if ((ctx = BN_CTX_new()) == NULL)
357.           goto err;
358.       BN_CTX_start(ctx);
           ^
359.       f = BN_CTX_get(ctx);
360.       ret = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:236:1: Parameter `ctx->stack.depth`
  234.   }
  235.   
  236. > void BN_CTX_start(BN_CTX *ctx)
  237.   {
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/rsa/rsa_ossl.c:450:14: Call
448.   
449.       if (blinding)
450.           if (!rsa_blinding_invert(blinding, ret, unblind, ctx))
                    ^
451.               goto err;
452.   

crypto/rsa/rsa_ossl.c:325:1: Parameter `ctx->stack.depth`
  323.   }
  324.   
  325. > static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,
  326.                                  BN_CTX *ctx)
  327.   {

crypto/rsa/rsa_ossl.c:336:12: Call
  334.        * to access the blinding without a lock.
  335.        */
  336.       return BN_BLINDING_invert_ex(f, unblind, b, ctx);
                    ^
  337.   }
  338.   

crypto/bn/bn_blind.c:254:1: Parameter `ctx->stack.depth`
    252.   }
    253.   
    254. > int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
    255.                             BN_CTX *ctx)
    256.   {

crypto/bn/bn_blind.c:262:15: Call
    260.   
    261.       if (r != NULL)
    262.           ret = BN_mod_mul(n, n, r, b->mod, ctx);
                         ^
    263.       else {
    264.           if (b->Ai == NULL) {

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:236:1: Parameter `ctx->stack.depth`
        234.   }
        235.   
        236. > void BN_CTX_start(BN_CTX *ctx)
        237.   {
        238.       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:236:1: Parameter `ctx->stack.depth`
          234.   }
          235.   
          236. > void BN_CTX_start(BN_CTX *ctx)
          237.   {
          238.       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:250:1: Parameter `ctx->stack.depth`
          248.   }
          249.   
          250. > void BN_CTX_end(BN_CTX *ctx)
          251.   {
          252.       CTXDBG_ENTRY("BN_CTX_end", ctx);

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

crypto/bn/bn_ctx.c:326:1: <LHS trace>
324.   }
325.   
326. > static unsigned int BN_STACK_pop(BN_STACK *st)
327.   {
328.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:326:1: Parameter `st->depth`
            324.   }
            325.   
            326. > static unsigned int BN_STACK_pop(BN_STACK *st)
            327.   {
            328.       return st->indexes[--(st->depth)];

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

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int rsa_ossl_private_encrypt(int flen, const unsigned char *from,\n                                   unsigned char *to, RSA *rsa, int padding)\n{\n    BIGNUM *f, *ret, *res;\n    int i, j, k, num = 0, r = -1;\n    unsigned char *buf = NULL;\n    BN_CTX *ctx = NULL;\n    int local_blinding = 0;\n    BIGNUM *unblind = NULL;\n    BN_BLINDING *blinding = NULL;\n    if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n    BN_CTX_start(ctx);\n    f = BN_CTX_get(ctx);\n    ret = BN_CTX_get(ctx);\n    num = BN_num_bytes(rsa->n);\n    buf = OPENSSL_malloc(num);\n    if (f == NULL || ret == NULL || buf == NULL) {\n        RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    switch (padding) {\n    case RSA_PKCS1_PADDING:\n        i = RSA_padding_add_PKCS1_type_1(buf, num, from, flen);\n        break;\n    case RSA_X931_PADDING:\n        i = RSA_padding_add_X931(buf, num, from, flen);\n        break;\n    case RSA_NO_PADDING:\n        i = RSA_padding_add_none(buf, num, from, flen);\n        break;\n    case RSA_SSLV23_PADDING:\n    default:\n        RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE);\n        goto err;\n    }\n    if (i <= 0)\n        goto err;\n    if (BN_bin2bn(buf, num, f) == NULL)\n        goto err;\n    if (BN_ucmp(f, rsa->n) >= 0) {\n        RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT,\n               RSA_R_DATA_TOO_LARGE_FOR_MODULUS);\n        goto err;\n    }\n    if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {\n        blinding = rsa_get_blinding(rsa, &local_blinding, ctx);\n        if (blinding == NULL) {\n            RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n    }\n    if (blinding != NULL) {\n        if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) {\n            RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        if (!rsa_blinding_convert(blinding, f, unblind, ctx))\n            goto err;\n    }\n    if ((rsa->flags & RSA_FLAG_EXT_PKEY) ||\n        ((rsa->p != NULL) &&\n         (rsa->q != NULL) &&\n         (rsa->dmp1 != NULL) && (rsa->dmq1 != NULL) && (rsa->iqmp != NULL))) {\n        if (!rsa->meth->rsa_mod_exp(ret, f, rsa, ctx))\n            goto err;\n    } else {\n        BIGNUM *d = NULL, *local_d = NULL;\n        if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) {\n            local_d = d = BN_new();\n            if (d == NULL) {\n                RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME);\n        } else {\n            d = rsa->d;\n        }\n        if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)\n            if (!BN_MONT_CTX_set_locked\n                (&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) {\n                BN_free(local_d);\n                goto err;\n            }\n        if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx,\n                                   rsa->_method_mod_n)) {\n            BN_free(local_d);\n            goto err;\n        }\n        BN_free(local_d);\n    }\n    if (blinding)\n        if (!rsa_blinding_invert(blinding, ret, unblind, ctx))\n            goto err;\n    if (padding == RSA_X931_PADDING) {\n        BN_sub(f, rsa->n, ret);\n        if (BN_cmp(ret, f) > 0)\n            res = f;\n        else\n            res = ret;\n    } else\n        res = ret;\n    j = BN_num_bytes(res);\n    i = BN_bn2bin(res, &(to[num - j]));\n    for (k = 0; k < (num - i); k++)\n        to[k] = 0;\n    r = num;\n err:\n    if (ctx != NULL)\n        BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    OPENSSL_clear_free(buf, num);\n    return (r);\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 rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,\n                               BN_CTX *ctx)\n{\n    return BN_BLINDING_invert_ex(f, unblind, b, ctx);\n}', 'int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *ctx)\n{\n    int ret;\n    bn_check_top(n);\n    if (r != NULL)\n        ret = BN_mod_mul(n, n, r, b->mod, ctx);\n    else {\n        if (b->Ai == NULL) {\n            BNerr(BN_F_BN_BLINDING_INVERT_EX, BN_R_NOT_INITIALIZED);\n            return (0);\n        }\n        ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);\n    }\n    bn_check_top(n);\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_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}', '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}']