@@ -154,6 +154,7 @@ def add_device(
154154 fw_hash_sha384 : str ,
155155 fw_hash_sha512 : str ,
156156 manifest : str = None ,
157+ class_id : str = None ,
157158 ) -> None :
158159 """Add metadata that describes the vendor's device that was tested.
159160
@@ -175,6 +176,9 @@ def add_device(
175176 this is a hash of that field instead.
176177 fw_hash_sha512: ... ditto but using SHA2-512 ...
177178 manifest: A JSON list of filename and file hash pairs. This field is optional.
179+ class_id: Optional class identifier string (e.g. "FMC_INFO"). When set,
180+ the CoRIM environment class-map includes this as the class-id
181+ (encoded as raw bytes at key 0) in addition to vendor/model.
178182 """
179183 self .report ["device" ] = {}
180184 self .report ["device" ]["vendor" ] = f"{ vendor } " .strip ()
@@ -186,6 +190,8 @@ def add_device(
186190 self .report ["device" ]["fw_hash_sha2_512" ] = f"{ fw_hash_sha512 } " .strip ()
187191 if manifest is not None :
188192 self .report ["device" ]["manifest" ] = manifest
193+ if class_id is not None :
194+ self .report ["device" ]["class_id" ] = f"{ class_id } " .strip ()
189195
190196 def add_audit (
191197 self ,
@@ -379,6 +385,22 @@ def _convert_to_corim_structure(self) -> Dict[str, Any]:
379385
380386 return sfr_map
381387
388+ def _build_class_map (self ) -> dict :
389+ """Build the class-map for the environment, using class-id when
390+ available, otherwise falling back to vendor/model."""
391+ class_map = {}
392+ class_id = self .report ["device" ].get ("class_id" )
393+ if class_id :
394+ # Encode class-id as raw bytes (UTF-8) at key 0
395+ class_map [0 ] = class_id .encode ("utf-8" )
396+ vendor = self .report ["device" ].get ("vendor" , "" ).strip ()
397+ model = self .report ["device" ].get ("product" , "" ).strip ()
398+ if vendor :
399+ class_map [1 ] = vendor
400+ if model :
401+ class_map [2 ] = model
402+ return class_map
403+
382404 def _build_corim_structure (self , sfr_map : Dict [str , Any ]) -> Dict [str , Any ]:
383405 """Build the complete CoRIM structure with embedded SFR data."""
384406
@@ -399,28 +421,20 @@ def _build_corim_structure(self, sfr_map: Dict[str, Any]) -> Dict[str, Any]:
399421 }
400422 }
401423
424+ class_map = self ._build_class_map ()
425+
402426 # Create endorsed-triple-record
403427 endorsed_triple = [
404428 # environment-map
405- {
406- 0 : { # class
407- 1 : self .report ["device" ]["vendor" ], # vendor
408- 2 : self .report ["device" ]["product" ], # model
409- }
410- },
429+ {0 : class_map },
411430 # endorsement (array of measurement-map)
412431 [endorsement_measurement_map ],
413432 ]
414433
415434 # Create stateful-environment-record for conditions
416435 stateful_environment = [
417436 # environment-map
418- {
419- 0 : { # class
420- 1 : self .report ["device" ]["vendor" ], # vendor
421- 2 : self .report ["device" ]["product" ], # model
422- }
423- },
437+ {0 : class_map },
424438 # claims-list (measurement-map array)
425439 [condition_measurement_map ],
426440 ]
0 commit comments