crypto/rand/drbg_lib.c:328: error: INTEGER_OVERFLOW_L2
  ([1, `len`] - [min(16, `drbg->ctr.keylen`), max(32, `drbg->ctr.keylen`)]):unsigned64 by call to `ctr_reseed`.
Showing all 11 steps of the trace


crypto/rand/drbg_lib.c:263:1: Parameter `drbg->ctr.keylen`
261.    * This function is used internally only.
262.    */
263. > int rand_drbg_restart(RAND_DRBG *drbg,
264.                         const unsigned char *buffer, size_t len, size_t entropy)
265.   {

crypto/rand/drbg_lib.c:328:13: Call
326.                * This is not a reseeding in the strict sense of NIST SP 800-90A.
327.                */
328.               ctr_reseed(drbg, adin, adinlen, NULL, 0);
                   ^
329.           } else if (reseeded == 0) {
330.               /* do a full reseeding if it has not been done yet above */

crypto/rand/drbg_rand.c:256:1: Parameter `entropylen`
  254.   }
  255.   
  256. > int ctr_reseed(RAND_DRBG *drbg,
  257.                  const unsigned char *entropy, size_t entropylen,
  258.                  const unsigned char *adin, size_t adinlen)

crypto/rand/drbg_rand.c:262:5: Call
  260.       if (entropy == NULL)
  261.           return 0;
  262.       ctr_update(drbg, entropy, entropylen, adin, adinlen, NULL, 0);
             ^
  263.       return 1;
  264.   }

crypto/rand/drbg_rand.c:199:1: Parameter `in1len`
    197.    * so we handle both cases in this function instead.
    198.    */
    199. > static void ctr_update(RAND_DRBG *drbg,
    200.                          const unsigned char *in1, size_t in1len,
    201.                          const unsigned char *in2, size_t in2len,

crypto/rand/drbg_rand.c:232:9: Call
    230.               ctr_XOR(ctr, ctr->KX, drbg->seedlen);
    231.       } else {
    232.           ctr_XOR(ctr, in1, in1len);
                   ^
    233.           ctr_XOR(ctr, in2, in2len);
    234.       }

crypto/rand/drbg_rand.c:39:1: <LHS trace>
37.   }
38.   
39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
40.   {
41.       size_t i, n;

crypto/rand/drbg_rand.c:39:1: Parameter `inlen`
      37.   }
      38.   
      39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
      40.   {
      41.       size_t i, n;

crypto/rand/drbg_rand.c:39:1: <RHS trace>
37.   }
38.   
39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
40.   {
41.       size_t i, n;

crypto/rand/drbg_rand.c:39:1: Parameter `inlen`
      37.   }
      38.   
      39. > static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
      40.   {
      41.       size_t i, n;

crypto/rand/drbg_rand.c:56:5: Binary operation: ([1, len] - [min(16, drbg->ctr.keylen), max(32, drbg->ctr.keylen)]):unsigned64 by call to `ctr_reseed` 
      54.           return;
      55.   
      56.       n = inlen - ctr->keylen;
                ^
      57.       if (n > 16) {
      58.           /* Should never happen */

static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
{
    size_t i, n;
    if (in == NULL || inlen == 0)
        return;
    n = inlen < ctr->keylen ? inlen : ctr->keylen;
    for (i = 0; i < n; i++)
        ctr->K[i] ^= in[i];
    if (inlen <= ctr->keylen)
        return;
    n = inlen - ctr->keylen;
    if (n > 16) {
        n = 16;
    }
    for (i = 0; i < n; i++)
        ctr->V[i] ^= in[i + ctr->keylen];
}
['int rand_drbg_restart(RAND_DRBG *drbg,\n                      const unsigned char *buffer, size_t len, size_t entropy)\n{\n    int reseeded = 0;\n    const unsigned char *adin = NULL;\n    size_t adinlen = 0;\n    if (drbg->pool != NULL) {\n        RANDerr(RAND_F_RAND_DRBG_RESTART, ERR_R_INTERNAL_ERROR);\n        RAND_POOL_free(drbg->pool);\n        drbg->pool = NULL;\n    }\n    if (buffer != NULL) {\n        if (entropy > 0) {\n            if (drbg->max_entropylen < len) {\n                RANDerr(RAND_F_RAND_DRBG_RESTART,\n                    RAND_R_ENTROPY_INPUT_TOO_LONG);\n                return 0;\n            }\n            if (entropy > 8 * len) {\n                RANDerr(RAND_F_RAND_DRBG_RESTART, RAND_R_ENTROPY_OUT_OF_RANGE);\n                return 0;\n            }\n            drbg->pool = RAND_POOL_new(entropy, len, len);\n            if (drbg->pool == NULL)\n                return 0;\n            RAND_POOL_add(drbg->pool, buffer, len, entropy);\n        } else {\n            if (drbg->max_adinlen < len) {\n                RANDerr(RAND_F_RAND_DRBG_RESTART,\n                        RAND_R_ADDITIONAL_INPUT_TOO_LONG);\n                return 0;\n            }\n            adin = buffer;\n            adinlen = len;\n        }\n    }\n    if (drbg->state == DRBG_ERROR)\n        RAND_DRBG_uninstantiate(drbg);\n    if (drbg->state == DRBG_UNINITIALISED) {\n        drbg_setup(drbg, NULL);\n        reseeded = (drbg->state == DRBG_READY);\n    }\n    if (drbg->state == DRBG_READY) {\n        if (adin != NULL) {\n            ctr_reseed(drbg, adin, adinlen, NULL, 0);\n        } else if (reseeded == 0) {\n            RAND_DRBG_reseed(drbg, NULL, 0);\n        }\n    }\n    if (drbg->pool != NULL) {\n        drbg->state = DRBG_ERROR;\n        RANDerr(RAND_F_RAND_DRBG_RESTART, ERR_R_INTERNAL_ERROR);\n        RAND_POOL_free(drbg->pool);\n        drbg->pool = NULL;\n        return 0;\n    }\n    return drbg->state == DRBG_READY;\n}', 'int ctr_reseed(RAND_DRBG *drbg,\n               const unsigned char *entropy, size_t entropylen,\n               const unsigned char *adin, size_t adinlen)\n{\n    if (entropy == NULL)\n        return 0;\n    ctr_update(drbg, entropy, entropylen, adin, adinlen, NULL, 0);\n    return 1;\n}', 'static void ctr_update(RAND_DRBG *drbg,\n                       const unsigned char *in1, size_t in1len,\n                       const unsigned char *in2, size_t in2len,\n                       const unsigned char *nonce, size_t noncelen)\n{\n    RAND_DRBG_CTR *ctr = &drbg->ctr;\n    inc_128(ctr);\n    AES_encrypt(ctr->V, ctr->K, &ctr->ks);\n    if (ctr->keylen != 16) {\n        inc_128(ctr);\n        AES_encrypt(ctr->V, ctr->K + 16, &ctr->ks);\n    }\n    inc_128(ctr);\n    AES_encrypt(ctr->V, ctr->V, &ctr->ks);\n    if (ctr->keylen == 24) {\n        memcpy(ctr->V + 8, ctr->V, 8);\n        memcpy(ctr->V, ctr->K + 24, 8);\n    }\n    if (drbg->flags & RAND_DRBG_FLAG_CTR_USE_DF) {\n        if (in1 != NULL || nonce != NULL || in2 != NULL)\n            ctr_df(ctr, in1, in1len, nonce, noncelen, in2, in2len);\n        if (in1len)\n            ctr_XOR(ctr, ctr->KX, drbg->seedlen);\n    } else {\n        ctr_XOR(ctr, in1, in1len);\n        ctr_XOR(ctr, in2, in2len);\n    }\n    AES_set_encrypt_key(ctr->K, drbg->strength, &ctr->ks);\n}', 'static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)\n{\n    size_t i, n;\n    if (in == NULL || inlen == 0)\n        return;\n    n = inlen < ctr->keylen ? inlen : ctr->keylen;\n    for (i = 0; i < n; i++)\n        ctr->K[i] ^= in[i];\n    if (inlen <= ctr->keylen)\n        return;\n    n = inlen - ctr->keylen;\n    if (n > 16) {\n        n = 16;\n    }\n    for (i = 0; i < n; i++)\n        ctr->V[i] ^= in[i + ctr->keylen];\n}']