@@ -40,9 +40,10 @@ class TcgEventLog:
4040 """
4141
4242 TCG_FORMAT_PCCLIENT = 0
43- TCG_FORMAT_CEL_TLV = 1
44- TCG_FORMAT_CEL_JSON = 2
45- TCG_FORMAT_CEL_CBOR = 3
43+ TCG_FORMAT_CEL = 1
44+ TCG_FORMAT_CEL_TLV = 2
45+ TCG_FORMAT_CEL_JSON = 3
46+ TCG_FORMAT_CEL_CBOR = 4
4647
4748 def __init__ (self , rec_num :int , imr_index :int , event_type :TcgEventType , digests :list [TcgDigest ],
4849 event_size :int , event :bytes , extra_info = None ) -> None :
@@ -59,9 +60,8 @@ def format_event_log(self, parse_format:str):
5960 if parse_format == self .TCG_FORMAT_PCCLIENT :
6061 return self ._to_tcg_pcclient_format ()
6162
62- if parse_format in (self .TCG_FORMAT_CEL_JSON , self .TCG_FORMAT_CEL_CBOR ,
63- self .TCG_FORMAT_CEL_TLV ) :
64- return self ._to_tcg_canonical_format (parse_format )
63+ if parse_format == self .TCG_FORMAT_CEL :
64+ return self ._to_tcg_canonical_format ()
6565
6666 return None
6767
@@ -79,7 +79,7 @@ def _to_tcg_pcclient_format(self):
7979 return TcgImrEvent (self ._imr_index , self ._event_type , self ._digests , self ._event_size ,
8080 self ._event )
8181
82- def _to_tcg_canonical_format (self , encoding : str = None ):
82+ def _to_tcg_canonical_format (self ):
8383 """The function to convert event log data into event log following
8484 Canonical Eventlog Spec.
8585 """
@@ -101,8 +101,9 @@ def _to_tcg_canonical_format(self, encoding:str=None):
101101 None ,
102102 content_data )
103103
104- # switch encoding according to user input
105- return TcgTpmsCelEvent .encode (event , encoding )
104+ # return basic CEL event
105+ # can switch encoding by calling the TcgTpmsCelEvent.encoding()
106+ return event
106107
107108class EventLogs :
108109 """EventLogs class.
@@ -251,7 +252,7 @@ def _parse(self) -> None:
251252 for event in self ._runtime_data .splitlines ():
252253 event_log = self ._parse_ima_event_log (event )
253254 self ._event_logs .append (
254- event_log .format_event_log (TcgEventLog .TCG_FORMAT_CEL_TLV ))
255+ event_log .format_event_log (TcgEventLog .TCG_FORMAT_CEL ))
255256 self ._count += 1
256257
257258 def _parse_spec_id_event_log (self , data :bytes ) -> (TcgEventLog , int ):
@@ -452,22 +453,21 @@ def replay(event_logs:list) -> dict:
452453 # TODO: consider CEL-JSON/CEL-CBOR encoding later
453454 # extract common attributes from different formats, only consider TLV encoding for now
454455 if isinstance (event , TcgTpmsCelEvent ):
455- content_type = event .content . type
456+ content_type = event .content_type
456457 # Align the Canonical types with TCG PCClient Event types
457458 match content_type :
458459 case TcgCelTypes .CEL_IMA_TEMPLATE :
459460 event_type = TcgEventType .IMA_MEASUREMENT_EVENT
460461 case TcgCelTypes .CEL_PCCLIENT_STD :
461462 # For PCClient_STD event,
462463 # the event type is store within the content attribute
463- event_type = event .content .value [0 ].value
464+ # event_type = event.content.value[0].value
465+ event_type = event .content .event_type
464466
465467 # TODO: consider the NV_INDEX case later
466- imr_index = event .index . value
468+ imr_index = event .index
467469
468- digests = []
469- for d in event .digests .value :
470- digests .append (TcgDigest (d .type , d .value ))
470+ digests = event .digests
471471 else :
472472 event_type = event .event_type
473473 # Skip EV_NO_ACTION event during replay as
0 commit comments