Skip to content

Commit

Permalink
Added sleep time to avoid stale report after nvindex update (#59)
Browse files Browse the repository at this point in the history
- Published changes as version 0.7.0

Signed-off-by: Pawel Proskurnicki <[email protected]>
  • Loading branch information
pawelpros authored Sep 6, 2024
1 parent a9d6b21 commit f273ba9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion az-cvm-vtpm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "az-cvm-vtpm"
version = "0.6.0"
version = "0.7.0"
edition = "2021"
repository = "https://github.com/kinvolk/azure-cvm-tooling/"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions az-cvm-vtpm/az-snp-vtpm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "az-snp-vtpm"
version = "0.6.0"
version = "0.7.0"
edition = "2021"
repository = "https://github.com/kinvolk/azure-cvm-tooling/"
license = "MIT"
Expand All @@ -17,7 +17,7 @@ path = "src/main.rs"
required-features = ["attester", "verifier"]

[dependencies]
az-cvm-vtpm = { path = "..", version = "0.6.0" }
az-cvm-vtpm = { path = "..", version = "0.7.0" }
bincode.workspace = true
clap.workspace = true
openssl = { workspace = true, optional = true }
Expand Down
4 changes: 2 additions & 2 deletions az-cvm-vtpm/az-tdx-vtpm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "az-tdx-vtpm"
version = "0.6.0"
version = "0.7.0"
edition = "2021"
repository = "https://github.com/kinvolk/azure-cvm-tooling/"
license = "MIT"
Expand All @@ -16,7 +16,7 @@ name = "tdx-vtpm"
path = "src/main.rs"

[dependencies]
az-cvm-vtpm = { path = "..", version = "0.6.0" }
az-cvm-vtpm = { path = "..", version = "0.7.0" }
base64-url = "3.0.0"
bincode.workspace = true
serde.workspace = true
Expand Down
7 changes: 6 additions & 1 deletion az-cvm-vtpm/src/vtpm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use core::time::Duration;
use serde::{Deserialize, Serialize};
use std::io::Write;
use std::thread;
use thiserror::Error;
use tss_esapi::abstraction::{nv, pcr, public::DecodedKey};
use tss_esapi::attributes::NvIndexAttributesBuilder;
Expand Down Expand Up @@ -102,13 +104,16 @@ pub fn get_report() -> Result<Vec<u8>, ReportError> {
}

/// Retrieve a fresh HCL report from a nvindex. The specified report_data will be reflected
/// in the HCL report in its user_data field and mixed into a hash in the TEE report's report_data
/// in the HCL report in its user_data field and mixed into a hash in the TEE report's report_data.
/// The Function contains a 3 seconds delay to avoid retrieving a stale report.
pub fn get_report_with_report_data(report_data: &[u8]) -> Result<Vec<u8>, ReportError> {
let (nv_index, mut context) = get_session_context()?;

let nv_index_report_data = NvIndexTpmHandle::new(INDEX_REPORT_DATA)?;
write_nv_index(&mut context, nv_index_report_data, report_data)?;

thread::sleep(Duration::new(3, 0));

let report = nv::read_full(&mut context, NvAuth::Owner, nv_index)?;
Ok(report)
}
Expand Down

0 comments on commit f273ba9

Please sign in to comment.