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
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
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
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
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