def parse()

in src/local_gpu_verifier/src/verifier/attestation/spdm_msrt_resp_msg.py [0:0]


    def parse(self, binary_data, settings):
        """ Parses the raw measurement record data and sets the fields of the class MeasurementRecord object
        representing the Measurement Record.

        Args:
            binary_data (bytes): the raw Measurement Record data
            settings (config.HopperSettings): the object containing the various config info.

        Raises:
            NoMeasurementBlockError: it is raised when there are zero number of measurement blocks.
            MeasurementSpecificationError: it is raised if any measurement block does not follow DMTF specification.
            ParsingError: it is raised if there is any issue in the parsing of the data.
        """
        assert type(binary_data) is bytes

        if self.NumberOfBlocks == 0:
            err_msg = "\tThere are no measurement blocks in the respone message."
            raise NoMeasurementBlockError(err_msg)

        byte_index = 0

        for _ in range(self.NumberOfBlocks):
            x = binary_data[byte_index: byte_index + self.FieldSize['Index']]
            index = int(x.hex(), 16)
            byte_index = byte_index + self.FieldSize['Index']

            x = binary_data[byte_index: byte_index + self.FieldSize['MeasurementSpecification']]
            measurement_specification = int(x.hex(), 16)
            if measurement_specification != self.DMTF_MEASUREMENT_SPECIFICATION_VALUE:
                raise MeasurementSpecificationError("Measurement block at index ", self.get_index(), \
                                                    " not following DMTF specification.\n\tQuitting now.")
            byte_index = byte_index + self.FieldSize['MeasurementSpecification']

            x = binary_data[byte_index: byte_index + self.FieldSize['MeasurementSize']]
            measurement_size = int(read_field_as_little_endian(x), 16)
            byte_index = byte_index + self.FieldSize['MeasurementSize']

            measurement_data = binary_data[byte_index: byte_index + measurement_size]
            self.MeasurementBlocks[index] = DmtfMeasurement(measurement_data)
            byte_index = byte_index + measurement_size

        if byte_index != len(binary_data):
            err_msg = "Something went wrong while parsing the MeasurementRecord.\nQuitting now."
            raise ParsingError(err_msg)

        count = 0
        for i in range(1, self.NumberOfBlocks + 1):

            if self.MeasurementBlocks[i] is not None \
               and len(self.MeasurementBlocks[i].get_measurement_value()) == self.MeasurementBlocks[i].get_measurement_value_size():
               count = count + 1