diff --git a/fw_updater_packer_unpacker/unofficial_pkg_repacker.sh b/fw_updater_packer_unpacker/unofficial_pkg_repacker.sh index 7aa8536..4383341 100755 --- a/fw_updater_packer_unpacker/unofficial_pkg_repacker.sh +++ b/fw_updater_packer_unpacker/unofficial_pkg_repacker.sh @@ -80,10 +80,10 @@ OFFSET_DATA=$((OFFSET_DATA + DATAKEY_E_SIZE + 4)) echo "* sign w/ private key $SIGKEY" openssl dgst -sha256 -sign $SIGKEY -out $TMPDIR/tmp.step4.1 $TMPDIR/tmp.step1 openssl dgst -sha256 -verify $SHA256KEY -signature $TMPDIR/tmp.step4.1 $TMPDIR/tmp.step1 -# if [ $? -ne 0 ]; then -# echo "! Err: failed to verify sha256 - highly likely $SIGKEY is wrong" -# exit 0 -# fi +if [ $? -ne 0 ]; then + echo "! Warning: failed to verify sha256 - highly likely $SIGKEY is not an nofficial one. Ignore this and proceed." + # exit 0 +fi SIG_SIZE=$(wc -c < $TMPDIR/tmp.step4.1) if [ $(((-(SIG_SIZE % 16)) % 16)) -gt 0 ]; then echo "! Err: not supported for SIG_SIZE not mutiple of 16" diff --git a/python_api/libDPT.py b/python_api/libDPT.py index 87232c3..ba312a9 100644 --- a/python_api/libDPT.py +++ b/python_api/libDPT.py @@ -2,6 +2,7 @@ # built-ins import os +import glob import time import serial import base64 @@ -591,6 +592,8 @@ class DPT(): ''' return the stored client key file paths ''' + self.dbg_print("self.client_id_fp = {}".format(self.client_id_fp)) + self.dbg_print("self.key_fp = {}".format(self.key_fp)) return self.client_id_fp, self.key_fp def set_client_key_fps(self, client_id_fp, key_fp): @@ -627,8 +630,18 @@ class DPT(): tmp_dpa_path = "{}/.dpapp".format(home_path) if os.path.isdir(tmp_dpa_path): dpa_path = tmp_dpa_path - tmp_client_fp = "{}/deviceid.dat".format(dpa_path) - tmp_key_fp = "{}/privatekey.dat".format(dpa_path) + self.dbg_print("dpa_path = {}".format(dpa_path)) + # search for desired files + tmp_client_fp = tmp_key_fp = '' + level3files = glob.glob(dpa_path + '/*/*/*.dat') + level2files = glob.glob(dpa_path + '/*/*.dat') + level1files = glob.glob(dpa_path + '/*.dat') + for tmp_fp in level3files + level2files + level1files: + self.dbg_print("looking at: {}".format(tmp_fp)) + if 'deviceid.dat' in tmp_fp: + tmp_client_fp = tmp_fp + elif 'privatekey.dat' in tmp_fp: + tmp_key_fp = tmp_fp if os.path.isfile(tmp_client_fp) and os.path.isfile(tmp_key_fp): default_client_fp = tmp_client_fp default_key_fp = tmp_key_fp