Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtdx-attest: minor improvements of the test_tdx_attest utility program #337

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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;
}
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 != ) {
fprintf(stderr, "\nFailed to extend rtmr[3] (%d)\n", ret);
} else {
fprintf(stderr, "\nSuccessfully extended rtmr[3]\n");
}
Expand Down