Skip to content

Commit

Permalink
tpm: fix tpm quote structure
Browse files Browse the repository at this point in the history
Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
  • Loading branch information
Ruoyu-y committed Jun 24, 2024
1 parent cf6b883 commit 7823787
Showing 1 changed file with 24 additions and 4 deletions.
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.")

0 comments on commit 7823787

Please sign in to comment.