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 // SGX
40 static constexpr size_t sgx_attestation_report_data_size = 32;
43
44 // SNP
45 static constexpr size_t snp_attestation_report_data_size = 64;
48
49 // Generic wrapper for attestation report data for _all_ platforms.
51 {
52 std::vector<uint8_t> data;
53
55
57 data(hash.h.begin(), hash.h.end())
58 {}
59
60 template <size_t N>
62 data(report_data.report_data.begin(), report_data.report_data.end())
63 {}
64
65 std::string hex_str() const
66 {
67 return ds::to_hex(data);
68 }
69
71 {
72 std::span<const uint8_t, ccf::crypto::Sha256Hash::SIZE> s(
75 }
76 };
77}
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:28
AttestationReportData< sgx_attestation_report_data_size > SgxAttestationReportData
Definition report_data.h:42
AttestationReportData< snp_attestation_report_data_size > SnpAttestationReportData
Definition report_data.h:47
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:51
PlatformAttestationReportData(const ccf::crypto::Sha256Hash &hash)
Definition report_data.h:56
PlatformAttestationReportData(const AttestationReportData< N > &report_data)
Definition report_data.h:61
std::vector< uint8_t > data
Definition report_data.h:52
ccf::crypto::Sha256Hash to_sha256_hash() const
Definition report_data.h:70
std::string hex_str() const
Definition report_data.h:65