occlum/demos/remote_attestation/app/ra_main.cpp
Junxian Xiao 86d11e9d44 Refactor the remote attestation demo
This commits consists of three major changes:

1. Support a new interface to get the base64 quote only.
This is useful in the case that application sends the quote
to service provider server and get the final IAS report there.
The application itself doesn't depend on IAS in this case.

2. Improve the C++ programming style. Now, we only provide
C++ classes and limited C APIs(for configuration and sgx device).

3. Use the more general keywords as names prefix.

Signed-off-by: Junxian Xiao <junxian.xjx@antfin.com>
2020-06-23 16:59:33 +08:00

29 lines
849 B
C++

#include <string>
#include "app/ra_config.h"
#include "tee/ra_quote.h"
int main() {
printf("Remote attestation testing ...\n");
// Don't need to set IAS key/cert when we used accesskey authentication
RaIasServerCfg ias_server;
ias_server.endpoint = RA_CONF_STR(kConfIasServer);
ias_server.accesskey = RA_CONF_STR(kConfIasAccessKey);
std::string spid = RA_CONF_STR(kConfSPID);
// 64Byts report data for adding some project special things if necessary
sgx_report_data_t report_data = {0};
ra::occlum::RaEnclaveQuote ra;
ra::occlum::RaIasReport ias_report;
int ret = ra.GetEnclaveIasReport(ias_server, spid, report_data, &ias_report);
if (ret) {
printf("Fail to get quote or fetch report, error code is %x!\n", ret);
} else {
printf("Test getting quote and fetching report successfully!\n");
}
return ret;
}