crypto/rsa/rsa_pk1.c:252: error: INTEGER_OVERFLOW_L2
  (0 - [0, 1]):unsigned64 by call to `err_clear_last_constant_time`.
Showing all 13 steps of the trace


crypto/rsa/rsa_pk1.c:227:13: Call
225.        * For good measure, do this check in constant time as well.
226.        */
227.       good &= constant_time_ge(tlen, mlen);
                   ^
228.   
229.       /*

include/internal/constant_time_locl.h:145:13: Call
  143.                                                    unsigned int b)
  144.   {
  145.       return ~constant_time_lt(a, b);
                     ^
  146.   }
  147.   

include/internal/constant_time_locl.h:120:1: Parameter `a`
    118.   }
    119.   
    120. > static ossl_inline unsigned int constant_time_lt(unsigned int a,
    121.                                                    unsigned int b)
    122.   {

include/internal/constant_time_locl.h:123:12: Call
    121.                                                    unsigned int b)
    122.   {
    123.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
                      ^
    124.   }
    125.   

include/internal/constant_time_locl.h:99:1: Parameter `a`
      97.   
      98.   
      99. > static ossl_inline unsigned int constant_time_msb(unsigned int a)
      100.   {
      101.       return 0 - (a >> (sizeof(a) * 8 - 1));

include/internal/constant_time_locl.h:101:5: Assignment
      99.   static ossl_inline unsigned int constant_time_msb(unsigned int a)
      100.   {
      101.       return 0 - (a >> (sizeof(a) * 8 - 1));
                 ^
      102.   }
      103.   

include/internal/constant_time_locl.h:123:5: Assignment
    121.                                                    unsigned int b)
    122.   {
    123.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
               ^
    124.   }
    125.   

include/internal/constant_time_locl.h:145:5: Assignment
  143.                                                    unsigned int b)
  144.   {
  145.       return ~constant_time_lt(a, b);
             ^
  146.   }
  147.   

crypto/rsa/rsa_pk1.c:227:5: Assignment
225.        * For good measure, do this check in constant time as well.
226.        */
227.       good &= constant_time_ge(tlen, mlen);
           ^
228.   
229.       /*

crypto/rsa/rsa_pk1.c:252:5: Call
250.       OPENSSL_clear_free(em, num);
251.       RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR);
252.       err_clear_last_constant_time(1 & good);
           ^
253.   
254.       return constant_time_select_int(good, mlen, -1);

crypto/err/err.c:902:1: <RHS trace>
900.   #endif
901.   
902. > void err_clear_last_constant_time(int clear)
903.   {
904.       ERR_STATE *es;

crypto/err/err.c:902:1: Parameter `clear`
  900.   #endif
  901.   
  902. > void err_clear_last_constant_time(int clear)
  903.   {
  904.       ERR_STATE *es;

crypto/err/err.c:914:5: Binary operation: (0 - [0, 1]):unsigned64 by call to `err_clear_last_constant_time` 
  912.   
  913.       es->err_flags[top] &= ~(0 - clear);
  914.       es->err_buffer[top] &= ~(0UL - clear);
             ^
  915.       es->err_file[top] = (const char *)((UINTPTR_T)es->err_file[top] &
  916.                                          ~((UINTPTR_T)0 - clear));

void err_clear_last_constant_time(int clear)
{
    ERR_STATE *es;
    int top;
    es = ERR_get_state();
    if (es == NULL)
        return;
    top = es->top;
    es->err_flags[top] &= ~(0 - clear);
    es->err_buffer[top] &= ~(0UL - clear);
    es->err_file[top] = (const char *)((UINTPTR_T)es->err_file[top] &
                                       ~((UINTPTR_T)0 - clear));
    es->err_line[top] |= 0 - clear;
    es->top = (top + ERR_NUM_ERRORS - clear) % ERR_NUM_ERRORS;
}
['int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,\n                                   const unsigned char *from, int flen,\n                                   int num)\n{\n    int i;\n    unsigned char *em = NULL;\n    unsigned int good, found_zero_byte, mask;\n    int zero_index = 0, msg_index, mlen = -1;\n    if (tlen < 0 || flen < 0)\n        return -1;\n    if (flen > num || num < 11) {\n        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,\n               RSA_R_PKCS_DECODING_ERROR);\n        return -1;\n    }\n    em = OPENSSL_malloc(num);\n    if (em == NULL) {\n        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, ERR_R_MALLOC_FAILURE);\n        return -1;\n    }\n    for (from += flen, em += num, i = 0; i < num; i++) {\n        mask = ~constant_time_is_zero(flen);\n        flen -= 1 & mask;\n        from -= 1 & mask;\n        *--em = *from & mask;\n    }\n    from = em;\n    good = constant_time_is_zero(from[0]);\n    good &= constant_time_eq(from[1], 2);\n    found_zero_byte = 0;\n    for (i = 2; i < num; i++) {\n        unsigned int equals0 = constant_time_is_zero(from[i]);\n        zero_index = constant_time_select_int(~found_zero_byte & equals0,\n                                              i, zero_index);\n        found_zero_byte |= equals0;\n    }\n    good &= constant_time_ge(zero_index, 2 + 8);\n    msg_index = zero_index + 1;\n    mlen = num - msg_index;\n    good &= constant_time_ge(tlen, mlen);\n    tlen = constant_time_select_int(constant_time_lt(num, tlen), num, tlen);\n    msg_index = constant_time_select_int(good, msg_index, num - tlen);\n    mlen = num - msg_index;\n    for (from += msg_index, mask = good, i = 0; i < tlen; i++) {\n        unsigned int equals = constant_time_eq(i, mlen);\n        from -= tlen & equals;\n        mask &= mask ^ equals;\n        to[i] = constant_time_select_8(mask, from[i], to[i]);\n    }\n    OPENSSL_clear_free(em, num);\n    RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR);\n    err_clear_last_constant_time(1 & good);\n    return constant_time_select_int(good, mlen, -1);\n}', 'static ossl_inline unsigned int constant_time_ge(unsigned int a,\n                                                 unsigned int b)\n{\n    return ~constant_time_lt(a, b);\n}', 'static ossl_inline unsigned int constant_time_lt(unsigned int a,\n                                                 unsigned int b)\n{\n    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));\n}', 'static ossl_inline unsigned int constant_time_msb(unsigned int a)\n{\n    return 0 - (a >> (sizeof(a) * 8 - 1));\n}', 'void err_clear_last_constant_time(int clear)\n{\n    ERR_STATE *es;\n    int top;\n    es = ERR_get_state();\n    if (es == NULL)\n        return;\n    top = es->top;\n    es->err_flags[top] &= ~(0 - clear);\n    es->err_buffer[top] &= ~(0UL - clear);\n    es->err_file[top] = (const char *)((UINTPTR_T)es->err_file[top] &\n                                       ~((UINTPTR_T)0 - clear));\n    es->err_line[top] |= 0 - clear;\n    es->top = (top + ERR_NUM_ERRORS - clear) % ERR_NUM_ERRORS;\n}']