occlum/demos/remote_attestation/lib/include/tee/ra_quote.h
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

52 lines
1.7 KiB
C++

#ifndef REMOTE_ATTESTATION_LIB_INCLUDE_RA_QUOTE_H_
#define REMOTE_ATTESTATION_LIB_INCLUDE_RA_QUOTE_H_
#include <string>
#include <vector>
#include "./sgx_quote.h"
#include "./sgx_report.h"
#include "./sgx_tseal.h"
#include "./sgx_urts.h"
#include "tee/common/error.h"
#include "tee/common/type.h"
#include "tee/ra_ias.h"
namespace ra {
namespace occlum {
class RaEnclaveQuote {
public:
// The methods that warp the ioctl device interfaces
static TeeErrorCode SgxDeviceInitQuote(sgx_epid_group_id_t* gid);
static TeeErrorCode SgxDeviceGetQuote(EnclaveQuoteArgs* quote_args);
// The methods which are higher wrapper of quote and IasClient together.
TeeErrorCode GetEnclaveQuoteB64(const RaIasServerCfg& ias_server,
const std::string& spid,
const sgx_report_data_t& report_data,
std::string* quote_b64);
TeeErrorCode GetEnclaveIasReport(const RaIasServerCfg& ias_server,
const std::string& spid,
const sgx_report_data_t& report_data,
RaIasReport* ias_report);
private:
uint8_t Hex2Dec(const char hex);
TeeErrorCode GetSpidFromHexStr(const std::string& spid_str);
TeeErrorCode GetIasSigRL(const RaIasServerCfg& ias_server);
TeeErrorCode GetEnclaveQuote(const RaIasServerCfg& ias_server,
const std::string& spid,
const sgx_report_data_t& report_data);
std::vector<uint8_t> quote_buf_;
EnclaveQuoteArgs quote_args_;
};
} // namespace occlum
} // namespace ra
#endif // REMOTE_ATTESTATION_LIB_INCLUDE_RA_QUOTE_H_