Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tpm: fix tpm quote structure #135

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions common/python/cctrusted_base/tpm/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
TPM Quote related classes.
"""

import logging
from cctrusted_base.ccreport import CcReport, CcReportData, CcReportSignature
from cctrusted_base.binaryblob import BinaryBlob

LOG = logging.getLogger(__name__)

class Tpm2Quote(CcReport):
"""TPM 2 Quote.
Expand All @@ -28,17 +32,26 @@ def __init__(self, data: bytearray, cc_type):
data: A bytearray storing the raw data.
"""
super().__init__(data, cc_type)
# TODO: parse raw data into header, body and sigature
self._quoted_data = None
self._signature = None

def set_quoted_data(self, data):
"""Set TPM2 quote header"""
self._quoted_data = data

def set_sig(self, sig):
"""Set TPM2 quote signature"""
self._signature = sig

def get_quoted_data(self) -> CcReportData:
"""Get TPM2 quote header."""
# TODO: parse the raw data to get quoted data
return None
return self._quoted_data.marshal()

def get_sig(self) -> CcReportSignature:
"""Get TPM2 quote signature."""
# TODO: parse the raw data to get signature
return None
return self._signature.marshal()

def dump(self, is_raw=True) -> None:
"""Dump Quote Data.
Expand All @@ -49,4 +62,11 @@ def dump(self, is_raw=True) -> None:
False: dump in human readable texts.
"""
# TODO: add human readable dump
super().dump()
LOG.info("======================================")
LOG.info("TPM2 Quote")
LOG.info("======================================")
if is_raw:
BinaryBlob(self._quoted_data.marshal()).dump()
BinaryBlob(self._signature.marshal()).dump()
else:
LOG.error("Structured TPM2 Quote dump is not available now.")
Loading