Skip to content

Commit ff2cb6e

Browse files
committed
Tmp
1 parent 1808c9a commit ff2cb6e

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

include/ccf/pal/attestation_sev_snp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ QPHfbkH0CyPfhl1jWhJFZasCAwEAAQ==
5151
static_assert(
5252
sizeof(TcbVersion) == sizeof(uint64_t),
5353
"Can't cast TcbVersion to uint64_t");
54+
DECLARE_JSON_TYPE(TcbVersion);
55+
DECLARE_JSON_REQUIRED_FIELDS(TcbVersion, boot_loader, tee, snp, microcode);
5456

5557
#pragma pack(push, 1)
5658
struct Signature
@@ -264,6 +266,7 @@ QPHfbkH0CyPfhl1jWhJFZasCAwEAAQ==
264266
virtual ~AttestationInterface() = default;
265267
};
266268

269+
static uint8_t MIN_TCB_VERIF_VERSION = 3;
267270
#pragma pack(push, 1)
268271
struct CPUID
269272
{
@@ -287,6 +290,8 @@ QPHfbkH0CyPfhl1jWhJFZasCAwEAAQ==
287290
bool operator==(const AttestChipModel&) const = default;
288291
};
289292
#pragma pack(pop)
293+
DECLARE_JSON_TYPE(AttestChipModel);
294+
DECLARE_JSON_REQUIRED_FIELDS(AttestChipModel, family, model, stepping);
290295

291296
constexpr AttestChipModel get_attest_chip_model(const CPUID& cpuid)
292297
{

src/node/rpc/member_frontend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ccf/service/tables/jwt.h"
1616
#include "ccf/service/tables/members.h"
1717
#include "ccf/service/tables/nodes.h"
18+
#include "ccf/service/tables/tcb_verification.h"
1819
#include "frontend.h"
1920
#include "js/extensions/ccf/network.h"
2021
#include "js/extensions/ccf/node.h"

src/node/rpc/node_frontend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ namespace ccf
16571657
}
16581658

16591659
InternalTablesAccess::trust_static_snp_tcb_version(ctx.tx);
1660+
//InternalTablesAccess::trust_node_snp_tcb_version(ctx.tx, in.quote_info);
16601661

16611662
std::optional<ccf::ClaimsDigest::Digest> digest =
16621663
ccf::get_create_tx_claims_digest(ctx.tx);

src/service/internal_tables_access.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ namespace ccf
833833
.base_family = 0xF,
834834
.extended_model = 0x0,
835835
.extended_family = 0x0A});
836-
constexpr pal::snp::TcbVersion milan_tcb_version = {.microcode = 0xDB, .snp = 0x18};
836+
constexpr pal::snp::TcbVersion milan_tcb_version = {
837+
.microcode = 0xDB, .snp = 0x18};
837838
h->put(milan_chip_id, milan_tcb_version);
838839

839840
constexpr auto milan_x_chip_id = pal::snp::get_attest_chip_model(
@@ -842,7 +843,8 @@ namespace ccf
842843
.base_family = 0xF,
843844
.extended_model = 0x0,
844845
.extended_family = 0x0A});
845-
constexpr pal::snp::TcbVersion milan_x_tcb_version = {.microcode = 0x44, .snp = 0x18};
846+
constexpr pal::snp::TcbVersion milan_x_tcb_version = {
847+
.microcode = 0x44, .snp = 0x18};
846848
h->put(milan_x_chip_id, milan_x_tcb_version);
847849

848850
constexpr auto genoa_chip_id = pal::snp::get_attest_chip_model(
@@ -851,7 +853,8 @@ namespace ccf
851853
.base_family = 0xF,
852854
.extended_model = 0x1,
853855
.extended_family = 0x0A});
854-
constexpr pal::snp::TcbVersion genoa_tcb_version = {.microcode = 0x54, .snp = 0x17};
856+
constexpr pal::snp::TcbVersion genoa_tcb_version = {
857+
.microcode = 0x54, .snp = 0x17};
855858
h->put(genoa_chip_id, genoa_tcb_version);
856859

857860
constexpr auto genoa_x_chip_id = pal::snp::get_attest_chip_model(
@@ -860,10 +863,26 @@ namespace ccf
860863
.base_family = 0xF,
861864
.extended_model = 0x1,
862865
.extended_family = 0x0A});
863-
constexpr pal::snp::TcbVersion genoa_x_tcb_version = {.microcode = 0x4F, .snp = 0x17};
866+
constexpr pal::snp::TcbVersion genoa_x_tcb_version = {
867+
.microcode = 0x4F, .snp = 0x17};
864868
h->put(genoa_x_chip_id, genoa_x_tcb_version);
865869
}
866870

871+
static void trust_node_snp_tcb_version(
872+
ccf::kv::Tx& tx, const pal::snp::Attestation& attestation)
873+
{
874+
if (attestation.version >= pal::snp::MIN_TCB_VERIF_VERSION)
875+
{
876+
pal::snp::AttestChipModel chip_id{
877+
.family = attestation.cpuid_fam_id,
878+
.model = attestation.cpuid_mod_id,
879+
.stepping = attestation.cpuid_step,
880+
};
881+
auto h = tx.wo<ccf::SnpTcbVersionMap>(Tables::SNP_TCB_VERSIONS);
882+
h->put(chip_id, attestation.reported_tcb);
883+
}
884+
}
885+
867886
static void init_configuration(
868887
ccf::kv::Tx& tx, const ServiceConfiguration& configuration)
869888
{

src/service/network_tables.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace ccf
9797
const SnpMeasurements snp_measurements = {Tables::NODE_SNP_MEASUREMENTS};
9898
const SNPUVMEndorsements snp_uvm_endorsements = {
9999
Tables::NODE_SNP_UVM_ENDORSEMENTS};
100-
const SNPTCBVersions snp_tcb_versions = {Tables::SNP_TCB_VERSIONS};
100+
const SnpTcbVersionMap snp_tcb_versions = {Tables::SNP_TCB_VERSIONS};
101101

102102
inline auto get_all_node_tables() const
103103
{
@@ -110,8 +110,8 @@ namespace ccf
110110
virtual_measurements,
111111
host_data,
112112
snp_measurements,
113-
snp_uvm_endorsements,
114-
snp_tcb_versions);
113+
snp_uvm_endorsements
114+
);
115115
}
116116

117117
//

0 commit comments

Comments
 (0)