image: add additional fields to Netgear encrypted image

These fields are used for EAX12 and EX6250v2 series, and perhaps other
devices. Compatibility is preserved with the WAX202 and WAX206.

In addition, adds the related vars to DEVICE_VARS so that the variables
work correctly with multiple devices.

References in GPL source:
https://www.downloads.netgear.com/files/GPL/EAX12_EAX11v2_EAX15v2_GPL_V1.0.3.34_src.tar.gz

* tools/imgencoder/src/gj_enc.c
  Contains code that generates the encrypted image.

Signed-off-by: Wenli Looi <wlooi@ucalgary.ca>
This commit is contained in:
Wenli Looi 2023-03-30 22:27:11 +00:00 committed by Hauke Mehrtens
parent b20be1e41e
commit 0a1ebccc87
4 changed files with 26 additions and 2 deletions

View File

@ -432,6 +432,8 @@ define Build/netgear-encrypted-factory
--output-file $@ \
--model $(NETGEAR_ENC_MODEL) \
--region $(NETGEAR_ENC_REGION) \
$(if $(NETGEAR_ENC_HW_ID_LIST),--hw-id-list "$(NETGEAR_ENC_HW_ID_LIST)") \
$(if $(NETGEAR_ENC_MODEL_LIST),--model-list "$(NETGEAR_ENC_MODEL_LIST)") \
--version V1.0.0.0.$(shell cat $(VERSION_DIST)| sed -e 's/[[:space:]]/-/g').$(firstword $(subst -, ,$(REVISION))) \
--encryption-block-size 0x20000 \
--openssl-bin "$(STAGING_DIR_HOST)/bin/openssl" \

View File

@ -14,6 +14,8 @@ def main():
parser.add_argument('--model', type=str, required=True)
parser.add_argument('--region', type=str, required=True)
parser.add_argument('--version', type=str, required=True)
parser.add_argument('--hw-id-list', type=str)
parser.add_argument('--model-list', type=str)
parser.add_argument('--encryption-block-size', type=str, required=True)
parser.add_argument('--openssl-bin', type=str, required=True)
parser.add_argument('--key', type=str, required=True)
@ -26,6 +28,10 @@ def main():
assert (encryption_block_size > 0 and encryption_block_size % 16 ==
0), 'Encryption block size must be a multiple of the AES block size (16)'
hw_id_list = args.hw_id_list.split(';') if args.hw_id_list else []
model_list = args.model_list.split(';') if args.model_list else []
hw_info = ';'.join(hw_id_list + model_list)
image = open(args.input_file, 'rb').read()
image_enc = []
for i in range(0, len(image), encryption_block_size):
@ -45,13 +51,18 @@ def main():
image_enc = b''.join(image_enc)
image_with_header = struct.pack(
'>32s32s64s64s64s256s12sII',
'>32s32s64s64sIBBB13s200s100s12sII',
args.model.encode('ascii'),
args.region.encode('ascii'),
args.version.encode('ascii'),
b'Thu Jan 1 00:00:00 1970', # static date for reproducibility
0, # product hw model
0, # model index
len(hw_id_list),
len(model_list),
b'', # reserved
hw_info.encode('ascii'),
b'', # reserved
b'', # RSA signature - omitted for now
b'encrpted_img',
len(image_enc),
encryption_block_size,

View File

@ -6,6 +6,8 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
DEVICE_VARS += NETGEAR_ENC_MODEL NETGEAR_ENC_REGION NETGEAR_ENC_HW_ID_LIST NETGEAR_ENC_MODEL_LIST
loadaddr-$(CONFIG_TARGET_mediatek_mt7622) := 0x44000000
loadaddr-$(CONFIG_TARGET_mediatek_mt7623) := 0x80008000
loadaddr-$(CONFIG_TARGET_mediatek_mt7629) := 0x40008000
@ -22,6 +24,10 @@ define Device/Default
KERNEL_LOADADDR = $(loadaddr-y)
FILESYSTEMS := squashfs
DEVICE_DTS_DIR := $(DTS_DIR)
NETGEAR_ENC_MODEL :=
NETGEAR_ENC_REGION :=
NETGEAR_ENC_HW_ID_LIST :=
NETGEAR_ENC_MODEL_LIST :=
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | pad-to 128k | append-rootfs | \
pad-rootfs | append-metadata

View File

@ -7,6 +7,7 @@ include $(INCLUDE_DIR)/image.mk
DEVICE_VARS += LOADER_TYPE LOADER_FLASH_OFFS LZMA_TEXT_START
DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID
DEVICE_VARS += NETGEAR_ENC_MODEL NETGEAR_ENC_REGION NETGEAR_ENC_HW_ID_LIST NETGEAR_ENC_MODEL_LIST
DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
DEVICE_VARS += SEAMA_SIGNATURE SEAMA_MTDBLOCK
DEVICE_VARS += SERCOMM_HWNAME SERCOMM_HWID SERCOMM_HWVER SERCOMM_SWVER
@ -179,6 +180,10 @@ define Device/Default
SOC := $(DEFAULT_SOC)
DEVICE_DTS_DIR := ../dts
DEVICE_DTS = $$(SOC)_$(1)
NETGEAR_ENC_MODEL :=
NETGEAR_ENC_REGION :=
NETGEAR_ENC_HW_ID_LIST :=
NETGEAR_ENC_MODEL_LIST :=
IMAGES := sysupgrade.bin
COMPILE :=
sysupgrade_bin := append-kernel | append-rootfs | pad-rootfs