def extract_fwid()

in src/local_gpu_verifier/src/verifier/cc_admin_utils.py [0:0]


    def extract_fwid(cert):
        """ A static function to extract the FWID data from the given certificate.
        Args:
            cert (OpenSSL.crypto.X509): The certificate whose FWID data is needed to be fetched.
        Returns:
            [str]: the FWID as a hex string extracted from the certificate if
                    it is present otherwise returns an empty string.
        """
        result = ''
        # The OID for the FWID extension.
        TCG_DICE_FWID_OID = '2.23.133.5.4.1'
        cryptography_cert = cert.to_cryptography()

        for i in range(len(cryptography_cert.extensions)):
            oid_obj = (vars(cryptography_cert.extensions)['_extensions'][i]).oid
            if getattr(oid_obj, 'dotted_string') == TCG_DICE_FWID_OID:
                # The FWID data is the last 48 bytes.
                result = vars((vars(cryptography_cert.extensions)['_extensions'][i]).value)['_value'][-48:].hex()

        return result