Skip to content

Commit

Permalink
attester: add evidence_getter binary
Browse files Browse the repository at this point in the history
This tool would help to get evidence in a tee environment, which would
help to do tests.

Signed-off-by: Xynnn007 <[email protected]>
  • Loading branch information
Xynnn007 committed Dec 22, 2023
1 parent 1e76429 commit 853e7f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions attestation-agent/attester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ tokio = { version = "1", features = ["full"], optional = true }
[dev-dependencies]
tokio.workspace = true

[[bin]]
name = "evidence_getter"
required-features = [ "bin" ]

[features]
default = ["all-attesters"]
all-attesters = ["tdx-attester", "sgx-attester", "az-snp-vtpm-attester", "snp-attester", "csv-attester", "cca-attester"]
Expand All @@ -39,3 +43,5 @@ az-snp-vtpm-attester = ["az-snp-vtpm"]
snp-attester = ["sev"]
csv-attester = ["csv-rs", "codicon", "hyper", "hyper-tls", "tokio"]
cca-attester = ["nix"]

bin = ["tokio/rt", "tokio/macros", "all-attesters"]
24 changes: 24 additions & 0 deletions attestation-agent/attester/src/bin/evidence_getter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2023 Alibaba Cloud
//
// SPDX-License-Identifier: Apache-2.0
//

use attester::*;
use codicon::Read;

#[tokio::main]
async fn main() {
// report_data on all platforms is 64 bytes length.
let mut report_data = vec![0; 64];
std::io::stdin()
.read(&mut report_data)
.expect("read input failed");

let tee = detect_tee_type().expect("unknown tee type");
let attester: BoxedAttester = tee.try_into().expect("create attester failed");
let evidence = attester
.get_evidence(report_data)
.await
.expect("get evidence failed");
println!("{evidence}");
}

0 comments on commit 853e7f7

Please sign in to comment.