mirror of
https://gitee.com/openharmony/update_packaging_tools
synced 2024-11-23 06:40:03 +00:00
Signed-off-by: chenzihan <chenzihan13@huawei.com>
fix:codex
This commit is contained in:
parent
3bffcee6a4
commit
3d059634e6
@ -120,7 +120,7 @@ def create_encap_content_info(diget):
|
||||
if not diget:
|
||||
UPDATE_LOGGER.print_log("calc package hash failed! file: %s",
|
||||
log_type=UPDATE_LOGGER.ERROR_LOG)
|
||||
return
|
||||
return False
|
||||
content_header = struct.pack(CONTENT_INFO_FORMAT, DIGEST_SHA256,
|
||||
SHA256_HASH_LEN, diget)
|
||||
return content_header
|
||||
|
@ -500,7 +500,7 @@ def generate_image_map_file(image_path, map_path, image_name):
|
||||
return True
|
||||
|
||||
|
||||
def get_File_SHA256(update_package):
|
||||
def get_file_sha256(update_package):
|
||||
sha256obj = hashlib.sha256()
|
||||
maxbuf = 8192
|
||||
f = open(update_package, 'rb')
|
||||
@ -524,9 +524,9 @@ def write_image_patch_script(partition, src_image_path, tgt_image_path,
|
||||
:param verse_script: verse script object
|
||||
:return:
|
||||
"""
|
||||
src_sha = get_File_SHA256(src_image_path)
|
||||
src_sha = get_file_sha256(src_image_path)
|
||||
src_size = os.path.getsize(src_image_path)
|
||||
tgt_sha = get_File_SHA256(tgt_image_path)
|
||||
tgt_sha = get_file_sha256(tgt_image_path)
|
||||
tgt_size = os.path.getsize(tgt_image_path)
|
||||
|
||||
sha_check_cmd = verse_script.image_sha_check(partition,
|
||||
@ -544,8 +544,8 @@ def write_image_patch_script(partition, src_image_path, tgt_image_path,
|
||||
script_check_cmd_list.append(cmd)
|
||||
|
||||
image_patch_cmd = verse_script.image_patch(partition, os.path.getsize(src_image_path),
|
||||
get_File_SHA256(src_image_path), os.path.getsize(tgt_image_path),
|
||||
get_File_SHA256(tgt_image_path))
|
||||
get_file_sha256(src_image_path), os.path.getsize(tgt_image_path),
|
||||
get_file_sha256(tgt_image_path))
|
||||
|
||||
cmd = '%s_WRITE_FLAG%s' % (partition, image_patch_cmd)
|
||||
script_write_cmd_list.append(cmd)
|
||||
@ -652,9 +652,9 @@ def increment_image_processing(
|
||||
OPTIONS_MANAGER.src_image = src_image_class
|
||||
OPTIONS_MANAGER.tgt_image = tgt_image_class
|
||||
|
||||
Inc_Image = OPTIONS_MANAGER.init.invoke_event(INC_IMAGE_EVENT)
|
||||
if Inc_Image:
|
||||
src_image_class, tgt_image_class = Inc_Image()
|
||||
inc_image = OPTIONS_MANAGER.init.invoke_event(INC_IMAGE_EVENT)
|
||||
if inc_image:
|
||||
src_image_class, tgt_image_class = inc_image()
|
||||
|
||||
transfers_manager = TransfersManager(
|
||||
each_img, tgt_image_class, src_image_class)
|
||||
|
@ -102,12 +102,12 @@ class CreatePackage(object):
|
||||
try:
|
||||
# Type is 1 for package header in TLV format
|
||||
header_tlv = struct.pack(TLV_FMT, self.header_tlv_type, UPGRADE_PKG_HEADER_SIZE)
|
||||
pkg_Info_Length = \
|
||||
pkg_info_length = \
|
||||
UPGRADE_RESERVE_LEN + TLV_SIZE + TLV_SIZE + TLV_SIZE + \
|
||||
UPGRADE_PKG_HEADER_SIZE + UPGRADE_PKG_TIME_SIZE + \
|
||||
self.upgrade_compinfo_size * self.head_list.entry_count
|
||||
upgrade_pkg_header = struct.pack(
|
||||
UPGRADE_PKG_HEADER_FMT, pkg_Info_Length, self.head_list.update_file_version,
|
||||
UPGRADE_PKG_HEADER_FMT, pkg_info_length, self.head_list.update_file_version,
|
||||
self.head_list.product_update_id, self.head_list.software_version)
|
||||
|
||||
# Type is 2 for time in TLV format
|
||||
@ -223,7 +223,7 @@ class CreatePackage(object):
|
||||
key_data,
|
||||
password=None,
|
||||
backend=default_backend())
|
||||
signature = private_key.sign(digset,padding.PKCS1v15(), hashes.SHA256())
|
||||
signature = private_key.sign(digset, padding.PKCS1v15(), hashes.SHA256())
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
return signature
|
||||
@ -298,7 +298,7 @@ class CreatePackage(object):
|
||||
"Add descriptPackageId failed!", log_type=UPDATE_LOGGER.ERROR_LOG)
|
||||
return False
|
||||
try:
|
||||
# Sign
|
||||
# Sign
|
||||
self.sign_offset = self.compinfo_offset + UPGRADE_RESERVE_LEN
|
||||
package_file.seek(self.sign_offset)
|
||||
sign_buffer = bytes(UPGRADE_SIGNATURE_LEN)
|
||||
|
@ -49,6 +49,7 @@ SIGNING_LENGTH_256 = 256
|
||||
DIGEST_LEN = 32
|
||||
HASH_VALUE_MAX_LEN = 128
|
||||
|
||||
|
||||
class SignMethod(enum.Enum):
|
||||
RSA = 1
|
||||
ECC = 2
|
||||
@ -402,7 +403,7 @@ def build_update_package(no_zip, update_package, prelude_script,
|
||||
update_file_name = ''.join(
|
||||
["updater_", OPTIONS_MANAGER.target_package_version.replace(" ", "_")])
|
||||
else :
|
||||
update_file_name = ''.join(
|
||||
update_file_name = ''.join(
|
||||
["updater_", package_type])
|
||||
|
||||
if not no_zip:
|
||||
|
Loading…
Reference in New Issue
Block a user