Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

SGX_ERROR_MAC_MISMATCH! during sgx_verify_report()


Hi there,

I am having SGX_ERROR_MAC_MISMATCH during sgx_verify_report() right after creating report. I'm a bit lost now what could be the reason. My code as follow:



report_t get_report(uint64_t enclave_id, uint8_t* test_spid)
    report_t report;
    sgx_status_t status;
    sgx_spid_t spid;
    memcpy(, test_spid, sizeof test_spid);

    /* Get report */

    sgx_target_info_t p_target_info;
    sgx_epid_group_id_t p_gid;
    memset(&p_target_info, 0, sizeof(p_target_info));

    status = sgx_init_quote(&p_target_info, &p_gid);
    memset(p_target_info.reserved1, 0, sizeof p_target_info.reserved1);
    memset(p_target_info.reserved2, 0, sizeof p_target_info.reserved2);

    if(SGX_SUCCESS != status) {
        printf("Init quote failed! status: %d \n", status);
        report.ret = INIT_QUOTE_FAILURE;
        return report;

    sgx_report_t sgx_report;
    memset(&sgx_report, 0, sizeof(sgx_report));

    status = ecall_create_report((sgx_enclave_id_t)enclave_id, &status, &p_target_info, &sgx_report);

    if(SGX_SUCCESS != status){
        printf("Get report failed! status: %d \n" , status);
        report.ret = GET_REPORT_FAILURE;
        return report;

    /* Get quote */

    uint32_t quote_size;
//    status = sgx_calc_quote_size(nullptr, 0, &quote_size);
    sgx_get_quote_size(NULL, &quote_size);

    sgx_quote_t* quote = (sgx_quote_t*) malloc(quote_size);
//    auto *quote = reinterpret_cast<sgx_quote_t *>(malloc(quote_size));

    status = sgx_get_quote(&sgx_report, SGX_LINKABLE_SIGNATURE, &spid, NULL, NULL,
                        0, NULL, quote, quote_size);

    if(SGX_SUCCESS != status){
        printf("Get quote failed! status: %d \n" , status);
        report.ret = GET_QUOTE_FAILURE;
        return report;

    report.ret = GET_REPORT_SUCCESS;
    return report;



sgx_status_t ecall_create_report(sgx_target_info_t *target_info, sgx_report_t *report)

    /*  Construct user defined 64 bytes report data */
    sgx_report_data_t report_data;
    memset(&report_data, 0, sizeof report_data);

    sgx_status_t ret = sgx_create_report(target_info, &report_data, report);

    if(ret != SGX_SUCCESS)
        printf("Create report failed! status: %d \n" , ret);
        return ret;
    sgx_report_t temp_report;
    memcpy(&temp_report, report, sizeof(sgx_report_t));
    ret = sgx_verify_report(&temp_report);

    if(ret != SGX_SUCCESS)
        printf("Verify report failed! status: %d \n" , ret);
        if (SGX_ERROR_MAC_MISMATCH == ret )
            printf("SGX_ERROR_MAC_MISMATCH! \n");
        if (SGX_ERROR_OUT_OF_MEMORY == ret)
            printf("SGX_ERROR_OUT_OF_MEMORY! \n");
        return ret;

    return ret;


I would appreciate any help!



0 Kudos
0 Replies