コード例 #1
0
ファイル: mbn_v3_base.py プロジェクト: Gehhilfe/Center-Stage
    def _get_data_int(self, sign):
        # Backup the parsegen
        backup = _BackupMbnParsegen(self._mbn_parsegen)

        # Update the security attributes per the flags
        if sign:
            self._mbn_parsegen.sign = self._data_signature
            self._mbn_parsegen.cert_chain = self._cert_chain

        self._mbn_parsegen.pad_max_encr_params_size = 0

        # Set padding info
        if sign:
            self._mbn_parsegen.set_pad_info(
                self.sig_size, self.get_cert_chain_size(self.authority))

        # Get the signed data
        retval = self._mbn_parsegen.get_data(self.authority, self.imageinfo,
                                             self.validating, self.signing,
                                             self.add_signing_attr_to_hash_seg)

        # Clear padding info
        self._mbn_parsegen.set_pad_info(0, 0)

        # Restore the parsegen
        backup.restore(self._mbn_parsegen, "sign", "cert_chain")

        return retval
コード例 #2
0
ファイル: mbn_v3_base.py プロジェクト: Gehhilfe/Center-Stage
    def data_to_sign(self):
        # Backup the parsegen
        backup = _BackupMbnParsegen(self._mbn_parsegen, "sign", "cert_chain")

        with V3DataToSignCtxMgr(self) as ctx:
            pass

        retval = ctx.header.pack() + self._mbn_parsegen.code

        # Clear padding info
        self._mbn_parsegen.set_pad_info(0, 0)

        # Restore the parsegen
        backup.restore(self._mbn_parsegen, "sign", "cert_chain")

        return retval
コード例 #3
0
    def data_to_sign_format(self):
        # Backup the parsegen
        backup = _BackupMbnParsegen(self._mbn_parsegen, "sign", "cert_chain")

        # Get the format of the data to sign
        with V3DataToSignCtxMgr(self) as ctx:
            pass
        fmt = ctx.header.get_format_description()

        # Clear padding info
        self._mbn_parsegen.set_pad_info(0, 0)

        # Restore the parsegen
        backup.restore(self._mbn_parsegen, "sign", "cert_chain")

        return fmt
コード例 #4
0
ファイル: mbn_v6.py プロジェクト: mxpro2003/qcs605_root
    def data_to_sign(self):
        # Backup the parsegen
        backup = _BackupMbnParsegen(
            self._mbn_parsegen, "sign", "cert_chain", "encryption_params",
            "sign_qti", "cert_chain_qti")

        with V5DataToSignCtxMgr(self) as ctx:
            pass

        # Mask metadata and sig/cert sizes of other authority
        header = self.utils.mask_header_values(ctx.header, self.authority)
        retval = header.pack() + self._mbn_parsegen.code

        # Clear padding info
        self._mbn_parsegen.set_pad_info(0, 0)

        # Restore the parsegen
        backup.restore(
            self._mbn_parsegen, "sign", "cert_chain", "encryption_params",
            "sign_qti", "cert_chain_qti")

        return retval
コード例 #5
0
ファイル: mbn_v5.py プロジェクト: mxpro2003/qcs605_root
    def _get_data_int(self, sign, encrypt):
        # Backup the parsegen
        backup = _BackupMbnParsegen(
            self._mbn_parsegen, "sign", "cert_chain", "encryption_params",
            "sign_qti", "cert_chain_qti")
        backup_encrypt_pad = self._mbn_parsegen.pad_max_encr_params_size

        # Update the security attributes per the flags
        if sign:
            self._mbn_parsegen.sign = self._data_signature
            self._mbn_parsegen.cert_chain = self._cert_chain
            self._mbn_parsegen.sign_qti = self._data_signature_qti
            self._mbn_parsegen.cert_chain_qti = self._cert_chain_qti

        if encrypt or (self.oem_signing_enabled and self.qti_signing_enabled):
            self._mbn_parsegen.encryption_params = self.encryption_params
        else:
            self._mbn_parsegen.pad_max_encr_params_size = 0

        # Set padding info
        if sign:
            self._mbn_parsegen.set_pad_info(
                self.sig_size, self.get_cert_chain_size(self.authority))

        # Get the signed data
        retval = self._mbn_parsegen.get_data(
            self.authority, self.imageinfo, self.validating, self.signing,
            self.add_signing_attr_to_hash_seg)

        # Clear padding info
        self._mbn_parsegen.set_pad_info(0, 0)

        # Restore the parsegen
        backup.restore(
            self._mbn_parsegen, "sign", "cert_chain", "encryption_params",
            "sign_qti", "cert_chain_qti")
        self._mbn_parsegen.pad_max_encr_params_size = backup_encrypt_pad

        return retval