Open
Description
My goal is a script which only parses a swTPM log and prints the PCR extends like this:
<PCR_index>: <hashAlg> <hash>
This is how far I came so far:
from tpmstream.io.swtpm_log import SWTPMLog
from tpmstream.io import bytes_from_files
from tpmstream.spec.commands import CommandResponseStream
from tpmstream.common.object import events_to_objs
from tpmstream.spec.commands import Command
from tpmstream.spec.structures.constants import TPM_CC
format_in = SWTPMLog
events = format_in.marshal(
tpm_type=CommandResponseStream,
buffer=bytes_from_files([open('tpm.log', 'rb')]),
command_code=None,
abort_on_error=False,
)
commands = events_to_objs(events)
for cmd in commands:
if type(cmd) is Command and cmd.commandCode == TPM_CC.PCR_Extend:
PCR_index = cmd.handles.pcrHandle._value._value
for digest in cmd.parameters.digests.digests:
hash_name = digest.hashAlg._name
print(f"{PCR_index}: {hash_name} <hash>")
But I struggle about how to print the extended hash in a standardized way. Probably it's very simple for someone who has a deep understanding of the code base. Thanks!
Metadata
Metadata
Assignees
Labels
No labels