@@ -144,6 +144,9 @@ enum AttestCommand {
144144 #[ clap( env) ]
145145 corpus : PathBuf ,
146146 } ,
147+ /// Show the set of measurements currently on the RoT. This includes
148+ /// the cert chain and the measurement log
149+ MeasurementSet ,
147150}
148151
149152/// An enum of the possible routes to the `Attest` task.
@@ -209,6 +212,7 @@ fn main() -> Result<()> {
209212 let cert_chain = attest
210213 . get_certificates ( )
211214 . context ( "Getting attestation certificate chain" ) ?;
215+
212216 for cert in cert_chain {
213217 let cert = cert
214218 . to_pem ( LineEnding :: default ( ) )
@@ -299,11 +303,46 @@ fn main() -> Result<()> {
299303 } => {
300304 verify_measurements ( & cert_chain, & log, & corpus) ?;
301305 }
306+ AttestCommand :: MeasurementSet => {
307+ let set = measurement_set ( attest. as_ref ( ) ) ?;
308+ for item in set. into_iter ( ) {
309+ println ! ( "* {item}" ) ;
310+ }
311+ }
302312 }
303313
304314 Ok ( ( ) )
305315}
306316
317+ fn measurement_set ( attest : & dyn Attest ) -> Result < MeasurementSet > {
318+ // get log
319+ info ! ( "getting measurement log" ) ;
320+ let log = attest
321+ . get_measurement_log ( )
322+ . context ( "Get measurement log from attestor" ) ?;
323+ let mut cert_chain = Vec :: new ( ) ;
324+
325+ let certs = attest
326+ . get_certificates ( )
327+ . context ( "Get certificate chain from attestor" ) ?;
328+
329+ for ( index, cert) in certs. iter ( ) . enumerate ( ) {
330+ info ! ( "writing cert[{index}]" ) ;
331+ let pem = cert
332+ . to_pem ( LineEnding :: default ( ) )
333+ . context ( format ! ( "Encode cert {index} as PEM" ) ) ?;
334+ cert_chain
335+ . write_all ( pem. as_bytes ( ) )
336+ . context ( format ! ( "Write cert {index}" , ) ) ?;
337+ }
338+
339+ let cert_chain: PkiPath = Certificate :: load_pem_chain ( & cert_chain)
340+ . context ( "loading PkiPath from PEM cert chain" ) ?;
341+
342+ MeasurementSet :: from_artifacts ( & cert_chain, & log)
343+ . context ( "MeasurementSet from PkiPath" )
344+ }
345+
307346// Check that the measurments in `cert_chain` and `log` are all present in
308347// the `corpus`.
309348// NOTE: The output of this function is only as trustworthy as its inputs.
0 commit comments