@@ -83,8 +83,9 @@ 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" # UFIE not published, forcing extract encrypted
87- module_changes_limit = 999999 # SLAK signature is shorter, making file layout different
86+ module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
87+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
88+ module_changes_limit = 2 + 384 + 32 + 3 * 16
8889 elif (m := re .match (r'^.*/(ag406|ag407|ag408|ag410|ag411)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$' , modl_inp_fn , re .IGNORECASE )):
8990 platform = m .group (1 )
9091 if (re .match (r'^.*{:s}_0801_[^/]*[.]fw_0801.*$' .format (platform ), modl_inp_fn , re .IGNORECASE )):
@@ -172,8 +173,9 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
172173 if False :
173174 pass # no quirks
174175 else : # if first level module
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
176+ module_cmdopts = "-k PRAK-2021-09 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
177+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
178+ module_changes_limit = 2 + 384 + 32 + 3 * 16
177179 elif (m := re .match (r'^.*/(pm320)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$' , modl_inp_fn , re .IGNORECASE )):
178180 platform = m .group (1 )
179181 if (re .match (r'^.*{:s}_0702_[^/]*[.]fw_0702.*$' .format (platform ), modl_inp_fn , re .IGNORECASE )):
@@ -187,7 +189,8 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
187189 # specific first level modules with different keys
188190 elif (re .match (r'^.*pm320_2805_v[0-9a-z_.-]*[.]pro[.]fw[.]sig$' , modl_inp_fn , re .IGNORECASE )):
189191 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
192+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
193+ module_changes_limit = 2 + 384 + 32 + 3 * 16
191194 else : # if first level module
192195 module_cmdopts = "-k PRAK-2020-01 -k UFIE-2020-04"
193196 # 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 +442,17 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
439442 if False :
440443 pass # no quirks
441444 else : # if first level module
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
445+ module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
446+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
447+ module_changes_limit = 2 + 384 + 32 + 3 * 16
444448 elif (m := re .match (r'^.*/(wm1695)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$' , modl_inp_fn , re .IGNORECASE )):
445449 platform = m .group (1 )
446450 if False :
447451 pass # no quirks
448452 else : # if first level module
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
453+ module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
454+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
455+ module_changes_limit = 2 + 384 + 32 + 3 * 16
451456 elif (m := re .match (r'^.*/(wm220)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$' , modl_inp_fn , re .IGNORECASE )):
452457 platform = m .group (1 )
453458 if (re .match (r'^.*{:s}_0801_[^/]*[.]fw_0801.*$' .format (platform ), modl_inp_fn , re .IGNORECASE )):
@@ -513,8 +518,9 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
513518 if False :
514519 pass # no quirks
515520 else : # if first level module
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
521+ module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
522+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
523+ module_changes_limit = 2 + 384 + 32 + 3 * 16
518524 elif (m := re .match (r'^.*/(wm240|wm245|wm246)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$' , modl_inp_fn , re .IGNORECASE )):
519525 platform = m .group (1 )
520526 if (re .match (r'^.*{:s}_0901_[^/]*[.]fw_0901.*$' .format (platform ), modl_inp_fn , re .IGNORECASE )):
@@ -567,11 +573,13 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
567573 # specific nested modules
568574 elif (re .match (r'^.*{:s}_0802_[^/]*[.]fw_0802.*$' .format (platform ), modl_inp_fn , re .IGNORECASE )):
569575 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
576+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
577+ module_changes_limit = 2 + 384 + 32 + 3 * 16
571578 # specific first level modules with different keys
572579 elif (re .match (r'^.*/(wm260|wm2605)_0802_v[0-9a-z_.-]*[.]pro[.]fw[.]sig$' , modl_inp_fn , re .IGNORECASE )):
573580 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
581+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
582+ module_changes_limit = 2 + 384 + 32 + 3 * 16
575583 # specific first level modules with encrypted data checksum verification issues
576584 elif (re .match (r'^.*V00[.]20[.]0101_wm260_dji_system/wm260([._].*)?[.]cfg[.]sig$' , modl_inp_fn , re .IGNORECASE ) or
577585 re .match (r'^.*V01[.]00[.]0100_wm260_dji_system/wm260([._].*)?[.]cfg[.]sig$' , modl_inp_fn , re .IGNORECASE )):
@@ -587,8 +595,9 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
587595 if False :
588596 pass # no quirks
589597 else : # if first level module
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
598+ module_cmdopts = "-k PRAK-9999-98 -k UFIE-9999-99 -f" # UFIE not published, forcing extract encrypted
599+ # allow change of 2 bytes from auth key name, 384+32 from signature, up to 3x16 chunk padding
600+ module_changes_limit = 2 + 384 + 32 + 3 * 16
592601 else :
593602 platform = "unknown"
594603 module_cmdopts = ""
@@ -622,6 +631,11 @@ def case_dji_imah_fwsig_rebin(capsys, cmdargs, modl_inp_fn):
622631 re .match (r'^.*-unpack_p[0-9]+.*[.]img[.]sig$' , modl_inp_fn , re .IGNORECASE ) or
623632 re .match (r'^.*-part_p[0-9]+.*[.]img[.]sig$' , modl_inp_fn , re .IGNORECASE )):
624633 ignore_inp_end_padding = True
634+ # Select auth key with private part which we can use for signing
635+ if (" PRAK-9999-98" in extra_cmdopts ) or (" PRAK-2021-09" in extra_cmdopts ): # 3072 bit auth key used
636+ auth_priv_key = "SLAK-2025-08"
637+ else : # 2048 bit auth key used
638+ auth_priv_key = "SLAK-2018-01"
625639
626640 inp_path , inp_filename = os .path .split (modl_inp_fn )
627641 inp_path = pathlib .Path (inp_path )
@@ -641,11 +655,11 @@ def case_dji_imah_fwsig_rebin(capsys, cmdargs, modl_inp_fn):
641655 with patch .object (sys , 'argv' , command ):
642656 dji_imah_fwsig_main ()
643657 # We do not have private parts of auth keys used for signing - use OG community key instead
644- # Different signature means we will get up to 256 different bytes in the resulting file
658+ # Different signature means we will get up to 256 or 384 different bytes (depending on which SLAK) in the resulting file
645659 # Additional 2 bytes of difference is the FourCC - two first bytes of it were changed
646- modify_head_ini_option ("{:s}_head.ini" .format (pfx_out_fn ), [('auth_key' ,' SLAK' ,)])
660+ modify_head_ini_option ("{:s}_head.ini" .format (pfx_out_fn ), [('auth_key' ," SLAK" ,)])
647661 # Re-sign the module
648- command = [os .path .join ("." , "dji_imah_fwsig.py" ), "-vv" ] + shlex .split (extra_cmdopts ) + ["-s" , "-m" , pfx_out_fn , "-i" , modl_out_fn ]
662+ command = [os .path .join ("." , "dji_imah_fwsig.py" ), "-vv" , "-k" , auth_priv_key ] + shlex .split (extra_cmdopts ) + ["-s" , "-m" , pfx_out_fn , "-i" , modl_out_fn ]
649663 LOGGER .info (' ' .join (command ))
650664 with patch .object (sys , 'argv' , command ):
651665 dji_imah_fwsig_main ()
0 commit comments