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

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