Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions QuoteGeneration/quote_wrapper/tdx_attest/test_tdx_attest.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include <time.h>
#include "tdx_attest.h"

#define devname "/dev/tdx-attest"

#define HEX_DUMP_SIZE 16

static void print_hex_dump(const char *title, const char *prefix_str,
Expand Down Expand Up @@ -81,19 +79,22 @@ int main(int argc, char *argv[])
uint8_t *p_quote_buf = NULL;
tdx_rtmr_event_t rtmr_event = {0};
FILE *fptr = NULL;
uint32_t ret = 0;

gen_report_data(report_data.d);
print_hex_dump("\n\t\tTDX report data\n", " ", report_data.d, sizeof(report_data.d));

if (TDX_ATTEST_SUCCESS != tdx_att_get_report(&report_data, &tdx_report)) {
fprintf(stderr, "\nFailed to get the report\n");
ret = tdx_att_get_report(&report_data, &tdx_report);
if (TDX_ATTEST_SUCCESS != ret) {
fprintf(stderr, "\nFailed to get the report (%d)\n", ret);
return 1;
Comment on lines +82 to 90
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tdx_att_get_report/get_quote/extend return tdx_attest_error_t, but ret is declared as uint32_t and printed with %d. This can trigger format/type warnings and makes the type intent less clear; consider using tdx_attest_error_t for ret and adjusting the printf format accordingly (e.g., cast or use an unsigned/hex format).

Copilot uses AI. Check for mistakes.
}
print_hex_dump("\n\t\tTDX report\n", " ", tdx_report.d, sizeof(tdx_report.d));

if (TDX_ATTEST_SUCCESS != tdx_att_get_quote(&report_data, NULL, 0, &selected_att_key_id,
&p_quote_buf, &quote_size, 0)) {
fprintf(stderr, "\nFailed to get the quote\n");
ret = tdx_att_get_quote(&report_data, NULL, 0, &selected_att_key_id,
&p_quote_buf, &quote_size, 0);
if (TDX_ATTEST_SUCCESS != ret) {
fprintf(stderr, "\nFailed to get the quote (%d)\n", ret);
return 1;
}
print_hex_dump("\n\t\tTDX quote data\n", " ", p_quote_buf, quote_size);
Expand All @@ -114,16 +115,18 @@ int main(int argc, char *argv[])
}
rtmr_event.event_data_size = 0;

if (TDX_ATTEST_SUCCESS != tdx_att_extend(&rtmr_event)) {
fprintf(stderr, "\nFailed to extend rtmr[2]\n");
ret = tdx_att_extend(&rtmr_event);
if (TDX_ATTEST_SUCCESS != ret) {
fprintf(stderr, "\nFailed to extend rtmr[2] (%d)\n", ret);
} else {
fprintf(stderr, "\nSuccessfully extended rtmr[2]\n");
}

rtmr_event.rtmr_index = 3;

if (TDX_ATTEST_SUCCESS != tdx_att_extend(&rtmr_event)) {
fprintf(stderr, "\nFailed to extend rtmr[3]\n");
ret = tdx_att_extend(&rtmr_event);
if (TDX_ATTEST_SUCCESS != ) {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if condition after the second tdx_att_extend call is missing the variable to compare against (TDX_ATTEST_SUCCESS != ...), which makes this file fail to compile. Please compare against ret as in the other checks.

Suggested change
if (TDX_ATTEST_SUCCESS != ) {
if (TDX_ATTEST_SUCCESS != ret) {

Copilot uses AI. Check for mistakes.
fprintf(stderr, "\nFailed to extend rtmr[3] (%d)\n", ret);
} else {
fprintf(stderr, "\nSuccessfully extended rtmr[3]\n");
}
Expand Down
Loading