@@ -33,7 +33,7 @@ fn get_attest(interface: Interface, log: &Logger) -> Result<Box<dyn Attest>> {
3333 slog:: info!( log, "attesting via {interface:?}" ) ;
3434 match interface {
3535 #[ cfg( feature = "ipcc" ) ]
36- Interface :: Ipcc => Ok ( Box :: new ( AttestIpcc :: new ( ) ? ) ) ,
36+ Interface :: Ipcc => Ok ( Box :: new ( AttestIpcc :: new ( ) ) ) ,
3737 Interface :: Rot => Ok ( Box :: new ( AttestHiffy :: new ( AttestTask :: Rot ) ) ) ,
3838 #[ cfg( feature = "sled-agent" ) ]
3939 Interface :: SledAgent ( addr) => {
@@ -205,7 +205,8 @@ impl fmt::Display for Encoding {
205205 }
206206}
207207
208- fn main ( ) -> Result < ( ) > {
208+ #[ tokio:: main( flavor = "current_thread" ) ]
209+ async fn main ( ) -> Result < ( ) > {
209210 let args = Args :: parse ( ) ;
210211
211212 let stderr_decorator = slog_term:: TermDecorator :: new ( ) . build ( ) ;
@@ -246,6 +247,7 @@ fn main() -> Result<()> {
246247 Nonce :: try_from ( nonce) . context ( "Nonce from file contents" ) ?;
247248 let attestation = attest
248249 . attest ( & nonce)
250+ . await
249251 . context ( "Getting attestation with provided Nonce" ) ?;
250252
251253 // serialize attestation to json & write to file
@@ -261,6 +263,7 @@ fn main() -> Result<()> {
261263 AttestCommand :: CertChain => {
262264 let cert_chain = attest
263265 . get_certificates ( )
266+ . await
264267 . context ( "Getting attestation certificate chain" ) ?;
265268
266269 for cert in cert_chain {
@@ -277,6 +280,7 @@ fn main() -> Result<()> {
277280 AttestCommand :: Log => {
278281 let log = attest
279282 . get_measurement_log ( )
283+ . await
280284 . context ( "Getting attestation measurement log" ) ?;
281285 let mut log = serde_json:: to_string ( & log)
282286 . context ( "Encode measurement log as JSON" ) ?;
@@ -311,13 +315,16 @@ fn main() -> Result<()> {
311315 // Use the directory provided by the caller to hold intermediate
312316 // files, or fall back to a temp dir.
313317 let platform_id = match work_dir {
314- Some ( w) => verify (
315- attest. as_ref ( ) ,
316- ca_cert. as_deref ( ) ,
317- corpus. as_deref ( ) ,
318- self_signed,
319- & w,
320- ) ?,
318+ Some ( w) => {
319+ verify (
320+ attest. as_ref ( ) ,
321+ ca_cert. as_deref ( ) ,
322+ corpus. as_deref ( ) ,
323+ self_signed,
324+ & w,
325+ )
326+ . await ?
327+ }
321328 None => {
322329 if corpus. is_none ( ) && !skip_appraisal {
323330 return Err ( anyhow ! ( "no corpus provided but not instructed to skip measurement log appraisal" ) ) ;
@@ -329,7 +336,8 @@ fn main() -> Result<()> {
329336 corpus. as_deref ( ) ,
330337 self_signed,
331338 work_dir. as_ref ( ) ,
332- ) ?
339+ )
340+ . await ?
333341 }
334342 } ;
335343
@@ -358,7 +366,7 @@ fn main() -> Result<()> {
358366 verify_measurements ( & cert_chain, & log, & corpus) ?;
359367 }
360368 AttestCommand :: MeasurementSet => {
361- let set = measurement_set ( attest. as_ref ( ) ) ?;
369+ let set = measurement_set ( attest. as_ref ( ) ) . await ?;
362370 for item in set. into_iter ( ) {
363371 println ! ( "* {item}" ) ;
364372 }
@@ -368,15 +376,17 @@ fn main() -> Result<()> {
368376 Ok ( ( ) )
369377}
370378
371- fn measurement_set ( attest : & dyn Attest ) -> Result < MeasurementSet > {
379+ async fn measurement_set ( attest : & dyn Attest ) -> Result < MeasurementSet > {
372380 info ! ( "getting measurement log" ) ;
373381 let log = attest
374382 . get_measurement_log ( )
383+ . await
375384 . context ( "Get measurement log from attestor" ) ?;
376385 let mut cert_chain = Vec :: new ( ) ;
377386
378387 let certs = attest
379388 . get_certificates ( )
389+ . await
380390 . context ( "Get certificate chain from attestor" ) ?;
381391
382392 for ( index, cert) in certs. iter ( ) . enumerate ( ) {
@@ -431,7 +441,7 @@ fn verify_measurements(
431441 . context ( "Verify measurements" )
432442}
433443
434- fn verify (
444+ async fn verify (
435445 attest : & dyn Attest ,
436446 ca_cert : Option < & Path > ,
437447 corpus : Option < & Path > ,
@@ -453,6 +463,7 @@ fn verify(
453463 info ! ( "getting attestation" ) ;
454464 let attestation = attest
455465 . attest ( & nonce)
466+ . await
456467 . context ( "Get attestation with nonce" ) ?;
457468
458469 // serialize attestation to json & write to file
@@ -471,6 +482,7 @@ fn verify(
471482 info ! ( "getting measurement log" ) ;
472483 let log = attest
473484 . get_measurement_log ( )
485+ . await
474486 . context ( "Get measurement log from attestor" ) ?;
475487 let mut log = serde_json:: to_string ( & log)
476488 . context ( "Serialize measurement log to JSON" ) ?;
@@ -494,6 +506,7 @@ fn verify(
494506
495507 let certs = attest
496508 . get_certificates ( )
509+ . await
497510 . context ( "Get certificate chain from attestor" ) ?;
498511
499512 // the first cert in the chain / the leaf cert is the one
0 commit comments