Skip to content

Commit 5de275c

Browse files
committed
psp/msg_report: Add attestation report data structures
Attestation report is one of the SNP_GUEST_REQUEST commands that can be send to the PSP firmware. The SnpGuestRequest is used to assemble the request and PSP firmware will send back the response in the SnpGuestResponse structure, which contains the signed attestation report. Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
1 parent 6a7d636 commit 5de275c

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

src/psp/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88

99
/// SNP Guest Request driver
1010
pub mod guest_request_cmd;
11+
/// Attestation report structures
12+
pub mod msg_report;

src/psp/msg_report.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright (C) 2023 IBM
4+
*
5+
* Authors:
6+
* Claudio Carvalho <cclaudio@linux.ibm.com>
7+
*/
8+
9+
/// SnpReportRequest size
10+
const REQUEST_SIZE: usize = core::mem::size_of::<SnpReportRequest>();
11+
12+
/// 64
13+
pub const USER_DATA_SIZE: usize = 64;
14+
15+
#[repr(C, packed)]
16+
#[derive(Debug, Copy, Clone)]
17+
pub struct SnpReportRequest {
18+
user_data: [u8; USER_DATA_SIZE],
19+
vmpl: u32,
20+
rsvd: [u8; 28usize],
21+
}
22+
23+
#[repr(C)]
24+
#[repr(align(2048))]
25+
#[derive(Debug, Copy, Clone)]
26+
pub struct SnpReportResponse {
27+
status: u32,
28+
report_size: u32,
29+
_reserved: [u8; 24],
30+
report: AttestationReport,
31+
}
32+
33+
// Converted tcb_version from enum to
34+
// struct to make alignment simple.
35+
#[repr(C, packed)]
36+
#[derive(Debug, Copy, Clone)]
37+
struct TcbVersion {
38+
raw: u64,
39+
}
40+
41+
#[repr(C, packed)]
42+
#[derive(Debug, Copy, Clone)]
43+
struct Signature {
44+
r: [u8; 72usize],
45+
s: [u8; 72usize],
46+
reserved: [u8; 368usize],
47+
}
48+
49+
#[repr(C, packed)]
50+
#[derive(Debug, Copy, Clone)]
51+
pub struct AttestationReport {
52+
version: u32,
53+
guest_svn: u32,
54+
policy: u64,
55+
family_id: [u8; 16usize],
56+
image_id: [u8; 16usize],
57+
vmpl: u32,
58+
signature_algo: u32,
59+
platform_version: TcbVersion,
60+
platform_info: u64,
61+
flags: u32,
62+
reserved0: u32,
63+
report_data: [u8; 64usize],
64+
measurement: [u8; 48usize],
65+
host_data: [u8; 32usize],
66+
id_key_digest: [u8; 48usize],
67+
author_key_digest: [u8; 48usize],
68+
report_id: [u8; 32usize],
69+
report_id_ma: [u8; 32usize],
70+
reported_tcb: TcbVersion,
71+
reserved1: [u8; 24usize],
72+
chip_id: [u8; 64usize],
73+
reserved2: [u8; 192usize],
74+
signature: Signature,
75+
}

0 commit comments

Comments
 (0)