Skip to content

Commit 84d8d6e

Browse files
committed
tests: Update for known keys in wm265e/m/t drones
1 parent 15a411d commit 84d8d6e

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

tests/test_dji_imah_fwsig_rebin1.py

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
173173
elif (m := re.match(r'^.*/(hg330)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
174174
platform = m.group(1)
175175
# specific first level modules
176-
if (re.match(r'^.*{:s}_1202_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)): # the module uses 2048-bit PRAK
176+
if (re.match(r'^.*{:s}_1202_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
177177
module_cmdopts = "-k PRAK-9999-99 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
178178
# allow change of 2 bytes from auth key name, 256+16 from signature, up to 3x16 chunk padding
179179
module_changes_limit = 2 + 256 + 16 + 3*16
@@ -518,15 +518,57 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
518518
module_cmdopts = "-k PRAK-2017-08 -k UFIE-2018-01 -k TBIE-2018-01"
519519
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 16 chunk padding, 32 payload digest
520520
module_changes_limit = 2 + 4 + 4 + 256 + 32+16
521-
elif (m := re.match(r'^.*/(wm265e|wm265m|wm265t)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
521+
elif (m := re.match(r'^.*/(wm265e)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
522522
platform = m.group(1)
523-
# specific first level modules
524-
if (re.match(r'^.*{:s}_1502_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)): # the module uses 2048-bit PRAK
525-
module_cmdopts = "-k PRAK-2020-01 -k UFIE-2020-04"
523+
# specific FW version with keys reused from wm260
524+
if (re.match(r'^.*/V00.01.0101[^/]*/{:s}.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
525+
# specific nested modules
526+
if (re.match(r'^.*{:s}_1502_[^/]*[.]fw_1502.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
527+
module_cmdopts = "-k PRAK-2020-01 -k TBIE-2020-02"
528+
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 9x16 chunk padding, 32 payload digest, 6x16 unknown additional
529+
module_changes_limit = 2 + 4 + 4 + 256 + 9*16 + 32 + 6*16
530+
# specific nested modules
531+
elif (re.match(r'^.*{:s}_0802_[^/]*[.]fw_0802.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
532+
module_cmdopts = "-k PRAK-2021-09 -k TBIE-2021-08"
533+
# allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
534+
module_changes_limit = 2 + 384 + 32 + 3*16
535+
# specific first level modules with different keys
536+
elif (re.match(r'^.*{:s}_0500_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
537+
module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # m0500 uses different PRAK; UFIE not published, forcing extract encrypted
538+
# allow change of 2 bytes from auth key name, 256+16 from signature, up to 3x16 chunk padding, 128 unknown
539+
module_changes_limit = 2 + 256 + 16 + 3*16 + 128
540+
# specific first level modules with different keys
541+
elif (re.match(r'^.*{:s}_1502_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
542+
module_cmdopts = "-k PRAK-2020-01 -k UFIE-2020-04"
543+
# allow change of 2 bytes from auth key name, 256+16 from signature, up to 3x16 chunk padding
544+
module_changes_limit = 2 + 256 + 16 + 3*16
545+
else: # if first level module
546+
module_cmdopts = "-k PRAK-2021-09 -k UFIE-2021-08"
547+
# allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
548+
module_changes_limit = 2 + 384 + 32 + 3*16
549+
# specific first level modules with different keys
550+
elif (re.match(r'^.*{:s}_1502_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
551+
module_cmdopts = "-k PRAK-9999-99 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
526552
# allow change of 2 bytes from auth key name, 256+16 from signature, up to 3x16 chunk padding
527553
module_changes_limit = 2 + 256 + 16 + 3*16
528554
else: # if first level module
529-
module_cmdopts = "-k PRAK-2021-09 -k UFIE-2021-08"
555+
module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
556+
# allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
557+
module_changes_limit = 2 + 384 + 32 + 3*16
558+
elif (m := re.match(r'^.*/(wm265m|wm265t)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
559+
platform = m.group(1)
560+
# specific first level modules with different keys
561+
if (re.match(r'^.*{:s}_0802_v[0-9a-z_.-]*[.]pro[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
562+
module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # m0802 uses different PRAK; UFIE not published, forcing extract encrypted
563+
# allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
564+
module_changes_limit = 2 + 384 + 32 + 3*16
565+
# specific first level modules with different keys
566+
elif (re.match(r'^.*{:s}_1502_[^/]*[.]fw[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
567+
module_cmdopts = "-k PRAK-9999-99 -k UFIE-9999-99 -f" # m1502 uses different PRAK; UFIE not published, forcing extract encrypted
568+
# allow change of 2 bytes from auth key name, 256+16 from signature, up to 3x16 chunk padding
569+
module_changes_limit = 2 + 256 + 16 + 3*16
570+
else: # if first level module
571+
module_cmdopts = "-k PRAK-9999-98 -k UFIE-2021-08 -f" # PRAK not published but UFIE works, forcing extract with signature verify fail
530572
# allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
531573
module_changes_limit = 2 + 384 + 32 + 3*16
532574
elif (m := re.match(r'^.*/(wm240|wm245|wm246)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
@@ -539,7 +581,7 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
539581
module_cmdopts = "-k PRAK-2017-12 -k PUEK-9999-99 -k IAEK-9999-99 -f" # m0907 uses different PRAK; IAEK not published, forcing extract encrypted
540582
# allow change of 2 bytes from auth key name, 256 from signature, up to 16 chunk padding, 32 payload digest
541583
module_changes_limit = 2 + 4 + 4 + 256 + 1*16 + 32
542-
elif (re.match(r'^.*V00.01.0852_Mavic2_dji_system/{:s}_[^/]*[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
584+
elif (re.match(r'^.*/V00.01.0852_Mavic2_dji_system/{:s}_[^/]*[.]sig$'.format(platform), modl_inp_fn, re.IGNORECASE)):
543585
module_cmdopts = "-k rrak-2018-03 -k ufie-2018-03 -f" # rrak and ufie (which are dev keys) not published, forcing extract encrypted
544586
# allow change of 2 bytes from auth key name, 256 from signature, up to 3x16 chunk padding, 3x16 unknown additional
545587
module_changes_limit = 2 + 256 + 3*16 + 3*16

0 commit comments

Comments
 (0)