Skip to content

Commit eeafc2c

Browse files
committed
feat: support V6 report format
- Use sev crate from GitHub (main branch) to support Report Version 6 - Update Cargo.toml with git dependency and required features - Modify code to handle new fields (e.g., launch_mit_vector) - Add description of --launch_mit_vector option in README.md Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
1 parent 255496e commit eeafc2c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ hyperv = ["tss-esapi"]
2222
clap = { version = "4.5", features = [ "derive" ] }
2323
env_logger = "0.10.0"
2424
anyhow = "1.0.69"
25-
sev = { version = "6.2.1", default-features = false, features = ['openssl','snp']}
25+
sev = { git = "https://github.com/virtee/sev", default-features = false, features = ['openssl','snp']}
2626
nix = "^0.23"
2727
serde = { version = "1.0", features = ["derive"] }
2828
bincode = "^1.2.1"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ snpguest fetch <SUBCOMMAND>
163163

164164
### 5. `key`
165165

166-
Creates the derived key based on input parameters and stores it. `$KEY_PATH` is the path to store the derived key. `$ROOT_KEY_SELECT` is the root key from which to derive the key (either "vcek" or "vmrk"). The `--guest_field_select` option specifies which Guest Field Select bits to enable as a 6-digit binary string. Each of the 6 bits from *right to left* correspond to Guest Policy, Image ID, Family ID, Measurement, SVN and TCB Version respectively. For each bit, 0 denotes off, and 1 denotes on. The `--guest_svn` option specifies the guest SVN to mix into the key, and the `--tcb_version` option specifies the TCB version to mix into the derived key. The `--vmpl` option specifies the VMPL level the Guest is running on and defaults to 1.
166+
Creates the derived key based on input parameters and stores it. `$KEY_PATH` is the path to store the derived key. `$ROOT_KEY_SELECT` is the root key from which to derive the key (either "vcek" or "vmrk"). The `--guest_field_select` option specifies which Guest Field Select bits to enable as a 6-digit binary string. Each of the 6 bits from *right to left* correspond to Guest Policy, Image ID, Family ID, Measurement, SVN and TCB Version respectively. For each bit, 0 denotes off, and 1 denotes on. The `--guest_svn` option specifies the guest SVN to mix into the key, the `--tcb_version` option specifies the TCB version to mix into the derived key, and the `--launch_mit_vector` option specifies the launch mitigation vector value to mix into the derived key. The `--vmpl` option specifies the VMPL level the Guest is running on and defaults to 1.
167167

168168

169169
**Usage**
@@ -180,6 +180,7 @@ snpguest key $KEY_PATH $ROOT_KEY_SELECT [-v, --vmpl] [-g, --guest_field_select]
180180
| `-g, --guest_field_select $GFS` | option specifies which Guest Field Select bits to enable as a 6-digit binary string. For each bit, 0 denotes off, and 1 denotes on. ||
181181
| `-s, --guest_svn $GSVN` | option specifies the guest SVN to mix into the key. ||
182182
| `-t, --tcb_version $TCBV` | option specifies the TCB version to mix into the derived key. ||
183+
| `-l, --launch_mit_vector $LMV` | option specifies the launch mitigation vector value to mix into the derived key (only available for report version 5). ||
183184

184185
**Guest Field Select**
185186

src/key.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ pub struct KeyArgs {
3232
/// Specify the TCB version to mix into the derived key. Must not exceed CommittedTcb.
3333
#[arg(short, long = "tcb_version")]
3434
pub tcbv: Option<u64>,
35+
36+
/// Specify the launch mitigation vector to mix into the derived key.
37+
#[arg(short, long = "launch_mit_vector")]
38+
pub lmv: Option<u64>,
3539
}
3640

3741
pub fn get_derived_key(args: KeyArgs) -> Result<()> {
@@ -68,7 +72,14 @@ pub fn get_derived_key(args: KeyArgs) -> Result<()> {
6872

6973
let tcbv: u64 = args.tcbv.unwrap_or(0);
7074

71-
let request = DerivedKey::new(root_key_select, GuestFieldSelect(gfs), vmpl, gsvn, tcbv);
75+
let request = DerivedKey::new(
76+
root_key_select,
77+
GuestFieldSelect(gfs),
78+
vmpl,
79+
gsvn,
80+
tcbv,
81+
args.lmv,
82+
);
7283
let mut sev_fw = Firmware::open().context("failed to open SEV firmware device.")?;
7384
let derived_key: [u8; 32] = sev_fw
7485
.get_derived_key(None, request)

0 commit comments

Comments
 (0)