1111#include < stdexcept>
1212
1313namespace accless ::attestation::mock {
14+ constexpr size_t MOCK_QUOTE_HEADER_SIZE = 16 ;
15+ constexpr uint32_t MOCK_QUOTE_VERSION = 1 ;
16+
1417std::vector<uint8_t > buildMockQuote (const std::vector<uint8_t > &reportData,
1518 const std::array<uint8_t , 8 > &magic) {
1619 std::vector<uint8_t > quote;
@@ -34,67 +37,4 @@ std::vector<uint8_t> buildMockQuote(const std::vector<uint8_t> &reportData,
3437
3538 return quote;
3639}
37-
38- /*
39- size_t mockCurlWriteCallback(char *ptr, size_t size, size_t nmemb,
40- void *userdata) {
41- size_t total = size * nmemb;
42- auto *response = static_cast<std::string *>(userdata);
43- response->append(ptr, total);
44- return total;
45- }
46-
47- std::string postMockQuote(const std::string &url, const std::string &certPath,
48- const std::string &body,
49- const std::string &endpoint) {
50- CURL *curl = curl_easy_init();
51- if (curl == nullptr) {
52- throw std::runtime_error("accless(att): failed to init curl");
53- }
54-
55- char errbuf[CURL_ERROR_SIZE];
56- errbuf[0] = 0;
57-
58- std::string response;
59- std::string fullUrl = url + endpoint;
60- curl_easy_setopt(curl, CURLOPT_URL, fullUrl.c_str());
61- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
62- curl_easy_setopt(curl, CURLOPT_CAINFO, certPath.c_str());
63- curl_easy_setopt(curl, CURLOPT_POST, 1L);
64- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
65- curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
66- static_cast<long>(body.size()));
67- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, mockCurlWriteCallback);
68- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
69- curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
70-
71- struct curl_slist *headers = nullptr;
72- headers = curl_slist_append(headers, "Content-Type: application/json");
73- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
74-
75- CURLcode res = curl_easy_perform(curl);
76- long status = 0;
77- curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
78- curl_easy_cleanup(curl);
79- curl_slist_free_all(headers);
80-
81- if (res != CURLE_OK) {
82- size_t len = strlen(errbuf);
83- fprintf(stderr, "accless(att): curl error: ");
84- if (len) {
85- fprintf(stderr, "%s%s", errbuf,
86- ((errbuf[len - 1] != '\n') ? "\n" : ""));
87- } else {
88- fprintf(stderr, "%s\n", curl_easy_strerror(res));
89- }
90- throw std::runtime_error("accless(att): curl error posting mock quote");
91- }
92- if (status != 200) {
93- throw std::runtime_error(
94- "accless(att): attestation service rejected mock quote");
95- }
96-
97- return response;
98- }
99- */
10040} // namespace accless::attestation::mock
0 commit comments