diff --git a/scripts/imgtool/image.py b/scripts/imgtool/image.py index 9946a2595..88293b1c3 100644 --- a/scripts/imgtool/image.py +++ b/scripts/imgtool/image.py @@ -259,7 +259,7 @@ def __init__(self, version=None, header_size=IMAGE_HEADER_SIZE, overwrite_only=False, endian="little", load_addr=0, rom_fixed=None, erased_val=None, save_enctlv=False, security_counter=None, max_align=None, - non_bootable=False): + non_bootable=False, not_quite_encryption=False): if load_addr and rom_fixed: raise click.UsageError("Can not set rom_fixed and load_addr at the same time") @@ -288,6 +288,7 @@ def __init__(self, version=None, header_size=IMAGE_HEADER_SIZE, self.enctlv_len = 0 self.max_align = max(DEFAULT_MAX_ALIGN, align) if max_align is None else int(max_align) self.non_bootable = non_bootable + self.not_quite_encryption = not_quite_encryption if self.max_align == DEFAULT_MAX_ALIGN: self.boot_magic = bytes([ @@ -713,6 +714,8 @@ def add_header(self, enckey, protected_tlv_size, compression_flags, aes_length=1 flags |= IMAGE_F['ENCRYPTED_AES128'] else: flags |= IMAGE_F['ENCRYPTED_AES256'] + elif self.not_quite_encryption: + flags |= IMAGE_F['ENCRYPTED_AES128'] if self.load_addr != 0: # Indicates that this image should be loaded into RAM # instead of run directly from flash. diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py index 03d46c907..b1fa987b7 100755 --- a/scripts/imgtool/main.py +++ b/scripts/imgtool/main.py @@ -370,6 +370,9 @@ def convert(self, value, param, ctx): help='Enable image compression using specified type. ' 'Will fall back without image compression automatically ' 'if the compression increases the image size.') +@click.option('--not-quite-encryption', default=False, is_flag=True, + help='Set encryption flag without applying encryption.' + 'Doesn\'t apply when encryption is trully used.') @click.option('-c', '--clear', required=False, is_flag=True, default=False, help='Output a non-encrypted image with encryption capabilities,' 'so it can be installed in the primary slot, and encrypted ' @@ -449,8 +452,9 @@ def sign(key, public_key_format, align, version, pad_sig, header_size, dependencies, load_addr, hex_addr, erased_val, save_enctlv, security_counter, boot_record, custom_tlv, rom_fixed, max_align, clear, fix_sig, fix_sig_pubkey, sig_out, user_sha, is_pure, - vector_to_sign, non_bootable): + vector_to_sign, non_bootable, not_quite_encryption): + print("not quite ", not_quite_encryption ) if confirm: # Confirmed but non-padded images don't make much sense, because # otherwise there's no trailer area for writing the confirmed status. @@ -462,7 +466,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size, endian=endian, load_addr=load_addr, rom_fixed=rom_fixed, erased_val=erased_val, save_enctlv=save_enctlv, security_counter=security_counter, max_align=max_align, - non_bootable=non_bootable) + non_bootable=non_bootable, not_quite_encryption=not_quite_encryption) compression_tlvs = {} img.load(infile) key = load_key(key) if key else None