Skip to content

Commit e181b3e

Browse files
iximeowflihp
authored andcommitted
Bump dice-util
This brings in the asyncification of `trait Attest`, and preparation for more kinds of nonce.
1 parent 68a4b3b commit e181b3e

6 files changed

Lines changed: 108 additions & 44 deletions

File tree

Cargo.lock

Lines changed: 81 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ panic = "abort"
1919
[workspace.dependencies]
2020
anyhow = { version = "1", default-features = false }
2121
camino = { version = "1.1.7", default-features = false, features = ["serde1"] }
22-
attest-data = { git = "https://github.com/oxidecomputer/dice-util", rev = "6e0ef48f72ff85ba50fc8286c8e89dc5f9c822dd" }
22+
attest-data = { git = "https://github.com/oxidecomputer/dice-util", rev = "d7472bfa91aee859c3fe0bdc1dbb1e320285228e" }
2323
clap = { version = "4", default-features = false, features = ["std", "derive", "default", "wrap_help"] }
2424
ciborium = "0.2.2"
2525
cfg-if = "1.0"
26-
dice-mfg-msgs = { git = "https://github.com/oxidecomputer/dice-util", rev = "6e0ef48f72ff85ba50fc8286c8e89dc5f9c822dd" }
27-
dice-verifier = { git = "https://github.com/oxidecomputer/dice-util", rev = "6e0ef48f72ff85ba50fc8286c8e89dc5f9c822dd" }
26+
dice-mfg-msgs = { git = "https://github.com/oxidecomputer/dice-util", rev = "d7472bfa91aee859c3fe0bdc1dbb1e320285228e" }
27+
dice-verifier = { git = "https://github.com/oxidecomputer/dice-util", rev = "d7472bfa91aee859c3fe0bdc1dbb1e320285228e" }
2828
ed25519-dalek = { version = "2.1", default-features = false, features = ["digest", "pkcs8"] }
2929
libipcc = { git = "https://github.com/oxidecomputer/ipcc-rs", rev = "524eb8f125003dff50b9703900c6b323f00f9e1b" }
3030
pem-rfc7468 = { version = "0.7.0"}

tls/src/client.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use crate::{
2222
use crate::{Error, Stream};
2323
use camino::Utf8PathBuf;
2424
use dice_verifier::{
25-
Attestation, Corim, Log, MeasurementSet, Nonce, ReferenceMeasurements,
25+
Attestation, Corim, Log, MeasurementSet, Nonce, Nonce32,
26+
ReferenceMeasurements,
2627
};
2728
use hubpack::SerializedSize;
2829
use rustls::{
@@ -315,7 +316,7 @@ impl Client {
315316
info!(log, "Running with protocol version {version}");
316317

317318
// send Nonce to server
318-
let nonce = Nonce::from_platform_rng()?;
319+
let nonce = Nonce::from_platform_rng(Nonce32::LENGTH)?;
319320
send_msg(&mut stream, nonce.as_ref()).await?;
320321

321322
// get Nonce from server
@@ -326,7 +327,8 @@ impl Client {
326327
// The attesation protocol has an inherent race condition between
327328
// getting the log and the attestation. We verify our own attestation
328329
// before sending it to the challenger to fail as early as possible.
329-
let attest_data = get_attest_data(&attest_config, &server_nonce)?;
330+
let attest_data =
331+
get_attest_data(&attest_config, &server_nonce).await?;
330332
dice_verifier::verify_attestation(
331333
&attest_data.certs[0],
332334
&attest_data.attestation,

tls/src/keys.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,21 +406,20 @@ pub struct AttestArtifacts {
406406
pub test_corpus: Vec<Utf8PathBuf>,
407407
}
408408

409-
/// This function encapsulates our IPCC usage in a non-async function. This is
410-
/// required till the Ipcc handle is `Send`.
409+
/// Collect attestation information from the configured attestor.
411410
///
412411
/// NOTE: The `Nonce` parameter must be the nonce provided by the peer in an
413412
/// attestation exchange.
414-
pub fn get_attest_data(
413+
pub async fn get_attest_data(
415414
config: &AttestConfig,
416415
nonce: &dice_verifier::Nonce,
417416
) -> Result<AttestArtifacts, Error> {
418417
use dice_verifier::{ipcc::AttestIpcc, Attest, AttestMock};
419418

420419
// create the `Attest` impl prescribed by the config
421-
let (attest, test_corpus): (Box<dyn Attest>, Vec<Utf8PathBuf>) =
420+
let (attest, test_corpus): (Box<dyn Attest + Send>, Vec<Utf8PathBuf>) =
422421
match config {
423-
AttestConfig::Ipcc => (Box::new(AttestIpcc::new()?), vec![]),
422+
AttestConfig::Ipcc => (Box::new(AttestIpcc {}), vec![]),
424423
AttestConfig::Local {
425424
priv_key,
426425
cert_chain,
@@ -432,10 +431,14 @@ pub fn get_attest_data(
432431
),
433432
};
434433

434+
let certs = attest.get_certificates().await?;
435+
let log = attest.get_measurement_log().await?;
436+
let attestation = attest.attest(nonce).await?;
437+
435438
Ok(AttestArtifacts {
436-
certs: attest.get_certificates()?,
437-
log: attest.get_measurement_log()?,
438-
attestation: attest.attest(nonce)?,
439+
certs,
440+
log,
441+
attestation,
439442
test_corpus,
440443
})
441444
}

tls/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub enum Error {
8686
#[error("AttestData error")]
8787
AttestData(#[from] attest_data::AttestDataError),
8888

89+
#[error("Nonce error")]
90+
NonceError(#[from] attest_data::NonceError),
91+
8992
#[error("Failed to verify peer attestation cert chain")]
9093
AttestCertVerifier(#[from] dice_verifier::PkiPathSignatureVerifierError),
9194

0 commit comments

Comments
 (0)