crypto/crmf/crmf_lib.c:700: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `constant_time_is_zero_s`.
Showing all 10 steps of the trace


crypto/crmf/crmf_lib.c:697:18: Call
695.                   || (ek = OPENSSL_malloc(eksize)) == NULL)
696.               goto oom;
697.           retval = EVP_PKEY_decrypt(pkctx, ek, &eksize,
                        ^
698.                                     encKey->data, encKey->length);
699.           ERR_clear_error(); /* error state may have sensitive information */

crypto/evp/pmeth_fn.c:551:9: Assignment
  549.           EVPerr(EVP_F_EVP_PKEY_DECRYPT,
  550.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
  551.           return -2;
                 ^
  552.       }
  553.       if (ctx->operation != EVP_PKEY_OP_DECRYPT) {

crypto/crmf/crmf_lib.c:697:9: Assignment
695.                   || (ek = OPENSSL_malloc(eksize)) == NULL)
696.               goto oom;
697.           retval = EVP_PKEY_decrypt(pkctx, ek, &eksize,
               ^
698.                                     encKey->data, encKey->length);
699.           ERR_clear_error(); /* error state may have sensitive information */

crypto/crmf/crmf_lib.c:700:44: Call
698.                                     encKey->data, encKey->length);
699.           ERR_clear_error(); /* error state may have sensitive information */
700.           failure = ~constant_time_is_zero_s(constant_time_msb(retval)
                                                  ^
701.                                              | constant_time_is_zero(retval));
702.           failure |= ~constant_time_eq_s(eksize, (size_t)cikeysize);

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.   

crypto/crmf/crmf_lib.c:700:20: Call
698.                                     encKey->data, encKey->length);
699.           ERR_clear_error(); /* error state may have sensitive information */
700.           failure = ~constant_time_is_zero_s(constant_time_msb(retval)
                          ^
701.                                              | constant_time_is_zero(retval));
702.           failure |= ~constant_time_eq_s(eksize, (size_t)cikeysize);

include/internal/constant_time_locl.h:169:1: <LHS trace>
167.   }
168.   
169. > static ossl_inline size_t constant_time_is_zero_s(size_t a)
170.   {
171.       return constant_time_msb_s(~a & (a - 1));

include/internal/constant_time_locl.h:169:1: Parameter `a`
  167.   }
  168.   
  169. > static ossl_inline size_t constant_time_is_zero_s(size_t a)
  170.   {
  171.       return constant_time_msb_s(~a & (a - 1));

include/internal/constant_time_locl.h:171:12: Binary operation: ([0, +oo] - 1):unsigned64 by call to `constant_time_is_zero_s` 
  169.   static ossl_inline size_t constant_time_is_zero_s(size_t a)
  170.   {
  171.       return constant_time_msb_s(~a & (a - 1));
                    ^
  172.   }
  173.   

static ossl_inline size_t constant_time_is_zero_s(size_t a)
{
    return constant_time_msb_s(~a & (a - 1));
}
['X509 *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(OSSL_CRMF_ENCRYPTEDVALUE *ecert,\n                                            EVP_PKEY *pkey)\n{\n    X509 *cert = NULL;\n    EVP_CIPHER_CTX *evp_ctx = NULL;\n    unsigned char *ek = NULL;\n    size_t eksize = 0;\n    const EVP_CIPHER *cipher = NULL;\n    int cikeysize = 0;\n    unsigned char *iv = NULL;\n    unsigned char *outbuf = NULL;\n    const unsigned char *p = NULL;\n    int symmAlg = 0;\n    int n, outlen = 0;\n    EVP_PKEY_CTX *pkctx = NULL;\n    if (ecert == NULL || ecert->symmAlg == NULL || ecert->encSymmKey == NULL\n            || ecert->encValue == NULL || pkey == NULL) {\n        CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                CRMF_R_NULL_ARGUMENT);\n        return NULL;\n    }\n    if ((symmAlg = OBJ_obj2nid(ecert->symmAlg->algorithm)) == 0) {\n        CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                CRMF_R_UNSUPPORTED_CIPHER);\n        return NULL;\n    }\n    if ((cipher = EVP_get_cipherbynid(symmAlg)) == NULL) {\n        CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                CRMF_R_UNSUPPORTED_CIPHER);\n        goto end;\n    }\n    cikeysize = EVP_CIPHER_key_length(cipher);\n    pkctx = EVP_PKEY_CTX_new(pkey, NULL);\n    if (pkctx != NULL && EVP_PKEY_decrypt_init(pkctx)) {\n        ASN1_BIT_STRING *encKey = ecert->encSymmKey;\n        size_t failure;\n        int retval;\n        if (EVP_PKEY_decrypt(pkctx, NULL, &eksize,\n                             encKey->data, encKey->length) <= 0\n                || (ek = OPENSSL_malloc(eksize)) == NULL)\n            goto oom;\n        retval = EVP_PKEY_decrypt(pkctx, ek, &eksize,\n                                  encKey->data, encKey->length);\n        ERR_clear_error();\n        failure = ~constant_time_is_zero_s(constant_time_msb(retval)\n                                           | constant_time_is_zero(retval));\n        failure |= ~constant_time_eq_s(eksize, (size_t)cikeysize);\n        if (failure) {\n            CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                    CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY);\n            goto end;\n        }\n    } else {\n        goto oom;\n    }\n    if ((iv = OPENSSL_malloc(EVP_CIPHER_iv_length(cipher))) == NULL)\n        goto oom;\n    if (ASN1_TYPE_get_octetstring(ecert->symmAlg->parameter, iv,\n                                   EVP_CIPHER_iv_length(cipher))\n        != EVP_CIPHER_iv_length(cipher)) {\n        CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                CRMF_R_MALFORMED_IV);\n        goto end;\n    }\n    if ((p = outbuf = OPENSSL_malloc(ecert->encValue->length +\n                                     EVP_CIPHER_block_size(cipher))) == NULL\n            || (evp_ctx = EVP_CIPHER_CTX_new()) == NULL)\n        goto oom;\n    EVP_CIPHER_CTX_set_padding(evp_ctx, 0);\n    if (!EVP_DecryptInit(evp_ctx, cipher, ek, iv)\n            || !EVP_DecryptUpdate(evp_ctx, outbuf, &outlen,\n                                  ecert->encValue->data,\n                                  ecert->encValue->length)\n            || !EVP_DecryptFinal(evp_ctx, outbuf + outlen, &n)) {\n        CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                CRMF_R_ERROR_DECRYPTING_CERTIFICATE);\n        goto end;\n    }\n    outlen += n;\n    if ((cert = d2i_X509(NULL, &p, outlen)) == NULL) {\n        CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT,\n                CRMF_R_ERROR_DECODING_CERTIFICATE);\n    }\n    goto end;\n oom:\n    CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, ERR_R_MALLOC_FAILURE);\n end:\n    EVP_PKEY_CTX_free(pkctx);\n    OPENSSL_free(outbuf);\n    EVP_CIPHER_CTX_free(evp_ctx);\n    OPENSSL_clear_free(ek, eksize);\n    OPENSSL_free(iv);\n    return cert;\n}', 'int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen)\n{\n    if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) {\n        EVPerr(EVP_F_EVP_PKEY_DECRYPT,\n               EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);\n        return -2;\n    }\n    if (ctx->operation != EVP_PKEY_OP_DECRYPT) {\n        EVPerr(EVP_F_EVP_PKEY_DECRYPT, EVP_R_OPERATON_NOT_INITIALIZED);\n        return -1;\n    }\n    M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_DECRYPT)\n        return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen);\n}', 'static ossl_inline unsigned int constant_time_msb(unsigned int a)\n{\n    return 0 - (a >> (sizeof(a) * 8 - 1));\n}', 'static ossl_inline size_t constant_time_is_zero_s(size_t a)\n{\n    return constant_time_msb_s(~a & (a - 1));\n}']