Skip to content

Commit a15e372

Browse files
committed
tests: Mark that longer auth keys are now supported
This enabled some tests without "force". But there is still a problem with checking test results - SLAK key is only 256 byte, causing different binary layout in files with longer original keys. We should introduce a longer.. SMAK key?
1 parent 728afd8 commit a15e372

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

tests/test_dji_imah_fwsig_rebin1.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
8383
if False:
8484
pass # no quirks
8585
else: # if first level module
86-
module_cmdopts = "-k PRAK-2020-01 -k UFIE-9999-99 -f" # unsupported signature_size=384 - forcing extract
87-
module_changes_limit = 999999 # we can not re-create signature
86+
module_cmdopts = "-k PRAK-2020-01 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
87+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
8888
elif (m := re.match(r'^.*/(ag406|ag407|ag408|ag410|ag411)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
8989
platform = m.group(1)
9090
if (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
@@ -172,8 +172,8 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
172172
if False:
173173
pass # no quirks
174174
else: # if first level module
175-
module_cmdopts = "-k PRAK-2020-01 -k UFIE-9999-99 -f" # unsupported signature_size=384 - forcing extract
176-
module_changes_limit = 999999 # we can not re-create signature
175+
module_cmdopts = "-k PRAK-2020-01 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
176+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
177177
elif (m := re.match(r'^.*/(pm320)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
178178
platform = m.group(1)
179179
if (re.match(r'^.*{:s}_0702_[^/]*[.]fw_0702.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
@@ -184,10 +184,10 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
184184
module_cmdopts = "-k PRAK-2020-01 -k TBIE-2020-02"
185185
# allow change of 2 bytes from auth key name, 256 from signature, up to 3x16 chunk padding
186186
module_changes_limit = 2 + 256 + 3*16
187-
# specific first level modules with unsupported signature_size=384
187+
# specific first level modules with different keys
188188
elif (re.match(r'^.*pm320_2805_v[0-9a-z_.-]*[.]pro[.]fw[.]sig$', modl_inp_fn, re.IGNORECASE)):
189-
module_cmdopts = "-k PRAK-2020-01 -k UFIE-2020-04 -f"
190-
module_changes_limit = 999999 # we can not re-create signature
189+
module_cmdopts = "-k PRAK-2021-09 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
190+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
191191
else: # if first level module
192192
module_cmdopts = "-k PRAK-2020-01 -k UFIE-2020-04"
193193
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 2*16 chunk padding
@@ -439,15 +439,15 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
439439
if False:
440440
pass # no quirks
441441
else: # if first level module
442-
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # unsupported signature_size=384 - forcing extract
443-
module_changes_limit = 999999 # we can not re-create signature
442+
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
443+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
444444
elif (m := re.match(r'^.*/(wm1695)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
445445
platform = m.group(1)
446446
if False:
447447
pass # no quirks
448448
else: # if first level module
449-
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # unsupported signature_size=384 - forcing extract
450-
module_changes_limit = 999999 # we can not re-create signature
449+
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
450+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
451451
elif (m := re.match(r'^.*/(wm220)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
452452
platform = m.group(1)
453453
if (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
@@ -513,8 +513,8 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
513513
if False:
514514
pass # no quirks
515515
else: # if first level module
516-
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # unsupported signature_size=384 - forcing extract
517-
module_changes_limit = 999999 # we can not re-create signature
516+
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
517+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
518518
elif (m := re.match(r'^.*/(wm240|wm245|wm246)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
519519
platform = m.group(1)
520520
if (re.match(r'^.*{:s}_0901_[^/]*[.]fw_0901.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
@@ -535,7 +535,13 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
535535
module_changes_limit = 2 + 4 + 4 + 256 + 1*16 + 32
536536
elif (m := re.match(r'^.*/(wm247)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
537537
platform = m.group(1)
538-
if (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
538+
# specific files within nested modules - nfz.fw.bin uses older keys
539+
if (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*\/nfz\/.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
540+
module_cmdopts = "-k PRAK-2017-08 -k TBIE-2018-07"
541+
# allow change of 2 bytes from auth key name, 256 from signature, up to 6x16 chunk padding, 32 payload digest, 3x16 unknown additional
542+
module_changes_limit = 2 + 256 + 6*16 + 32 + 4*16
543+
# specific nested modules
544+
elif (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
539545
module_cmdopts = "-k PRAK-2020-01 -k TBIE-2020-02"
540546
# allow change of 2 bytes from auth key name, 256 from signature, up to 6x16 chunk padding, 32 payload digest, 3x16 unknown additional
541547
module_changes_limit = 2 + 256 + 6*16 + 32 + 4*16
@@ -560,12 +566,12 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
560566
module_changes_limit = 2 + 4 + 4 + 256 + 9*16 + 32 + 6*16
561567
# specific nested modules
562568
elif (re.match(r'^.*{:s}_0802_[^/]*[.]fw_0802.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
563-
module_cmdopts = "-k PRAK-2020-01 -k TBIE-2020-02 -f" # unsupported signature_size=384 - forcing extract
564-
module_changes_limit = 999999 # we can not re-create signature
565-
# specific first level modules with unsupported signature_size=384
569+
module_cmdopts = "-k PRAK-2021-09 -k TBIE-2020-02" # first level key is not publihed, making this unused
570+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
571+
# specific first level modules with different keys
566572
elif (re.match(r'^.*/(wm260|wm2605)_0802_v[0-9a-z_.-]*[.]pro[.]fw[.]sig$', modl_inp_fn, re.IGNORECASE)):
567-
module_cmdopts = "-k PRAK-2020-01 -k UFIE-2021-08 -f"
568-
module_changes_limit = 999999 # we can not re-create signature
573+
module_cmdopts = "-k PRAK-2021-09 -k UFIE-2021-08 -f" # UFIE not published, forcing extract encrypted
574+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
569575
# specific first level modules with encrypted data checksum verification issues
570576
elif (re.match(r'^.*V00[.]20[.]0101_wm260_dji_system/wm260([._].*)?[.]cfg[.]sig$', modl_inp_fn, re.IGNORECASE) or
571577
re.match(r'^.*V01[.]00[.]0100_wm260_dji_system/wm260([._].*)?[.]cfg[.]sig$', modl_inp_fn, re.IGNORECASE)):
@@ -581,8 +587,8 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
581587
if False:
582588
pass # no quirks
583589
else: # if first level module
584-
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # unsupported signature_size=384 - forcing extract
585-
module_changes_limit = 999999 # we can not re-create signature
590+
module_cmdopts = "-k PRAK-2019-09 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
591+
module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
586592
else:
587593
platform = "unknown"
588594
module_cmdopts = ""

0 commit comments

Comments
 (0)