crypto/ec/ecp_nistz256.c:746: error: INTEGER_OVERFLOW_L2
  (0 - [0, 1]):unsigned64 by call to `copy_conditional`.
Showing all 11 steps of the trace


crypto/ec/ecp_nistz256.c:741:18: Call
739.           wvalue = (wvalue << 1) & mask;
740.   
741.           wvalue = _booth_recode_w5(wvalue);
                        ^
742.   
743.           ecp_nistz256_gather_w5(&temp[0], table[i], wvalue >> 1);

crypto/ec/ecp_nistz256.c:163:1: Parameter `in`
  161.   
  162.   /* Recode window to a signed digit, see ecp_nistputil.c for details */
  163. > static unsigned int _booth_recode_w5(unsigned int in)
  164.   {
  165.       unsigned int s, d;

crypto/ec/ecp_nistz256.c:167:5: Assignment
  165.       unsigned int s, d;
  166.   
  167.       s = ~((in >> 5) - 1);
             ^
  168.       d = (1 << 6) - in - 1;
  169.       d = (d & s) | (in & ~s);

crypto/ec/ecp_nistz256.c:169:5: Assignment
  167.       s = ~((in >> 5) - 1);
  168.       d = (1 << 6) - in - 1;
  169.       d = (d & s) | (in & ~s);
             ^
  170.       d = (d >> 1) + (d & 1);
  171.   

crypto/ec/ecp_nistz256.c:170:5: Assignment
  168.       d = (1 << 6) - in - 1;
  169.       d = (d & s) | (in & ~s);
  170.       d = (d >> 1) + (d & 1);
             ^
  171.   
  172.       return (d << 1) + (s & 1);

crypto/ec/ecp_nistz256.c:172:5: Assignment
  170.       d = (d >> 1) + (d & 1);
  171.   
  172.       return (d << 1) + (s & 1);
             ^
  173.   }
  174.   

crypto/ec/ecp_nistz256.c:741:9: Assignment
739.           wvalue = (wvalue << 1) & mask;
740.   
741.           wvalue = _booth_recode_w5(wvalue);
               ^
742.   
743.           ecp_nistz256_gather_w5(&temp[0], table[i], wvalue >> 1);

crypto/ec/ecp_nistz256.c:746:9: Call
744.   
745.           ecp_nistz256_neg(temp[1].Y, temp[0].Y);
746.           copy_conditional(temp[0].Y, temp[1].Y, wvalue & 1);
               ^
747.   
748.           ecp_nistz256_point_add(r, r, &temp[0]);

crypto/ec/ecp_nistz256.c:187:1: <RHS trace>
185.   }
186.   
187. > static void copy_conditional(BN_ULONG dst[P256_LIMBS],
188.                                const BN_ULONG src[P256_LIMBS], BN_ULONG move)
189.   {

crypto/ec/ecp_nistz256.c:187:1: Parameter `move`
  185.   }
  186.   
  187. > static void copy_conditional(BN_ULONG dst[P256_LIMBS],
  188.                                const BN_ULONG src[P256_LIMBS], BN_ULONG move)
  189.   {

crypto/ec/ecp_nistz256.c:190:5: Binary operation: (0 - [0, 1]):unsigned64 by call to `copy_conditional` 
  188.                                const BN_ULONG src[P256_LIMBS], BN_ULONG move)
  189.   {
  190.       BN_ULONG mask1 = 0-move;
             ^
  191.       BN_ULONG mask2 = ~mask1;
  192.   

static void copy_conditional(BN_ULONG dst[P256_LIMBS],
                             const BN_ULONG src[P256_LIMBS], BN_ULONG move)
{
    BN_ULONG mask1 = 0-move;
    BN_ULONG mask2 = ~mask1;
    dst[0] = (src[0] & mask1) ^ (dst[0] & mask2);
    dst[1] = (src[1] & mask1) ^ (dst[1] & mask2);
    dst[2] = (src[2] & mask1) ^ (dst[2] & mask2);
    dst[3] = (src[3] & mask1) ^ (dst[3] & mask2);
    if (P256_LIMBS == 8) {
        dst[4] = (src[4] & mask1) ^ (dst[4] & mask2);
        dst[5] = (src[5] & mask1) ^ (dst[5] & mask2);
        dst[6] = (src[6] & mask1) ^ (dst[6] & mask2);
        dst[7] = (src[7] & mask1) ^ (dst[7] & mask2);
    }
}
['static int ecp_nistz256_windowed_mul(const EC_GROUP *group,\n                                            P256_POINT *r,\n                                            const BIGNUM **scalar,\n                                            const EC_POINT **point,\n                                            size_t num, BN_CTX *ctx)\n{\n    size_t i;\n    int j, ret = 0;\n    unsigned int idx;\n    unsigned char (*p_str)[33] = NULL;\n    const unsigned int window_size = 5;\n    const unsigned int mask = (1 << (window_size + 1)) - 1;\n    unsigned int wvalue;\n    P256_POINT *temp;\n    const BIGNUM **scalars = NULL;\n    P256_POINT (*table)[16] = NULL;\n    void *table_storage = NULL;\n    if ((num * 16 + 6) > OPENSSL_MALLOC_MAX_NELEMS(P256_POINT)\n        || (table_storage =\n            OPENSSL_malloc((num * 16 + 5) * sizeof(P256_POINT) + 64)) == NULL\n        || (p_str =\n            OPENSSL_malloc(num * 33 * sizeof(unsigned char))) == NULL\n        || (scalars = OPENSSL_malloc(num * sizeof(BIGNUM *))) == NULL) {\n        ECerr(EC_F_ECP_NISTZ256_WINDOWED_MUL, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    table = (void *)ALIGNPTR(table_storage, 64);\n    temp = (P256_POINT *)(table + num);\n    for (i = 0; i < num; i++) {\n        P256_POINT *row = table[i];\n        if ((BN_num_bits(scalar[i]) > 256) || BN_is_negative(scalar[i])) {\n            BIGNUM *mod;\n            if ((mod = BN_CTX_get(ctx)) == NULL)\n                goto err;\n            if (!BN_nnmod(mod, scalar[i], group->order, ctx)) {\n                ECerr(EC_F_ECP_NISTZ256_WINDOWED_MUL, ERR_R_BN_LIB);\n                goto err;\n            }\n            scalars[i] = mod;\n        } else\n            scalars[i] = scalar[i];\n        for (j = 0; j < bn_get_top(scalars[i]) * BN_BYTES; j += BN_BYTES) {\n            BN_ULONG d = bn_get_words(scalars[i])[j / BN_BYTES];\n            p_str[i][j + 0] = (unsigned char)d;\n            p_str[i][j + 1] = (unsigned char)(d >> 8);\n            p_str[i][j + 2] = (unsigned char)(d >> 16);\n            p_str[i][j + 3] = (unsigned char)(d >>= 24);\n            if (BN_BYTES == 8) {\n                d >>= 8;\n                p_str[i][j + 4] = (unsigned char)d;\n                p_str[i][j + 5] = (unsigned char)(d >> 8);\n                p_str[i][j + 6] = (unsigned char)(d >> 16);\n                p_str[i][j + 7] = (unsigned char)(d >> 24);\n            }\n        }\n        for (; j < 33; j++)\n            p_str[i][j] = 0;\n        if (!ecp_nistz256_bignum_to_field_elem(temp[0].X, point[i]->X)\n            || !ecp_nistz256_bignum_to_field_elem(temp[0].Y, point[i]->Y)\n            || !ecp_nistz256_bignum_to_field_elem(temp[0].Z, point[i]->Z)) {\n            ECerr(EC_F_ECP_NISTZ256_WINDOWED_MUL,\n                  EC_R_COORDINATES_OUT_OF_RANGE);\n            goto err;\n        }\n        ecp_nistz256_scatter_w5  (row, &temp[0], 1);\n        ecp_nistz256_point_double(&temp[1], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[1], 2);\n        ecp_nistz256_point_add   (&temp[2], &temp[1], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[2], 3);\n        ecp_nistz256_point_double(&temp[1], &temp[1]);\n        ecp_nistz256_scatter_w5  (row, &temp[1], 4);\n        ecp_nistz256_point_double(&temp[2], &temp[2]);\n        ecp_nistz256_scatter_w5  (row, &temp[2], 6);\n        ecp_nistz256_point_add   (&temp[3], &temp[1], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[3], 5);\n        ecp_nistz256_point_add   (&temp[4], &temp[2], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[4], 7);\n        ecp_nistz256_point_double(&temp[1], &temp[1]);\n        ecp_nistz256_scatter_w5  (row, &temp[1], 8);\n        ecp_nistz256_point_double(&temp[2], &temp[2]);\n        ecp_nistz256_scatter_w5  (row, &temp[2], 12);\n        ecp_nistz256_point_double(&temp[3], &temp[3]);\n        ecp_nistz256_scatter_w5  (row, &temp[3], 10);\n        ecp_nistz256_point_double(&temp[4], &temp[4]);\n        ecp_nistz256_scatter_w5  (row, &temp[4], 14);\n        ecp_nistz256_point_add   (&temp[2], &temp[2], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[2], 13);\n        ecp_nistz256_point_add   (&temp[3], &temp[3], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[3], 11);\n        ecp_nistz256_point_add   (&temp[4], &temp[4], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[4], 15);\n        ecp_nistz256_point_add   (&temp[2], &temp[1], &temp[0]);\n        ecp_nistz256_scatter_w5  (row, &temp[2], 9);\n        ecp_nistz256_point_double(&temp[1], &temp[1]);\n        ecp_nistz256_scatter_w5  (row, &temp[1], 16);\n    }\n    idx = 255;\n    wvalue = p_str[0][(idx - 1) / 8];\n    wvalue = (wvalue >> ((idx - 1) % 8)) & mask;\n    ecp_nistz256_gather_w5(&temp[0], table[0], _booth_recode_w5(wvalue) >> 1);\n    memcpy(r, &temp[0], sizeof(temp[0]));\n    while (idx >= 5) {\n        for (i = (idx == 255 ? 1 : 0); i < num; i++) {\n            unsigned int off = (idx - 1) / 8;\n            wvalue = p_str[i][off] | p_str[i][off + 1] << 8;\n            wvalue = (wvalue >> ((idx - 1) % 8)) & mask;\n            wvalue = _booth_recode_w5(wvalue);\n            ecp_nistz256_gather_w5(&temp[0], table[i], wvalue >> 1);\n            ecp_nistz256_neg(temp[1].Y, temp[0].Y);\n            copy_conditional(temp[0].Y, temp[1].Y, (wvalue & 1));\n            ecp_nistz256_point_add(r, r, &temp[0]);\n        }\n        idx -= window_size;\n        ecp_nistz256_point_double(r, r);\n        ecp_nistz256_point_double(r, r);\n        ecp_nistz256_point_double(r, r);\n        ecp_nistz256_point_double(r, r);\n        ecp_nistz256_point_double(r, r);\n    }\n    for (i = 0; i < num; i++) {\n        wvalue = p_str[i][0];\n        wvalue = (wvalue << 1) & mask;\n        wvalue = _booth_recode_w5(wvalue);\n        ecp_nistz256_gather_w5(&temp[0], table[i], wvalue >> 1);\n        ecp_nistz256_neg(temp[1].Y, temp[0].Y);\n        copy_conditional(temp[0].Y, temp[1].Y, wvalue & 1);\n        ecp_nistz256_point_add(r, r, &temp[0]);\n    }\n    ret = 1;\n err:\n    OPENSSL_free(table_storage);\n    OPENSSL_free(p_str);\n    OPENSSL_free(scalars);\n    return ret;\n}', 'static unsigned int _booth_recode_w5(unsigned int in)\n{\n    unsigned int s, d;\n    s = ~((in >> 5) - 1);\n    d = (1 << 6) - in - 1;\n    d = (d & s) | (in & ~s);\n    d = (d >> 1) + (d & 1);\n    return (d << 1) + (s & 1);\n}', 'static void copy_conditional(BN_ULONG dst[P256_LIMBS],\n                             const BN_ULONG src[P256_LIMBS], BN_ULONG move)\n{\n    BN_ULONG mask1 = 0-move;\n    BN_ULONG mask2 = ~mask1;\n    dst[0] = (src[0] & mask1) ^ (dst[0] & mask2);\n    dst[1] = (src[1] & mask1) ^ (dst[1] & mask2);\n    dst[2] = (src[2] & mask1) ^ (dst[2] & mask2);\n    dst[3] = (src[3] & mask1) ^ (dst[3] & mask2);\n    if (P256_LIMBS == 8) {\n        dst[4] = (src[4] & mask1) ^ (dst[4] & mask2);\n        dst[5] = (src[5] & mask1) ^ (dst[5] & mask2);\n        dst[6] = (src[6] & mask1) ^ (dst[6] & mask2);\n        dst[7] = (src[7] & mask1) ^ (dst[7] & mask2);\n    }\n}']