crypto/bn/bn_prime.c:210: 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:210:28: Call
208.       if (do_trial_division) {
209.           for (i = 1; i < NUMPRIMES; i++) {
210.               BN_ULONG mod = BN_mod_word(w, primes[i]);
                                  ^
211.               if (mod == (BN_ULONG)-1)
212.                   return -1;

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;
}
['int BN_is_prime_fasttest_ex(const BIGNUM *w, int checks, BN_CTX *ctx_passed,\n                            int do_trial_division, BN_GENCB *cb)\n{\n    int i, status, ret = -1;\n    BN_CTX *ctx = NULL;\n    if (BN_cmp(w, BN_value_one()) <= 0)\n        return 0;\n    if (BN_is_odd(w)) {\n        if (BN_is_word(w, 3))\n            return 1;\n    } else {\n        return BN_is_word(w, 2);\n    }\n    if (do_trial_division) {\n        for (i = 1; i < NUMPRIMES; i++) {\n            BN_ULONG mod = BN_mod_word(w, primes[i]);\n            if (mod == (BN_ULONG)-1)\n                return -1;\n            if (mod == 0)\n                return BN_is_word(w, primes[i]);\n        }\n        if (!BN_GENCB_call(cb, 1, -1))\n            return -1;\n    }\n    if (ctx_passed != NULL)\n        ctx = ctx_passed;\n    else if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n    ret = bn_miller_rabin_is_prime(w, checks, ctx, cb, 0, &status);\n    if (!ret)\n        goto err;\n    ret = (status == BN_PRIMETEST_PROBABLY_PRIME);\nerr:\n    if (ctx_passed == NULL)\n        BN_CTX_free(ctx);\n    return ret;\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}']