#tdx #azure #tpm

bin+lib az-tdx-vtpm

vTPM based TDX attestation for Azure Confidential VMs

13 releases

0.8.1 Feb 12, 2026
0.7.4 Aug 5, 2025
0.7.3 Jul 30, 2025
0.7.1 Nov 18, 2024
0.4.0 Nov 28, 2023

#1578 in Cryptography

Download history 1106/week @ 2025-11-11 1251/week @ 2025-11-18 884/week @ 2025-11-25 1486/week @ 2025-12-02 1350/week @ 2025-12-09 1182/week @ 2025-12-16 768/week @ 2025-12-23 523/week @ 2025-12-30 900/week @ 2026-01-06 1102/week @ 2026-01-13 829/week @ 2026-01-20 1309/week @ 2026-01-27 650/week @ 2026-02-03 965/week @ 2026-02-10 1057/week @ 2026-02-17 2493/week @ 2026-02-24

5,508 downloads per month

MIT license

53KB
822 lines

This library enables guest attestation flows for TDX CVMs on Azure.

A TD report can be retrieved in parsed form using report::get_report() function, or as raw bytes including the hcl envelope using vtpm::get_report(). The library provides a function to retrieve the TD quote from the Azure Instance Metadata Service (IMDS) using imds::get_td_quote(), produce returning a quote signed by a TDX Quoting Enclave.

Variable Data is part of the HCL envelope and holds the public part of the vTPM Attestation Key (AK). A hash of the Variable Data block is included in the TD report as reportdata. TPM quotes retrieved with vtpm::get_quote() should be signed by this AK. A verification function would need to check this to ensure the TD report is linked to this unique TDX CVM.

use az_tdx_vtpm::{hcl, imds, report, tdx, vtpm};
use openssl::pkey::{PKey, Public};
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
  let td_report = report::get_report()?;
  let td_quote_bytes = imds::get_td_quote(&td_report)?;
  std::fs::write("td_quote.bin", td_quote_bytes)?;

  let bytes = vtpm::get_report()?;
  let hcl_report = hcl::HclReport::new(bytes)?;
  let var_data_hash = hcl_report.var_data_sha256();
  let ak_pub = hcl_report.ak_pub()?;

  let td_report: tdx::TdReport = hcl_report.try_into()?;
  assert!(var_data_hash == td_report.report_mac.reportdata[..32]);
  let nonce = "a nonce".as_bytes();

  let tpm_quote = vtpm::get_quote(nonce)?;
  let der = ak_pub.key.try_to_der()?;
  let pub_key = PKey::public_key_from_der(&der)?;
  tpm_quote.verify(&pub_key, nonce)?;

  Ok(())
}

az-tdx-vtpm

Rust Crate Docs

This library enables guest attestation and verification for TDX CVMs on Azure.

Build & Install

cargo b --release -p az-tdx-vtpm
scp ../target/release/tdx-vtpm azureuser@$CONFIDENTIAL_VM:

Run Binary

On the TDX CVM, retrieve a TD Quote and write it to disk:

sudo ./tdx-vtpm

Integration Tests

The integration test suite can run on a TDX CVM. It needs to be executed as root and the tests have to run sequentially.

sudo -E env "PATH=$PATH" cargo t --features integration_test -- --test-threads 1

Dependencies

~9–14MB
~251K SLoC