CCF
Loading...
Searching...
No Matches
report_data.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
6
7#include <array>
8#include <span>
9#include <type_traits>
10
11namespace ccf::pal
12{
13 template <size_t N>
15 {
16 std::array<uint8_t, N> report_data;
17
18 static size_t size()
19 {
20 return N;
21 }
22
24 AttestationReportData(std::span<const uint8_t> data)
25 {
26 if (data.size() != size())
27 {
28 throw std::logic_error(fmt::format(
29 "Cannot initialise AttestationReportData with data of size {}, "
30 "expected {}",
31 data.size(),
32 size()));
33 }
34
35 std::copy(data.data(), data.data() + data.size(), report_data.data());
36 }
37 };
38
39 // Virtual
40 static constexpr size_t virtual_attestation_report_data_size = 32;
43
44 // SGX
45 static constexpr size_t sgx_attestation_report_data_size = 32;
48
49 // SNP
50 static constexpr size_t snp_attestation_report_data_size = 64;
53
54 // Generic wrapper for attestation report data for _all_ platforms.
56 {
57 std::vector<uint8_t> data;
58
60
62 data(hash.h.begin(), hash.h.end())
63 {}
64
65 template <size_t N>
67 data(report_data.report_data.begin(), report_data.report_data.end())
68 {}
69
70 std::string hex_str() const
71 {
72 return ds::to_hex(data);
73 }
74
76 {
77 std::span<const uint8_t, ccf::crypto::Sha256Hash::SIZE> s(
80 }
81 };
82}
Definition sha256_hash.h:16
static Sha256Hash from_span(const std::span< const uint8_t, SIZE > &sp)
Definition sha256_hash.cpp:73
static constexpr size_t SIZE
Definition sha256_hash.h:18
Definition attestation.h:20
Definition report_data.h:15
std::array< uint8_t, N > report_data
Definition report_data.h:16
static size_t size()
Definition report_data.h:18
AttestationReportData(std::span< const uint8_t > data)
Definition report_data.h:24
Definition report_data.h:56
PlatformAttestationReportData(const ccf::crypto::Sha256Hash &hash)
Definition report_data.h:61
PlatformAttestationReportData(const AttestationReportData< N > &report_data)
Definition report_data.h:66
std::vector< uint8_t > data
Definition report_data.h:57
ccf::crypto::Sha256Hash to_sha256_hash() const
Definition report_data.h:75
std::string hex_str() const
Definition report_data.h:70