crypto/bn/bn_prime.c:285: error: INTEGER_OVERFLOW_L2
  (0 - [0, 18446744073709551615]):unsigned64 by call to `BN_mod_word`.
Showing all 10 steps of the trace


crypto/bn/bn_prime.c:285:24: Call
283.       /* we now have a random number 'rnd' to test. */
284.       for (i = 1; i < NUMPRIMES; i++) {
285.           BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]);
                              ^
286.           if (mod == (BN_ULONG)-1)
287.               return 0;

crypto/bn/bn_word.c:13:1: Parameter `w`
  11.   #include "bn_lcl.h"
  12.   
  13. > BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
  14.   {
  15.   #ifndef BN_LLONG

crypto/bn/bn_word.c:35:15: Call
  33.               return (BN_ULONG)-1;
  34.   
  35.           ret = BN_div_word(tmp, w);
                      ^
  36.           BN_free(tmp);
  37.   

crypto/bn/bn_word.c:61:1: Parameter `w`
    59.   }
    60.   
    61. > BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)
    62.   {
    63.       BN_ULONG ret = 0;

crypto/bn/bn_word.c:67:5: Assignment
    65.   
    66.       bn_check_top(a);
    67.       w &= BN_MASK2;
              ^
    68.   
    69.       if (!w)

crypto/bn/bn_word.c:76:20: Call
    74.   
    75.       /* normalize input (so bn_div_words doesn't complain) */
    76.       j = BN_BITS2 - BN_num_bits_word(w);
                             ^
    77.       w <<= j;
    78.       if (!BN_lshift(a, a, j))

crypto/bn/bn_lib.c:90:1: <RHS trace>
88.   }
89.   
90. > int BN_num_bits_word(BN_ULONG l)
91.   {
92.       BN_ULONG x, mask;

crypto/bn/bn_lib.c:90:1: Parameter `l`
      88.   }
      89.   
      90. > int BN_num_bits_word(BN_ULONG l)
      91.   {
      92.       BN_ULONG x, mask;

crypto/bn/bn_lib.c:96:5: Assignment
      94.   
      95.   #if BN_BITS2 > 32
      96.       x = l >> 32;
                ^
      97.       mask = (0 - x) & BN_MASK2;
      98.       mask = (0 - (mask >> (BN_BITS2 - 1)));

crypto/bn/bn_lib.c:97:5: Binary operation: (0 - [0, 18446744073709551615]):unsigned64 by call to `BN_mod_word` 
      95.   #if BN_BITS2 > 32
      96.       x = l >> 32;
      97.       mask = (0 - x) & BN_MASK2;
                 ^
      98.       mask = (0 - (mask >> (BN_BITS2 - 1)));
      99.       bits += 32 & mask;

int BN_num_bits_word(BN_ULONG l)
{
    BN_ULONG x, mask;
    int bits = (l != 0);
#if BN_BITS2 > 32
    x = l >> 32;
    mask = (0 - x) & BN_MASK2;
    mask = (0 - (mask >> (BN_BITS2 - 1)));
    bits += 32 & mask;
    l ^= (x ^ l) & mask;
#endif
    x = l >> 16;
    mask = (0 - x) & BN_MASK2;
    mask = (0 - (mask >> (BN_BITS2 - 1)));
    bits += 16 & mask;
    l ^= (x ^ l) & mask;
    x = l >> 8;
    mask = (0 - x) & BN_MASK2;
    mask = (0 - (mask >> (BN_BITS2 - 1)));
    bits += 8 & mask;
    l ^= (x ^ l) & mask;
    x = l >> 4;
    mask = (0 - x) & BN_MASK2;
    mask = (0 - (mask >> (BN_BITS2 - 1)));
    bits += 4 & mask;
    l ^= (x ^ l) & mask;
    x = l >> 2;
    mask = (0 - x) & BN_MASK2;
    mask = (0 - (mask >> (BN_BITS2 - 1)));
    bits += 2 & mask;
    l ^= (x ^ l) & mask;
    x = l >> 1;
    mask = (0 - x) & BN_MASK2;
    mask = (0 - (mask >> (BN_BITS2 - 1)));
    bits += 1 & mask;
    return bits;
}
['static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods)\n{\n    int i;\n    BN_ULONG delta;\n    BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1];\n    char is_single_word = bits <= BN_BITS2;\n again:\n    if (!BN_priv_rand(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD))\n        return 0;\n    for (i = 1; i < NUMPRIMES; i++) {\n        BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]);\n        if (mod == (BN_ULONG)-1)\n            return 0;\n        mods[i] = (prime_t) mod;\n    }\n    if (is_single_word) {\n        BN_ULONG size_limit;\n        if (bits == BN_BITS2) {\n            size_limit = ~((BN_ULONG)0) - BN_get_word(rnd);\n        } else {\n            size_limit = (((BN_ULONG)1) << bits) - BN_get_word(rnd) - 1;\n        }\n        if (size_limit < maxdelta)\n            maxdelta = size_limit;\n    }\n    delta = 0;\n loop:\n    if (is_single_word) {\n        BN_ULONG rnd_word = BN_get_word(rnd);\n        for (i = 1; i < NUMPRIMES && primes[i] < rnd_word; i++) {\n            if ((mods[i] + delta) % primes[i] == 0) {\n                delta += 2;\n                if (delta > maxdelta)\n                    goto again;\n                goto loop;\n            }\n        }\n    } else {\n        for (i = 1; i < NUMPRIMES; i++) {\n            if (((mods[i] + delta) % primes[i]) <= 1) {\n                delta += 2;\n                if (delta > maxdelta)\n                    goto again;\n                goto loop;\n            }\n        }\n    }\n    if (!BN_add_word(rnd, delta))\n        return 0;\n    if (BN_num_bits(rnd) != bits)\n        goto again;\n    bn_check_top(rnd);\n    return 1;\n}', 'BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)\n{\n#ifndef BN_LLONG\n    BN_ULONG ret = 0;\n#else\n    BN_ULLONG ret = 0;\n#endif\n    int i;\n    if (w == 0)\n        return (BN_ULONG)-1;\n#ifndef BN_LLONG\n    if (w > ((BN_ULONG)1 << BN_BITS4)) {\n        BIGNUM *tmp = BN_dup(a);\n        if (tmp == NULL)\n            return (BN_ULONG)-1;\n        ret = BN_div_word(tmp, w);\n        BN_free(tmp);\n        return ret;\n    }\n#endif\n    bn_check_top(a);\n    w &= BN_MASK2;\n    for (i = a->top - 1; i >= 0; i--) {\n#ifndef BN_LLONG\n        ret = ((ret << BN_BITS4) | ((a->d[i] >> BN_BITS4) & BN_MASK2l)) % w;\n        ret = ((ret << BN_BITS4) | (a->d[i] & BN_MASK2l)) % w;\n#else\n        ret = (BN_ULLONG) (((ret << (BN_ULLONG) BN_BITS2) | a->d[i]) %\n                           (BN_ULLONG) w);\n#endif\n    }\n    return (BN_ULONG)ret;\n}', 'BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG ret = 0;\n    int i, j;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return (BN_ULONG)-1;\n    if (a->top == 0)\n        return 0;\n    j = BN_BITS2 - BN_num_bits_word(w);\n    w <<= j;\n    if (!BN_lshift(a, a, j))\n        return (BN_ULONG)-1;\n    for (i = a->top - 1; i >= 0; i--) {\n        BN_ULONG l, d;\n        l = a->d[i];\n        d = bn_div_words(ret, l, w);\n        ret = (l - ((d * w) & BN_MASK2)) & BN_MASK2;\n        a->d[i] = d;\n    }\n    if ((a->top > 0) && (a->d[a->top - 1] == 0))\n        a->top--;\n    ret >>= j;\n    if (!a->top)\n        a->neg = 0;\n    bn_check_top(a);\n    return ret;\n}', 'int BN_num_bits_word(BN_ULONG l)\n{\n    BN_ULONG x, mask;\n    int bits = (l != 0);\n#if BN_BITS2 > 32\n    x = l >> 32;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 32 & mask;\n    l ^= (x ^ l) & mask;\n#endif\n    x = l >> 16;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 16 & mask;\n    l ^= (x ^ l) & mask;\n    x = l >> 8;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 8 & mask;\n    l ^= (x ^ l) & mask;\n    x = l >> 4;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 4 & mask;\n    l ^= (x ^ l) & mask;\n    x = l >> 2;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 2 & mask;\n    l ^= (x ^ l) & mask;\n    x = l >> 1;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 1 & mask;\n    return bits;\n}']