lowRISC / manticore

Apache License 2.0
16 stars 13 forks source link

[tables] Add a parser for the Cerberus Message Table format #150

Closed mcy closed 2 years ago

mcy commented 3 years ago

There is a recently merged RFC in Cerberus that adds tables to the effect of

message AttestationLogFormat Type Name Description
0x0b header_format Header format version.
b16 entry_length Total length of the entry.
b32 unique_id A unique identifier for the entry.
b32 tcg_type The associated TCG event type.
b8 measurement_index Index of the measurement within the PMR.
b8 pmr_index Index of the PMR being extended.
0x0000 _ Reserved.
b8 digest_count Number of digests.
0x0000 _ Reserved.
0x0b digest_algo_id Digest algorithm ID, fixed to SHA-256.
b256 digest SHA-256 digest used to extend the measurement.
[b32] measurement The measurement value.

I designed these tables on the assertion I wanted them to be machine-parseable; this PR is intended to make well on that promise.

Currently, I can only parse things and pretty-print them. Testing this kind of parser is... a pain, so I'm open to suggestions for parsing strategies. I'm not sure if unit tests will be terrifically useful but I can definitely give them a shot.

A followup will add a mode for emitting naive std-using Rust code, and from there we can work on writing a real parser generator.

mcy commented 2 years ago

Johnathan: @capoferro will be taking over this and will be resolving any opens; I'd like to merge it so they can keep this moving along.