Skip to content

Commit efb7277

Browse files
Laura Abbottlabbott
Laura Abbott
authored andcommitted
wip
1 parent e0cb22d commit efb7277

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

attest-data/src/messages.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub const ATTEST_MAGIC: u32 = 0xA77E5700;
1313
/// Right now `Attest` and `TqSign` are the only commands that take data
1414
/// argumenets. They happen to be the same length right now but this also
1515
/// catches anything silly
16-
1716
const fn const_max(a: usize, b: usize) -> usize {
1817
[a, b][(a < b) as usize]
1918
}

verifier-ipcc/src/main.rs

+36-11
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,8 @@ enum Command {
6060
/// Generates a nonce, attestation and verifies it
6161
VerifyRoundTrip {
6262
/// Path to file holding trust anchor for the associated PKI.
63-
#[clap(
64-
long,
65-
env = "VERIFIER_CLI_CA_CERT",
66-
conflicts_with = "self_signed"
67-
)]
63+
#[clap(long, env = "VERIFIER_CLI_CA_CERT")]
6864
ca_cert: Option<PathBuf>,
69-
70-
/// Verify the final cert in the provided PkiPath against itself.
71-
#[clap(long, env, conflicts_with = "ca_cert")]
72-
self_signed: bool,
7365
},
7466
/// Verify the log against the given set of measurements
7567
VerifyLog {
@@ -167,7 +159,7 @@ impl Ipcc {
167159
&mut rot_message,
168160
&HostToRotCommand::Attest,
169161
|buf| {
170-
buf[..nonce.len()].copy_from_slice(&nonce);
162+
buf[..nonce.len()].copy_from_slice(nonce);
171163
32
172164
},
173165
)
@@ -185,6 +177,7 @@ impl Ipcc {
185177
}
186178

187179
fn main() -> Result<()> {
180+
env_logger::init();
188181
let handle = Ipcc::new()?;
189182

190183
let args = Args::parse();
@@ -232,7 +225,7 @@ fn main() -> Result<()> {
232225
let nonce = std::fs::read(nonce)?;
233226
let nonce = Nonce::try_from(&nonce[..])?;
234227

235-
let attest = handle.attest(&nonce.as_ref())?;
228+
let attest = handle.attest(nonce.as_ref())?;
236229

237230
std::fs::write(&out, &attest)?;
238231
info!("Wrote attestation to {:?}", out);
@@ -261,6 +254,38 @@ fn main() -> Result<()> {
261254
&log,
262255
&nonce,
263256
)?;
257+
info!("Attestation succeeded.");
258+
}
259+
Command::VerifyRoundTrip { ca_cert } => {
260+
let nonce = Nonce::from_platform_rng()?;
261+
262+
let attestation = handle.attest(nonce.as_ref())?;
263+
let (attestation, _) = hubpack::deserialize::<Attestation>(
264+
&attestation,
265+
)
266+
.map_err(|e| anyhow!("Failed to deserialize Attestation: {}", e))?;
267+
268+
let log = handle.get_measurement_log()?;
269+
270+
let chain = handle.get_certificates()?;
271+
let root = match ca_cert {
272+
Some(r) => {
273+
let root = std::fs::read(r)?;
274+
Some(Certificate::from_pem(root)?)
275+
}
276+
None => None,
277+
};
278+
279+
let verifier = PkiPathSignatureVerifier::new(root)?;
280+
verifier.verify(&chain)?;
281+
282+
dice_verifier::verify_attestation(
283+
&chain[0],
284+
&attestation,
285+
&log,
286+
&nonce,
287+
)?;
288+
info!("Success.");
264289
}
265290
_ => todo!(),
266291
}

0 commit comments

Comments
 (0)