8000 Filter PCR extends · Issue #29 · joholl/tpmstream · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Filter PCR extends #29
Open
Open
@akorb

Description

@akorb

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0