crypto/bn/bn_sqrt.c:98: error: INTEGER_OVERFLOW_L2
  (0 - [0, max(1, `p->top`)]):unsigned64 by call to `BN_mod_exp`.
Showing all 36 steps of the trace


crypto/bn/bn_sqrt.c:13:1: Parameter `p->top`
11.   #include "bn_lcl.h"
12.   
13. > BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
14.   /*
15.    * Returns 'ret' such that ret^2 == a (mod p), using the Tonelli/Shanks

crypto/bn/bn_sqrt.c:26:10: Call
24.       int e, i, j;
25.   
26.       if (!BN_is_odd(p) || BN_abs_is_word(p, 1)) {
               ^
27.           if (BN_abs_is_word(p, 2)) {
28.               if (ret == NULL)

crypto/bn/bn_lib.c:860:1: Parameter `a->top`
  858.   }
  859.   
  860. > int BN_is_odd(const BIGNUM *a)
  861.   {
  862.       return (a->top > 0) && (a->d[0] & 1);

crypto/bn/bn_sqrt.c:26:26: Call
24.       int e, i, j;
25.   
26.       if (!BN_is_odd(p) || BN_abs_is_word(p, 1)) {
                               ^
27.           if (BN_abs_is_word(p, 2)) {
28.               if (ret == NULL)

crypto/bn/bn_lib.c:840:1: Parameter `a->top`
  838.   }
  839.   
  840. > int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
  841.   {
  842.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));

crypto/bn/bn_sqrt.c:75:10: Call
73.   
74.       /* A = a mod p */
75.       if (!BN_nnmod(A, a, p, ctx))
               ^
76.           goto end;
77.   

crypto/bn/bn_mod.c:13:1: Parameter `d->top`
  11.   #include "bn_lcl.h"
  12.   
  13. > int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
  14.   {
  15.       /*

crypto/bn/bn_mod.c:20:11: Call
  18.        */
  19.   
  20.       if (!(BN_mod(r, m, d, ctx)))
                  ^
  21.           return 0;
  22.       if (!r->neg)

crypto/bn/bn_div.c:137:1: Parameter `divisor->top`
    135.    * If 'dv' or 'rm' is NULL, the respective value is not returned.
    136.    */
    137. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
    138.              BN_CTX *ctx)
    139.   {

crypto/bn/bn_sqrt.c:80:13: Call
78.       /* now write  |p| - 1  as  2^e*q  where  q  is odd */
79.       e = 1;
80.       while (!BN_is_bit_set(p, e))
                  ^
81.           e++;
82.       /* we'll set  q  later (if needed) */

crypto/bn/bn_lib.c:629:1: Parameter `a->top`
  627.   }
  628.   
  629. > int BN_is_bit_set(const BIGNUM *a, int n)
  630.   {
  631.       int i, j;

crypto/bn/bn_sqrt.c:93:14: Call
91.            * so we can use exponent  (|p|+1)/4,  i.e.  (|p|-3)/4 + 1.
92.            */
93.           if (!BN_rshift(q, p, 2))
                   ^
94.               goto end;
95.           q->neg = 0;

crypto/bn/bn_shift.c:122:1: Parameter `a->top`
  120.   }
  121.   
  122. > int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
  123.   {
  124.       int i, j, nw, lb, rb;

crypto/bn/bn_sqrt.c:98:14: Call
96.           if (!BN_add_word(q, 1))
97.               goto end;
98.           if (!BN_mod_exp(ret, A, q, p, ctx))
                    ^
99.               goto end;
100.           err = 0;

crypto/bn/bn_exp.c:89:1: Parameter `m->top`
  87.   }
  88.   
  89. > int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
  90.                  BN_CTX *ctx)
  91.   {

crypto/bn/bn_exp.c:134:9: Call
  132.   
  133.   #ifdef MONT_MUL_MOD
  134.       if (BN_is_odd(m)) {
                 ^
  135.   # ifdef MONT_EXP_WORD
  136.           if (a->top == 1 && !a->neg

crypto/bn/bn_lib.c:860:1: Parameter `a->top`
    858.   }
    859.   
    860. > int BN_is_odd(const BIGNUM *a)
    861.   {
    862.       return (a->top > 0) && (a->d[0] & 1);

crypto/bn/bn_exp.c:144:19: Call
  142.           } else
  143.   # endif
  144.               ret = BN_mod_exp_mont(r, a, p, m, ctx, NULL);
                           ^
  145.       } else
  146.   #endif

crypto/bn/bn_exp.c:296:1: Parameter `m->top`
    294.   }
    295.   
    296. > int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
    297.                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
    298.   {

crypto/bn/bn_exp.c:310:16: Call
    308.               || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
    309.               || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {
    310.           return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);
                          ^
    311.       }
    312.   

crypto/bn/bn_exp.c:747:14: Assignment
      745.           /* 2^(top*BN_BITS2) - m */
      746.           tmp.d[0] = (0 - m->d[0]) & BN_MASK2;
      747.           for (i = 1; i < top; i++)
                          ^
      748.               tmp.d[i] = (~m->d[i]) & BN_MASK2;
      749.           tmp.top = top;

crypto/bn/bn_exp.c:1046:14: Call
      1044.           for (wvalue = 0, i = bits % window; i >= 0; i--, bits--)
      1045.               wvalue = (wvalue << 1) + BN_is_bit_set(p, bits);
      1046.           if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf, wvalue,
                           ^
      1047.                                               window))
      1048.               goto err;

crypto/bn/bn_exp.c:522:1: Parameter `top`
        520.   }
        521.   
        522. > static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top,
        523.                                             unsigned char *buf, int idx,
        524.                                             int window)

crypto/bn/bn_exp.c:579:5: Assignment
        577.       }
        578.   
        579.       b->top = top;
                   ^
        580.       bn_correct_top(b);
        581.       return 1;

crypto/bn/bn_exp.c:580:5: Call
        578.   
        579.       b->top = top;
        580.       bn_correct_top(b);
                   ^
        581.       return 1;
        582.   }

crypto/bn/bn_lib.c:946:1: Parameter `a->top`
          944.   }
          945.   
          946. > void bn_correct_top(BIGNUM *a)
          947.   {
          948.       BN_ULONG *ftl;

crypto/bn/bn_exp.c:1059:22: Call
      1057.               /* Scan the window, squaring the result as we go */
      1058.               for (i = 0; i < window; i++, bits--) {
      1059.                   if (!BN_mod_mul_montgomery(&tmp, &tmp, &tmp, mont, ctx))
                                   ^
      1060.                       goto err;
      1061.                   wvalue = (wvalue << 1) + BN_is_bit_set(p, bits);

crypto/bn/bn_mont.c:26:1: Parameter `b->top`
        24.   #endif
        25.   
        26. > int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
        27.                             BN_MONT_CTX *mont, BN_CTX *ctx)
        28.   {

crypto/bn/bn_mont.c:56:14: Call
        54.               goto err;
        55.       } else {
        56.           if (!BN_mul(tmp, a, b, ctx))
                           ^
        57.               goto err;
        58.       }

crypto/bn/bn_mul.c:497:1: Parameter `b->top`
          495.   #endif                          /* BN_RECURSION */
          496.   
          497. > int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
          498.   {
          499.       int ret = 0;

crypto/bn/bn_mul.c:515:5: Assignment
          513.   
          514.       al = a->top;
          515.       bl = b->top;
                     ^
          516.   
          517.       if ((al == 0) || (bl == 0)) {

crypto/bn/bn_mul.c:564:21: Call
          562.               }
          563.               if (i == -1) {
          564.                   j = BN_num_bits_word((BN_ULONG)bl);
                                     ^
          565.               }
          566.               j = 1 << (j - 1);

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

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

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

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