crypto/ec/ecdsa_ossl.c:260: error: INTEGER_OVERFLOW_L2
  ([1, +oo] - [-125, 127]):unsigned64 by call to `ecdsa_sign_setup`.
Showing all 11 steps of the trace


crypto/ec/ecdsa_ossl.c:194:1: Parameter `dgst_len`
192.   }
193.   
194. > ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
195.                                  const BIGNUM *in_kinv, const BIGNUM *in_r,
196.                                  EC_KEY *eckey)

crypto/ec/ecdsa_ossl.c:260:18: Call
258.       do {
259.           if (in_kinv == NULL || in_r == NULL) {
260.               if (!ecdsa_sign_setup(eckey, ctx, &kinv, &ret->r, dgst, dgst_len)) {
                        ^
261.                   ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_ECDSA_LIB);
262.                   goto err;

crypto/ec/ecdsa_ossl.c:34:1: Parameter `dlen`
  32.   }
  33.   
  34. > static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
  35.                               BIGNUM **kinvp, BIGNUM **rp,
  36.                               const unsigned char *dgst, int dlen)

crypto/ec/ecdsa_ossl.c:84:22: Call
  82.           do
  83.               if (dgst != NULL) {
  84.                   if (!BN_generate_dsa_nonce
                             ^
  85.                       (k, order, EC_KEY_get0_private_key(eckey), dgst, dlen,
  86.                        ctx)) {

crypto/bn/bn_rand.c:192:1: Parameter `message_len`
    190.    * used.
    191.    */
    192. > int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
    193.                             const BIGNUM *priv, const unsigned char *message,
    194.                             size_t message_len, BN_CTX *ctx)

crypto/bn/bn_rand.c:234:9: Call
    232.           SHA512_Update(&sha, &done, sizeof(done));
    233.           SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
    234.           SHA512_Update(&sha, message, message_len);
                   ^
    235.           SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
    236.           SHA512_Final(digest, &sha);

crypto/sha/sha512.c:188:1: <LHS trace>
186.   }
187.   
188. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
189.   {
190.       SHA_LONG64 l;

crypto/sha/sha512.c:188:1: Parameter `len`
      186.   }
      187.   
      188. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
      189.   {
      190.       SHA_LONG64 l;

crypto/sha/sha512.c:188:1: <RHS trace>
186.   }
187.   
188. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
189.   {
190.       SHA_LONG64 l;

crypto/sha/sha512.c:188:1: Parameter `len`
      186.   }
      187.   
      188. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
      189.   {
      190.       SHA_LONG64 l;

crypto/sha/sha512.c:212:13: Binary operation: ([1, +oo] - [-125, 127]):unsigned64 by call to `ecdsa_sign_setup` 
      210.           } else {
      211.               memcpy(p + c->num, data, n), c->num = 0;
      212.               len -= n, data += n;
                         ^
      213.               sha512_block_data_order(c, p, 1);
      214.           }

int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
{
    SHA_LONG64 l;
    unsigned char *p = c->u.p;
    const unsigned char *data = (const unsigned char *)_data;
    if (len == 0)
        return 1;
    l = (c->Nl + (((SHA_LONG64) len) << 3)) & U64(0xffffffffffffffff);
    if (l < c->Nl)
        c->Nh++;
    if (sizeof(len) >= 8)
        c->Nh += (((SHA_LONG64) len) >> 61);
    c->Nl = l;
    if (c->num != 0) {
        size_t n = sizeof(c->u) - c->num;
        if (len < n) {
            memcpy(p + c->num, data, len), c->num += (unsigned int)len;
            return 1;
        } else {
            memcpy(p + c->num, data, n), c->num = 0;
            len -= n, data += n;
            sha512_block_data_order(c, p, 1);
        }
    }
    if (len >= sizeof(c->u)) {
#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
        if ((size_t)data % sizeof(c->u.d[0]) != 0)
            while (len >= sizeof(c->u))
                memcpy(p, data, sizeof(c->u)),
                    sha512_block_data_order(c, p, 1),
                    len -= sizeof(c->u), data += sizeof(c->u);
        else
#endif
            sha512_block_data_order(c, data, len / sizeof(c->u)),
                data += len, len %= sizeof(c->u), data -= len;
    }
    if (len != 0)
        memcpy(p, data, len), c->num = (int)len;
    return 1;
}
['ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,\n                               const BIGNUM *in_kinv, const BIGNUM *in_r,\n                               EC_KEY *eckey)\n{\n    int ok = 0, i;\n    BIGNUM *kinv = NULL, *s, *m = NULL, *tmp = NULL;\n    const BIGNUM *order, *ckinv;\n    BN_CTX *ctx = NULL;\n    const EC_GROUP *group;\n    ECDSA_SIG *ret;\n    const BIGNUM *priv_key;\n    group = EC_KEY_get0_group(eckey);\n    priv_key = EC_KEY_get0_private_key(eckey);\n    if (group == NULL || priv_key == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_PASSED_NULL_PARAMETER);\n        return NULL;\n    }\n    if (!EC_KEY_can_sign(eckey)) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING);\n        return NULL;\n    }\n    ret = ECDSA_SIG_new();\n    if (ret == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->r = BN_new();\n    ret->s = BN_new();\n    if (ret->r == NULL || ret->s == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    s = ret->s;\n    if ((ctx = BN_CTX_new()) == NULL ||\n        (tmp = BN_new()) == NULL || (m = BN_new()) == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    order = EC_GROUP_get0_order(group);\n    if (order == NULL) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_EC_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        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) {\n        ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_BN_LIB);\n        goto err;\n    }\n    do {\n        if (in_kinv == NULL || in_r == NULL) {\n            if (!ecdsa_sign_setup(eckey, ctx, &kinv, &ret->r, dgst, dgst_len)) {\n                ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_ECDSA_LIB);\n                goto err;\n            }\n            ckinv = kinv;\n        } else {\n            ckinv = in_kinv;\n            if (BN_copy(ret->r, in_r) == NULL) {\n                ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n        }\n        if (!BN_mod_mul(tmp, priv_key, ret->r, order, ctx)) {\n            ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!BN_mod_add_quick(s, tmp, m, order)) {\n            ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!BN_mod_mul(s, s, ckinv, order, ctx)) {\n            ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (BN_is_zero(s)) {\n            if (in_kinv != NULL && in_r != NULL) {\n                ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, EC_R_NEED_NEW_SETUP_VALUES);\n                goto err;\n            }\n        } else\n            break;\n    }\n    while (1);\n    ok = 1;\n err:\n    if (!ok) {\n        ECDSA_SIG_free(ret);\n        ret = NULL;\n    }\n    BN_CTX_free(ctx);\n    BN_clear_free(m);\n    BN_clear_free(tmp);\n    BN_clear_free(kinv);\n    return ret;\n}', 'static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,\n                            BIGNUM **kinvp, BIGNUM **rp,\n                            const unsigned char *dgst, int dlen)\n{\n    BN_CTX *ctx = NULL;\n    BIGNUM *k = NULL, *r = NULL, *X = NULL;\n    const BIGNUM *order;\n    EC_POINT *tmp_point = NULL;\n    const EC_GROUP *group;\n    int ret = 0;\n    if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) {\n        ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    if (!EC_KEY_can_sign(eckey)) {\n        ECerr(EC_F_ECDSA_SIGN_SETUP, EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING);\n        return 0;\n    }\n    if (ctx_in == NULL) {\n        if ((ctx = BN_CTX_new()) == NULL) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n    } else\n        ctx = ctx_in;\n    k = BN_new();\n    r = BN_new();\n    X = BN_new();\n    if (k == NULL || r == NULL || X == NULL) {\n        ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if ((tmp_point = EC_POINT_new(group)) == NULL) {\n        ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);\n        goto err;\n    }\n    order = EC_GROUP_get0_order(group);\n    if (order == NULL) {\n        ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);\n        goto err;\n    }\n    do {\n        do\n            if (dgst != NULL) {\n                if (!BN_generate_dsa_nonce\n                    (k, order, EC_KEY_get0_private_key(eckey), dgst, dlen,\n                     ctx)) {\n                    ECerr(EC_F_ECDSA_SIGN_SETUP,\n                             EC_R_RANDOM_NUMBER_GENERATION_FAILED);\n                    goto err;\n                }\n            } else {\n                if (!BN_rand_range(k, order)) {\n                    ECerr(EC_F_ECDSA_SIGN_SETUP,\n                             EC_R_RANDOM_NUMBER_GENERATION_FAILED);\n                    goto err;\n                }\n            }\n        while (BN_is_zero(k));\n        if (!BN_add(k, k, order))\n            goto err;\n        if (BN_num_bits(k) <= BN_num_bits(order))\n            if (!BN_add(k, k, order))\n                goto err;\n        if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, 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\n                (group, tmp_point, X, NULL, ctx)) {\n                ECerr(EC_F_ECDSA_SIGN_SETUP, 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,\n                                                      tmp_point, X, NULL,\n                                                      ctx)) {\n                ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);\n                goto err;\n            }\n        }\n#endif\n        if (!BN_nnmod(r, X, order, ctx)) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n            goto err;\n        }\n    }\n    while (BN_is_zero(r));\n    if (EC_GROUP_get_mont_data(group) != NULL) {\n        if (!BN_set_word(X, 2)) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!BN_mod_sub(X, order, X, order, ctx)) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n            goto err;\n        }\n        BN_set_flags(X, BN_FLG_CONSTTIME);\n        if (!BN_mod_exp_mont_consttime\n            (k, k, X, order, ctx, EC_GROUP_get_mont_data(group))) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n            goto err;\n        }\n    } else {\n        if (!BN_mod_inverse(k, k, order, ctx)) {\n            ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n            goto err;\n        }\n    }\n    BN_clear_free(*rp);\n    BN_clear_free(*kinvp);\n    *rp = r;\n    *kinvp = k;\n    ret = 1;\n err:\n    if (!ret) {\n        BN_clear_free(k);\n        BN_clear_free(r);\n    }\n    if (ctx != ctx_in)\n        BN_CTX_free(ctx);\n    EC_POINT_free(tmp_point);\n    BN_clear_free(X);\n    return (ret);\n}', 'int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,\n                          const BIGNUM *priv, const unsigned char *message,\n                          size_t message_len, BN_CTX *ctx)\n{\n    SHA512_CTX sha;\n    unsigned char random_bytes[64];\n    unsigned char digest[SHA512_DIGEST_LENGTH];\n    unsigned done, todo;\n    const unsigned num_k_bytes = BN_num_bytes(range) + 8;\n    unsigned char private_bytes[96];\n    unsigned char *k_bytes;\n    int ret = 0;\n    k_bytes = OPENSSL_malloc(num_k_bytes);\n    if (k_bytes == NULL)\n        goto err;\n    todo = sizeof(priv->d[0]) * priv->top;\n    if (todo > sizeof(private_bytes)) {\n        BNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_PRIVATE_KEY_TOO_LARGE);\n        goto err;\n    }\n    memcpy(private_bytes, priv->d, todo);\n    memset(private_bytes + todo, 0, sizeof(private_bytes) - todo);\n    for (done = 0; done < num_k_bytes;) {\n        if (RAND_bytes(random_bytes, sizeof(random_bytes)) != 1)\n            goto err;\n        SHA512_Init(&sha);\n        SHA512_Update(&sha, &done, sizeof(done));\n        SHA512_Update(&sha, private_bytes, sizeof(private_bytes));\n        SHA512_Update(&sha, message, message_len);\n        SHA512_Update(&sha, random_bytes, sizeof(random_bytes));\n        SHA512_Final(digest, &sha);\n        todo = num_k_bytes - done;\n        if (todo > SHA512_DIGEST_LENGTH)\n            todo = SHA512_DIGEST_LENGTH;\n        memcpy(k_bytes + done, digest, todo);\n        done += todo;\n    }\n    if (!BN_bin2bn(k_bytes, num_k_bytes, out))\n        goto err;\n    if (BN_mod(out, out, range, ctx) != 1)\n        goto err;\n    ret = 1;\n err:\n    OPENSSL_free(k_bytes);\n    return ret;\n}', 'int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)\n{\n    SHA_LONG64 l;\n    unsigned char *p = c->u.p;\n    const unsigned char *data = (const unsigned char *)_data;\n    if (len == 0)\n        return 1;\n    l = (c->Nl + (((SHA_LONG64) len) << 3)) & U64(0xffffffffffffffff);\n    if (l < c->Nl)\n        c->Nh++;\n    if (sizeof(len) >= 8)\n        c->Nh += (((SHA_LONG64) len) >> 61);\n    c->Nl = l;\n    if (c->num != 0) {\n        size_t n = sizeof(c->u) - c->num;\n        if (len < n) {\n            memcpy(p + c->num, data, len), c->num += (unsigned int)len;\n            return 1;\n        } else {\n            memcpy(p + c->num, data, n), c->num = 0;\n            len -= n, data += n;\n            sha512_block_data_order(c, p, 1);\n        }\n    }\n    if (len >= sizeof(c->u)) {\n#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA\n        if ((size_t)data % sizeof(c->u.d[0]) != 0)\n            while (len >= sizeof(c->u))\n                memcpy(p, data, sizeof(c->u)),\n                    sha512_block_data_order(c, p, 1),\n                    len -= sizeof(c->u), data += sizeof(c->u);\n        else\n#endif\n            sha512_block_data_order(c, data, len / sizeof(c->u)),\n                data += len, len %= sizeof(c->u), data -= len;\n    }\n    if (len != 0)\n        memcpy(p, data, len), c->num = (int)len;\n    return 1;\n}']