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 <[email protected]>
  • Loading branch information
Ruoyu-y committed Jun 21, 2024
1 parent cf6b883 commit c6cc4a7
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 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.marshal()

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

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

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

def dump(self, is_raw=True) -> None:
"""Dump Quote Data.
Expand All @@ -49,4 +62,8 @@ 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("======================================")
BinaryBlob(self._quoted_data).dump()
BinaryBlob(self._signature).dump()

0 comments on commit c6cc4a7

Please sign in to comment.