Skip to content

Commit

Permalink
attestation-service: add az-tdx-vtpm verifier
Browse files Browse the repository at this point in the history
- Added verification code
- Added tdx fixtures and test cases
- Reorganized snp fixtures
- Added missing dependency for tdx e2e test
- Added entry for e2e test

Signed-off-by: Magnus Kulke <[email protected]>
  • Loading branch information
mkulke committed Nov 29, 2023
1 parent 6aab539 commit aaf600c
Show file tree
Hide file tree
Showing 21 changed files with 255 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/kbs-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
tee:
- sample
# - az-snp-vtpm
# - az-tdx-vtpm

runs-on: ${{ ((matrix.tee == 'az-snp-vtpm') && fromJSON('["self-hosted","azure-cvm"]')) || 'ubuntu-22.04' }}
runs-on: ${{ ((matrix.tee == 'az-snp-vtpm') && fromJSON('["self-hosted","az-snp-vtpm"]')) || ((matrix.tee == 'az-tdx-vtpm') && fromJSON('["self-hosted","az-tdx-vtpm"]')) || 'ubuntu-22.04' }}

steps:
- uses: actions/checkout@v4
Expand Down
107 changes: 77 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion attestation-service/attestation-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ all-verifier = [ "verifier/all-verifier" ]
tdx-verifier = [ "verifier/tdx-verifier" ]
sgx-verifier = [ "verifier/sgx-verifier" ]
az-snp-vtpm-verifier = [ "verifier/az-snp-vtpm-verifier" ]
az-tdx-vtpm-verifier = [ "verifier/az-tdx-vtpm-verifier" ]
snp-verifier = [ "verifier/snp-verifier" ]
csv-verifier = [ "verifier/csv-verifier" ]
cca-verifier = [ "verifier/cca-verifier" ]
Expand All @@ -25,7 +26,7 @@ base64 = "0.21"
cfg-if = "1.0.0"
futures = "0.3.17"
# TODO: change it to "0.5", once released.
kbs-types = { git = "https://github.com/virtee/kbs-types", rev = "c90df0e" }
kbs-types = { git = "https://github.com/virtee/kbs-types", rev = "90b13bb" }
lazy_static = "1.4.0"
log.workspace = true
openssl = { version = "0.10.55", optional = true }
Expand Down
6 changes: 4 additions & 2 deletions attestation-service/verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ edition = "2021"

[features]
default = [ "all-verifier" ]
all-verifier = [ "tdx-verifier", "sgx-verifier", "snp-verifier", "az-snp-vtpm-verifier", "csv-verifier", "cca-verifier" ]
all-verifier = [ "tdx-verifier", "sgx-verifier", "snp-verifier", "az-snp-vtpm-verifier", "az-tdx-vtpm-verifier", "csv-verifier", "cca-verifier" ]
tdx-verifier = [ "eventlog-rs", "scroll", "sgx-dcap-quoteverify-rs" ]
sgx-verifier = [ "scroll", "sgx-dcap-quoteverify-rs" ]
az-snp-vtpm-verifier = [ "az-snp-vtpm", "sev", "snp-verifier" ]
az-tdx-vtpm-verifier = [ "az-tdx-vtpm", "openssl", "tdx-verifier" ]
snp-verifier = [ "asn1-rs", "openssl", "sev", "x509-parser" ]
csv-verifier = [ "openssl", "csv-rs", "codicon" ]
cca-verifier = [ "cbor-diag", "veraison-apiclient" ]
Expand All @@ -18,6 +19,7 @@ anyhow.workspace = true
asn1-rs = { version = "0.5.1", optional = true }
async-trait.workspace = true
az-snp-vtpm = { version = "0.4", default-features = false, features = ["verifier"], optional = true }
az-tdx-vtpm = { version = "0.4", default-features = false, features = ["verifier"], optional = true }
base64 = "0.21"
bincode = "1.3.3"
byteorder = "1"
Expand All @@ -30,7 +32,7 @@ eventlog-rs = { version = "0.1.3", optional = true }
hex = "0.4.3"
jsonwebtoken = "8"
# TODO: change it to "0.5", once released.
kbs-types = { git = "https://github.com/virtee/kbs-types", rev = "c90df0e" }
kbs-types = { git = "https://github.com/virtee/kbs-types", rev = "90b13bb" }
log.workspace = true
openssl = { version = "0.10.55", optional = true }
scroll = { version = "0.11.0", default-features = false, features = ["derive"], optional = true }
Expand Down
12 changes: 6 additions & 6 deletions attestation-service/verifier/src/az_snp_vtpm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ fn verify_snp_report(
mod tests {
use super::*;

const REPORT: &[u8; 2048] = include_bytes!("../../test_data/az-hcl-data.bin");
const SIGNATURE: &[u8; 256] = include_bytes!("../../test_data/az-vtpm-quote-sig.bin");
const MESSAGE: &[u8; 122] = include_bytes!("../../test_data/az-vtpm-quote-msg.bin");
const REPORT: &[u8; 2048] = include_bytes!("../../test_data/az-snp-vtpm/hcl-report.bin");
const SIGNATURE: &[u8; 256] = include_bytes!("../../test_data/az-snp-vtpm/tpm-quote.sig");
const MESSAGE: &[u8; 122] = include_bytes!("../../test_data/az-snp-vtpm/tpm-quote.msg");
const REPORT_DATA: &[u8] = "challenge".as_bytes();

#[test]
fn test_verify_snp_report() {
let hcl_report = HclReport::new(REPORT.to_vec()).unwrap();
let snp_report = hcl_report.try_into().unwrap();
let vcek = Vcek::from_pem(include_str!("../../test_data/az-vcek.pem")).unwrap();
let vcek = Vcek::from_pem(include_str!("../../test_data/az-snp-vtpm/vcek.pem")).unwrap();
let vendor_certs = load_milan_cert_chain().as_ref().unwrap();
verify_snp_report(&snp_report, &vcek, vendor_certs).unwrap();
}
Expand All @@ -143,7 +143,7 @@ mod tests {
wrong_report[0x00b0] = 0;
let hcl_report = HclReport::new(wrong_report.to_vec()).unwrap();
let snp_report = hcl_report.try_into().unwrap();
let vcek = Vcek::from_pem(include_str!("../../test_data/az-vcek.pem")).unwrap();
let vcek = Vcek::from_pem(include_str!("../../test_data/az-snp-vtpm/vcek.pem")).unwrap();
let vendor_certs = load_milan_cert_chain().as_ref().unwrap();
verify_snp_report(&snp_report, &vcek, vendor_certs).unwrap_err();
}
Expand Down Expand Up @@ -194,7 +194,7 @@ mod tests {
signature: SIGNATURE.to_vec(),
message: MESSAGE.to_vec(),
};
let report = include_bytes!("../../test_data/az-hcl-data.bin");
let report = include_bytes!("../../test_data/az-snp-vtpm/hcl-report.bin");
let hcl_report = HclReport::new(report.to_vec()).unwrap();
let mut report_data = REPORT_DATA.to_vec();
report_data.reverse();
Expand Down
Loading

0 comments on commit aaf600c

Please sign in to comment.